OpcUaCanOpen
CANopen OPC-UA server
CanOpenData.h
Go to the documentation of this file.
1 #ifndef __CANOPENDATEADDRESS_H__
2 #define __CANOPENDATEADDRESS_H__
3 
5  {
11  };
12 
14 
15 class CanOpenDataAddress : public UserDataBase
16 {
18 public:
20  CanOpenItemType itemType,
21  OpcUa_UInt16 dataAddress,
22  OpcUa_UInt16 numberByte,
23  OpcUa_UInt16 bitNumber,
24  OpcUa_UInt16 ch)
25  : m_itemType(itemType),
29  m_channel(ch)
30  {}
31  virtual ~CanOpenDataAddress(){}
32  static bool getDirection(const char * ndir,DirectionType &d)
33  {
34  if(!strcmp(ndir,"R")) d = CAN_IN;
35  else {
36  if(!strcmp(ndir,"W")) d = CAN_OUT;
37  else {
38  if(!strcmp(ndir,"RW")) d = CAN_IO;
39  else return false;
40  }
41  }
42  return true;
43  }
44 
45 
46  static bool getOpcUaType(const char * ndir,OpcUa_BuiltInType &d)
47  {
48  if(!strcmp(ndir,"Int32")) d = OpcUaType_Int32;
49  else {
50  if(!strcmp(ndir,"Int16")) d = OpcUaType_Int16;
51  else {
52  if(!strcmp(ndir,"UInt32")) d = OpcUaType_UInt32;
53  else {
54  if(!strcmp(ndir,"UInt16")) d = OpcUaType_UInt16;
55  else {
56  if(!strcmp(ndir,"float")) d = OpcUaType_Float;
57  else {
58  if(!strcmp(ndir,"double")) d = OpcUaType_Double;
59  else {
60  if(!strcmp(ndir,"byte")) d = OpcUaType_Byte;
61  else {
62  if(!strcmp(ndir,"bit")) d = OpcUaType_Boolean;
63  else {
64  if (!strcmp(ndir, "bool")) d = OpcUaType_Boolean;
65  else {
66  if (!strcmp(ndir, "array")) d = OpcUaType_ByteString;
67  else return false;
68  }
69  }
70  }
71  }
72  }
73  }
74  }
75  }
76  }
77  return true;
78  }
80  inline CanOpenItemType msgType() const { return m_itemType; }
82  inline OpcUa_UInt16 dataAddress() const { return m_dataAddress; }
84  inline OpcUa_UInt16 numberByte() const { return m_numberByte; }
86  inline OpcUa_UInt16 bitNumber() const { return m_bitNumber; }
88  inline OpcUa_UInt16 channel() const { return m_channel; }
89 
90 private:
93  OpcUa_UInt16 m_dataAddress;
94  OpcUa_UInt16 m_numberByte;
95  OpcUa_UInt16 m_bitNumber;
96  OpcUa_UInt16 m_channel;
97 };
98 
99 #endif