40 #include <boost/unordered_map.hpp> 42 #ifdef _IC_BUILDER_ICL_COMM_WEBSOCKET_ 44 #include <icl_comm_websocket/WsBroadcaster.h> 54 #endif // _IC_BUILDER_ICL_COMM_WEBSOCKET_ 58 namespace canopen_schunk {
107 virtual void initNode();
118 virtual void startHeartbeat();
139 const bool dummy_mapping =
false,
140 const uint8_t cyclic_timeout_cycles = 0);
161 const bool dummy_mapping =
false,
162 const uint8_t cyclic_timeout_cycles = 0);
164 template <
typename T>
168 if (m_rpdo_mapping.find(identifier) == m_rpdo_mapping.end())
170 std::stringstream ss;
171 ss <<
"Could not find RPDO entry identifier string " << identifier <<
". Aborting action now. ";
174 const PDOMapEntry& entry = m_rpdo_mapping[identifier];
176 const PDO::Mapping&
mapping = m_rpdos[entry.pdo_nr]->m_mapping_list[entry.pdo_mapping_index];
179 return convertFromCharVector<T>(mapping.
data);
189 template <
typename T>
193 if (m_tpdo_mapping.find(identifier) == m_tpdo_mapping.end())
195 std::stringstream ss;
196 ss <<
"Could not find TPDO entry identifier string " << identifier <<
". Aborting action now. ";
199 const PDOMapEntry& entry = m_tpdo_mapping[identifier];
201 const PDO::Mapping&
mapping = m_tpdos[entry.pdo_nr]->m_mapping_list[entry.pdo_mapping_index];
204 return convertFromCharVector<T>(mapping.
data);
214 template <
typename T>
218 if (m_rpdo_mapping.find(identifier) == m_rpdo_mapping.end())
220 std::stringstream ss;
221 ss <<
"Could not find RPDO entry identifier string " << identifier <<
". Aborting action now. ";
224 const PDOMapEntry& entry = m_rpdo_mapping[identifier];
227 if (
sizeof(T) == mapping.
data.size())
229 std::memcpy(&(mapping.
data[0]), &value,
sizeof(T));
232 LOGGING_TRACE (CanOpen,
"Setting " << identifier <<
" for node " << m_node_id <<
" to " << value <<
endl);
245 template <
typename T>
249 if (m_tpdo_mapping.find(identifier) == m_tpdo_mapping.end())
251 std::stringstream ss;
252 ss <<
"Could not find TPDO entry identifier string " << identifier <<
". Aborting action now. ";
255 const PDOMapEntry& entry = m_tpdo_mapping[identifier];
258 if (
sizeof(T) == mapping.
data.size())
260 std::memcpy(&(mapping.
data[0]), &value,
sizeof(T));
263 LOGGING_TRACE (CanOpen,
"Setting " << identifier <<
" for node " << m_node_id <<
" to " << value <<
endl);
276 void downloadPDOs ();
281 void printPDOMapping();
295 void registerPDONotifyCallback (
const std::string& identifier,
const boost::function<
void ()>&
f );
300 virtual void stopNode();
337 #endif // DS301NODE_H boost::shared_ptr< const DS301Node > ConstPtr
Shared pointer to a const DS301Node.
RPDO::PtrList m_rpdos
RPDOS of this node (up to 4 in standard config)
CanDevPtr m_can_dev
Device handle for transmission of messages.
uint8_t getNodeId() const
std::vector< MappingConfiguration > MappingConfigurationList
The MappingConfigurationList holds multiple Mapping configurations. The Mapping of a single PDO is de...
boost::shared_ptr< DS301Node > Ptr
Shared pointer to a DS301Node.
Unique index to find a mapped Object dictionary item in a PDO.
SDO m_sdo
SDO object for specific calls.
The NMT class provides access to NMT functions of the canOpen protocol and keeps the NMT state of can...
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::vector< uint8_t > data
Actual data of the PDO is stored in this data vector.
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.
uint16_t m_heartbeat_cycle_time_ms
T getRPDOValue(const std::string &identifier)
PDO related exceptions go here.
std::vector< boost::shared_ptr< TPDO > > PtrList
Convenience typedef to use PDO lists with shared pointers.
uint8_t m_node_id
CANOPEN ID of the node.
eTransmissionType
Transmission types of a PDO, needed when mapping PDOs.
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.
ThreadStream & endl(ThreadStream &stream)
bool setRPDOValue(const std::string &identifier, const T value)
Set the value of a PDO which is mapped to a given identifier.
std::vector< boost::shared_ptr< RPDO > > PtrList
Convenience typedef to use PDO lists with shared pointers.
std::vector< unsigned int > mapping(const T &t1, const T &t2)
bool setTPDOValue(const std::string &identifier, const T value)
Set the value of a PDO which is mapped to a given identifier.
The SDO class represents Service Data Objects (SDO) that are used for slow access of the canOpen obje...
Holds the mapping parameter plus the actual data.
EMCY::Ptr m_emcy
EMCY object to handle spontaneous callbacks with emergency messages.
TPDO::PtrList m_tpdos
TPDOS of this node (up to 4 in standard config)
ePDO_TYPE
Type of a PDO. RECEIVE_PDOs carry data from the host to the device, TRANSMIT_PDOs from the device to ...
HeartBeatMonitor::Ptr m_heartbeat_monitor
#define LOGGING_TRACE(streamname, arg)
uint8_t pdo_mapping_index
The DS301Node class Is the base class representation of canOpen devices. It is the access point to th...
T getTPDOValue(const std::string &identifier)
Get the value of a PDO which is mapped to a given identifier.
NMT m_nmt
Object to handle NMT calls and status.