OpcUaCanOpen
CANopen OPC-UA server
CanNodeObject.h
Go to the documentation of this file.
1 #ifndef __CANNODEOBJECT_H__
2 #define __CANNODEOBJECT_H__
3 
4 #include "uavariant.h"
5 #include "CanObject.h"
6 #include <opcua_basedatavariabletype.h>
7 #include "CANOpenServerConfig.h"
8 #include "CANopen.h"
9 #include "CanBusAccess.h"
10 #include "UaCanTrace.h"
11 #include <map>
12 #include "IOManagerSDO.h"
13 
14 namespace CanOpen
15 {
16  class CanSDOObject;
17 
28  public CanObject
29  {
30  public:
31 
38  CanNodeObject(pUserDeviceStruct *interf,NODE *ca,UaNode *blink,OpcUa_UInt32 code);
39 
41  virtual ~CanNodeObject(void);
42 
47  virtual UaStatus getDeviceMessage(OpcUa_UInt32 code)
48  {
49  OpcUa_ReferenceParameter(code);
50  return OpcUa_Good;
51  }
52  virtual UaStatus sendDeviceMessage(OpcUa_UInt32 code, UaDataValue *value = 0);
53 
54  void passSDO( const CanMsgStruct *cms);
55  virtual void setState(const CanMsgStruct *cms) ;
56  virtual void setEmergencyEvent(const CanMsgStruct *cms);
58  {
59  m_mutexReqSDO.lock();
60  m_requestedSDO = msdo;
61  }
62 
64  {
65  m_requestedSDO = 0;
66  m_mutexReqSDO.unlock();
67  }
68 
74  virtual UaStatus connectCode(OpcUa_UInt32 code,::xsd::cxx::tree::type *conf,UaNode *blink);
75  virtual UaVariant getPropertyValue(OpcUa_UInt32 code, ::xsd::cxx::tree::type *conf);
76 
78  virtual void sendNG();
79 
84  void NGComing(OpcUa_Byte st)
85  {
86  if (st == 0) {
87  setLastState();
88  return;
89  }
90 
92  setLastState();
93  }
94 
96  m_currentState = st;
97  }
98 
99  void setInitLive() {
100  m_currentState = 0;
101  m_lastState = 0;
103  }
104 
105  void decNGCounter()
106  {
107  if (isAlive())
108  {
110  if (m_repeatedCounter == 0)
111  {
113  }
114  }
115  }
116 
117  static OpcUa_Int16 ngCounter;
118  static OpcUa_Boolean DisconectRecovery;
119 
120 
121  private:
122  UaMutex m_mutexReqSDO;
124  void setDisconnectedState();
125  void setStateRecursevely(UaNode *p,bool state);
126 
127  void setLastState();
128 
129  OpcUa_Boolean isAlive() { return !(m_currentState == NMT_DISCONNECTED); }
130 
131  OpcUa_Byte m_currentState;
132  OpcUa_Byte m_lastState;
133  OpcUa_Int16 m_repeatedCounter;
134 
135  OpcUa::BaseVariableType *m_state;
136  OpcUa::BaseVariableType *m_iBootupCounter;
137  OpcUa::BaseVariableType *m_EmergencyErrorCode;
138  OpcUa::BaseVariableType *m_EmergencyCounter;
139  OpcUa::BaseVariableType *m_Error;
140  OpcUa::BaseVariableType *m_SpecificErrorCodeByte1;
141  OpcUa::BaseVariableType *m_SpecificErrorCodeByte2;
142  OpcUa::BaseVariableType *m_SpecificErrorCodeByte3;
143  OpcUa::BaseVariableType *m_SpecificErrorCodeByte4;
144  OpcUa::BaseVariableType *m_SpecificErrorCodeByte5;
145  list<OpcUa::BaseVariableType *> m_programList;
146  };
147 }
148 #endif