ChimeraTK-ControlSystemAdapter-OPCUAAdapter  04.00.01
csa_processvariable.h
Go to the documentation of this file.
1 /*
2  * This file is part of ChimeraTKs ControlSystem-OPC-UA-Adapter.
3  *
4  * ChimeraTKs ControlSystem-OPC-UA-Adapter is free software: you can
5  * redistribute it and/or modify it under the terms of the Lesser GNU
6  * General Public License as published by the Free Software Foundation,
7  * either version 3 of the License, or (at your option) any later version.
8  *
9  * ChimeraTKs ControlSystem-OPC-UA-Adapter is distributed in the hope
10  * that it will be useful, but WITHOUT ANY WARRANTY; without even the
11  * implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the Lesser GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Foobar. If not, see https://www.gnu.org/licenses/lgpl.html
16  *
17  * Copyright (c) 2016 Chris Iatrou <Chris_Paul.Iatrou@tu-dresden.de>
18  * Copyright (c) 2016 Julian Rahm <Julian.Rahm@tu-dresden.de>
19  * Copyright (c) 2019-2021 Andreas Ebner <Andreas.Ebner@iosb.fraunhofer.de>
20  */
21 
22 #pragma once
23 
24 #include "ChimeraTK/ControlSystemAdapter/ControlSystemPVManager.h"
25 #include "ChimeraTK/SupportedUserTypes.h"
26 #include "ua_mapped_class.h"
27 
28 #include <boost/fusion/container/map.hpp>
29 
30 #include <string>
31 using namespace std;
32 namespace fusion = boost::fusion;
33 
34 namespace ChimeraTK {
35 
36  typedef fusion::map<fusion::pair<int8_t, uint>, fusion::pair<uint8_t, uint>, fusion::pair<int16_t, uint>,
37  fusion::pair<uint16_t, uint>, fusion::pair<int32_t, uint>, fusion::pair<uint32_t, uint>,
38  fusion::pair<int64_t, uint>, fusion::pair<uint64_t, uint>, fusion::pair<float, uint>, fusion::pair<double, uint>,
39  fusion::pair<string, uint>, fusion::pair<Boolean, uint>>
41 
50  private:
51  string namePV;
52  string nameNew;
53  string nodeStringIdOverwrite;
54  string engineeringUnit;
55  string description;
56  UA_NodeId ownNodeId = UA_NODEID_NULL;
57 
58  TypesMap typesMap{fusion::make_pair<int8_t>(UA_TYPES_SBYTE), fusion::make_pair<uint8_t>(UA_TYPES_BYTE),
59  fusion::make_pair<int16_t>(UA_TYPES_INT16), fusion::make_pair<uint16_t>(UA_TYPES_UINT16),
60  fusion::make_pair<int32_t>(UA_TYPES_INT32), fusion::make_pair<uint32_t>(UA_TYPES_UINT32),
61  fusion::make_pair<int64_t>(UA_TYPES_INT64), fusion::make_pair<uint64_t>(UA_TYPES_UINT64),
62  fusion::make_pair<float>(UA_TYPES_FLOAT), fusion::make_pair<double>(UA_TYPES_DOUBLE),
63  fusion::make_pair<string>(UA_TYPES_STRING), fusion::make_pair<Boolean>(UA_TYPES_BOOLEAN)};
64 
65  private:
66  bool array;
67  boost::shared_ptr<ControlSystemPVManager> csManager;
68  UA_StatusCode addPVChildNodes(UA_NodeId pvNodeId, const string& baseNodePath, UA_DataSource_Map& map);
69 
74  UA_StatusCode mapSelfToNamespace(const UA_Logger* logger);
75 
76  public:
86  ua_processvariable(UA_Server* server, UA_NodeId basenodeid, const string& namePV,
87  boost::shared_ptr<ControlSystemPVManager> csManager, const UA_Logger* logger, string overwriteNodeString = "");
88 
93 
97  UA_DateTime getSourceTimeStamp();
98 
99  static UA_StatusCode ua_readproxy_ua_processvariable_getName(UA_Server* server, const UA_NodeId* sessionId,
100  void* sessionContext, const UA_NodeId* nodeId, void* nodeContext, UA_Boolean includeSourceTimeStamp,
101  const UA_NumericRange* range, UA_DataValue* value);
102 
107  string getName();
108 
109  static UA_StatusCode ua_readproxy_ua_processvariable_getType(UA_Server* server, const UA_NodeId* sessionId,
110  void* sessionContext, const UA_NodeId* nodeId, void* nodeContext, UA_Boolean includeSourceTimeStamp,
111  const UA_NumericRange* range, UA_DataValue* value);
112 
117  string getType();
118 
119  static UA_StatusCode ua_readproxy_ua_processvariable_getEngineeringUnit(UA_Server* server,
120  const UA_NodeId* sessionId, void* sessionContext, const UA_NodeId* nodeId, void* nodeContext,
121  UA_Boolean includeSourceTimeStamp, const UA_NumericRange* range, UA_DataValue* value);
122 
123  static UA_StatusCode ua_writeproxy_ua_processvariable_setEngineeringUnit(UA_Server* server,
124  const UA_NodeId* sessionId, void* sessionContext, const UA_NodeId* nodeId, void* nodeContext,
125  const UA_NumericRange* range, const UA_DataValue* value);
126 
131  void setEngineeringUnit(string engineeringUnit);
136  string getEngineeringUnit();
137 
138  static UA_StatusCode ua_writeproxy_ua_processvariable_setDescription(UA_Server* server, const UA_NodeId* sessionId,
139  void* sessionContext, const UA_NodeId* nodeId, void* nodeContext, const UA_NumericRange* range,
140  const UA_DataValue* value);
141 
142  static UA_StatusCode ua_readproxy_ua_processvariable_getDescription(UA_Server* server, const UA_NodeId* sessionId,
143  void* sessionContext, const UA_NodeId* nodeId, void* nodeContext, UA_Boolean includeSourceTimeStamp,
144  const UA_NumericRange* range, UA_DataValue* value);
145 
147  static UA_StatusCode ua_readproxy_ua_processvariable_getValidity(UA_Server* server, const UA_NodeId* sessionId,
148  void* sessionContext, const UA_NodeId* nodeId, void* nodeContext, UA_Boolean includeSourceTimeStamp,
149  const UA_NumericRange* range, UA_DataValue* value);
150 
155  void setDescription(string description);
160  string getDescription();
161 
166  UA_NodeId getOwnNodeId();
167 
168  template<typename T>
169  static UA_StatusCode ua_readproxy_ua_processvariable_getValue(UA_Server* server, const UA_NodeId* sessionId,
170  void* sessionContext, const UA_NodeId* nodeId, void* nodeContext, UA_Boolean includeSourceTimeStamp,
171  const UA_NumericRange* range, UA_DataValue* value);
172 
173  template<typename T>
174  UA_StatusCode getValue(UA_Variant* v, const UA_NumericRange* range);
175 
176  template<typename T>
177  static UA_StatusCode ua_writeproxy_ua_processvariable_setValue(UA_Server* server, const UA_NodeId* sessionId,
178  void* sessionContext, const UA_NodeId* nodeId, void* nodeContext, const UA_NumericRange* range,
179  const UA_DataValue* value);
180 
181  template<typename T>
182  UA_StatusCode setValue(const UA_Variant* data);
183 
184  template<typename T>
185  UA_UInt32 typeSpecificSetup(UA_DataSource_Map_Element& mapElem, const UA_NodeId nodeId);
186  };
187 } // namespace ChimeraTK
ChimeraTK::ua_mapped_class
This class mapped all inforamtion into the opca server.
Definition: ua_mapped_class.h:33
ua_mapped_class.h
ChimeraTK::UA_DataSource_Map
std::list< UA_DataSource_Map_Element > UA_DataSource_Map
Definition: ua_map_types.h:56
csManager
boost::shared_ptr< ChimeraTK::ControlSystemPVManager > csManager
Definition: csa_opcua_application.cpp:59
ChimeraTK::TypesMap
fusion::map< fusion::pair< int8_t, uint >, fusion::pair< uint8_t, uint >, fusion::pair< int16_t, uint >, fusion::pair< uint16_t, uint >, fusion::pair< int32_t, uint >, fusion::pair< uint32_t, uint >, fusion::pair< int64_t, uint >, fusion::pair< uint64_t, uint >, fusion::pair< float, uint >, fusion::pair< double, uint >, fusion::pair< string, uint >, fusion::pair< Boolean, uint > > TypesMap
Definition: csa_processvariable.h:40
ChimeraTK::UA_DataSource_Map_Element_t
For generic callback use, this sturct contains the methode pointer and a NodeId of the model....
Definition: ua_map_types.h:50
ChimeraTK
Definition: csa_additionalvariable.h:28
generate_open62541CCode.logger
logger
Definition: generate_open62541CCode.py:29
ChimeraTK::ua_processvariable
This class represent a processvariable of the controlsystemadapter in the information model of a OPC ...
Definition: csa_processvariable.h:49