diff --git a/silecs-codegen/src/xml/test/general/genplcsrcTest.py b/silecs-codegen/src/xml/test/general/genplcsrcTest.py index 7262d6a2d106f74ccc23e4adb97f0c58e020fce4..24eb2b91e29a811fc0ee371bda5ea7853d526910 100644 --- a/silecs-codegen/src/xml/test/general/genplcsrcTest.py +++ b/silecs-codegen/src/xml/test/general/genplcsrcTest.py @@ -65,15 +65,7 @@ def SiemensSourcesTest(): def SiemensVirtualSourcesTest(): CompareGeneratedFiles("SilecsHeader_1.0.0",".h") CompareGeneratedFiles("Virtual_SiemensBlock_0.1.0",".cpp") - CompareGeneratedFiles("Virtual_SiemensBlock.AllTypes",".h") - CompareGeneratedFiles("Virtual_SiemensBlock",".cpp") - CompareGeneratedFiles("Virtual_SiemensBlock",".h") - CompareGeneratedFiles("Virtual_SiemensBlock.SilecsHeader",".h") CompareGeneratedFiles("Virtual_SiemensDevice_0.1.0",".cpp") - CompareGeneratedFiles("Virtual_SiemensDevice.AllTypes",".h") - CompareGeneratedFiles("Virtual_SiemensDevice",".cpp") - CompareGeneratedFiles("Virtual_SiemensDevice",".h") - CompareGeneratedFiles("Virtual_SiemensDevice.SilecsHeader",".h") def BeckhoffSourcesTest(): CompareGeneratedFiles("Beckhoff_BC9020",".exp") diff --git a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.AllTypes.h b/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.AllTypes.h deleted file mode 100644 index 20575358570ca5090c7998c15c3e0c4673cab700..0000000000000000000000000000000000000000 --- a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.AllTypes.h +++ /dev/null @@ -1,1272 +0,0 @@ - -/* Copyright CERN 2015 - * - * WARNING: This code is automatically generated from your SILECS deploy unit document. - * You should never modify the content of this file as it would break consistency. - * Furthermore, any changes will be overwritten in the next code generation. - * Any modification shall be done using the SILECS development environment - * and regenerating this source code. - */ - -#ifndef ALLTYPES_0_1_0_H_ -#define ALLTYPES_0_1_0_H_ - -#include <silecs-virtual-controller/interface/Block.h> -#include <silecs-virtual-controller/interface/DeployUnit.h> -#include <silecs-virtual-controller/interface/Design.h> -#include <silecs-virtual-controller/interface/Device.h> - -namespace AllTypes_0_1_0 -{ - -class Design; - -class MyROBlock : public SilecsServer::Block -{ -public: - /*! - * \brief MyROBlock constructor. It creates an empty block. - */ - MyROBlock() : SilecsServer::Block("AllTypes:MyROBlock") - { - - } - - ~MyROBlock() - { - } - - /*! - * \brief Get RO_int8 register. - * \return value. - */ - int8_t getRO_int8() const - { - return structData_.RO_int8; - } - - /*! - * \brief Set RO_int8 register. - * \param value to be set. - */ - void setRO_int8(int8_t value) - { - structData_.RO_int8 = value; - } - - /*! - * \brief Get RO_uint8 register. - * \return value. - */ - uint8_t getRO_uint8() const - { - return structData_.RO_uint8; - } - - /*! - * \brief Set RO_uint8 register. - * \param value to be set. - */ - void setRO_uint8(uint8_t value) - { - structData_.RO_uint8 = value; - } - - /*! - * \brief Get RO_int16 register. - * \return value. - */ - int16_t getRO_int16() const - { - return structData_.RO_int16; - } - - /*! - * \brief Set RO_int16 register. - * \param value to be set. - */ - void setRO_int16(int16_t value) - { - structData_.RO_int16 = value; - } - - /*! - * \brief Get RO_uint16 register. - * \return value. - */ - uint16_t getRO_uint16() const - { - return structData_.RO_uint16; - } - - /*! - * \brief Set RO_uint16 register. - * \param value to be set. - */ - void setRO_uint16(uint16_t value) - { - structData_.RO_uint16 = value; - } - - /*! - * \brief Get RO_int32 register. - * \return value. - */ - int32_t getRO_int32() const - { - return structData_.RO_int32; - } - - /*! - * \brief Set RO_int32 register. - * \param value to be set. - */ - void setRO_int32(int32_t value) - { - structData_.RO_int32 = value; - } - - /*! - * \brief Get RO_uint32 register. - * \return value. - */ - uint32_t getRO_uint32() const - { - return structData_.RO_uint32; - } - - /*! - * \brief Set RO_uint32 register. - * \param value to be set. - */ - void setRO_uint32(uint32_t value) - { - structData_.RO_uint32 = value; - } - - /*! - * \brief Get RO_float32 register. - * \return value. - */ - float getRO_float32() const - { - return structData_.RO_float32; - } - - /*! - * \brief Set RO_float32 register. - * \param value to be set. - */ - void setRO_float32(float value) - { - structData_.RO_float32 = value; - } - - /*! - * \brief Get RO_string register. - * \return value. - */ - std::string getRO_string() const - { - size_t len = (size_t)structData_.RO_string[1]; - return std::string((char*)&(structData_.RO_string[2]), len); - } - - /*! - * \brief Set RO_string register. - * \param value to be set. - */ - void setRO_string(const std::string &value) - { - size_t len = (value.length() < RO_stringLen_) ? value.length() : RO_stringLen_; - memcpy((char*)&(structData_.RO_string[2]), value.c_str(), len); - structData_.RO_string[0] = char(0); - structData_.RO_string[1] = char(len); - } - - /*! - * \brief Get RO_date register. - * \return value. - */ - double getRO_date() const - { - return structData_.RO_date; - } - - /*! - * \brief Set RO_date register. - * \param value to be set. - */ - void setRO_date(double value) - { - structData_.RO_date = value; - } - - /*! - * \brief Get RO_char register. - * \return value. - */ - int8_t getRO_char() const - { - return structData_.RO_char; - } - - /*! - * \brief Set RO_char register. - * \param value to be set. - */ - void setRO_char(int8_t value) - { - structData_.RO_char = value; - } - - /*! - * \brief Get RO_byte register. - * \return value. - */ - uint8_t getRO_byte() const - { - return structData_.RO_byte; - } - - /*! - * \brief Set RO_byte register. - * \param value to be set. - */ - void setRO_byte(uint8_t value) - { - structData_.RO_byte = value; - } - - /*! - * \brief Get RO_word register. - * \return value. - */ - uint16_t getRO_word() const - { - return structData_.RO_word; - } - - /*! - * \brief Set RO_word register. - * \param value to be set. - */ - void setRO_word(uint16_t value) - { - structData_.RO_word = value; - } - - /*! - * \brief Get RO_dword register. - * \return value. - */ - uint32_t getRO_dword() const - { - return structData_.RO_dword; - } - - /*! - * \brief Set RO_dword register. - * \param value to be set. - */ - void setRO_dword(uint32_t value) - { - structData_.RO_dword = value; - } - - /*! - * \brief Get RO_int register. - * \return value. - */ - int16_t getRO_int() const - { - return structData_.RO_int; - } - - /*! - * \brief Set RO_int register. - * \param value to be set. - */ - void setRO_int(int16_t value) - { - structData_.RO_int = value; - } - - /*! - * \brief Get RO_dint register. - * \return value. - */ - int32_t getRO_dint() const - { - return structData_.RO_dint; - } - - /*! - * \brief Set RO_dint register. - * \param value to be set. - */ - void setRO_dint(int32_t value) - { - structData_.RO_dint = value; - } - - /*! - * \brief Get RO_real register. - * \return value. - */ - float getRO_real() const - { - return structData_.RO_real; - } - - /*! - * \brief Set RO_real register. - * \param value to be set. - */ - void setRO_real(float value) - { - structData_.RO_real = value; - } - - /*! - * \brief Get RO_dt register. - * \return value. - */ - double getRO_dt() const - { - return structData_.RO_dt; - } - - /*! - * \brief Set RO_dt register. - * \param value to be set. - */ - void setRO_dt(double value) - { - structData_.RO_dt = value; - } - - virtual inline size_t getSize() const - { - return sizeof(structData_); - } - - virtual void getData(unsigned char * data) const - { - memcpy(data, &structData_, this->getSize()); - } - - virtual void setData(unsigned char * data) - { - memcpy(&structData_, data, this->getSize()); - } - - virtual inline size_t getOffset() const { return 48; } - - static const std::size_t RO_stringLen_ = 64; - -private: - -#pragma pack(push, 1) - struct - { - int8_t RO_int8; - uint8_t RO_uint8; - int16_t RO_int16; - uint16_t RO_uint16; - int32_t RO_int32; - uint32_t RO_uint32; - float RO_float32; - char RO_string[RO_stringLen_+2]; - double RO_date; - int8_t RO_char; - uint8_t RO_byte; - uint16_t RO_word; - uint32_t RO_dword; - int16_t RO_int; - int32_t RO_dint; - float RO_real; - double RO_dt; - - } structData_; -#pragma pack(pop) - -}; - -class MyRWBlock : public SilecsServer::Block -{ -public: - /*! - * \brief MyRWBlock constructor. It creates an empty block. - */ - MyRWBlock() : SilecsServer::Block("AllTypes:MyRWBlock") - { - - } - - ~MyRWBlock() - { - } - - /*! - * \brief Get array RW_int8 register. - * \return value. - */ - void getRW_int8(int8_t* value) const - { - memcpy(value, &structData_.RW_int8, RW_int8Dim1_ * RW_int8Dim2_ * sizeof(int8_t)); - } - - /*! - * \brief Set array RW_int8 register. - * \param value to be set. - */ - void setRW_int8(int8_t* value) - { - memcpy(&structData_.RW_int8, value, RW_int8Dim1_ * RW_int8Dim2_ * sizeof(int8_t)); - } - - /*! - * \brief Get array RW_uint8 register. - * \return value. - */ - void getRW_uint8(uint8_t* value) const - { - memcpy(value, &structData_.RW_uint8, RW_uint8Dim1_ * RW_uint8Dim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Set array RW_uint8 register. - * \param value to be set. - */ - void setRW_uint8(uint8_t* value) - { - memcpy(&structData_.RW_uint8, value, RW_uint8Dim1_ * RW_uint8Dim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Get array RW_int16 register. - * \return value. - */ - void getRW_int16(int16_t* value) const - { - memcpy(value, &structData_.RW_int16, RW_int16Dim1_ * RW_int16Dim2_ * sizeof(int16_t)); - } - - /*! - * \brief Set array RW_int16 register. - * \param value to be set. - */ - void setRW_int16(int16_t* value) - { - memcpy(&structData_.RW_int16, value, RW_int16Dim1_ * RW_int16Dim2_ * sizeof(int16_t)); - } - - /*! - * \brief Get array RW_uint16 register. - * \return value. - */ - void getRW_uint16(uint16_t* value) const - { - memcpy(value, &structData_.RW_uint16, RW_uint16Dim1_ * RW_uint16Dim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Set array RW_uint16 register. - * \param value to be set. - */ - void setRW_uint16(uint16_t* value) - { - memcpy(&structData_.RW_uint16, value, RW_uint16Dim1_ * RW_uint16Dim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Get array RW_int32 register. - * \return value. - */ - void getRW_int32(int32_t* value) const - { - memcpy(value, &structData_.RW_int32, RW_int32Dim1_ * RW_int32Dim2_ * sizeof(int32_t)); - } - - /*! - * \brief Set array RW_int32 register. - * \param value to be set. - */ - void setRW_int32(int32_t* value) - { - memcpy(&structData_.RW_int32, value, RW_int32Dim1_ * RW_int32Dim2_ * sizeof(int32_t)); - } - - /*! - * \brief Get array RW_uint32 register. - * \return value. - */ - void getRW_uint32(uint32_t* value) const - { - memcpy(value, &structData_.RW_uint32, RW_uint32Dim1_ * RW_uint32Dim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Set array RW_uint32 register. - * \param value to be set. - */ - void setRW_uint32(uint32_t* value) - { - memcpy(&structData_.RW_uint32, value, RW_uint32Dim1_ * RW_uint32Dim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Get array RW_float32 register. - * \return value. - */ - void getRW_float32(float* value) const - { - memcpy(value, &structData_.RW_float32, RW_float32Dim1_ * RW_float32Dim2_ * sizeof(float)); - } - - /*! - * \brief Set array RW_float32 register. - * \param value to be set. - */ - void setRW_float32(float* value) - { - memcpy(&structData_.RW_float32, value, RW_float32Dim1_ * RW_float32Dim2_ * sizeof(float)); - } - - /*! - * \brief Get std::string RW_string register. - * \param value buffer where the value will be stored. - */ - void getRW_string(std::string* value) const - { - for (std::size_t i = 0; i < RW_stringDim1_; i++) - { - size_t len = (size_t)structData_.RW_string[i][1]; - value[i].assign(&(structData_.RW_string[i][2]), len); - } - } - - /*! - * \brief Set std::string RW_string register. - * \param value to be set. - */ - void setRW_string(std::string* value) - { - for (std::size_t i = 0; i < RW_stringDim1_; i++) - { - size_t len = (value[i].length() < RW_stringLen_) ? value[i].length() : RW_stringLen_; - memcpy(&(structData_.RW_string[i][2]), value[i].c_str(), len); - structData_.RW_string[i][0] = char(0); - structData_.RW_string[i][1] = char(len); - } - } - - /*! - * \brief Get array RW_date register. - * \return value. - */ - void getRW_date(double* value) const - { - memcpy(value, &structData_.RW_date, RW_dateDim1_ * RW_dateDim2_ * sizeof(double)); - } - - /*! - * \brief Set array RW_date register. - * \param value to be set. - */ - void setRW_date(double* value) - { - memcpy(&structData_.RW_date, value, RW_dateDim1_ * RW_dateDim2_ * sizeof(double)); - } - - /*! - * \brief Get array RW_char register. - * \return value. - */ - void getRW_char(int8_t* value) const - { - memcpy(value, &structData_.RW_char, RW_charDim1_ * RW_charDim2_ * sizeof(int8_t)); - } - - /*! - * \brief Set array RW_char register. - * \param value to be set. - */ - void setRW_char(int8_t* value) - { - memcpy(&structData_.RW_char, value, RW_charDim1_ * RW_charDim2_ * sizeof(int8_t)); - } - - /*! - * \brief Get array RW_byte register. - * \return value. - */ - void getRW_byte(uint8_t* value) const - { - memcpy(value, &structData_.RW_byte, RW_byteDim1_ * RW_byteDim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Set array RW_byte register. - * \param value to be set. - */ - void setRW_byte(uint8_t* value) - { - memcpy(&structData_.RW_byte, value, RW_byteDim1_ * RW_byteDim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Get array RW_word register. - * \return value. - */ - void getRW_word(uint16_t* value) const - { - memcpy(value, &structData_.RW_word, RW_wordDim1_ * RW_wordDim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Set array RW_word register. - * \param value to be set. - */ - void setRW_word(uint16_t* value) - { - memcpy(&structData_.RW_word, value, RW_wordDim1_ * RW_wordDim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Get array RW_dword register. - * \return value. - */ - void getRW_dword(uint32_t* value) const - { - memcpy(value, &structData_.RW_dword, RW_dwordDim1_ * RW_dwordDim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Set array RW_dword register. - * \param value to be set. - */ - void setRW_dword(uint32_t* value) - { - memcpy(&structData_.RW_dword, value, RW_dwordDim1_ * RW_dwordDim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Get array RW_int register. - * \return value. - */ - void getRW_int(int16_t* value) const - { - memcpy(value, &structData_.RW_int, RW_intDim1_ * RW_intDim2_ * sizeof(int16_t)); - } - - /*! - * \brief Set array RW_int register. - * \param value to be set. - */ - void setRW_int(int16_t* value) - { - memcpy(&structData_.RW_int, value, RW_intDim1_ * RW_intDim2_ * sizeof(int16_t)); - } - - /*! - * \brief Get array RW_dint register. - * \return value. - */ - void getRW_dint(int32_t* value) const - { - memcpy(value, &structData_.RW_dint, RW_dintDim1_ * RW_dintDim2_ * sizeof(int32_t)); - } - - /*! - * \brief Set array RW_dint register. - * \param value to be set. - */ - void setRW_dint(int32_t* value) - { - memcpy(&structData_.RW_dint, value, RW_dintDim1_ * RW_dintDim2_ * sizeof(int32_t)); - } - - /*! - * \brief Get array RW_real register. - * \return value. - */ - void getRW_real(float* value) const - { - memcpy(value, &structData_.RW_real, RW_realDim1_ * RW_realDim2_ * sizeof(float)); - } - - /*! - * \brief Set array RW_real register. - * \param value to be set. - */ - void setRW_real(float* value) - { - memcpy(&structData_.RW_real, value, RW_realDim1_ * RW_realDim2_ * sizeof(float)); - } - - /*! - * \brief Get array RW_dt register. - * \return value. - */ - void getRW_dt(double* value) const - { - memcpy(value, &structData_.RW_dt, RW_dtDim1_ * RW_dtDim2_ * sizeof(double)); - } - - /*! - * \brief Set array RW_dt register. - * \param value to be set. - */ - void setRW_dt(double* value) - { - memcpy(&structData_.RW_dt, value, RW_dtDim1_ * RW_dtDim2_ * sizeof(double)); - } - - virtual inline size_t getSize() const - { - return sizeof(structData_); - } - - virtual void getData(unsigned char * data) const - { - memcpy(data, &structData_, this->getSize()); - } - - virtual void setData(unsigned char * data) - { - memcpy(&structData_, data, this->getSize()); - } - - virtual inline size_t getOffset() const { return 284; } - - static const std::size_t RW_int8Dim1_ = 2; - static const std::size_t RW_int8Dim2_ = 2; - static const std::size_t RW_uint8Dim1_ = 2; - static const std::size_t RW_uint8Dim2_ = 2; - static const std::size_t RW_int16Dim1_ = 2; - static const std::size_t RW_int16Dim2_ = 2; - static const std::size_t RW_uint16Dim1_ = 2; - static const std::size_t RW_uint16Dim2_ = 2; - static const std::size_t RW_int32Dim1_ = 2; - static const std::size_t RW_int32Dim2_ = 2; - static const std::size_t RW_uint32Dim1_ = 2; - static const std::size_t RW_uint32Dim2_ = 2; - static const std::size_t RW_float32Dim1_ = 2; - static const std::size_t RW_float32Dim2_ = 2; - static const std::size_t RW_stringDim1_ = 2; - static const std::size_t RW_stringDim2_ = 2; - static const std::size_t RW_stringLen_ = 64; - static const std::size_t RW_dateDim1_ = 2; - static const std::size_t RW_dateDim2_ = 2; - static const std::size_t RW_charDim1_ = 2; - static const std::size_t RW_charDim2_ = 2; - static const std::size_t RW_byteDim1_ = 2; - static const std::size_t RW_byteDim2_ = 2; - static const std::size_t RW_wordDim1_ = 2; - static const std::size_t RW_wordDim2_ = 2; - static const std::size_t RW_dwordDim1_ = 2; - static const std::size_t RW_dwordDim2_ = 2; - static const std::size_t RW_intDim1_ = 2; - static const std::size_t RW_intDim2_ = 2; - static const std::size_t RW_dintDim1_ = 2; - static const std::size_t RW_dintDim2_ = 2; - static const std::size_t RW_realDim1_ = 2; - static const std::size_t RW_realDim2_ = 2; - static const std::size_t RW_dtDim1_ = 2; - static const std::size_t RW_dtDim2_ = 2; - -private: - -#pragma pack(push, 1) - struct - { - int8_t RW_int8[RW_int8Dim1_][RW_int8Dim2_]; - uint8_t RW_uint8[RW_uint8Dim1_][RW_uint8Dim2_]; - int16_t RW_int16[RW_int16Dim1_][RW_int16Dim2_]; - uint16_t RW_uint16[RW_uint16Dim1_][RW_uint16Dim2_]; - int32_t RW_int32[RW_int32Dim1_][RW_int32Dim2_]; - uint32_t RW_uint32[RW_uint32Dim1_][RW_uint32Dim2_]; - float RW_float32[RW_float32Dim1_][RW_float32Dim2_]; - char RW_string[RW_stringDim1_][RW_stringDim2_][RW_stringLen_+2]; - double RW_date[RW_dateDim1_][RW_dateDim2_]; - int8_t RW_char[RW_charDim1_][RW_charDim2_]; - uint8_t RW_byte[RW_byteDim1_][RW_byteDim2_]; - uint16_t RW_word[RW_wordDim1_][RW_wordDim2_]; - uint32_t RW_dword[RW_dwordDim1_][RW_dwordDim2_]; - int16_t RW_int[RW_intDim1_][RW_intDim2_]; - int32_t RW_dint[RW_dintDim1_][RW_dintDim2_]; - float RW_real[RW_realDim1_][RW_realDim2_]; - double RW_dt[RW_dtDim1_][RW_dtDim2_]; - - } structData_; -#pragma pack(pop) - -}; - -class MyWOBlock : public SilecsServer::Block -{ -public: - /*! - * \brief MyWOBlock constructor. It creates an empty block. - */ - MyWOBlock() : SilecsServer::Block("AllTypes:MyWOBlock") - { - - } - - ~MyWOBlock() - { - } - - /*! - * \brief Get array WO_int8 register. - * \return value. - */ - void getWO_int8(int8_t* value) const - { - memcpy(value, &structData_.WO_int8, WO_int8Dim1_ * WO_int8Dim2_ * sizeof(int8_t)); - } - - /*! - * \brief Set array WO_int8 register. - * \param value to be set. - */ - void setWO_int8(int8_t* value) - { - memcpy(&structData_.WO_int8, value, WO_int8Dim1_ * WO_int8Dim2_ * sizeof(int8_t)); - } - - /*! - * \brief Get array WO_uint8 register. - * \return value. - */ - void getWO_uint8(uint8_t* value) const - { - memcpy(value, &structData_.WO_uint8, WO_uint8Dim1_ * WO_uint8Dim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Set array WO_uint8 register. - * \param value to be set. - */ - void setWO_uint8(uint8_t* value) - { - memcpy(&structData_.WO_uint8, value, WO_uint8Dim1_ * WO_uint8Dim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Get array WO_int16 register. - * \return value. - */ - void getWO_int16(int16_t* value) const - { - memcpy(value, &structData_.WO_int16, WO_int16Dim1_ * WO_int16Dim2_ * sizeof(int16_t)); - } - - /*! - * \brief Set array WO_int16 register. - * \param value to be set. - */ - void setWO_int16(int16_t* value) - { - memcpy(&structData_.WO_int16, value, WO_int16Dim1_ * WO_int16Dim2_ * sizeof(int16_t)); - } - - /*! - * \brief Get array WO_uint16 register. - * \return value. - */ - void getWO_uint16(uint16_t* value) const - { - memcpy(value, &structData_.WO_uint16, WO_uint16Dim1_ * WO_uint16Dim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Set array WO_uint16 register. - * \param value to be set. - */ - void setWO_uint16(uint16_t* value) - { - memcpy(&structData_.WO_uint16, value, WO_uint16Dim1_ * WO_uint16Dim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Get array WO_int32 register. - * \return value. - */ - void getWO_int32(int32_t* value) const - { - memcpy(value, &structData_.WO_int32, WO_int32Dim1_ * WO_int32Dim2_ * sizeof(int32_t)); - } - - /*! - * \brief Set array WO_int32 register. - * \param value to be set. - */ - void setWO_int32(int32_t* value) - { - memcpy(&structData_.WO_int32, value, WO_int32Dim1_ * WO_int32Dim2_ * sizeof(int32_t)); - } - - /*! - * \brief Get array WO_uint32 register. - * \return value. - */ - void getWO_uint32(uint32_t* value) const - { - memcpy(value, &structData_.WO_uint32, WO_uint32Dim1_ * WO_uint32Dim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Set array WO_uint32 register. - * \param value to be set. - */ - void setWO_uint32(uint32_t* value) - { - memcpy(&structData_.WO_uint32, value, WO_uint32Dim1_ * WO_uint32Dim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Get array WO_float32 register. - * \return value. - */ - void getWO_float32(float* value) const - { - memcpy(value, &structData_.WO_float32, WO_float32Dim1_ * WO_float32Dim2_ * sizeof(float)); - } - - /*! - * \brief Set array WO_float32 register. - * \param value to be set. - */ - void setWO_float32(float* value) - { - memcpy(&structData_.WO_float32, value, WO_float32Dim1_ * WO_float32Dim2_ * sizeof(float)); - } - - /*! - * \brief Get std::string WO_string register. - * \param value buffer where the value will be stored. - */ - void getWO_string(std::string* value) const - { - for (std::size_t i = 0; i < WO_stringDim1_; i++) - { - size_t len = (size_t)structData_.WO_string[i][1]; - value[i].assign(&(structData_.WO_string[i][2]), len); - } - } - - /*! - * \brief Set std::string WO_string register. - * \param value to be set. - */ - void setWO_string(std::string* value) - { - for (std::size_t i = 0; i < WO_stringDim1_; i++) - { - size_t len = (value[i].length() < WO_stringLen_) ? value[i].length() : WO_stringLen_; - memcpy(&(structData_.WO_string[i][2]), value[i].c_str(), len); - structData_.WO_string[i][0] = char(0); - structData_.WO_string[i][1] = char(len); - } - } - - /*! - * \brief Get array WO_date register. - * \return value. - */ - void getWO_date(double* value) const - { - memcpy(value, &structData_.WO_date, WO_dateDim1_ * WO_dateDim2_ * sizeof(double)); - } - - /*! - * \brief Set array WO_date register. - * \param value to be set. - */ - void setWO_date(double* value) - { - memcpy(&structData_.WO_date, value, WO_dateDim1_ * WO_dateDim2_ * sizeof(double)); - } - - /*! - * \brief Get array WO_char register. - * \return value. - */ - void getWO_char(int8_t* value) const - { - memcpy(value, &structData_.WO_char, WO_charDim1_ * WO_charDim2_ * sizeof(int8_t)); - } - - /*! - * \brief Set array WO_char register. - * \param value to be set. - */ - void setWO_char(int8_t* value) - { - memcpy(&structData_.WO_char, value, WO_charDim1_ * WO_charDim2_ * sizeof(int8_t)); - } - - /*! - * \brief Get array WO_byte register. - * \return value. - */ - void getWO_byte(uint8_t* value) const - { - memcpy(value, &structData_.WO_byte, WO_byteDim1_ * WO_byteDim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Set array WO_byte register. - * \param value to be set. - */ - void setWO_byte(uint8_t* value) - { - memcpy(&structData_.WO_byte, value, WO_byteDim1_ * WO_byteDim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Get array WO_word register. - * \return value. - */ - void getWO_word(uint16_t* value) const - { - memcpy(value, &structData_.WO_word, WO_wordDim1_ * WO_wordDim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Set array WO_word register. - * \param value to be set. - */ - void setWO_word(uint16_t* value) - { - memcpy(&structData_.WO_word, value, WO_wordDim1_ * WO_wordDim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Get array WO_dword register. - * \return value. - */ - void getWO_dword(uint32_t* value) const - { - memcpy(value, &structData_.WO_dword, WO_dwordDim1_ * WO_dwordDim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Set array WO_dword register. - * \param value to be set. - */ - void setWO_dword(uint32_t* value) - { - memcpy(&structData_.WO_dword, value, WO_dwordDim1_ * WO_dwordDim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Get array WO_int register. - * \return value. - */ - void getWO_int(int16_t* value) const - { - memcpy(value, &structData_.WO_int, WO_intDim1_ * WO_intDim2_ * sizeof(int16_t)); - } - - /*! - * \brief Set array WO_int register. - * \param value to be set. - */ - void setWO_int(int16_t* value) - { - memcpy(&structData_.WO_int, value, WO_intDim1_ * WO_intDim2_ * sizeof(int16_t)); - } - - /*! - * \brief Get array WO_dint register. - * \return value. - */ - void getWO_dint(int32_t* value) const - { - memcpy(value, &structData_.WO_dint, WO_dintDim1_ * WO_dintDim2_ * sizeof(int32_t)); - } - - /*! - * \brief Set array WO_dint register. - * \param value to be set. - */ - void setWO_dint(int32_t* value) - { - memcpy(&structData_.WO_dint, value, WO_dintDim1_ * WO_dintDim2_ * sizeof(int32_t)); - } - - /*! - * \brief Get array WO_real register. - * \return value. - */ - void getWO_real(float* value) const - { - memcpy(value, &structData_.WO_real, WO_realDim1_ * WO_realDim2_ * sizeof(float)); - } - - /*! - * \brief Set array WO_real register. - * \param value to be set. - */ - void setWO_real(float* value) - { - memcpy(&structData_.WO_real, value, WO_realDim1_ * WO_realDim2_ * sizeof(float)); - } - - /*! - * \brief Get array WO_dt register. - * \return value. - */ - void getWO_dt(double* value) const - { - memcpy(value, &structData_.WO_dt, WO_dtDim1_ * WO_dtDim2_ * sizeof(double)); - } - - /*! - * \brief Set array WO_dt register. - * \param value to be set. - */ - void setWO_dt(double* value) - { - memcpy(&structData_.WO_dt, value, WO_dtDim1_ * WO_dtDim2_ * sizeof(double)); - } - - virtual inline size_t getSize() const - { - return sizeof(structData_); - } - - virtual void getData(unsigned char * data) const - { - memcpy(data, &structData_, this->getSize()); - } - - virtual void setData(unsigned char * data) - { - memcpy(&structData_, data, this->getSize()); - } - - virtual inline size_t getOffset() const { return 1228; } - - static const std::size_t WO_int8Dim1_ = 10; - static const std::size_t WO_int8Dim2_ = 1; - static const std::size_t WO_uint8Dim1_ = 10; - static const std::size_t WO_uint8Dim2_ = 1; - static const std::size_t WO_int16Dim1_ = 10; - static const std::size_t WO_int16Dim2_ = 1; - static const std::size_t WO_uint16Dim1_ = 10; - static const std::size_t WO_uint16Dim2_ = 1; - static const std::size_t WO_int32Dim1_ = 10; - static const std::size_t WO_int32Dim2_ = 1; - static const std::size_t WO_uint32Dim1_ = 10; - static const std::size_t WO_uint32Dim2_ = 1; - static const std::size_t WO_float32Dim1_ = 10; - static const std::size_t WO_float32Dim2_ = 1; - static const std::size_t WO_stringDim1_ = 10; - static const std::size_t WO_stringDim2_ = 1; - static const std::size_t WO_stringLen_ = 64; - static const std::size_t WO_dateDim1_ = 10; - static const std::size_t WO_dateDim2_ = 1; - static const std::size_t WO_charDim1_ = 10; - static const std::size_t WO_charDim2_ = 1; - static const std::size_t WO_byteDim1_ = 10; - static const std::size_t WO_byteDim2_ = 1; - static const std::size_t WO_wordDim1_ = 10; - static const std::size_t WO_wordDim2_ = 1; - static const std::size_t WO_dwordDim1_ = 10; - static const std::size_t WO_dwordDim2_ = 1; - static const std::size_t WO_intDim1_ = 10; - static const std::size_t WO_intDim2_ = 1; - static const std::size_t WO_dintDim1_ = 10; - static const std::size_t WO_dintDim2_ = 1; - static const std::size_t WO_realDim1_ = 10; - static const std::size_t WO_realDim2_ = 1; - static const std::size_t WO_dtDim1_ = 10; - static const std::size_t WO_dtDim2_ = 1; - -private: - -#pragma pack(push, 1) - struct - { - int8_t WO_int8[WO_int8Dim1_]; - uint8_t WO_uint8[WO_uint8Dim1_]; - int16_t WO_int16[WO_int16Dim1_]; - uint16_t WO_uint16[WO_uint16Dim1_]; - int32_t WO_int32[WO_int32Dim1_]; - uint32_t WO_uint32[WO_uint32Dim1_]; - float WO_float32[WO_float32Dim1_]; - char WO_string[WO_stringDim1_][WO_stringLen_+2]; - double WO_date[WO_dateDim1_]; - int8_t WO_char[WO_charDim1_]; - uint8_t WO_byte[WO_byteDim1_]; - uint16_t WO_word[WO_wordDim1_]; - uint32_t WO_dword[WO_dwordDim1_]; - int16_t WO_int[WO_intDim1_]; - int32_t WO_dint[WO_dintDim1_]; - float WO_real[WO_realDim1_]; - double WO_dt[WO_dtDim1_]; - - } structData_; -#pragma pack(pop) - -}; - - - -class Device : public SilecsServer::Device -{ -public: - Device(const std::string& label, size_t number):SilecsServer::Device(label, number) - { - blockMap_["AllTypes:MyROBlock"] = new MyROBlock(); - blockMap_["AllTypes:MyRWBlock"] = new MyRWBlock(); - blockMap_["AllTypes:MyWOBlock"] = new MyWOBlock(); - } - - ~Device() - { - delete (blockMap_["AllTypes:MyROBlock"]); - delete (blockMap_["AllTypes:MyRWBlock"]); - delete (blockMap_["AllTypes:MyWOBlock"]); - } -}; - - -class Design : public SilecsServer::Design -{ -public: - - Design():SilecsServer::Design("AllTypes", "0.1.0") - { - deviceMap_["AllTypes:testDevice1"] = new Device("AllTypes:testDevice1", 0); - deviceMap_["AllTypes:testDevice2"] = new Device("AllTypes:testDevice2", 1); - } - - ~Design() - { - delete(deviceMap_["AllTypes:testDevice1"]); - delete(deviceMap_["AllTypes:testDevice2"]); - } - - /*! - * \brief Return pointer to the requested device. - * \param label Device label. - */ - AllTypes_0_1_0::Device* getDevice(const std::string& label) - { - if (deviceMap_.find(label) != deviceMap_.end()) - { - return dynamic_cast<AllTypes_0_1_0::Device*>(deviceMap_[label]); - } - return NULL; - } -}; - -} /* namespace */ -#endif diff --git a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.SilecsHeader.h b/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.SilecsHeader.h deleted file mode 100644 index b6929715548326dafede84de2ed0143fba5f4dae..0000000000000000000000000000000000000000 --- a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.SilecsHeader.h +++ /dev/null @@ -1,203 +0,0 @@ - -/* Copyright CERN 2015 - * - * WARNING: This code is automatically generated from your SILECS deploy unit document. - * You should never modify the content of this file as it would break consistency. - * Furthermore, any changes will be overwritten in the next code generation. - * Any modification shall be done using the SILECS development environment - * and regenerating this source code. - */ - -#ifndef SILECSHEADER_1_0_0_H_ -#define SILECSHEADER_1_0_0_H_ - -#include <silecs-virtual-controller/interface/Block.h> -#include <silecs-virtual-controller/interface/DeployUnit.h> -#include <silecs-virtual-controller/interface/Design.h> -#include <silecs-virtual-controller/interface/Device.h> - -namespace SilecsHeader_1_0_0 -{ - -class Design; - -class HdrBlk : public SilecsServer::Block -{ -public: - /*! - * \brief hdrBlk constructor. It creates an empty block. - */ - HdrBlk() : SilecsServer::Block("SilecsHeader:hdrBlk") - { - set_version("DEV"); - set_checksum(0XFFE06812); - set_user("schwinn"); - set_date(0.0); - } - - ~HdrBlk() - { - } - - /*! - * \brief Get _version register. - * \return value. - */ - std::string get_version() const - { - size_t len = (size_t)structData_._version[1]; - return std::string((char*)&(structData_._version[2]), len); - } - - /*! - * \brief Set _version register. - * \param value to be set. - */ - void set_version(const std::string &value) - { - size_t len = (value.length() < _versionLen_) ? value.length() : _versionLen_; - memcpy((char*)&(structData_._version[2]), value.c_str(), len); - structData_._version[0] = char(0); - structData_._version[1] = char(len); - } - - /*! - * \brief Get _checksum register. - * \return value. - */ - uint32_t get_checksum() const - { - return structData_._checksum; - } - - /*! - * \brief Set _checksum register. - * \param value to be set. - */ - void set_checksum(uint32_t value) - { - structData_._checksum = value; - } - - /*! - * \brief Get _user register. - * \return value. - */ - std::string get_user() const - { - size_t len = (size_t)structData_._user[1]; - return std::string((char*)&(structData_._user[2]), len); - } - - /*! - * \brief Set _user register. - * \param value to be set. - */ - void set_user(const std::string &value) - { - size_t len = (value.length() < _userLen_) ? value.length() : _userLen_; - memcpy((char*)&(structData_._user[2]), value.c_str(), len); - structData_._user[0] = char(0); - structData_._user[1] = char(len); - } - - /*! - * \brief Get _date register. - * \return value. - */ - double get_date() const - { - return structData_._date; - } - - /*! - * \brief Set _date register. - * \param value to be set. - */ - void set_date(double value) - { - structData_._date = value; - } - - virtual inline size_t getSize() const - { - return sizeof(structData_); - } - - virtual void getData(unsigned char * data) const - { - memcpy(data, &structData_, this->getSize()); - } - - virtual void setData(unsigned char * data) - { - memcpy(&structData_, data, this->getSize()); - } - - virtual inline size_t getOffset() const { return 0; } - - static const std::size_t _versionLen_ = 16; - static const std::size_t _userLen_ = 16; - -private: - -#pragma pack(push, 1) - struct - { - char _version[_versionLen_+2]; - uint32_t _checksum; - char _user[_userLen_+2]; - double _date; - - } structData_; -#pragma pack(pop) - -}; - - - -class Device : public SilecsServer::Device -{ -public: - Device(const std::string& label, size_t number):SilecsServer::Device(label, number) - { - blockMap_["SilecsHeader:hdrBlk"] = new HdrBlk(); - } - - ~Device() - { - delete (blockMap_["SilecsHeader:hdrBlk"]); - } -}; - - -class Design : public SilecsServer::Design -{ -public: - - Design():SilecsServer::Design("SilecsHeader", "1.0.0") - { - deviceMap_["SilecsHeader:SilecsHeader"] = new Device("SilecsHeader:SilecsHeader", 0); - } - - ~Design() - { - delete(deviceMap_["SilecsHeader:SilecsHeader"]); - } - - /*! - * \brief Return pointer to the requested device. - * \param label Device label. - */ - SilecsHeader_1_0_0::Device* getDevice(const std::string& label) - { - if (deviceMap_.find(label) != deviceMap_.end()) - { - return dynamic_cast<SilecsHeader_1_0_0::Device*>(deviceMap_[label]); - } - return NULL; - } -}; - -} /* namespace */ -#endif diff --git a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.cpp b/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.cpp deleted file mode 100644 index d7e2a30372df7923ad5c8667bbdf45c9d043942e..0000000000000000000000000000000000000000 --- a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <cstring> -#include <iostream> - -#include <silecs-virtual-controller/core/SilecsSnap7Server.h> -#include "Virtual_SiemensBlock.h" - -class UserSnap7Server : public SilecsServer::SilecsSnap7Server -{ -public: - UserSnap7Server(Virtual_SiemensBlock::DeployUnit* du) : SilecsSnap7Server(du, true) {} - virtual ~UserSnap7Server() {} - - virtual void userFunction() - { - // Implement the specific process control here! - // Look at SILECS Wikis: 'Create a virtual controller' chapter - } -}; - -int main(int argc, char*argv[]) -{ - Virtual_SiemensBlock::DeployUnit du; - UserSnap7Server server(&du); - if (server.startServer() < 0) - { - std::cout << "Failed to start the VC server: " << du.getName() << std::endl; - return -1; - } - return 0; -} diff --git a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.h b/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.h deleted file mode 100644 index 819405bef1b250069e55be5edebff102efa37f28..0000000000000000000000000000000000000000 --- a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensBlock.h +++ /dev/null @@ -1,53 +0,0 @@ - -/* Copyright CERN 2015 - * - * WARNING: This code is automatically generated from your SILECS deploy unit document. - * You should never modify the content of this file as it would break consistency. - * Furthermore, any changes will be overwritten in the next code generation. - * Any modification shall be done using the SILECS development environment - * and regenerating this source code. - */ - -#ifndef VIRTUAL_SIEMENSBLOCK_H_ -#define VIRTUAL_SIEMENSBLOCK_H_ - -#include <silecs-virtual-controller/interface/DeployUnit.h> -#include <silecs-virtual-controller/interface/Design.h> -#include "SilecsHeader_1.0.0.h" -#include "AllTypes_0.1.0.h" - - -namespace Virtual_SiemensBlock -{ - -class DeployUnit : public SilecsServer::DeployUnit -{ -public: - - DeployUnit() : SilecsServer::DeployUnit("Virtual_SiemensBlock", SilecsServer::S7Protocol, SilecsServer::BlockMode, 0) - { - mapDesigns_["SilecsHeader"] = new SilecsHeader_1_0_0::Design(); - mapDesigns_["AllTypes"] = new AllTypes_0_1_0::Design(); - } - - ~DeployUnit() - { - delete mapDesigns_["SilecsHeader"]; - delete mapDesigns_["AllTypes"]; - } - - SilecsHeader_1_0_0::Design* getSilecsHeader() - { - return dynamic_cast<SilecsHeader_1_0_0::Design*>(mapDesigns_["SilecsHeader"]); - } - - AllTypes_0_1_0::Design* getAllTypes() - { - return dynamic_cast<AllTypes_0_1_0::Design*>(mapDesigns_["AllTypes"]); - } - -}; - -} - -#endif diff --git a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.AllTypes.h b/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.AllTypes.h deleted file mode 100644 index 3883554cce81e731ece7cea9a4b17f7aacad908f..0000000000000000000000000000000000000000 --- a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.AllTypes.h +++ /dev/null @@ -1,1272 +0,0 @@ - -/* Copyright CERN 2015 - * - * WARNING: This code is automatically generated from your SILECS deploy unit document. - * You should never modify the content of this file as it would break consistency. - * Furthermore, any changes will be overwritten in the next code generation. - * Any modification shall be done using the SILECS development environment - * and regenerating this source code. - */ - -#ifndef ALLTYPES_0_1_0_H_ -#define ALLTYPES_0_1_0_H_ - -#include <silecs-virtual-controller/interface/Block.h> -#include <silecs-virtual-controller/interface/DeployUnit.h> -#include <silecs-virtual-controller/interface/Design.h> -#include <silecs-virtual-controller/interface/Device.h> - -namespace AllTypes_0_1_0 -{ - -class Design; - -class MyROBlock : public SilecsServer::Block -{ -public: - /*! - * \brief MyROBlock constructor. It creates an empty block. - */ - MyROBlock() : SilecsServer::Block("AllTypes:MyROBlock") - { - - } - - ~MyROBlock() - { - } - - /*! - * \brief Get RO_int8 register. - * \return value. - */ - int8_t getRO_int8() const - { - return structData_.RO_int8; - } - - /*! - * \brief Set RO_int8 register. - * \param value to be set. - */ - void setRO_int8(int8_t value) - { - structData_.RO_int8 = value; - } - - /*! - * \brief Get RO_uint8 register. - * \return value. - */ - uint8_t getRO_uint8() const - { - return structData_.RO_uint8; - } - - /*! - * \brief Set RO_uint8 register. - * \param value to be set. - */ - void setRO_uint8(uint8_t value) - { - structData_.RO_uint8 = value; - } - - /*! - * \brief Get RO_int16 register. - * \return value. - */ - int16_t getRO_int16() const - { - return structData_.RO_int16; - } - - /*! - * \brief Set RO_int16 register. - * \param value to be set. - */ - void setRO_int16(int16_t value) - { - structData_.RO_int16 = value; - } - - /*! - * \brief Get RO_uint16 register. - * \return value. - */ - uint16_t getRO_uint16() const - { - return structData_.RO_uint16; - } - - /*! - * \brief Set RO_uint16 register. - * \param value to be set. - */ - void setRO_uint16(uint16_t value) - { - structData_.RO_uint16 = value; - } - - /*! - * \brief Get RO_int32 register. - * \return value. - */ - int32_t getRO_int32() const - { - return structData_.RO_int32; - } - - /*! - * \brief Set RO_int32 register. - * \param value to be set. - */ - void setRO_int32(int32_t value) - { - structData_.RO_int32 = value; - } - - /*! - * \brief Get RO_uint32 register. - * \return value. - */ - uint32_t getRO_uint32() const - { - return structData_.RO_uint32; - } - - /*! - * \brief Set RO_uint32 register. - * \param value to be set. - */ - void setRO_uint32(uint32_t value) - { - structData_.RO_uint32 = value; - } - - /*! - * \brief Get RO_float32 register. - * \return value. - */ - float getRO_float32() const - { - return structData_.RO_float32; - } - - /*! - * \brief Set RO_float32 register. - * \param value to be set. - */ - void setRO_float32(float value) - { - structData_.RO_float32 = value; - } - - /*! - * \brief Get RO_string register. - * \return value. - */ - std::string getRO_string() const - { - size_t len = (size_t)structData_.RO_string[1]; - return std::string((char*)&(structData_.RO_string[2]), len); - } - - /*! - * \brief Set RO_string register. - * \param value to be set. - */ - void setRO_string(const std::string &value) - { - size_t len = (value.length() < RO_stringLen_) ? value.length() : RO_stringLen_; - memcpy((char*)&(structData_.RO_string[2]), value.c_str(), len); - structData_.RO_string[0] = char(0); - structData_.RO_string[1] = char(len); - } - - /*! - * \brief Get RO_date register. - * \return value. - */ - double getRO_date() const - { - return structData_.RO_date; - } - - /*! - * \brief Set RO_date register. - * \param value to be set. - */ - void setRO_date(double value) - { - structData_.RO_date = value; - } - - /*! - * \brief Get RO_char register. - * \return value. - */ - int8_t getRO_char() const - { - return structData_.RO_char; - } - - /*! - * \brief Set RO_char register. - * \param value to be set. - */ - void setRO_char(int8_t value) - { - structData_.RO_char = value; - } - - /*! - * \brief Get RO_byte register. - * \return value. - */ - uint8_t getRO_byte() const - { - return structData_.RO_byte; - } - - /*! - * \brief Set RO_byte register. - * \param value to be set. - */ - void setRO_byte(uint8_t value) - { - structData_.RO_byte = value; - } - - /*! - * \brief Get RO_word register. - * \return value. - */ - uint16_t getRO_word() const - { - return structData_.RO_word; - } - - /*! - * \brief Set RO_word register. - * \param value to be set. - */ - void setRO_word(uint16_t value) - { - structData_.RO_word = value; - } - - /*! - * \brief Get RO_dword register. - * \return value. - */ - uint32_t getRO_dword() const - { - return structData_.RO_dword; - } - - /*! - * \brief Set RO_dword register. - * \param value to be set. - */ - void setRO_dword(uint32_t value) - { - structData_.RO_dword = value; - } - - /*! - * \brief Get RO_int register. - * \return value. - */ - int16_t getRO_int() const - { - return structData_.RO_int; - } - - /*! - * \brief Set RO_int register. - * \param value to be set. - */ - void setRO_int(int16_t value) - { - structData_.RO_int = value; - } - - /*! - * \brief Get RO_dint register. - * \return value. - */ - int32_t getRO_dint() const - { - return structData_.RO_dint; - } - - /*! - * \brief Set RO_dint register. - * \param value to be set. - */ - void setRO_dint(int32_t value) - { - structData_.RO_dint = value; - } - - /*! - * \brief Get RO_real register. - * \return value. - */ - float getRO_real() const - { - return structData_.RO_real; - } - - /*! - * \brief Set RO_real register. - * \param value to be set. - */ - void setRO_real(float value) - { - structData_.RO_real = value; - } - - /*! - * \brief Get RO_dt register. - * \return value. - */ - double getRO_dt() const - { - return structData_.RO_dt; - } - - /*! - * \brief Set RO_dt register. - * \param value to be set. - */ - void setRO_dt(double value) - { - structData_.RO_dt = value; - } - - virtual inline size_t getSize() const - { - return sizeof(structData_); - } - - virtual void getData(unsigned char * data) const - { - memcpy(data, &structData_, this->getSize()); - } - - virtual void setData(unsigned char * data) - { - memcpy(&structData_, data, this->getSize()); - } - - virtual inline size_t getOffset() const { return 0; } - - static const std::size_t RO_stringLen_ = 64; - -private: - -#pragma pack(push, 1) - struct - { - int8_t RO_int8; - uint8_t RO_uint8; - int16_t RO_int16; - uint16_t RO_uint16; - int32_t RO_int32; - uint32_t RO_uint32; - float RO_float32; - char RO_string[RO_stringLen_+2]; - double RO_date; - int8_t RO_char; - uint8_t RO_byte; - uint16_t RO_word; - uint32_t RO_dword; - int16_t RO_int; - int32_t RO_dint; - float RO_real; - double RO_dt; - - } structData_; -#pragma pack(pop) - -}; - -class MyRWBlock : public SilecsServer::Block -{ -public: - /*! - * \brief MyRWBlock constructor. It creates an empty block. - */ - MyRWBlock() : SilecsServer::Block("AllTypes:MyRWBlock") - { - - } - - ~MyRWBlock() - { - } - - /*! - * \brief Get array RW_int8 register. - * \return value. - */ - void getRW_int8(int8_t* value) const - { - memcpy(value, &structData_.RW_int8, RW_int8Dim1_ * RW_int8Dim2_ * sizeof(int8_t)); - } - - /*! - * \brief Set array RW_int8 register. - * \param value to be set. - */ - void setRW_int8(int8_t* value) - { - memcpy(&structData_.RW_int8, value, RW_int8Dim1_ * RW_int8Dim2_ * sizeof(int8_t)); - } - - /*! - * \brief Get array RW_uint8 register. - * \return value. - */ - void getRW_uint8(uint8_t* value) const - { - memcpy(value, &structData_.RW_uint8, RW_uint8Dim1_ * RW_uint8Dim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Set array RW_uint8 register. - * \param value to be set. - */ - void setRW_uint8(uint8_t* value) - { - memcpy(&structData_.RW_uint8, value, RW_uint8Dim1_ * RW_uint8Dim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Get array RW_int16 register. - * \return value. - */ - void getRW_int16(int16_t* value) const - { - memcpy(value, &structData_.RW_int16, RW_int16Dim1_ * RW_int16Dim2_ * sizeof(int16_t)); - } - - /*! - * \brief Set array RW_int16 register. - * \param value to be set. - */ - void setRW_int16(int16_t* value) - { - memcpy(&structData_.RW_int16, value, RW_int16Dim1_ * RW_int16Dim2_ * sizeof(int16_t)); - } - - /*! - * \brief Get array RW_uint16 register. - * \return value. - */ - void getRW_uint16(uint16_t* value) const - { - memcpy(value, &structData_.RW_uint16, RW_uint16Dim1_ * RW_uint16Dim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Set array RW_uint16 register. - * \param value to be set. - */ - void setRW_uint16(uint16_t* value) - { - memcpy(&structData_.RW_uint16, value, RW_uint16Dim1_ * RW_uint16Dim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Get array RW_int32 register. - * \return value. - */ - void getRW_int32(int32_t* value) const - { - memcpy(value, &structData_.RW_int32, RW_int32Dim1_ * RW_int32Dim2_ * sizeof(int32_t)); - } - - /*! - * \brief Set array RW_int32 register. - * \param value to be set. - */ - void setRW_int32(int32_t* value) - { - memcpy(&structData_.RW_int32, value, RW_int32Dim1_ * RW_int32Dim2_ * sizeof(int32_t)); - } - - /*! - * \brief Get array RW_uint32 register. - * \return value. - */ - void getRW_uint32(uint32_t* value) const - { - memcpy(value, &structData_.RW_uint32, RW_uint32Dim1_ * RW_uint32Dim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Set array RW_uint32 register. - * \param value to be set. - */ - void setRW_uint32(uint32_t* value) - { - memcpy(&structData_.RW_uint32, value, RW_uint32Dim1_ * RW_uint32Dim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Get array RW_float32 register. - * \return value. - */ - void getRW_float32(float* value) const - { - memcpy(value, &structData_.RW_float32, RW_float32Dim1_ * RW_float32Dim2_ * sizeof(float)); - } - - /*! - * \brief Set array RW_float32 register. - * \param value to be set. - */ - void setRW_float32(float* value) - { - memcpy(&structData_.RW_float32, value, RW_float32Dim1_ * RW_float32Dim2_ * sizeof(float)); - } - - /*! - * \brief Get std::string RW_string register. - * \param value buffer where the value will be stored. - */ - void getRW_string(std::string* value) const - { - for (std::size_t i = 0; i < RW_stringDim1_; i++) - { - size_t len = (size_t)structData_.RW_string[i][1]; - value[i].assign(&(structData_.RW_string[i][2]), len); - } - } - - /*! - * \brief Set std::string RW_string register. - * \param value to be set. - */ - void setRW_string(std::string* value) - { - for (std::size_t i = 0; i < RW_stringDim1_; i++) - { - size_t len = (value[i].length() < RW_stringLen_) ? value[i].length() : RW_stringLen_; - memcpy(&(structData_.RW_string[i][2]), value[i].c_str(), len); - structData_.RW_string[i][0] = char(0); - structData_.RW_string[i][1] = char(len); - } - } - - /*! - * \brief Get array RW_date register. - * \return value. - */ - void getRW_date(double* value) const - { - memcpy(value, &structData_.RW_date, RW_dateDim1_ * RW_dateDim2_ * sizeof(double)); - } - - /*! - * \brief Set array RW_date register. - * \param value to be set. - */ - void setRW_date(double* value) - { - memcpy(&structData_.RW_date, value, RW_dateDim1_ * RW_dateDim2_ * sizeof(double)); - } - - /*! - * \brief Get array RW_char register. - * \return value. - */ - void getRW_char(int8_t* value) const - { - memcpy(value, &structData_.RW_char, RW_charDim1_ * RW_charDim2_ * sizeof(int8_t)); - } - - /*! - * \brief Set array RW_char register. - * \param value to be set. - */ - void setRW_char(int8_t* value) - { - memcpy(&structData_.RW_char, value, RW_charDim1_ * RW_charDim2_ * sizeof(int8_t)); - } - - /*! - * \brief Get array RW_byte register. - * \return value. - */ - void getRW_byte(uint8_t* value) const - { - memcpy(value, &structData_.RW_byte, RW_byteDim1_ * RW_byteDim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Set array RW_byte register. - * \param value to be set. - */ - void setRW_byte(uint8_t* value) - { - memcpy(&structData_.RW_byte, value, RW_byteDim1_ * RW_byteDim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Get array RW_word register. - * \return value. - */ - void getRW_word(uint16_t* value) const - { - memcpy(value, &structData_.RW_word, RW_wordDim1_ * RW_wordDim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Set array RW_word register. - * \param value to be set. - */ - void setRW_word(uint16_t* value) - { - memcpy(&structData_.RW_word, value, RW_wordDim1_ * RW_wordDim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Get array RW_dword register. - * \return value. - */ - void getRW_dword(uint32_t* value) const - { - memcpy(value, &structData_.RW_dword, RW_dwordDim1_ * RW_dwordDim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Set array RW_dword register. - * \param value to be set. - */ - void setRW_dword(uint32_t* value) - { - memcpy(&structData_.RW_dword, value, RW_dwordDim1_ * RW_dwordDim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Get array RW_int register. - * \return value. - */ - void getRW_int(int16_t* value) const - { - memcpy(value, &structData_.RW_int, RW_intDim1_ * RW_intDim2_ * sizeof(int16_t)); - } - - /*! - * \brief Set array RW_int register. - * \param value to be set. - */ - void setRW_int(int16_t* value) - { - memcpy(&structData_.RW_int, value, RW_intDim1_ * RW_intDim2_ * sizeof(int16_t)); - } - - /*! - * \brief Get array RW_dint register. - * \return value. - */ - void getRW_dint(int32_t* value) const - { - memcpy(value, &structData_.RW_dint, RW_dintDim1_ * RW_dintDim2_ * sizeof(int32_t)); - } - - /*! - * \brief Set array RW_dint register. - * \param value to be set. - */ - void setRW_dint(int32_t* value) - { - memcpy(&structData_.RW_dint, value, RW_dintDim1_ * RW_dintDim2_ * sizeof(int32_t)); - } - - /*! - * \brief Get array RW_real register. - * \return value. - */ - void getRW_real(float* value) const - { - memcpy(value, &structData_.RW_real, RW_realDim1_ * RW_realDim2_ * sizeof(float)); - } - - /*! - * \brief Set array RW_real register. - * \param value to be set. - */ - void setRW_real(float* value) - { - memcpy(&structData_.RW_real, value, RW_realDim1_ * RW_realDim2_ * sizeof(float)); - } - - /*! - * \brief Get array RW_dt register. - * \return value. - */ - void getRW_dt(double* value) const - { - memcpy(value, &structData_.RW_dt, RW_dtDim1_ * RW_dtDim2_ * sizeof(double)); - } - - /*! - * \brief Set array RW_dt register. - * \param value to be set. - */ - void setRW_dt(double* value) - { - memcpy(&structData_.RW_dt, value, RW_dtDim1_ * RW_dtDim2_ * sizeof(double)); - } - - virtual inline size_t getSize() const - { - return sizeof(structData_); - } - - virtual void getData(unsigned char * data) const - { - memcpy(data, &structData_, this->getSize()); - } - - virtual void setData(unsigned char * data) - { - memcpy(&structData_, data, this->getSize()); - } - - virtual inline size_t getOffset() const { return 118; } - - static const std::size_t RW_int8Dim1_ = 2; - static const std::size_t RW_int8Dim2_ = 2; - static const std::size_t RW_uint8Dim1_ = 2; - static const std::size_t RW_uint8Dim2_ = 2; - static const std::size_t RW_int16Dim1_ = 2; - static const std::size_t RW_int16Dim2_ = 2; - static const std::size_t RW_uint16Dim1_ = 2; - static const std::size_t RW_uint16Dim2_ = 2; - static const std::size_t RW_int32Dim1_ = 2; - static const std::size_t RW_int32Dim2_ = 2; - static const std::size_t RW_uint32Dim1_ = 2; - static const std::size_t RW_uint32Dim2_ = 2; - static const std::size_t RW_float32Dim1_ = 2; - static const std::size_t RW_float32Dim2_ = 2; - static const std::size_t RW_stringDim1_ = 2; - static const std::size_t RW_stringDim2_ = 2; - static const std::size_t RW_stringLen_ = 64; - static const std::size_t RW_dateDim1_ = 2; - static const std::size_t RW_dateDim2_ = 2; - static const std::size_t RW_charDim1_ = 2; - static const std::size_t RW_charDim2_ = 2; - static const std::size_t RW_byteDim1_ = 2; - static const std::size_t RW_byteDim2_ = 2; - static const std::size_t RW_wordDim1_ = 2; - static const std::size_t RW_wordDim2_ = 2; - static const std::size_t RW_dwordDim1_ = 2; - static const std::size_t RW_dwordDim2_ = 2; - static const std::size_t RW_intDim1_ = 2; - static const std::size_t RW_intDim2_ = 2; - static const std::size_t RW_dintDim1_ = 2; - static const std::size_t RW_dintDim2_ = 2; - static const std::size_t RW_realDim1_ = 2; - static const std::size_t RW_realDim2_ = 2; - static const std::size_t RW_dtDim1_ = 2; - static const std::size_t RW_dtDim2_ = 2; - -private: - -#pragma pack(push, 1) - struct - { - int8_t RW_int8[RW_int8Dim1_][RW_int8Dim2_]; - uint8_t RW_uint8[RW_uint8Dim1_][RW_uint8Dim2_]; - int16_t RW_int16[RW_int16Dim1_][RW_int16Dim2_]; - uint16_t RW_uint16[RW_uint16Dim1_][RW_uint16Dim2_]; - int32_t RW_int32[RW_int32Dim1_][RW_int32Dim2_]; - uint32_t RW_uint32[RW_uint32Dim1_][RW_uint32Dim2_]; - float RW_float32[RW_float32Dim1_][RW_float32Dim2_]; - char RW_string[RW_stringDim1_][RW_stringDim2_][RW_stringLen_+2]; - double RW_date[RW_dateDim1_][RW_dateDim2_]; - int8_t RW_char[RW_charDim1_][RW_charDim2_]; - uint8_t RW_byte[RW_byteDim1_][RW_byteDim2_]; - uint16_t RW_word[RW_wordDim1_][RW_wordDim2_]; - uint32_t RW_dword[RW_dwordDim1_][RW_dwordDim2_]; - int16_t RW_int[RW_intDim1_][RW_intDim2_]; - int32_t RW_dint[RW_dintDim1_][RW_dintDim2_]; - float RW_real[RW_realDim1_][RW_realDim2_]; - double RW_dt[RW_dtDim1_][RW_dtDim2_]; - - } structData_; -#pragma pack(pop) - -}; - -class MyWOBlock : public SilecsServer::Block -{ -public: - /*! - * \brief MyWOBlock constructor. It creates an empty block. - */ - MyWOBlock() : SilecsServer::Block("AllTypes:MyWOBlock") - { - - } - - ~MyWOBlock() - { - } - - /*! - * \brief Get array WO_int8 register. - * \return value. - */ - void getWO_int8(int8_t* value) const - { - memcpy(value, &structData_.WO_int8, WO_int8Dim1_ * WO_int8Dim2_ * sizeof(int8_t)); - } - - /*! - * \brief Set array WO_int8 register. - * \param value to be set. - */ - void setWO_int8(int8_t* value) - { - memcpy(&structData_.WO_int8, value, WO_int8Dim1_ * WO_int8Dim2_ * sizeof(int8_t)); - } - - /*! - * \brief Get array WO_uint8 register. - * \return value. - */ - void getWO_uint8(uint8_t* value) const - { - memcpy(value, &structData_.WO_uint8, WO_uint8Dim1_ * WO_uint8Dim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Set array WO_uint8 register. - * \param value to be set. - */ - void setWO_uint8(uint8_t* value) - { - memcpy(&structData_.WO_uint8, value, WO_uint8Dim1_ * WO_uint8Dim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Get array WO_int16 register. - * \return value. - */ - void getWO_int16(int16_t* value) const - { - memcpy(value, &structData_.WO_int16, WO_int16Dim1_ * WO_int16Dim2_ * sizeof(int16_t)); - } - - /*! - * \brief Set array WO_int16 register. - * \param value to be set. - */ - void setWO_int16(int16_t* value) - { - memcpy(&structData_.WO_int16, value, WO_int16Dim1_ * WO_int16Dim2_ * sizeof(int16_t)); - } - - /*! - * \brief Get array WO_uint16 register. - * \return value. - */ - void getWO_uint16(uint16_t* value) const - { - memcpy(value, &structData_.WO_uint16, WO_uint16Dim1_ * WO_uint16Dim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Set array WO_uint16 register. - * \param value to be set. - */ - void setWO_uint16(uint16_t* value) - { - memcpy(&structData_.WO_uint16, value, WO_uint16Dim1_ * WO_uint16Dim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Get array WO_int32 register. - * \return value. - */ - void getWO_int32(int32_t* value) const - { - memcpy(value, &structData_.WO_int32, WO_int32Dim1_ * WO_int32Dim2_ * sizeof(int32_t)); - } - - /*! - * \brief Set array WO_int32 register. - * \param value to be set. - */ - void setWO_int32(int32_t* value) - { - memcpy(&structData_.WO_int32, value, WO_int32Dim1_ * WO_int32Dim2_ * sizeof(int32_t)); - } - - /*! - * \brief Get array WO_uint32 register. - * \return value. - */ - void getWO_uint32(uint32_t* value) const - { - memcpy(value, &structData_.WO_uint32, WO_uint32Dim1_ * WO_uint32Dim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Set array WO_uint32 register. - * \param value to be set. - */ - void setWO_uint32(uint32_t* value) - { - memcpy(&structData_.WO_uint32, value, WO_uint32Dim1_ * WO_uint32Dim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Get array WO_float32 register. - * \return value. - */ - void getWO_float32(float* value) const - { - memcpy(value, &structData_.WO_float32, WO_float32Dim1_ * WO_float32Dim2_ * sizeof(float)); - } - - /*! - * \brief Set array WO_float32 register. - * \param value to be set. - */ - void setWO_float32(float* value) - { - memcpy(&structData_.WO_float32, value, WO_float32Dim1_ * WO_float32Dim2_ * sizeof(float)); - } - - /*! - * \brief Get std::string WO_string register. - * \param value buffer where the value will be stored. - */ - void getWO_string(std::string* value) const - { - for (std::size_t i = 0; i < WO_stringDim1_; i++) - { - size_t len = (size_t)structData_.WO_string[i][1]; - value[i].assign(&(structData_.WO_string[i][2]), len); - } - } - - /*! - * \brief Set std::string WO_string register. - * \param value to be set. - */ - void setWO_string(std::string* value) - { - for (std::size_t i = 0; i < WO_stringDim1_; i++) - { - size_t len = (value[i].length() < WO_stringLen_) ? value[i].length() : WO_stringLen_; - memcpy(&(structData_.WO_string[i][2]), value[i].c_str(), len); - structData_.WO_string[i][0] = char(0); - structData_.WO_string[i][1] = char(len); - } - } - - /*! - * \brief Get array WO_date register. - * \return value. - */ - void getWO_date(double* value) const - { - memcpy(value, &structData_.WO_date, WO_dateDim1_ * WO_dateDim2_ * sizeof(double)); - } - - /*! - * \brief Set array WO_date register. - * \param value to be set. - */ - void setWO_date(double* value) - { - memcpy(&structData_.WO_date, value, WO_dateDim1_ * WO_dateDim2_ * sizeof(double)); - } - - /*! - * \brief Get array WO_char register. - * \return value. - */ - void getWO_char(int8_t* value) const - { - memcpy(value, &structData_.WO_char, WO_charDim1_ * WO_charDim2_ * sizeof(int8_t)); - } - - /*! - * \brief Set array WO_char register. - * \param value to be set. - */ - void setWO_char(int8_t* value) - { - memcpy(&structData_.WO_char, value, WO_charDim1_ * WO_charDim2_ * sizeof(int8_t)); - } - - /*! - * \brief Get array WO_byte register. - * \return value. - */ - void getWO_byte(uint8_t* value) const - { - memcpy(value, &structData_.WO_byte, WO_byteDim1_ * WO_byteDim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Set array WO_byte register. - * \param value to be set. - */ - void setWO_byte(uint8_t* value) - { - memcpy(&structData_.WO_byte, value, WO_byteDim1_ * WO_byteDim2_ * sizeof(uint8_t)); - } - - /*! - * \brief Get array WO_word register. - * \return value. - */ - void getWO_word(uint16_t* value) const - { - memcpy(value, &structData_.WO_word, WO_wordDim1_ * WO_wordDim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Set array WO_word register. - * \param value to be set. - */ - void setWO_word(uint16_t* value) - { - memcpy(&structData_.WO_word, value, WO_wordDim1_ * WO_wordDim2_ * sizeof(uint16_t)); - } - - /*! - * \brief Get array WO_dword register. - * \return value. - */ - void getWO_dword(uint32_t* value) const - { - memcpy(value, &structData_.WO_dword, WO_dwordDim1_ * WO_dwordDim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Set array WO_dword register. - * \param value to be set. - */ - void setWO_dword(uint32_t* value) - { - memcpy(&structData_.WO_dword, value, WO_dwordDim1_ * WO_dwordDim2_ * sizeof(uint32_t)); - } - - /*! - * \brief Get array WO_int register. - * \return value. - */ - void getWO_int(int16_t* value) const - { - memcpy(value, &structData_.WO_int, WO_intDim1_ * WO_intDim2_ * sizeof(int16_t)); - } - - /*! - * \brief Set array WO_int register. - * \param value to be set. - */ - void setWO_int(int16_t* value) - { - memcpy(&structData_.WO_int, value, WO_intDim1_ * WO_intDim2_ * sizeof(int16_t)); - } - - /*! - * \brief Get array WO_dint register. - * \return value. - */ - void getWO_dint(int32_t* value) const - { - memcpy(value, &structData_.WO_dint, WO_dintDim1_ * WO_dintDim2_ * sizeof(int32_t)); - } - - /*! - * \brief Set array WO_dint register. - * \param value to be set. - */ - void setWO_dint(int32_t* value) - { - memcpy(&structData_.WO_dint, value, WO_dintDim1_ * WO_dintDim2_ * sizeof(int32_t)); - } - - /*! - * \brief Get array WO_real register. - * \return value. - */ - void getWO_real(float* value) const - { - memcpy(value, &structData_.WO_real, WO_realDim1_ * WO_realDim2_ * sizeof(float)); - } - - /*! - * \brief Set array WO_real register. - * \param value to be set. - */ - void setWO_real(float* value) - { - memcpy(&structData_.WO_real, value, WO_realDim1_ * WO_realDim2_ * sizeof(float)); - } - - /*! - * \brief Get array WO_dt register. - * \return value. - */ - void getWO_dt(double* value) const - { - memcpy(value, &structData_.WO_dt, WO_dtDim1_ * WO_dtDim2_ * sizeof(double)); - } - - /*! - * \brief Set array WO_dt register. - * \param value to be set. - */ - void setWO_dt(double* value) - { - memcpy(&structData_.WO_dt, value, WO_dtDim1_ * WO_dtDim2_ * sizeof(double)); - } - - virtual inline size_t getSize() const - { - return sizeof(structData_); - } - - virtual void getData(unsigned char * data) const - { - memcpy(data, &structData_, this->getSize()); - } - - virtual void setData(unsigned char * data) - { - memcpy(&structData_, data, this->getSize()); - } - - virtual inline size_t getOffset() const { return 590; } - - static const std::size_t WO_int8Dim1_ = 10; - static const std::size_t WO_int8Dim2_ = 1; - static const std::size_t WO_uint8Dim1_ = 10; - static const std::size_t WO_uint8Dim2_ = 1; - static const std::size_t WO_int16Dim1_ = 10; - static const std::size_t WO_int16Dim2_ = 1; - static const std::size_t WO_uint16Dim1_ = 10; - static const std::size_t WO_uint16Dim2_ = 1; - static const std::size_t WO_int32Dim1_ = 10; - static const std::size_t WO_int32Dim2_ = 1; - static const std::size_t WO_uint32Dim1_ = 10; - static const std::size_t WO_uint32Dim2_ = 1; - static const std::size_t WO_float32Dim1_ = 10; - static const std::size_t WO_float32Dim2_ = 1; - static const std::size_t WO_stringDim1_ = 10; - static const std::size_t WO_stringDim2_ = 1; - static const std::size_t WO_stringLen_ = 64; - static const std::size_t WO_dateDim1_ = 10; - static const std::size_t WO_dateDim2_ = 1; - static const std::size_t WO_charDim1_ = 10; - static const std::size_t WO_charDim2_ = 1; - static const std::size_t WO_byteDim1_ = 10; - static const std::size_t WO_byteDim2_ = 1; - static const std::size_t WO_wordDim1_ = 10; - static const std::size_t WO_wordDim2_ = 1; - static const std::size_t WO_dwordDim1_ = 10; - static const std::size_t WO_dwordDim2_ = 1; - static const std::size_t WO_intDim1_ = 10; - static const std::size_t WO_intDim2_ = 1; - static const std::size_t WO_dintDim1_ = 10; - static const std::size_t WO_dintDim2_ = 1; - static const std::size_t WO_realDim1_ = 10; - static const std::size_t WO_realDim2_ = 1; - static const std::size_t WO_dtDim1_ = 10; - static const std::size_t WO_dtDim2_ = 1; - -private: - -#pragma pack(push, 1) - struct - { - int8_t WO_int8[WO_int8Dim1_]; - uint8_t WO_uint8[WO_uint8Dim1_]; - int16_t WO_int16[WO_int16Dim1_]; - uint16_t WO_uint16[WO_uint16Dim1_]; - int32_t WO_int32[WO_int32Dim1_]; - uint32_t WO_uint32[WO_uint32Dim1_]; - float WO_float32[WO_float32Dim1_]; - char WO_string[WO_stringDim1_][WO_stringLen_+2]; - double WO_date[WO_dateDim1_]; - int8_t WO_char[WO_charDim1_]; - uint8_t WO_byte[WO_byteDim1_]; - uint16_t WO_word[WO_wordDim1_]; - uint32_t WO_dword[WO_dwordDim1_]; - int16_t WO_int[WO_intDim1_]; - int32_t WO_dint[WO_dintDim1_]; - float WO_real[WO_realDim1_]; - double WO_dt[WO_dtDim1_]; - - } structData_; -#pragma pack(pop) - -}; - - - -class Device : public SilecsServer::Device -{ -public: - Device(const std::string& label, size_t number):SilecsServer::Device(label, number) - { - blockMap_["AllTypes:MyROBlock"] = new MyROBlock(); - blockMap_["AllTypes:MyRWBlock"] = new MyRWBlock(); - blockMap_["AllTypes:MyWOBlock"] = new MyWOBlock(); - } - - ~Device() - { - delete (blockMap_["AllTypes:MyROBlock"]); - delete (blockMap_["AllTypes:MyRWBlock"]); - delete (blockMap_["AllTypes:MyWOBlock"]); - } -}; - - -class Design : public SilecsServer::Design -{ -public: - - Design():SilecsServer::Design("AllTypes", "0.1.0") - { - deviceMap_["AllTypes:testDevice1"] = new Device("AllTypes:testDevice1", 0); - deviceMap_["AllTypes:testDevice2"] = new Device("AllTypes:testDevice2", 1); - } - - ~Design() - { - delete(deviceMap_["AllTypes:testDevice1"]); - delete(deviceMap_["AllTypes:testDevice2"]); - } - - /*! - * \brief Return pointer to the requested device. - * \param label Device label. - */ - AllTypes_0_1_0::Device* getDevice(const std::string& label) - { - if (deviceMap_.find(label) != deviceMap_.end()) - { - return dynamic_cast<AllTypes_0_1_0::Device*>(deviceMap_[label]); - } - return NULL; - } -}; - -} /* namespace */ -#endif diff --git a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.SilecsHeader.h b/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.SilecsHeader.h deleted file mode 100644 index b6929715548326dafede84de2ed0143fba5f4dae..0000000000000000000000000000000000000000 --- a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.SilecsHeader.h +++ /dev/null @@ -1,203 +0,0 @@ - -/* Copyright CERN 2015 - * - * WARNING: This code is automatically generated from your SILECS deploy unit document. - * You should never modify the content of this file as it would break consistency. - * Furthermore, any changes will be overwritten in the next code generation. - * Any modification shall be done using the SILECS development environment - * and regenerating this source code. - */ - -#ifndef SILECSHEADER_1_0_0_H_ -#define SILECSHEADER_1_0_0_H_ - -#include <silecs-virtual-controller/interface/Block.h> -#include <silecs-virtual-controller/interface/DeployUnit.h> -#include <silecs-virtual-controller/interface/Design.h> -#include <silecs-virtual-controller/interface/Device.h> - -namespace SilecsHeader_1_0_0 -{ - -class Design; - -class HdrBlk : public SilecsServer::Block -{ -public: - /*! - * \brief hdrBlk constructor. It creates an empty block. - */ - HdrBlk() : SilecsServer::Block("SilecsHeader:hdrBlk") - { - set_version("DEV"); - set_checksum(0XFFE06812); - set_user("schwinn"); - set_date(0.0); - } - - ~HdrBlk() - { - } - - /*! - * \brief Get _version register. - * \return value. - */ - std::string get_version() const - { - size_t len = (size_t)structData_._version[1]; - return std::string((char*)&(structData_._version[2]), len); - } - - /*! - * \brief Set _version register. - * \param value to be set. - */ - void set_version(const std::string &value) - { - size_t len = (value.length() < _versionLen_) ? value.length() : _versionLen_; - memcpy((char*)&(structData_._version[2]), value.c_str(), len); - structData_._version[0] = char(0); - structData_._version[1] = char(len); - } - - /*! - * \brief Get _checksum register. - * \return value. - */ - uint32_t get_checksum() const - { - return structData_._checksum; - } - - /*! - * \brief Set _checksum register. - * \param value to be set. - */ - void set_checksum(uint32_t value) - { - structData_._checksum = value; - } - - /*! - * \brief Get _user register. - * \return value. - */ - std::string get_user() const - { - size_t len = (size_t)structData_._user[1]; - return std::string((char*)&(structData_._user[2]), len); - } - - /*! - * \brief Set _user register. - * \param value to be set. - */ - void set_user(const std::string &value) - { - size_t len = (value.length() < _userLen_) ? value.length() : _userLen_; - memcpy((char*)&(structData_._user[2]), value.c_str(), len); - structData_._user[0] = char(0); - structData_._user[1] = char(len); - } - - /*! - * \brief Get _date register. - * \return value. - */ - double get_date() const - { - return structData_._date; - } - - /*! - * \brief Set _date register. - * \param value to be set. - */ - void set_date(double value) - { - structData_._date = value; - } - - virtual inline size_t getSize() const - { - return sizeof(structData_); - } - - virtual void getData(unsigned char * data) const - { - memcpy(data, &structData_, this->getSize()); - } - - virtual void setData(unsigned char * data) - { - memcpy(&structData_, data, this->getSize()); - } - - virtual inline size_t getOffset() const { return 0; } - - static const std::size_t _versionLen_ = 16; - static const std::size_t _userLen_ = 16; - -private: - -#pragma pack(push, 1) - struct - { - char _version[_versionLen_+2]; - uint32_t _checksum; - char _user[_userLen_+2]; - double _date; - - } structData_; -#pragma pack(pop) - -}; - - - -class Device : public SilecsServer::Device -{ -public: - Device(const std::string& label, size_t number):SilecsServer::Device(label, number) - { - blockMap_["SilecsHeader:hdrBlk"] = new HdrBlk(); - } - - ~Device() - { - delete (blockMap_["SilecsHeader:hdrBlk"]); - } -}; - - -class Design : public SilecsServer::Design -{ -public: - - Design():SilecsServer::Design("SilecsHeader", "1.0.0") - { - deviceMap_["SilecsHeader:SilecsHeader"] = new Device("SilecsHeader:SilecsHeader", 0); - } - - ~Design() - { - delete(deviceMap_["SilecsHeader:SilecsHeader"]); - } - - /*! - * \brief Return pointer to the requested device. - * \param label Device label. - */ - SilecsHeader_1_0_0::Device* getDevice(const std::string& label) - { - if (deviceMap_.find(label) != deviceMap_.end()) - { - return dynamic_cast<SilecsHeader_1_0_0::Device*>(deviceMap_[label]); - } - return NULL; - } -}; - -} /* namespace */ -#endif diff --git a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.cpp b/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.cpp deleted file mode 100644 index 43c22864b768a82ba2ad177475d15288ad6e606a..0000000000000000000000000000000000000000 --- a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.cpp +++ /dev/null @@ -1,33 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <cstring> -#include <iostream> - -#include <silecs-virtual-controller/core/SilecsSnap7Server.h> -#include "Virtual_SiemensDevice.h" - -class UserSnap7Server : public SilecsServer::SilecsSnap7Server -{ -public: - UserSnap7Server(Virtual_SiemensDevice::DeployUnit* du) : SilecsSnap7Server(du, true) {} - virtual ~UserSnap7Server() {} - - virtual void userFunction() - { - // Implement the specific process control here! - // Look at SILECS Wikis: 'Create a virtual controller' chapter - } -}; - -int main(int argc, char*argv[]) -{ - Virtual_SiemensDevice::DeployUnit du; - UserSnap7Server server(&du); - if (server.startServer() < 0) - { - std::cout << "Failed to start the VC server: " << du.getName() << std::endl; - return -1; - } - return 0; -} diff --git a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.h b/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.h deleted file mode 100644 index 1827c94a58cd3d50d26a1f866c1c11978e3ccfb0..0000000000000000000000000000000000000000 --- a/silecs-codegen/src/xml/test/generated_correct/controller/Virtual_SiemensDevice.h +++ /dev/null @@ -1,53 +0,0 @@ - -/* Copyright CERN 2015 - * - * WARNING: This code is automatically generated from your SILECS deploy unit document. - * You should never modify the content of this file as it would break consistency. - * Furthermore, any changes will be overwritten in the next code generation. - * Any modification shall be done using the SILECS development environment - * and regenerating this source code. - */ - -#ifndef VIRTUAL_SIEMENSDEVICE_H_ -#define VIRTUAL_SIEMENSDEVICE_H_ - -#include <silecs-virtual-controller/interface/DeployUnit.h> -#include <silecs-virtual-controller/interface/Design.h> -#include "SilecsHeader_1.0.0.h" -#include "AllTypes_0.1.0.h" - - -namespace Virtual_SiemensDevice -{ - -class DeployUnit : public SilecsServer::DeployUnit -{ -public: - - DeployUnit() : SilecsServer::DeployUnit("Virtual_SiemensDevice", SilecsServer::S7Protocol, SilecsServer::DeviceMode, 0) - { - mapDesigns_["SilecsHeader"] = new SilecsHeader_1_0_0::Design(); - mapDesigns_["AllTypes"] = new AllTypes_0_1_0::Design(); - } - - ~DeployUnit() - { - delete mapDesigns_["SilecsHeader"]; - delete mapDesigns_["AllTypes"]; - } - - SilecsHeader_1_0_0::Design* getSilecsHeader() - { - return dynamic_cast<SilecsHeader_1_0_0::Design*>(mapDesigns_["SilecsHeader"]); - } - - AllTypes_0_1_0::Design* getAllTypes() - { - return dynamic_cast<AllTypes_0_1_0::Design*>(mapDesigns_["AllTypes"]); - } - -}; - -} - -#endif