diff --git a/src/RPC2TangoBridge.cpp b/src/RPC2TangoBridge.cpp index 6e5dcbbf79e121601fd4830d8e5bf8d2b9207428..26a85bc86ecd45d2ff03a3d9b63c080ab4b35e7d 100644 --- a/src/RPC2TangoBridge.cpp +++ b/src/RPC2TangoBridge.cpp @@ -188,10 +188,21 @@ void RPC2TangoBridge::init_device() * is taken from the configuration file. */ set_status("Allocating dynamic attributes"); + inserted = 0; + failed = 0; AllocateAttributes(); + if (inserted == 0){ + set_state(Tango::FAULT); + set_status("failed to create all dynamic attributes"); + } + else{ set_state(Tango::ON); - set_status("ON"); + char mesg[90]; + sprintf(mesg,"created attributes : %d , failed: %d \n",inserted,failed); + string sts(mesg); + set_status(sts); + } } @@ -298,7 +309,9 @@ void RPC2TangoBridge::AllocateAttributes() DEBUG_STREAM << "Aggiunto alla mappa con nome " << name << " e " << spattr->get_name() << " 0x" << spattr << endl; spectrumNamesMap[name] = spattr; add_attribute(spattr); + inserted++; } + else failed++; } else @@ -310,17 +323,20 @@ void RPC2TangoBridge::AllocateAttributes() /* insert the couple attribute name/BridgeAttr* into the names map */ namesMap[name] = att; add_attribute(att); + inserted++; } + else { ERROR_STREAM << "failed: " << name << endl;failed++;} } } catch(Tango::DevFailed &e) { - printException("Error creating attribute", e); + failed++; + printException("Error creating attribute", e); } } /* else: element not already present in the map */ } - RPCHandleSet::instance()->handleCount(); + RPCHandleSet::instance()->handleCount(); } //+---------------------------------------------------------------------------- diff --git a/src/RPC2TangoBridge.h b/src/RPC2TangoBridge.h index 870ff365c79bf676f4796d5929c9dabb1edb9fdc..6ee71bf1a08b8ca43d343d30352fbb7c48464feb 100644 --- a/src/RPC2TangoBridge.h +++ b/src/RPC2TangoBridge.h @@ -262,6 +262,10 @@ private: bool write_dynamic_attribute(Tango::WAttribute &w); void printException(const char* msg, Tango::DevFailed &e); bool force_spectrum(char* device_property); + + //coutrer of ok/failed + unsigned int inserted; + unsigned int failed; // Tango::DevShort *attr_AlarmAttribute_read; }; diff --git a/src/RpcHandle.cpp b/src/RpcHandle.cpp index 59434e9bfcc0710bf8d817bfc7c579329fc15192..5fd9145c48c0eeb34be554c95da0ca7c4d12f49f 100644 --- a/src/RpcHandle.cpp +++ b/src/RpcHandle.cpp @@ -43,22 +43,28 @@ RPCHandle::RPCHandle(string rpccall) } else /* do not connect(): this will leave _sid to -1 */ _lastRpcErr = "failed resolving call " + rpccall; + } bool RPCHandle::resolve_rpc(const char *call, char** host, short int *port) { - int res; - char fam[RPCSPLITLEN], mem[RPCSPLITLEN], act[RPCSPLITLEN], mode[RPCSPLITLEN]; - - RpcResolver resolver; - if(split_rpccall(call, fam, mem, act, mode) >= 0) - { - res = resolver.resolve(fam, mem, act, mode, host, port); - if(res >= 0 && host != NULL) - return true; - } - return false; + int res; + char fam[RPCSPLITLEN], mem[RPCSPLITLEN], act[RPCSPLITLEN], mode[RPCSPLITLEN]; + + + try{ + RpcResolver resolver; + if(split_rpccall(call, fam, mem, act, mode) >= 0) + { + res = resolver.resolve(fam, mem, act, mode, host, port); + if(res >= 0 && host != NULL) return true; + else return false; + } + } + catch (...){ + return false; + } } RPCHandle::~RPCHandle() diff --git a/src/attribute_converter.cpp b/src/attribute_converter.cpp index 4b2c06df5925aa6625dd446e3620a06b74680fad..e73703ad506d085aa846e5aa63d4fec21bc109b6 100644 --- a/src/attribute_converter.cpp +++ b/src/attribute_converter.cpp @@ -41,7 +41,7 @@ AttributeConverter::AttributeConverter(char *propertyName, bool force_spectrum) * returns false and strlen(writeCall) is 0. */ readWrite = isReadWrite(propertyName, readCall, writeCall); - printf ("AttributeConverter %s readWrite: %d\n",propertyName,readWrite); + //printf ("AttributeConverter %s readWrite: %d\n",propertyName,readWrite); /* used to determine data_type below. We refer to read name, we are not * interested in write_name. The configuration of the device properties must * be consistent, but we do not check it. @@ -53,7 +53,7 @@ AttributeConverter::AttributeConverter(char *propertyName, bool force_spectrum) } data_type = data_type_for_mode(mode); - printf("creating in converter attribute for \"%s\": data type: \"%s\"\n", propertyName, dataType(data_type).c_str()); + //printf("creating in converter attribute for \"%s\": data type: \"%s\"\n", propertyName, dataType(data_type).c_str()); if(data_type >= 0 && (is_spectrum(mode) || force_spectrum)) { spectrum = true; @@ -181,10 +181,10 @@ SpectrumBridgeAttr* AttributeConverter::createSpectrumAttribute(const char* name "READ ONLY spectrum attribute with the same name", name); if(RPCHandle::split_rpccall(name, fam, mem, act, mode) < 0) - { - //printf("\e[1;31m*\e[0m Error in RPC data_type: \"%s\"\n", name); - exit(EXIT_FAILURE); - } + { + //printf("\e[1;31m*\e[0m Error in RPC data_type: \"%s\"\n", name); + exit(EXIT_FAILURE); + } /* particular case in which we know that the RF is long 32 */ if(strcmp(mode, "RF") == 0) max_x = 32; @@ -208,8 +208,8 @@ SpectrumBridgeAttr* AttributeConverter::createSpectrumAttribute(const char* name BridgeAttr* AttributeConverter::createScalarAttribute(const char* name, long int data_type) { - printf("createScalarAttribute %s\n",name); - char desc[256]; + //DEBUG_STREAM << "createScalarAttribute "<< name; + char desc[256]; char res[256]; UserDefaultAttrProp default_att_prop; BridgeAttr* attr; @@ -234,16 +234,16 @@ BridgeAttr* AttributeConverter::createScalarAttribute(const char* name, long int BridgeAttr* AttributeConverter::createScalarAttribute(const char* name, const char* writeName, long int data_type) { - printf("createScalarAttribute_write %s\n",name); - char desc[256]; + //DEBUG_STREAM << "create ScalarAttribute_write " << name; + char desc[256]; char res[256]; UserDefaultAttrProp default_att_prop; BridgeAttr* attr; snprintf(desc, 255, "This attribute maps the RPC call \"%s\" in a tango " "READ WRITE scalar attribute. RPC read call: \"%s\" write call: \"%s\"", name, name, writeName); - printf("createScalarAttribute_write %s %s...\n",name,writeName); + //printf("createScalarAttribute_write %s %s...\n",name,writeName); attr = new BridgeAttr(name, writeName, data_type, Tango::READ_WRITE); - printf(".....createScalarAttribute_write %s %s\n",name,writeName); + //printf(".....createScalarAttribute_write %s %s\n",name,writeName); if(attr != NULL) { // snprintf(res, 256, "\e[1;32m* \e[0mcreated \"%s\"\t\e[0;37m[\e[0;32mscalar"