Command.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 
00024 // -- END LICENSE BLOCK ------------------------------------------------
00025 
00026 //----------------------------------------------------------------------
00033 //----------------------------------------------------------------------
00034 
00035 #ifndef SICK_SAFETYSCANNERS_COLA2_COMMAND_H
00036 #define SICK_SAFETYSCANNERS_COLA2_COMMAND_H
00037 
00038 #include <ros/ros.h>
00039 
00040 #include <vector>
00041 
00042 #include <sick_safetyscanners/datastructure/PacketBuffer.h>
00043 
00044 #include <sick_safetyscanners/data_processing/ParseTCPPacket.h>
00045 #include <sick_safetyscanners/data_processing/ReadWriteHelper.h>
00046 
00047 #include <boost/thread/mutex.hpp>
00048 
00049 namespace sick {
00050 namespace cola2 {
00051 
00055 class Cola2Session;
00056 
00057 
00061 class Command
00062 {
00063 public:
00072   Command(sick::cola2::Cola2Session& session,
00073           const uint16_t& command_type,
00074           const uint16_t& command_mode);
00075 
00079   virtual ~Command() {}
00080 
00081 
00085   void lockExecutionMutex();
00086 
00092   void constructTelegram(sick::datastructure::PacketBuffer::VectorBuffer& telegram) const;
00093 
00101   void processReplyBase(const sick::datastructure::PacketBuffer::VectorBuffer& packet);
00102 
00103 
00107   void waitForCompletion();
00108 
00109 
00115   uint32_t getSessionID() const;
00116 
00117 
00123   void setSessionID(const uint32_t& session_id);
00124 
00125 
00131   bool wasSuccessful() const;
00132 
00133 
00139   uint8_t getCommandType() const;
00140 
00146   void setCommandType(const uint8_t& command_type);
00147 
00153   uint8_t getCommandMode() const;
00154 
00160   void setCommandMode(const uint8_t& command_mode);
00161 
00167   uint16_t getRequestID() const;
00168 
00174   void setRequestID(const uint16_t& request_id);
00175 
00181   std::vector<uint8_t> getDataVector() const;
00182 
00188   void setDataVector(const std::vector<uint8_t>& data);
00189 
00190 protected:
00191   sick::cola2::Cola2Session& m_session;
00192 
00193 private:
00194   std::shared_ptr<sick::data_processing::ParseTCPPacket> m_tcp_parser_ptr;
00195   std::shared_ptr<sick::data_processing::ReadWriteHelper> m_writer_ptr;
00196 
00197   boost::mutex m_execution_mutex;
00198 
00199   bool m_was_successful;
00200 
00201   uint8_t m_command_mode;
00202   uint8_t m_command_type;
00203 
00204   uint32_t m_session_id;
00205   uint16_t m_request_id;
00206 
00207   std::vector<uint8_t> m_data_vector;
00208 
00209   virtual bool processReply()                                                                   = 0;
00210   virtual void addTelegramData(sick::datastructure::PacketBuffer::VectorBuffer& telegram) const = 0;
00211 
00212   void addTelegramHeader(sick::datastructure::PacketBuffer::VectorBuffer& telegram) const;
00213   sick::datastructure::PacketBuffer::VectorBuffer prepareHeader() const;
00214   void writeCola2StxToDataPtr(uint8_t*& data_ptr) const;
00215   void writeLengthToDataPtr(uint8_t*& data_ptr,
00216                             datastructure::PacketBuffer::VectorBuffer& telegram) const;
00217   void writeCola2HubCntrToDataPtr(uint8_t*& data_ptr) const;
00218   void writeCola2NoCToDataPtr(uint8_t*& data_ptr) const;
00219   void writeSessionIdToDataPtr(uint8_t*& data_ptr) const;
00220   void writeRequestIdToDataPtr(uint8_t*& data_ptr) const;
00221   void writeCommandTypeToDataPtr(uint8_t*& data_ptr) const;
00222   void writeCommandModeToDataPtr(uint8_t*& data_ptr) const;
00223   void writeDataToDataPtr(uint8_t*& data_ptr,
00224                           datastructure::PacketBuffer::VectorBuffer& telegram) const;
00225 };
00226 
00227 
00228 } // namespace cola2
00229 } // namespace sick
00230 
00231 
00232 #endif // SICK_SAFETYSCANNERS_COLA2_COMMAND_H


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Tue May 7 2019 03:27:36