OpcUaCanOpen
CANopen OPC-UA server
CanObject.h
Go to the documentation of this file.
1 #ifndef __CANOBJECT_H__
2 #define __CANOBJECT_H__
3 
4 //#include "BuildingAutomationTypeIds.h"
5 #include "Ids.h"
6 #include "uamutex.h"
8 #include "CanBusAccess.h"
9 
10 #include "CANopen.h"
11 #include "iomanager.h"
12 
13 
14 using namespace UserDevice;
15 using namespace CanModule;
16 
17 namespace CanOpen
18 {
24  {
25  UA_DISABLE_COPY(CanObject);
26 
27  public:
34  CanObject(pUserDeviceStruct *parent,::xsd::cxx::tree::type *conf,UaNode *pAS,OpcUa_UInt32 code):
35  InterfaceUserDataBase(parent,conf,pAS,code)
36  {
37  m_CanNodeId = 0;
38  m_pCommIf = 0;
39  m_pIOManager = 0;
40  }
41 
43  virtual ~CanObject(void)
44  {
45  if (m_pIOManager) {
46  delete m_pIOManager;
47  m_pIOManager = 0;
48  }
49  }
50 
54  OpcUa_Byte getCanNodeId() {
55  return m_CanNodeId;
56  }
57 
62  {
63  unsigned char mes[8];
64  mes[1] = getCanNodeId();
65  mes[0] = nmt;
66  if (m_pCommIf) m_pCommIf->sendMessage(0,2,mes);
67  }
68 
72  virtual void setInitNmt( enum NMTcommand iNMT)
73  {
74  m_initNMTcommand = iNMT;
75  }
76 
80  virtual void setInitNmt( std::string sNmt)
81  {
82  if (sNmt.empty()) { setInitNmt(nop); return; }
83  if (sNmt == "start") { setInitNmt(start); return; }
84  if (sNmt == "stop") { setInitNmt(stop); return; }
85  if (sNmt == "reset") { setInitNmt(reset); return; }
86  if (sNmt == "preOperational") { setInitNmt(preOperational); return; }
87  if (sNmt == "none") { setInitNmt(nop); return; }
88  }
89 
91  virtual void sendInitNmt() { if (m_initNMTcommand != nop ) sendNMT(m_initNMTcommand); }
92 
93 // virtual UaStatus connectCode(OpcUa_UInt32 code,UaNode *blink) = 0;
94 
98  CCanAccess *getCanBusInterface() { return m_pCommIf; }
99 
103  void setCanBusInterface(CCanAccess * ccac) { m_pCommIf = ccac; }
104 
105  IOManager * getIOManager() { return m_pIOManager; }
106 
107  protected:
108 
110 
111  OpcUa_Byte m_CanNodeId;
112 
113  enum NMTcommand m_initNMTcommand;
114  IOManager *m_pIOManager;
115  };
116 }
117 #endif