29 namespace canopen_schunk {
32 m_nmt(node_id,can_device),
33 m_sdo(node_id, can_device),
36 m_can_dev(can_device),
37 m_heartbeat_monitor(heartbeat_monitor),
38 m_heartbeat_cycle_time_ms(50)
40 for (
size_t i = 0; i < 4; ++i)
70 const bool dummy_mapping,
71 const uint8_t cyclic_timeout_cycles)
74 boost::unordered_map<std::string, PDOMapEntry>* map;
77 mapping =
m_rpdos.at(pdo_nr)->remap(
m_sdo, config, transmission_type, dummy_mapping, cyclic_timeout_cycles);
82 mapping =
m_tpdos.at(pdo_nr)->remap(
m_sdo, config, transmission_type, dummy_mapping, cyclic_timeout_cycles);
91 for (boost::unordered_map<std::string, PDOMapEntry>::iterator it = map->begin();
95 if (it->second.pdo_nr == pdo_nr)
106 for (PDO::PDOStringMatchVec::iterator it = mapping.begin(); it != mapping.end(); ++it)
112 map->insert(std::pair<std::string, PDOMapEntry>(it->name, entry));
120 const bool dummy_mapping,
121 const uint8_t cyclic_timeout_cycles)
124 boost::unordered_map<std::string, PDOMapEntry>* map;
128 mapping =
m_rpdos.at(pdo_nr)->appendMapping(
m_sdo, config, transmission_type, dummy_mapping, cyclic_timeout_cycles);
133 mapping =
m_tpdos.at(pdo_nr)->appendMapping(
m_sdo, config, transmission_type, dummy_mapping, cyclic_timeout_cycles);
142 for (PDO::PDOStringMatchVec::iterator it = mapping.begin(); it != mapping.end(); ++it)
148 map->insert(std::pair<std::string, PDOMapEntry>(it->name, entry));
156 for (TPDO::PtrList::iterator it =
m_tpdos.begin(); it !=
m_tpdos.end(); ++it)
164 for (RPDO::PtrList::iterator it =
m_rpdos.begin(); it !=
m_rpdos.end(); ++it)
173 size_t max_num_rpdo = 512;
176 std::stringstream ss;
177 ss <<
"PDO Mapping queried from device:" << std::endl;
178 ss <<
"===== RPDOs ===== " << std::endl;
180 for (
uint8_t i = 0; i < max_num_rpdo; ++i)
192 ss <<
" === RPDO " <<
static_cast<int>(i) <<
" - " << static_cast<int>(num_entries) <<
" entries ===" << std::endl;
194 for (
uint8_t j = 1; j <= num_entries; ++j)
197 int index = (data32 & 0xFFFF0000) >> 16;
198 int subindex = (data32 & 0x0000FF00) >> 8;
199 int length = data32 & 0x000000FF;
200 ss <<
" " <<
static_cast<int>(j) <<
" -> " 201 <<
hexToString(index) <<
" / " << subindex <<
", length: " << length <<
" bits" << std::endl;
207 size_t max_num_tpdo = 512;
209 ss <<
"===== TPDOs ===== " << std::endl;
211 for (
uint8_t i = 0; i < max_num_tpdo; ++i)
223 ss <<
" === TPDO " <<
static_cast<int>(i) <<
" - " << static_cast<int>(num_entries) <<
" entries ===" << std::endl;
225 for (
uint8_t j = 1; j <= num_entries; ++j)
228 int index = (data32 & 0xFFFF0000) >> 16;
229 int subindex = (data32 & 0x0000FF00) >> 8;
230 int length = data32 & 0x000000FF;
231 ss <<
" " <<
static_cast<int>(j) <<
" -> " 232 <<
hexToString(index) <<
" / " << subindex <<
", length: " << length <<
" bits" << std::endl;
240 const boost::function<
void() >& f)
242 boost::unordered_map<std::string,PDOMapEntry>::iterator it =
m_tpdo_mapping.find(identifier);
245 size_t pdo_nr = it->second.pdo_nr;
246 m_tpdos[pdo_nr]->registerNotifyCallback(
f);
247 LOGGING_DEBUG_C (CanOpen, DS302Node,
"Registered notification callback for PDO entry " <<
253 std::stringstream ss;
254 ss <<
"Notifier callback function for a PDO entry named " << identifier
255 <<
" requested, however, no entry with this given identifier exists within this PDO";
RPDO::PtrList m_rpdos
RPDOS of this node (up to 4 in standard config)
DS301Node(const uint8_t node_id, const CanDevPtr &can_device, HeartBeatMonitor::Ptr heartbeat_monitor)
std::vector< MappingConfiguration > MappingConfigurationList
The MappingConfigurationList holds multiple Mapping configurations. The Mapping of a single PDO is de...
virtual void initPDOMappingSingle(const PDO::MappingConfigurationList &config, const uint16_t pdo_nr, const PDO::eTransmissionType &transmission_type, const ePDO_TYPE &pdo_type, const bool dummy_mapping=false, const uint8_t cyclic_timeout_cycles=0)
Init PDO mapping with a given mapping configuration for a given pdo nr.
Unique index to find a mapped Object dictionary item in a PDO.
virtual void startHeartbeat()
Initializes the heartbeat for the node. Throws ProtocolException it heartbeat cannot be initialized...
#define LOGGING_INFO(streamname, arg)
Basic CanOpen exception that contains the Object dictionary index and subindex.
SDO m_sdo
SDO object for specific calls.
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...
This class describes Receive PDOs, meaning PDOs that send data from the host to the device...
bool download(const bool normal_transfer, const uint16_t index, const uint8_t subindex, const std::vector< uint8_t > &usrdata)
Downloads SDO data from the master to the slave (From PC to node).
boost::unordered_map< std::string, PDOMapEntry > m_rpdo_mapping
This map holds a mapping between an identifier string and a mapped position in a RPDO.
void preOperational()
preOperational switches the device back into pre-operational state where configuration can occur ...
uint16_t m_heartbeat_cycle_time_ms
virtual void appendPDOMappingSingle(const PDO::MappingConfigurationList &config, const uint16_t pdo_nr, const PDO::eTransmissionType &transmission_type, const ePDO_TYPE &pdo_type, const bool dummy_mapping=false, const uint8_t cyclic_timeout_cycles=0)
Appends one or more mapping parameters to the existing mapping. Note that the PDO will be disabled wh...
PDO related exceptions go here.
virtual void initNode()
Initializes the node.
uint8_t m_node_id
CANOPEN ID of the node.
eTransmissionType
Transmission types of a PDO, needed when mapping PDOs.
virtual void registerWSBroadcaster(boost::shared_ptr< icl_comm::websocket::WsBroadcaster > broadcaster)
registerWSBroadcaster Adds a debug interface
void stop()
stop Stops the device by setting the NMT state to stopped
boost::unordered_map< std::string, PDOMapEntry > m_tpdo_mapping
This map holds a mapping between an identifier string and a mapped position in a TPDO.
void printPDOMapping()
Will query the PDO mapping from the device and print that to the output.
#define LOGGING_DEBUG_C(streamname, classname, arg)
This class describes Transmit PDOs, meaning PDOs that send data from the device to the host...
ThreadStream & endl(ThreadStream &stream)
The EMCY class handles the spontaneously occurring Emergency (EMCY) messages, keeps track of a nodes ...
virtual void stopNode()
Puts the node into nmt state preo_operational.
bool upload(const bool normal_transfer, const uint16_t index, const uint8_t subindex, std::vector< uint8_t > &uploaded_data)
Uploads data from a slave (node) to a master (PC).
std::vector< PDOStringMatch > PDOStringMatchVec
std::vector< unsigned int > mapping(const T &t1, const T &t2)
void downloadPDOs()
Downloads all Receive-PDOs of this node to the device.
TPDO::PtrList m_tpdos
TPDOS of this node (up to 4 in standard config)
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
ePDO_TYPE
Type of a PDO. RECEIVE_PDOs carry data from the host to the device, TRANSMIT_PDOs from the device to ...
void uploadPDOs()
Uploads all Transmit-PDOs of this node from the device.
std::string hexToString(const uint64_t num)
Converts a hexadecimal number into its string representation 0xXX.
HeartBeatMonitor::Ptr m_heartbeat_monitor
#define LOGGING_ERROR_C(streamname, classname, arg)
uint8_t pdo_mapping_index
The DS301Node class Is the base class representation of canOpen devices. It is the access point to th...
NMT m_nmt
Object to handle NMT calls and status.
void registerPDONotifyCallback(const std::string &identifier, const boost::function< void()> &f)
This function maps a callback to a specific mapped PDO entry. This callback will be called by the PDO...