OpcUaCanOpen
CANopen OPC-UA server
CanBusObject.h
Go to the documentation of this file.
1 #ifndef __CANBUSOBJECT_H__
2 #define __CANBUSOBJECT_H__
3 
4 #include "CanObject.h"
5 #include <opcua_basedatavariabletype.h>
6 #include "CCanUACallback.h"
7 
8 #include "CANOpenServerConfig.h"
9 
10 #include "SyncInterval.h"
11 #include "NodeGuardingInterval.h"
12 #include "CanBusAccess.h"
13 //#include "IOManagerPDO.h"
14 #include <time.h>
15 #include <list>
16 
17 namespace CanOpen
18 {
19 
20  class CanNodeObject;
21  class CanPDOOBject;
22 
27  class CanBusObject:
28  public CanObject
29  {
31 
32  public:
33 
40  CanBusObject(pUserDeviceStruct *interf,CANBUS *ca,UaNode *link,int code);
41 
43  virtual ~CanBusObject(void);
49  virtual void setPortError(const int err, const char *errmsg, timeval &tv);
50 
52  virtual UaStatus getDeviceMessage(OpcUa_UInt32 code)
53  {
54  OpcUa_ReferenceParameter(code);
55  return OpcUa_Good;
56  }
57 
59  void openCanBus();
60 
62  void closeCanBus();
63 
68  virtual UaStatus sendDeviceMessage(OpcUa_UInt32 code, UaDataValue *value = 0);
69 
71  void sendSync()
72  {
73  if( m_pCommIf )
75  }
76 
82  virtual UaStatus connectCode(OpcUa_UInt32 code,::xsd::cxx::tree::type *conf,UaNode *blink);
83  virtual UaVariant getPropertyValue(OpcUa_UInt32 code, ::xsd::cxx::tree::type *conf);
84 
85 
88 
92  void addPDO(CanPDOObject * pdoo)
93  {
94  m_pCallback->addPDO(pdoo);
95  }
97  {
98  return m_pCallback->getListNodes();
99  }
100 
104  void addNode(CanNodeObject *pnode) { m_pCallback->addCanNode(pnode); }
108  void initialize();
109 
112 
115 
116  string &getCanBusName() { return m_sBusName; }
117  string &getCanBusAddress() { return m_sBusAddress; }
118 
119  void waitData();
120 
121  private:
122 
124 
127 
128  OpcUa::BaseVariableType *m_iPortError;
129  OpcUa::BaseVariableType *m_sPortErrorDescription;
130 
131  string m_sBusName;
133  string m_sBusAddress;
134  };
135 }
136 #endif
137