DS301Group.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of the SCHUNK Canopen Driver suite.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 SCHUNK GmbH, Lauffen/Neckar Germany
12 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
23 //----------------------------------------------------------------------
24 
25 #include "DS301Group.h"
26 
27 namespace icl_hardware {
28 namespace canopen_schunk {
29 
30 DS301Group::DS301Group(const std::string& name)
31  : m_name(name)
32 {
33 }
34 
35 void DS301Group::deleteNodes(std::vector<uint8_t>& deleted_ids)
36 {
37  deleted_ids.clear();
38  for (size_t i=0; i < m_nodes.size(); ++i)
39  {
40  deleted_ids.push_back(m_nodes.at(i)->getNodeId());
41  }
42  m_nodes.clear();
43 }
44 
46 {
47  for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
48  {
49  if ((*it)->getNodeId() == node_id)
50  {
51  m_nodes.erase(it);
52  return true;
53  }
54  }
55  return false;
56 }
57 
59  const uint16_t pdo_nr,
60  const PDO::eTransmissionType& transmission_type,
61  const DS301Node::ePDO_TYPE& pdo_type,
62  const bool dummy_mapping,
63  const uint8_t cyclic_timeout_cycles,
64  const int16_t node_id)
65 {
66  for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
67  {
68  if ((*it)->getNodeId() == node_id || node_id < 0)
69  {
70  (*it)->initPDOMappingSingle(config,
71  pdo_nr,
72  transmission_type,
73  pdo_type,
74  dummy_mapping,
75  cyclic_timeout_cycles);
76  }
77  }
78 }
79 
81  const uint16_t pdo_nr,
82  const PDO::eTransmissionType& transmission_type,
83  const DS301Node::ePDO_TYPE& pdo_type,
84  const bool dummy_mapping,
85  const uint8_t cyclic_timeout_cycles,
86  const int16_t node_id)
87 {
88  for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
89  {
90  if ((*it)->getNodeId() == node_id || node_id < 0)
91  {
92  (*it)->appendPDOMappingSingle(config,
93  pdo_nr,
94  transmission_type,
95  pdo_type,
96  dummy_mapping,
97  cyclic_timeout_cycles);
98  }
99  }
100 }
101 
103 {
104  for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
105  {
106  (*it)->uploadPDOs();
107  }
108 }
109 
111 {
112  for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
113  {
114  (*it)->downloadPDOs();
115  }
116 }
117 
119 {
120  for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
121  {
122  if ((*it)->getNodeId() == node_id || node_id < 0)
123  {
124  (*it)->printPDOMapping();
125  }
126  }
127 }
128 
130 {
131  m_ws_broadcaster = broadcaster;
132 }
133 
134 
135 
136 }} // end of NS
virtual bool deleteNodeFromId(const uint8_t node_id)
Deletes a node with a given node id from the node list, if it is present. If the node can&#39;t be found ...
Definition: DS301Group.cpp:45
virtual void appendPDOMappingSingle(const PDO::MappingConfigurationList &config, const uint16_t pdo_nr, const PDO::eTransmissionType &transmission_type, const DS301Node::ePDO_TYPE &pdo_type, const bool dummy_mapping=false, const uint8_t cyclic_timeout_cycles=0, const int16_t node_id=-1)
Appends one or more mapping parameters to the existing mapping. Note that the PDO will be disabled wh...
Definition: DS301Group.cpp:80
std::vector< MappingConfiguration > MappingConfigurationList
The MappingConfigurationList holds multiple Mapping configurations. The Mapping of a single PDO is de...
Definition: PDO.h:70
void registerWSBroadcaster(boost::shared_ptr< icl_comm::websocket::WsBroadcaster > broadcaster)
registerWSBroadcaster Adds a debug interface
Definition: DS301Group.cpp:129
eTransmissionType
Transmission types of a PDO, needed when mapping PDOs.
Definition: PDO.h:122
unsigned char uint8_t
virtual void deleteNodes(std::vector< uint8_t > &deleted_ids)
Deletes all nodes assigned to the group.
Definition: DS301Group.cpp:35
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...
Definition: DS301Group.h:168
std::vector< DS301Node::Ptr > m_nodes
Definition: DS301Group.h:161
void printPDOMapping(const uint8_t node_id=-1)
Will query the PDO mapping from the device and print that to the output.
Definition: DS301Group.cpp:118
signed short int16_t
virtual void initPDOMappingSingle(const PDO::MappingConfigurationList &config, const uint16_t pdo_nr, const PDO::eTransmissionType &transmission_type, const DS301Node::ePDO_TYPE &pdo_type, const bool dummy_mapping=false, const uint8_t cyclic_timeout_cycles=0, const int16_t node_id=-1)
Init PDO mapping with a given mapping configuration for a given pdo nr.
Definition: DS301Group.cpp:58
DS301Group(const std::string &name="")
Definition: DS301Group.cpp:30
ePDO_TYPE
Type of a PDO. RECEIVE_PDOs carry data from the host to the device, TRANSMIT_PDOs from the device to ...
Definition: DS301Node.h:88
unsigned short uint16_t


schunk_canopen_driver
Author(s): Felix Mauch , Georg Heppner
autogenerated on Mon Jun 10 2019 15:07:49