DS301Group.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of the SCHUNK Canopen Driver suite.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 SCHUNK GmbH, Lauffen/Neckar Germany
00012 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00023 //----------------------------------------------------------------------
00024 
00025 #include "DS301Group.h"
00026 
00027 namespace icl_hardware {
00028 namespace canopen_schunk {
00029 
00030 DS301Group::DS301Group(const std::string& name)
00031   : m_name(name)
00032 {
00033 }
00034 
00035 void DS301Group::deleteNodes(std::vector<uint8_t>& deleted_ids)
00036 {
00037   deleted_ids.clear();
00038   for (size_t i=0; i < m_nodes.size(); ++i)
00039   {
00040     deleted_ids.push_back(m_nodes.at(i)->getNodeId());
00041   }
00042   m_nodes.clear();
00043 }
00044 
00045 bool DS301Group::deleteNodeFromId(const uint8_t node_id)
00046 {
00047   for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
00048   {
00049     if ((*it)->getNodeId() == node_id)
00050     {
00051       m_nodes.erase(it);
00052       return true;
00053     }
00054   }
00055   return false;
00056 }
00057 
00058 void DS301Group::initPDOMappingSingle (const PDO::MappingConfigurationList& config,
00059                                        const uint16_t pdo_nr,
00060                                        const PDO::eTransmissionType& transmission_type,
00061                                        const DS301Node::ePDO_TYPE& pdo_type,
00062                                        const bool dummy_mapping,
00063                                        const uint8_t cyclic_timeout_cycles,
00064                                        const int16_t node_id)
00065 {
00066   for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
00067   {
00068     if ((*it)->getNodeId() == node_id || node_id < 0)
00069     {
00070       (*it)->initPDOMappingSingle(config,
00071                                   pdo_nr,
00072                                   transmission_type,
00073                                   pdo_type,
00074                                   dummy_mapping,
00075                                   cyclic_timeout_cycles);
00076     }
00077   }
00078 }
00079 
00080 void DS301Group::appendPDOMappingSingle (const PDO::MappingConfigurationList& config,
00081                                          const uint16_t pdo_nr,
00082                                          const PDO::eTransmissionType& transmission_type,
00083                                          const DS301Node::ePDO_TYPE& pdo_type,
00084                                          const bool dummy_mapping,
00085                                          const uint8_t cyclic_timeout_cycles,
00086                                          const int16_t node_id)
00087 {
00088   for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
00089   {
00090     if ((*it)->getNodeId() == node_id || node_id < 0)
00091     {
00092       (*it)->appendPDOMappingSingle(config,
00093                                   pdo_nr,
00094                                   transmission_type,
00095                                   pdo_type,
00096                                   dummy_mapping,
00097                                   cyclic_timeout_cycles);
00098     }
00099   }
00100 }
00101 
00102 void DS301Group::uploadPDOs()
00103 {
00104   for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
00105   {
00106     (*it)->uploadPDOs();
00107   }
00108 }
00109 
00110 void DS301Group::downloadPDOs()
00111 {
00112   for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
00113   {
00114     (*it)->downloadPDOs();
00115   }
00116 }
00117 
00118 void DS301Group::printPDOMapping (const uint8_t node_id)
00119 {
00120   for (std::vector<DS301Node::Ptr>::iterator it = m_nodes.begin(); it != m_nodes.end(); ++it)
00121   {
00122     if ((*it)->getNodeId() == node_id || node_id < 0)
00123     {
00124       (*it)->printPDOMapping();
00125     }
00126   }
00127 }
00128 
00129 void DS301Group::registerWSBroadcaster(boost::shared_ptr<icl_comm::websocket::WsBroadcaster> broadcaster)
00130 {
00131   m_ws_broadcaster = broadcaster;
00132 }
00133 
00134 
00135 
00136 }} // end of NS


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