OpcUaCanOpen
CANopen OPC-UA server
CanOpenObject.cpp
Go to the documentation of this file.
1 #include "CanOpenObject.h"
2 //#include "BuildingAutomationTypeIds.h"
3 #include "Ids.h"
4 #include "CanObject.h"
5 #include "UaCanTrace.h"
6 
7 namespace CanOpen
8 {
9  #define gl_Timeout 2000;
10 
11 // using namespace AddressSpace;
12 
14  pUserDeviceStruct *par,
15  ::xml_schema::type *conf,UaNode *blink, int code
16  ) : InterfaceUserDataBase(par,conf,blink,code),
17 // m_waitMessage(0, (code == Ba_PDOType) ? ((((PDO *)conf)->numch() == 0) ? 1 : ((PDO *)conf)->numch()) : 1)
18  m_waitMessage(0, 1)
19  {
20 // m_iTimeout = 0;
21  }
22 
24  {
25  }
26 
32  {
33  return (getCobId() == cmg->c_id);
34  }
35 
37  {
38  return ((CanObject *)getParentDevice())->getCanBusInterface();
39  }
40 
41  UaStatus CanOpenObject::waitOperation(OpcUa_UInt tout)
42  {
43  UaStatus ret = OpcUa_Good;
44 
45  while ( m_iMaxCount - m_iCount > 0) {
46  OpcUa_StatusCode status = m_waitMessage.timedWait(tout);
47  if (status == OpcUa_GoodNonCriticalTimeout) {
48  LOG(Log::DBG, SdoMessage) << "bus=" << getBusName() << " node=" << std::hex << (int)getCobId() <<" status=Timeout expire " << std::dec << tout ;
49  ret.setStatus(OpcUa_BadTimeout," Timeout expire");
50  return ret;
51  }
52  else ret = status;
53  }
54  m_iCount = 0;
55  return ret;
56  }
58  {
59  UaStatus ret = OpcUa_Good;
60  OpcUa_UInt32 timeout = m_iTimeout > 0 ? m_iTimeout : gl_Timeout;
61  ret = waitOperation(timeout);
62  return ret;
63  }
64 
66  {
67  OpcUa_StatusCode status = m_waitMessage.timedWait(0);
68  return status;
69  }
70 
71 }