OpcUaCanOpen
CANopen OPC-UA server
CanOpenItem.h
Go to the documentation of this file.
1 #ifndef __CANOPENITEM_H__
2 #define __CANOPENITEM_H__
3 
4 #include <opcua_basedatavariabletype.h>
5 #include "CanBusAccess.h"
6 #include "uaobjecttypes.h"
7 #include "UserDeviceItem.h"
8 #include "CANOpenServerConfig.h"
10 
11 #pragma once
12 
13 namespace CanOpen
14 {
19  using namespace UserDevice;
20  static OpcUa_Boolean TypeConversion = true;
21  static OpcUa_UInt32 InitTimeout = 10;
22 
23  class CanOpenItem : public UserDeviceItem
24  {
25  public:
26 
27  CanOpenItem(pUserDeviceStruct *parent,::xml_schema::type *conf,UaNode *pAS,OpcUa_UInt code):
28  UserDeviceItem(parent,conf,pAS,code)
29  {
30  };
31 
32  CanOpenItem() = default;
33 
34  virtual UaVariant UnPack() {
35  UaVariant a;
36  return a;
37  }; // Unpack data from device message
38  virtual UaStatus pack(const OpcUa_Variant *) {
39  return OpcUa_Good;
40  }; // pack data to device message
41 
42  virtual UaStatus write(UaDataValue &udv) // pass data to device
43  {
44  InterfaceUserDataBase * device = static_cast<InterfaceUserDataBase *>(getParentDevice());
45  UaStatus ret = device->sendDeviceMessage(getCodeFunction(),&udv);
46  return ret;
47  }
48 
49  virtual UaStatus read() // read data from device
50  {
51  InterfaceUserDataBase * device = static_cast<InterfaceUserDataBase *>(getParentDevice());
52 
53  UaStatus ret = device->getDeviceMessage(getCodeFunction());
54  return ret;
55  }
56 
57  static UaStatus convertOpcUaType(const OpcUa_Variant *sData, OpcUa_Variant *oData, OpcUa_BuiltInType bType);
58 
59  virtual ~CanOpenItem(void)
60  {
61  } ;
62 
63 
64  virtual UaStatus getDeviceMessage(OpcUa_UInt32 commandCode)
65  {
66  OpcUa_ReferenceParameter(commandCode);
67  return OpcUa_Good;
68  }
69 
70  virtual UaStatus sendDeviceMessage(OpcUa_UInt32 code, UaDataValue *value = 0)
71  {
72  InterfaceUserDataBase * device = static_cast<InterfaceUserDataBase*>(getParentDevice());
73  UaStatus ret = device->sendDeviceMessage(code, value);
74  return ret;
75  }
76 
77  virtual UaStatus connectCode(OpcUa_UInt32 code, ::xsd::cxx::tree::type *conf, UaNode *blink)
78  {
79  OpcUa_ReferenceParameter(code);
80  OpcUa_ReferenceParameter(conf);
81  OpcUa_ReferenceParameter(blink);
82  return OpcUa_Good;
83 
84  }
85  virtual UaVariant getPropertyValue(OpcUa_UInt32 code, ::xsd::cxx::tree::type *conf)
86  {
87  OpcUa_ReferenceParameter(code);
88  OpcUa_ReferenceParameter(conf);
89  UaVariant val;
90  val.clear();
91  return val;
92  }
93 
94  };
95 }
96 #endif
97