diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCBlock.cpp b/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCBlock.cpp index c6271e1155325c100f12d53d907f042d46357ad0..3b73d9524f6fb9a5510946cb97b3acfb1340d48a 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCBlock.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCBlock.cpp @@ -27,12 +27,13 @@ Contributors: namespace Silecs { -PLCBlock::PLCBlock(const ElementXML& blockNode, const std::vector<ElementXML>& registerNodes, AccessType accessType, long deviceInputAddress, long deviceOutputAddress, Connection& plcConnection_, const SilecsParamConfig& paramConfig) : - Block(blockNode, accessType, plcConnection_), +PLCBlock::PLCBlock(const ElementXML& blockNode, long deviceInputAddress, long deviceOutputAddress, Connection& plcConnection_, const SilecsParamConfig& paramConfig) : + Block(blockNode, plcConnection_), deviceInputAddress_(deviceInputAddress), deviceOutputAddress_(deviceOutputAddress), paramConfig_(paramConfig) { + auto& registerNodes = blockNode.getChildNodes(); for (auto registerIter = registerNodes.begin(); registerIter != registerNodes.end(); registerIter++) { std::string registerName = registerIter->getAttribute("name"); @@ -67,7 +68,7 @@ PLCBlock::PLCBlock(const ElementXML& blockNode, const std::vector<ElementXML>& r } reg->setAccessArea(accessArea); - reg->setAccessType(accessType); + reg->setAccessType(Block::whichAccessType(blockNode.getName())); reg->setBlockName(blockNode.getAttribute("name")); registers_.emplace_back(std::move(reg)); } diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCBlock.h b/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCBlock.h index d76660040e166a6d2f22ea85c29c0222415e4484..98baaf796d5fc9e99deff42358836445d1ac8468 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCBlock.h +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/PLCBlock.h @@ -27,7 +27,7 @@ class PLCBlock : public Block { public: - PLCBlock(const ElementXML& blockNode, const std::vector<ElementXML>& registerNodes, AccessType accessType, long deviceInputAddress, long deviceOutputAddress, Connection& plcConnection, const SilecsParamConfig& paramConfig); + PLCBlock(const ElementXML& blockNode, long deviceInputAddress, long deviceOutputAddress, Connection& plcConnection, const SilecsParamConfig& paramConfig); virtual ~PLCBlock(); // TODO: Receive and send functions can be made void and exceptions instead thrown. diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsBlock.cpp b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsBlock.cpp index deb4651eb489ef6087852262e6ee6f009628057d..173fe7b0e25799c316131b1321e985a5d989be8e 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsBlock.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsBlock.cpp @@ -24,7 +24,7 @@ Contributors: namespace Silecs { -Block::Block(const ElementXML& blockNode, AccessType accessType, Connection& plcConnection) : +Block::Block(const ElementXML& blockNode, Connection& plcConnection) : plcConnection_(plcConnection), configuration_(false) { @@ -42,7 +42,7 @@ Block::Block(const ElementXML& blockNode, AccessType accessType, Connection& plc resetCustomAttributes(); //by default custom-size of the block is the maximum size - accessType_ = accessType; + accessType_ = whichAccessType(blockNode.getName()); } Block::~Block() @@ -51,7 +51,7 @@ Block::~Block() LOG(ALLOC) << "Block (delete): " << name_; } -AccessType Block::whichAccessType(std::string type) +AccessType Block::whichAccessType(const std::string& type) { if (type == "Acquisition-Block") return AccessType::Acquisition; diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsBlock.h b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsBlock.h index e9a637187e2e5b37802a60b9eb5e7a80d75594b2..5c1d37765fda36f23b599190e600738d5ea199ae 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsBlock.h +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsBlock.h @@ -38,7 +38,7 @@ class Block { friend class PLC; public: - Block(const ElementXML& blockNode, AccessType accessType, Connection& plcConnection); + Block(const ElementXML& blockNode, Connection& plcConnection); virtual ~Block(); virtual int receive() = 0; @@ -48,7 +48,7 @@ public: * \fn whichAccessType * \return the enumeration value of the given access-type string */ - static AccessType whichAccessType(std::string type); + static AccessType whichAccessType(const std::string& type); static std::string whichAccessType(AccessType type); /*! 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 e1fa0812aa5aae2023f55f8d6082339fcc68a57f..1f2a777a99d0a64fc56fd251c1b3315d9e12162f 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.cpp +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.cpp @@ -48,13 +48,11 @@ Device::Device(const ElementXML& deviceNode, const std::vector<ElementXML>& bloc { std::string blockName = blockIter->getAttribute("name"); LOG(ALLOC) << "Adding Block to Device: " << blockName; - AccessType accessType = Block::whichAccessType(blockIter->getName()); AccessArea accessArea = AccessArea::Memory; if (blockIter->hasAttribute("ioType")) // only IO-Blocks have this attribute accessArea = Block::whichAccessArea(blockIter->getAttribute("ioType")); - auto& registerNodes = blockIter->getChildNodes(); - blocks_.emplace_back(new PLCBlock(*blockIter, registerNodes, accessType, getInputAddress(accessArea), + blocks_.emplace_back(new PLCBlock(*blockIter, getInputAddress(accessArea), getOutputAddress(accessArea), plcConnection, paramConfig)); } } diff --git a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.h b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.h index 264824f4f15f7a51eda64ed442a224fc3e4578da..802ce57b1fb8fda43d14785b8b63cba9b5eed240 100644 --- a/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.h +++ b/silecs-communication-cpp/src/silecs-communication/interface/equipment/SilecsDevice.h @@ -81,13 +81,6 @@ public: */ int send(const std::string& blockName); - /*! - * \brief Copies input buffer in output buffer - * The method copies the input buffer in the output buffer for each READ-WRITE register for the block passed as parameter - * \param blockName name of the block for which the copy must be performed - */ - // void copyInToOut(const std::string& blockName); - /// @cond /*! * \return all registers of the device for a given block