Cola2Session.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_COLA2SESSION_H
00036 #define SICK_SAFETYSCANNERS_COLA2_COLA2SESSION_H
00037 
00038 #include <sick_safetyscanners/datastructure/PacketBuffer.h>
00039 
00040 #include <sick_safetyscanners/communication/AsyncTCPClient.h>
00041 
00042 #include <sick_safetyscanners/cola2/CloseSession.h>
00043 #include <sick_safetyscanners/cola2/Command.h>
00044 #include <sick_safetyscanners/cola2/CreateSession.h>
00045 
00046 #include <sick_safetyscanners/data_processing/ParseTCPPacket.h>
00047 #include <sick_safetyscanners/data_processing/TCPPacketMerger.h>
00048 
00049 #include <boost/bind.hpp>
00050 #include <limits>
00051 #include <map>
00052 
00053 namespace sick {
00054 namespace cola2 {
00055 
00059 class Command;
00060 
00061 
00065 class CreateSession;
00066 
00067 
00072 class Cola2Session
00073 {
00074 public:
00078   typedef std::shared_ptr<sick::cola2::Command> CommandPtr;
00079 
00086   explicit Cola2Session(const std::shared_ptr<communication::AsyncTCPClient>& async_tcp_client);
00087 
00088 
00092   void doDisconnect();
00093 
00101   bool executeCommand(const CommandPtr& command);
00102 
00108   uint32_t getSessionID() const;
00109 
00115   void setSessionID(const uint32_t& session_id);
00116 
00123   uint16_t getNextRequestID();
00124 
00125 
00131   bool close();
00132 
00133 
00139   bool open();
00140 
00141 
00142 private:
00143   std::shared_ptr<sick::communication::AsyncTCPClient> m_async_tcp_client_ptr;
00144   std::shared_ptr<sick::data_processing::ParseTCPPacket> m_parser_ptr;
00145   std::shared_ptr<sick::data_processing::TCPPacketMerger> m_packet_merger_ptr;
00146   std::shared_ptr<sick::data_processing::ParseTCPPacket> m_tcp_parser_ptr;
00147 
00148   std::map<uint16_t, CommandPtr> m_pending_commands_map;
00149 
00150   boost::mutex m_execution_mutex;
00151 
00152   uint32_t m_session_id;
00153   uint16_t m_last_request_id;
00154 
00155   void processPacket(const sick::datastructure::PacketBuffer& packet);
00156 
00157   bool addCommand(const uint16_t& request_id, const CommandPtr& command);
00158   bool findCommand(const uint16_t& request_id, CommandPtr& command);
00159   bool removeCommand(const uint16_t& request_id);
00160 
00161   bool
00162   startProcessingAndRemovePendingCommandAfterwards(const sick::datastructure::PacketBuffer& packet);
00163   bool addPacketToMerger(const sick::datastructure::PacketBuffer& packet);
00164   bool checkIfPacketIsCompleteAndOtherwiseListenForMorePackets();
00165   bool sendTelegramAndListenForAnswer(const CommandPtr& command);
00166 };
00167 
00168 
00169 } // namespace cola2
00170 } // namespace sick
00171 
00172 #endif // SICK_SAFETYSCANNERS_COLA2_COLA2SESSION_H


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