OpcUaCanOpen
CANopen OPC-UA server
PROGRAMitem.h
Go to the documentation of this file.
1 #ifndef __CANBUSOBJECT_H__
2 #define __CANBUSOBJECT_H__
3 
4 #include <opcua_basedatavariabletype.h>
5 
6 #include "CANOpenServerConfig.h"
7 
8 #include <time.h>
9 #include <list>
10 
11 namespace CanOpen
12 {
13  using namespace std;
14 
19  class PROGRAMitem:
20  public CanObject
21  {
22  UA_DISABLE_COPY(CanBusObject);
23 
24  public:
25 
32  CanBusObject(UserDataBase *interf,CANBUS *ca,UaNode *link,int code);
33 
35  virtual ~CanBusObject(void);
41  virtual void setPortError(const int err, const char *errmsg, timeval &tv);
42 
44  virtual UaStatus getDeviceMessage(OpcUa_UInt32 code)
45  {
46  OpcUa_ReferenceParameter(code);
47  return OpcUa_Good;
48  }
49 
51  void openCanBus();
52 
57  virtual UaStatus sendDeviceMessage(OpcUa_UInt32 code, UaDataValue *value = 0);
58 
60  void sendSync()
61  {
62  if( m_pCommIf ) m_pCommIf->sendMessage(CANOPEN_SYNC_COBID,0,0);
63  }
64 
70  virtual UaStatus connectCode(OpcUa_UInt32 code,::xsd::cxx::tree::type *conf,UaNode *blink);
71 
73  CCanUACallback *getCanUACallback() { return m_pCallback; }
74 
78  void addPDO(CanPDOObject * pdoo) { m_pCallback->addPDO(pdoo); }
79  busNodes & getListNodes() { return m_pCallback->getListNodes(); }
80 
84  void addNode(CanNodeObject *pnode) { m_pCallback->addCanNode(pnode); }
86  void sendInitNodeNmt() { m_pCallback->sendInitNodeNmt(); }
88  void initialize();
89 
91  void startSyncInterval() { m_pSyncIn->startSyncInterval(); }
92 
94  void startNodeGuardingInterval() { m_pNgIn->startNodeGuardingInterval(); }
95 
96  string &getCanBusName() { return m_sBusName; }
97  string &getCanBusAddress() { return m_sBusAddress; }
98 
99  void waitData();
100 
101  private:
102 
104 
107 
108  OpcUa::BaseVariableType *m_iPortError;
109  OpcUa::BaseVariableType *m_sPortErrorDescription;
110 
111  string m_sBusName;
113  string m_sBusAddress;
114  };
115 }
116 #endif
117