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 CANOPENRECEIVETHREAD_H 00026 #define CANOPENRECEIVETHREAD_H 00027 00028 #include <boost/thread.hpp> 00029 00030 #include <icl_core/TimeSpan.h> 00031 00032 #include <icl_hardware_can/tCanMessage.h> 00033 #include <icl_hardware_can/tCanDevice.h> 00034 00035 namespace icl_hardware { 00036 namespace canopen_schunk { 00037 00039 typedef boost::function<void (const icl_hardware::can::tCanMessage& msg)> ReceivedPacketCallback; 00040 00049 class CanOpenReceiveThread 00050 { 00051 public: 00059 CanOpenReceiveThread( const icl_core::TimeSpan& period, 00060 const boost::shared_ptr< icl_hardware::can::tCanDevice >& can_device, 00061 const ReceivedPacketCallback& received_callback ); 00062 00066 virtual ~CanOpenReceiveThread(); 00067 00069 void stop(); 00070 00071 private: 00073 void workerFunction(); 00078 int32_t receiveData(); 00079 00081 int32_t m_period_time_ms; 00082 00084 boost::shared_ptr<icl_hardware::can::tCanDevice> m_can_device; 00085 00087 ReceivedPacketCallback m_received_callback; 00088 00090 boost::thread m_thread; 00091 00093 icl_hardware::can::tCanMessage m_can_msg; 00094 }; 00095 00096 00097 00098 }} // end of NS 00099 00100 #endif // CANOPENRECEIVETHREAD_H