Skip to content
Snippets Groups Projects
Commit d7c35b73 authored by m.marn's avatar m.marn
Browse files

Cleanup

parent 852f7ff7
No related branches found
No related tags found
1 merge request!54Partially resolve "Restructure C++ Classes in order to reflect SilecsClasses"
......@@ -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));
}
......
......@@ -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.
......
......@@ -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;
......
......@@ -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);
/*!
......
......@@ -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));
}
}
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment