CanOpenController.h
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 #ifndef CANOPENCONTROLLER_H
00026 #define CANOPENCONTROLLER_H
00027 
00028 #include <boost/noncopyable.hpp>
00029 #include <boost/shared_ptr.hpp>
00030 #include <icl_hardware_can/tCanDevice.h>
00031 
00032 #include "helper.h"
00033 #include "CanOpenReceiveThread.h"
00034 #include "DS301Group.h"
00035 #include "HeartBeatMonitor.h"
00036 
00037 #ifdef _IC_BUILDER_ICL_COMM_WEBSOCKET_
00038   // Schunk Diagnostics addon
00039   #include <icl_comm_websocket/WsBroadcaster.h>
00040 #else
00041 // Forward Deklaration of the WsBroadcaster
00042 // This is not needed for normal driver operation
00043 // but might be added later. To keep the interface the same
00044 // a forward declaration becomes necessary
00045 namespace icl_comm{
00046 namespace websocket{
00047   class WsBroadcaster;
00048 }}// NS end
00049 #endif // _IC_BUILDER_ICL_COMM_WEBSOCKET_
00050 
00051 namespace icl_hardware{
00052 namespace canopen_schunk{
00053 
00054 
00065 class CanOpenController : protected virtual boost::noncopyable
00066 {
00067 public:
00069   typedef boost::shared_ptr<CanOpenController> Ptr;
00071   typedef boost::shared_ptr<const CanOpenController> ConstPtr;
00072 
00082   CanOpenController(const std::string can_device_identifier = "/dev/pcanusb0",
00083                     const uint32_t baud_rate = 500,
00084                     const std::string& resource_folder_location = "");
00085 
00086   ~CanOpenController ();
00087 
00094   void initNodes(const int16_t node_id = -1);
00095 
00101   void processCanMsgCallback (const icl_hardware::can::tCanMessage& msg);
00102 
00109   void reconnectCanDevice(const std::string& can_identifier, const uint32_t baud_rate);
00110 
00117   template <typename GroupT>
00118   void addGroup(const std::string& identifier);
00119 
00131   template <typename GroupT>
00132   boost::shared_ptr<GroupT> getGroup (const std::string& index = "default");
00133 
00139   void deleteGroup(const std::string& identifier);
00140 
00141 
00149   template <typename NodeT>
00150   void addNode(const uint8_t node_id, const std::string& group_name = "default");
00151 
00157   void deleteNode (const uint8_t node_id);
00158 
00165   CanDevPtr getCanDevice () const { return m_can_device; }
00166 
00170   void syncAll();
00171 
00179   template <typename NodeT>
00180   boost::shared_ptr<NodeT> getNode (const uint8_t node_id);
00181 
00185   void stopAll();
00186 
00190   std::vector<uint8_t> getNodeList ();
00191 
00200   void enablePPMotion(const int16_t node_id = -1);
00201 
00202 private:
00205   void init();
00206 
00208   void getResources();
00209 
00211   DS301Node::Ptr getNodeById (const uint8_t node_id);
00212 
00214   CanOpenReceiveThreadPtr m_receive_thread;
00215 
00217   CanDevPtr m_can_device;
00218 
00219 
00221 
00222   std::string m_can_device_name;
00223   int32_t m_can_device_flags;
00224   unsigned char m_can_device_acceptance_code;
00225   unsigned char m_can_device_acceptance_mask;
00226   uint32_t m_can_device_send_fifo_size;
00227   uint32_t m_can_device_receive_fifo_size;
00228   uint32_t m_can_device_baud_rate;
00230   HeartBeatMonitor::Ptr m_heartbeat_monitor;
00231 
00233   uint32_t m_polling_period_ms;
00234 
00236   std::map<std::string, DS301Group::Ptr> m_groups;
00238   std::map<uint8_t, DS301Node::Ptr> m_nodes;
00239 
00241   std::string m_resource_folder_location;
00242 
00244   boost::shared_ptr<icl_comm::websocket::WsBroadcaster> m_ws_broadcaster;
00245   size_t m_ws_broadcast_counter; 
00246   size_t m_ws_broadcast_rate; 
00247 
00248 };
00249 
00250 
00251 }// End of NS
00252 }
00253 
00254 // include template implementations
00255 #include "CanOpenController.hpp"
00256 
00257 #endif // CANOPENCONTROLLER_H


schunk_canopen_driver
Author(s): Felix Mauch , Georg Heppner
autogenerated on Thu Jun 6 2019 20:17:24