OpcUaCanOpen
CANopen OPC-UA server
CanOpen::CanBusObject Class Reference

This class comprises all properties and functions to control Can bus This class has the implementation of two main abstract function from CanObject getDeviceMasage and sendDeviceMessage. More...

#include <CanBusObject.h>

Inherits CanOpen::CanObject.

Public Member Functions

 CanBusObject (pUserDeviceStruct *interf, CANBUS *ca, UaNode *link, int code)
 Constructor. More...
 
virtual ~CanBusObject (void)
 Destructor. More...
 
virtual void setPortError (const int err, const char *errmsg, timeval &tv)
 Callback function to set bus error. More...
 
virtual UaStatus getDeviceMessage (OpcUa_UInt32 code)
 this function is dummy for CanBusObject. There is no any readable data More...
 
void openCanBus ()
 open can bus More...
 
void closeCanBus ()
 close can bus More...
 
virtual UaStatus sendDeviceMessage (OpcUa_UInt32 code, UaDataValue *value=0)
 send message to canbus More...
 
void sendSync ()
 send sync message More...
 
virtual UaStatus connectCode (OpcUa_UInt32 code,::xsd::cxx::tree::type *conf, UaNode *blink)
 connect function code to ua node to pass data More...
 
virtual UaVariant getPropertyValue (OpcUa_UInt32 code, ::xsd::cxx::tree::type *conf)
 
CCanUACallbackgetCanUACallback ()
 get main can bus callback function More...
 
void addPDO (CanPDOObject *pdoo)
 Add pdo object. More...
 
busNodesgetListNodes ()
 
void addNode (CanNodeObject *pnode)
 add Can node to the bus More...
 
void sendInitNodeNmt ()
 send nmt message after startup More...
 
void initialize ()
 initialize the bus. send RTR after startup More...
 
void startSyncInterval ()
 start sync interval thread to send sync message More...
 
void startNodeGuardingInterval ()
 start nodeGuarding interval thread to send NG messages More...
 
string & getCanBusName ()
 
string & getCanBusAddress ()
 
void waitData ()
 
- Public Member Functions inherited from CanOpen::CanObject
 CanObject (pUserDeviceStruct *parent,::xsd::cxx::tree::type *conf, UaNode *pAS, OpcUa_UInt32 code)
 Constructor. More...
 
virtual ~CanObject (void)
 Destructor. More...
 
OpcUa_Byte getCanNodeId ()
 get Node Id More...
 
void sendNMT (enum ::NMTcommand nmt)
 Send nmt message. More...
 
virtual void setInitNmt (enum NMTcommand iNMT)
 Save initial nmt message which will send to initialize devices. More...
 
virtual void setInitNmt (std::string sNmt)
 Save initial nmt message which will send to initialize devices. More...
 
virtual void sendInitNmt ()
 send initial nmt message More...
 
CCanAccessgetCanBusInterface ()
 get pointer to can bus interface More...
 
void setCanBusInterface (CCanAccess *ccac)
 save pointer to can bus interface More...
 
IOManager * getIOManager ()
 
- Public Member Functions inherited from UserDevice::InterfaceUserDataBase
 InterfaceUserDataBase (pUserDeviceStruct *parent,::xsd::cxx::tree::type *conf, UaNode *pAS, OpcUa_UInt code)
 Constructor Also create the shared mutex which can be used to synchronize operation on device using lock/unlock function. More...
 
virtual ~InterfaceUserDataBase (void)
 Destructor. More...
 
- Public Member Functions inherited from UserDevice::UserDeviceStruct
 UserDeviceStruct (pUserDeviceStruct *parent, ::xsd::cxx::tree::type *conf, UaNode *pAS, OpcUa_UInt code)
 constructor More...
 
void lock ()
 lock shared mutex to protect More...
 
void unlock ()
 unlock shared mutex More...
 
::UaMutexRefCounted * getShareMutex ()
 get mutex More...
 
void releaseMutex ()
 
OpcUa_Int32 countMutex ()
 
virtual ~UserDeviceStruct (void)
 
OpcUa_UInt getCodeFunction ()
 
UserDeviceStructgetParentDevice ()
 
pUserDeviceStructgetTopInterface ()
 
pUserDeviceStructgetParent ()
 
virtual void setInvalid ()
 
UaNode * getAddressSpaceEntry ()
 

Private Member Functions

 UA_DISABLE_COPY (CanBusObject)
 

Private Attributes

CCanUACallbackm_pCallback
 wait initial data after startup More...
 
SyncIntervalm_pSyncIn
 Call back class to take data from can bus. More...
 
NodeGuardingIntervalm_pNgIn
 Sync interval thread object. More...
 
OpcUa::BaseVariableType * m_iPortError
 Node Guarding thread object. More...
 
OpcUa::BaseVariableType * m_sPortErrorDescription
 Can Bus error reading from driver. More...
 
string m_sBusName
 Description of the port error. More...
 
string m_sBusParameters
 bus name More...
 
string m_sBusAddress
 buss parameters More...
 

Additional Inherited Members

- Protected Attributes inherited from CanOpen::CanObject
CCanAccessm_pCommIf
 Address of can interface. More...
 
OpcUa_Byte m_CanNodeId
 Node Id for bus = 0. More...
 
enum NMTcommand m_initNMTcommand
 initial NMT commands More...
 
IOManager * m_pIOManager
 
- Protected Attributes inherited from UserDevice::UserDeviceStruct
UaMutexRefCounted * m_pSharedMutex
 

Detailed Description

This class comprises all properties and functions to control Can bus This class has the implementation of two main abstract function from CanObject getDeviceMasage and sendDeviceMessage.

Definition at line 27 of file CanBusObject.h.

Constructor & Destructor Documentation

◆ CanBusObject()

CanOpen::CanBusObject::CanBusObject ( pUserDeviceStruct interf,
CANBUS ca,
UaNode *  link,
int  code 
)

Constructor.

Parameters
interfpointer to parent object usually null for CanBusObject
caXML configuration entry
linkpointer to Ua Node
codecode of function

Definition at line 11 of file CanBusObject.cpp.

◆ ~CanBusObject()

CanOpen::CanBusObject::~CanBusObject ( void  )
virtual

Destructor.

Definition at line 71 of file CanBusObject.cpp.

Member Function Documentation

◆ addNode()

void CanOpen::CanBusObject::addNode ( CanNodeObject pnode)
inline

add Can node to the bus

Parameters
pnodenode to add

Definition at line 104 of file CanBusObject.h.

◆ addPDO()

void CanOpen::CanBusObject::addPDO ( CanPDOObject pdoo)
inline

Add pdo object.

Parameters
pdoopointer to CanPDOObject

Definition at line 92 of file CanBusObject.h.

◆ closeCanBus()

void CanOpen::CanBusObject::closeCanBus ( void  )

close can bus

Definition at line 41 of file CanBusObject.cpp.

◆ connectCode()

UaStatus CanOpen::CanBusObject::connectCode ( OpcUa_UInt32  code,
::xsd::cxx::tree::type *  conf,
UaNode *  blink 
)
virtual

connect function code to ua node to pass data

Parameters
codefunction code defines the operation
confXML object containing the configuration information for this object
blinkua node to pass data

Implements UserDevice::InterfaceUserDataBase.

Definition at line 148 of file CanBusObject.cpp.

◆ getCanBusAddress()

string& CanOpen::CanBusObject::getCanBusAddress ( )
inline

Definition at line 117 of file CanBusObject.h.

◆ getCanBusName()

string& CanOpen::CanBusObject::getCanBusName ( )
inline

Definition at line 116 of file CanBusObject.h.

◆ getCanUACallback()

CCanUACallback* CanOpen::CanBusObject::getCanUACallback ( )
inline

get main can bus callback function

Definition at line 87 of file CanBusObject.h.

◆ getDeviceMessage()

virtual UaStatus CanOpen::CanBusObject::getDeviceMessage ( OpcUa_UInt32  code)
inlinevirtual

this function is dummy for CanBusObject. There is no any readable data

Implements UserDevice::InterfaceUserDataBase.

Definition at line 52 of file CanBusObject.h.

◆ getListNodes()

busNodes& CanOpen::CanBusObject::getListNodes ( )
inline

Definition at line 96 of file CanBusObject.h.

◆ getPropertyValue()

UaVariant CanOpen::CanBusObject::getPropertyValue ( OpcUa_UInt32  code,
::xsd::cxx::tree::type *  conf 
)
virtual

Implements UserDevice::InterfaceUserDataBase.

Definition at line 238 of file CanBusObject.cpp.

◆ initialize()

void CanOpen::CanBusObject::initialize ( )

initialize the bus. send RTR after startup

Definition at line 22 of file CanBusObject.cpp.

◆ openCanBus()

void CanOpen::CanBusObject::openCanBus ( void  )

open can bus

Definition at line 27 of file CanBusObject.cpp.

◆ sendDeviceMessage()

UaStatus CanOpen::CanBusObject::sendDeviceMessage ( OpcUa_UInt32  code,
UaDataValue *  value = 0 
)
virtual

send message to canbus

Parameters
codecode of function
valuedata to send

Implements UserDevice::InterfaceUserDataBase.

Definition at line 96 of file CanBusObject.cpp.

◆ sendInitNodeNmt()

void CanOpen::CanBusObject::sendInitNodeNmt ( )
inline

send nmt message after startup

Definition at line 106 of file CanBusObject.h.

◆ sendSync()

void CanOpen::CanBusObject::sendSync ( )
inline

send sync message

Definition at line 71 of file CanBusObject.h.

◆ setPortError()

void CanOpen::CanBusObject::setPortError ( const int  err,
const char *  errmsg,
timeval &  tv 
)
virtual

Callback function to set bus error.

Parameters
errerror code
errmsgerror message
tvtimestamps

Definition at line 258 of file CanBusObject.cpp.

◆ startNodeGuardingInterval()

void CanOpen::CanBusObject::startNodeGuardingInterval ( )
inline

start nodeGuarding interval thread to send NG messages

Definition at line 114 of file CanBusObject.h.

◆ startSyncInterval()

void CanOpen::CanBusObject::startSyncInterval ( )
inline

start sync interval thread to send sync message

Definition at line 111 of file CanBusObject.h.

◆ UA_DISABLE_COPY()

CanOpen::CanBusObject::UA_DISABLE_COPY ( CanBusObject  )
private

◆ waitData()

void CanOpen::CanBusObject::waitData ( )

Definition at line 278 of file CanBusObject.cpp.

Member Data Documentation

◆ m_iPortError

OpcUa::BaseVariableType* CanOpen::CanBusObject::m_iPortError
private

Node Guarding thread object.

Definition at line 128 of file CanBusObject.h.

◆ m_pCallback

CCanUACallback* CanOpen::CanBusObject::m_pCallback
private

wait initial data after startup

Definition at line 123 of file CanBusObject.h.

◆ m_pNgIn

NodeGuardingInterval* CanOpen::CanBusObject::m_pNgIn
private

Sync interval thread object.

Definition at line 126 of file CanBusObject.h.

◆ m_pSyncIn

SyncInterval* CanOpen::CanBusObject::m_pSyncIn
private

Call back class to take data from can bus.

Definition at line 125 of file CanBusObject.h.

◆ m_sBusAddress

string CanOpen::CanBusObject::m_sBusAddress
private

buss parameters

Definition at line 133 of file CanBusObject.h.

◆ m_sBusName

string CanOpen::CanBusObject::m_sBusName
private

Description of the port error.

Definition at line 131 of file CanBusObject.h.

◆ m_sBusParameters

string CanOpen::CanBusObject::m_sBusParameters
private

bus name

Definition at line 132 of file CanBusObject.h.

◆ m_sPortErrorDescription

OpcUa::BaseVariableType* CanOpen::CanBusObject::m_sPortErrorDescription
private

Can Bus error reading from driver.

Definition at line 129 of file CanBusObject.h.


The documentation for this class was generated from the following files: