diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.cpp b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.cpp index 22fda207f53babd16037f13f4df9108a2206ea13..2455ab03a0d28d5d304f0e44060070ab0a4c83d5 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.cpp @@ -40,8 +40,8 @@ Device::Device(PLC* thePLC, const ElementXML& deviceNode, boost::ptr_vector<Elem label_ = deviceNode.getAttribute("label"); StringUtilities::fromString(address_, deviceNode.getAttribute("address")); - //For backward compatibility reason, IO addresses could be undefined. - //It will be initialized to (-1) by default. + //For backward compatibility (IO addresses are not defined in Silecs version <1.4.0) + //Undefined address = -1 by default. ai_address_ = -1; ao_address_ = -1; di_address_ = -1; diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.cpp b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.cpp index c2edd3957e8e37fce36dccc03aa9d8b1e2c222df..da46231b83fd0202f613d49019368c3cfb405cd0 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsPLC.cpp @@ -435,11 +435,22 @@ void PLC::extractDatabase() system_ = mappingNode.getAttribute("plc-system"); protocolMode_ = mappingNode.getAttribute("protocol"); model_ = mappingNode.getAttribute("plc-model"); + StringUtilities::fromString(baseMemAddr_, mappingNode.getAttribute("address")); - StringUtilities::fromString(baseDIAddr_, mappingNode.getAttribute("DI-address")); - StringUtilities::fromString(baseDOAddr_, mappingNode.getAttribute("DO-address")); - StringUtilities::fromString(baseAIAddr_, mappingNode.getAttribute("AI-address")); - StringUtilities::fromString(baseAOAddr_, mappingNode.getAttribute("AO-address")); + //For backward compatibility (IO addresses are not defined in Silecs version <1.4.0) + //Undefined address = -1 by default. + baseDIAddr_ = -1; + baseDOAddr_ = -1; + baseAIAddr_ = -1; + baseAOAddr_ = -1; + if (mappingNode.hasAttribute("AI-address")) + StringUtilities::fromString(baseAIAddr_, mappingNode.getAttribute("AI-address")); + if (mappingNode.hasAttribute("AO-address")) + StringUtilities::fromString(baseAOAddr_, mappingNode.getAttribute("AO-address")); + if (mappingNode.hasAttribute("DI-address")) + StringUtilities::fromString(baseDIAddr_, mappingNode.getAttribute("DI-address")); + if (mappingNode.hasAttribute("DO-address")) + StringUtilities::fromString(baseDOAddr_, mappingNode.getAttribute("DO-address")); usedMem_ = mappingNode.getAttribute("used-mem"); typeID_ = whichPLCType(model_); brandID_ = whichPLCBrand(brand_);