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
13
CanOpenObject::CanOpenObject
(
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
23
CanOpenObject::~CanOpenObject
(
void
)
24
{
25
}
26
31
bool
CanOpenObject::isMsgForObject
(
const
CanMsgStruct
*cmg)
32
{
33
return
(
getCobId
() == cmg->
c_id
);
34
}
35
36
CCanAccess
*
CanOpenObject::getCanBus
()
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
}
57
UaStatus
CanOpenObject::waitOperation
()
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
65
UaStatus
CanOpenObject::releaseOperation
()
66
{
67
OpcUa_StatusCode status =
m_waitMessage
.timedWait(0);
68
return
status;
69
}
70
71
}
CanOpen
src
CanOpenObject.cpp
Generated on Fri Sep 11 2020 14:29:54 for OpcUaCanOpen by
1.8.14