SILECS C++ Code Snippets

- General -

Specific Init

In order to make the generated silecs-code work, you need to initialize it in the specifc-init of your class (usually in RealTime/ RTDeviceClass.cpp)

// include the silecs header
#include <SiemensTest/Common/SiemensTest.h>
...
// Repalce "MyClass" with the name of your class 
RTDeviceClass::~RTDeviceClass()
{
   MyClass::cleanup();
}

void RTDeviceClass::specificInit()
{
   MyClass::setup(this->MyClassServiceLocator_);
}

- Access of PLC-blocks -

Read a block

// include the silecs header
#include <SiemensTest/Common/SiemensTest.h>
...
// Repalce "MyClass" with the name of your class
// Repalce "MyBlock" with the name of the block you want to read
std::vector<Device*> devCol = this->MyClassServiceLocator_->getDeviceCollection();
std::vector<Device*>::iterator device;
for(device=devCol.begin();device!=devCol.end();++device)
{
   MyClass::MyBlock.getOneDevice((*device),true,pEvt->getMultiplexingContext());
}

Write a block

// include the silecs header
#include <SiemensTest/Common/SiemensTest.h>
...
// Repalce "MyClass" with the name of your class
// Repalce "MyBlock" with the name of the block you want to write
std::vector<Device*> devCol = this->MyClassServiceLocator_->getDeviceCollection();
std::vector<Device*>::iterator device;
for(device=devCol.begin();device!=devCol.end();++device)
{
   MyClass::MyBlock.setOneDevice((*device),true,pEvt->getMultiplexingContext());
}
Topic revision: r1 - 22 Jun 2016, AlexanderSchwinn
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback