Public Types | Public Member Functions | Private Member Functions | Private Attributes
icl_hardware::canopen_schunk::CanOpenController Class Reference

The CanOpenController class is the main entry point for any calls to the canOpen System. More...

#include <CanOpenController.h>

Inheritance diagram for icl_hardware::canopen_schunk::CanOpenController:
Inheritance graph
[legend]

List of all members.

Public Types

typedef boost::shared_ptr
< const CanOpenController
ConstPtr
 Shared pointer to a const CanOpenController.
typedef boost::shared_ptr
< CanOpenController
Ptr
 Shared pointer to a CanOpenController.

Public Member Functions

template<typename GroupT >
void addGroup (const std::string &identifier)
 Adds a new node group with a given identifier. The group's type is given as template parameter.
template<typename NodeT >
void addNode (const uint8_t node_id, const std::string &group_name="default")
 Adds a new node to a group. If the group is not found (e.g. it was not created before), nothing will be done.
 CanOpenController (const std::string can_device_identifier="/dev/pcanusb0", const uint32_t baud_rate=500, const std::string &resource_folder_location="")
 CanOpenController constructor.
void deleteGroup (const std::string &identifier)
 Deletes a group with the given identifier. Also deletes all its nodes.
void deleteNode (const uint8_t node_id)
 Delete a node with a given CANOPEN-ID.
void enablePPMotion (const int16_t node_id=-1)
 When using the ProfilePositionMode is used, in addition to setting the target motion has to be triggered manually. Therefor, intermediate syncs are needed, which is why this is done in the controller-.
CanDevPtr getCanDevice () const
 Get a handle to the current CAN device. This is basically for debugging with a Dummy Can Device.
template<typename GroupT >
boost::shared_ptr< GroupT > getGroup (const std::string &index="default")
 Returns a shared pointer to the group with a given index if possible.
template<typename NodeT >
boost::shared_ptr< NodeT > getNode (const uint8_t node_id)
 Returns a shared pointer handle to a node.
std::vector< uint8_tgetNodeList ()
 Returns a list containing all used node ids.
void initNodes (const int16_t node_id=-1)
 Initializes a node with a given ID or all nodes.
void processCanMsgCallback (const icl_hardware::can::tCanMessage &msg)
 Incoming can messages are processed in this function and forwarded to the addressed node.
void reconnectCanDevice (const std::string &can_identifier, const uint32_t baud_rate)
 Reconnects the CAN device with the given configuration.
void stopAll ()
 Calls stop() on all registered nodes.
void syncAll ()
 Downloads all the RPDOs, Sends a Sync and Uploads all the TPDOs.
 ~CanOpenController ()

Private Member Functions

DS301Node::Ptr getNodeById (const uint8_t node_id)
 get a handle for a node identified by its CANOPEN-ID
void getResources ()
 Load resources like error-code lookup maps.
void init ()

Private Attributes

CanDevPtr m_can_device
 Handle for the can device.
std::map< std::string,
DS301Group::Ptr
m_groups
 Map of all node groups, with string identifier.
HeartBeatMonitor::Ptr m_heartbeat_monitor
std::map< uint8_t, DS301Node::Ptrm_nodes
 Map of all nodes with id identifier.
uint32_t m_polling_period_ms
 The CAN message polling period duration in milliseconds.
CanOpenReceiveThreadPtr m_receive_thread
 Handle for the can receive thread.
std::string m_resource_folder_location
 This folder contains for example the error code definitions.
size_t m_ws_broadcast_counter
size_t m_ws_broadcast_rate
 Counts sync cycles.
boost::shared_ptr
< icl_comm::websocket::WsBroadcaster > 
m_ws_broadcaster
 Interface to send out diagnostics data. Only available if compiled with _IC_BUILDER_ICL_COMM_WEBSOCKET_.
std::string m_can_device_name
int32_t m_can_device_flags
unsigned char m_can_device_acceptance_code
unsigned char m_can_device_acceptance_mask
uint32_t m_can_device_send_fifo_size
uint32_t m_can_device_receive_fifo_size
uint32_t m_can_device_baud_rate

Detailed Description

The CanOpenController class is the main entry point for any calls to the canOpen System.

The CanOpenController is the main entry point for any calls to the whole canOpen System. It is used to set up the hardware (i.e. can device used), configure device groups and add individual devices to these groups. It is also the entity providing access to the device groups, handling all the required type conversions as to provide the most safe and convenient way to access the hardware. Actual control commands (i.e. move a motor to a given position) are usually send directly to the corresponding group as each group might present an individual interface.

Definition at line 65 of file CanOpenController.h.


Member Typedef Documentation

Shared pointer to a const CanOpenController.

Definition at line 71 of file CanOpenController.h.

Shared pointer to a CanOpenController.

Definition at line 69 of file CanOpenController.h.


Constructor & Destructor Documentation

icl_hardware::canopen_schunk::CanOpenController::CanOpenController ( const std::string  can_device_identifier = "/dev/pcanusb0",
const uint32_t  baud_rate = 500,
const std::string &  resource_folder_location = "" 
)

CanOpenController constructor.

Parameters:
can_device_identifieridentifier string for the can device
baud_ratebaud rate of the can device
resource_folder_locationFolder location that contains ini files with error messages. If none is given, it defaults to the environment variable CANOPEN_RESOURCE_PATH. If that is not defined either, it searches in the resources subfolder where the program was launched. If no error description is found at all, plain error codes will be displayed instead.

Definition at line 38 of file CanOpenController.cpp.

Definition at line 58 of file CanOpenController.cpp.


Member Function Documentation

template<typename GroupT >
void icl_hardware::canopen_schunk::CanOpenController::addGroup ( const std::string &  identifier)

Adds a new node group with a given identifier. The group's type is given as template parameter.

Parameters:
identifierName of the new group

Definition at line 34 of file CanOpenController.hpp.

template<typename NodeT >
void icl_hardware::canopen_schunk::CanOpenController::addNode ( const uint8_t  node_id,
const std::string &  group_name = "default" 
)

Adds a new node to a group. If the group is not found (e.g. it was not created before), nothing will be done.

Parameters:
node_idID of the new node
group_nameThe new node will belong to this group.

Definition at line 80 of file CanOpenController.hpp.

void icl_hardware::canopen_schunk::CanOpenController::deleteGroup ( const std::string &  identifier)

Deletes a group with the given identifier. Also deletes all its nodes.

Parameters:
identifierThe group's identifier

Definition at line 430 of file CanOpenController.cpp.

Delete a node with a given CANOPEN-ID.

Parameters:
node_idCANOPEN-ID of the node that should be deleted.

Definition at line 461 of file CanOpenController.cpp.

When using the ProfilePositionMode is used, in addition to setting the target motion has to be triggered manually. Therefor, intermediate syncs are needed, which is why this is done in the controller-.

Parameters:
node_idIf left out or given a negative value, the function will be called for all nodes in the group, otherwise it will only be used for the given node-id.

Definition at line 590 of file CanOpenController.cpp.

Get a handle to the current CAN device. This is basically for debugging with a Dummy Can Device.

Returns:
icl_hardware::canopen_schunk::CanDevPtr Handle to the CAN device

Definition at line 165 of file CanOpenController.h.

template<typename GroupT >
boost::shared_ptr< GroupT > icl_hardware::canopen_schunk::CanOpenController::getGroup ( const std::string &  index = "default")

Returns a shared pointer to the group with a given index if possible.

Note that this function will return a NULL pointer if either the given index does not exist or if the group cannot be casted to the requested type. Error messages are output in both cases. Therefore, check for NULL pointers after calling this method.

Parameters:
indexThe group's identifier string
Returns:
boost::shared_ptr< GroupT > Shared pointer of type GroupT

Definition at line 56 of file CanOpenController.hpp.

template<typename NodeT >
boost::shared_ptr< NodeT > icl_hardware::canopen_schunk::CanOpenController::getNode ( const uint8_t  node_id)

Returns a shared pointer handle to a node.

Parameters:
node_idThe node's CanOpen-ID
Exceptions:
NotFoundExceptionwhen no node with the given ID can be found
std::bad_castwhen the node can't be casted into the requested template type.

Definition at line 124 of file CanOpenController.hpp.

get a handle for a node identified by its CANOPEN-ID

Definition at line 481 of file CanOpenController.cpp.

Returns a list containing all used node ids.

Definition at line 571 of file CanOpenController.cpp.

Load resources like error-code lookup maps.

Definition at line 494 of file CanOpenController.cpp.

Start can device and Message receiving throws a DeviceException if the device can't be initialized

Definition at line 318 of file CanOpenController.cpp.

Initializes a node with a given ID or all nodes.

Parameters:
node_idIf left out or given a negative value, the function will be called for all nodes in the group, otherwise it will only be used for the given node-id.

Definition at line 67 of file CanOpenController.cpp.

Incoming can messages are processed in this function and forwarded to the addressed node.

Parameters:
msgCan message received by m_receive_thread

Definition at line 78 of file CanOpenController.cpp.

void icl_hardware::canopen_schunk::CanOpenController::reconnectCanDevice ( const std::string &  can_identifier,
const uint32_t  baud_rate 
)

Reconnects the CAN device with the given configuration.

Parameters:
can_identifierIdentifier string for the can device
baud_rateBaud rate of the can device

Definition at line 295 of file CanOpenController.cpp.

Calls stop() on all registered nodes.

Definition at line 560 of file CanOpenController.cpp.

Downloads all the RPDOs, Sends a Sync and Uploads all the TPDOs.

Definition at line 526 of file CanOpenController.cpp.


Member Data Documentation

Handle for the can device.

Definition at line 217 of file CanOpenController.h.

Definition at line 224 of file CanOpenController.h.

Definition at line 225 of file CanOpenController.h.

Definition at line 228 of file CanOpenController.h.

Definition at line 223 of file CanOpenController.h.

Can device parameters

Definition at line 222 of file CanOpenController.h.

Definition at line 227 of file CanOpenController.h.

Definition at line 226 of file CanOpenController.h.

Map of all node groups, with string identifier.

Definition at line 236 of file CanOpenController.h.

Definition at line 230 of file CanOpenController.h.

Map of all nodes with id identifier.

Definition at line 238 of file CanOpenController.h.

The CAN message polling period duration in milliseconds.

Definition at line 233 of file CanOpenController.h.

Handle for the can receive thread.

Definition at line 214 of file CanOpenController.h.

This folder contains for example the error code definitions.

Definition at line 241 of file CanOpenController.h.

Definition at line 245 of file CanOpenController.h.

Counts sync cycles.

Definition at line 246 of file CanOpenController.h.

boost::shared_ptr<icl_comm::websocket::WsBroadcaster> icl_hardware::canopen_schunk::CanOpenController::m_ws_broadcaster [private]

Interface to send out diagnostics data. Only available if compiled with _IC_BUILDER_ICL_COMM_WEBSOCKET_.

Definition at line 244 of file CanOpenController.h.


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


schunk_canopen_driver
Author(s): Felix Mauch , Georg Heppner
autogenerated on Sun May 22 2016 03:30:56