Cola2Session.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 
24 // -- END LICENSE BLOCK ------------------------------------------------
25 
26 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
34 
35 #ifndef SICK_SAFETYSCANNERS_COLA2_COLA2SESSION_H
36 #define SICK_SAFETYSCANNERS_COLA2_COLA2SESSION_H
37 
39 
41 
45 
48 
49 #include <boost/bind.hpp>
50 #include <limits>
51 #include <map>
52 
53 namespace sick {
54 namespace cola2 {
55 
59 class Command;
60 
61 
65 class CreateSession;
66 
67 
73 {
74 public:
78  typedef std::shared_ptr<sick::cola2::Command> CommandPtr;
79 
86  explicit Cola2Session(const std::shared_ptr<communication::AsyncTCPClient>& async_tcp_client);
87 
88 
92  void doDisconnect();
93 
101  bool executeCommand(const CommandPtr& command);
102 
108  uint32_t getSessionID() const;
109 
115  void setSessionID(const uint32_t& session_id);
116 
123  uint16_t getNextRequestID();
124 
125 
131  bool close();
132 
133 
139  bool open();
140 
141 
142 private:
143  std::shared_ptr<sick::communication::AsyncTCPClient> m_async_tcp_client_ptr;
144  std::shared_ptr<sick::data_processing::ParseTCPPacket> m_parser_ptr;
145  std::shared_ptr<sick::data_processing::TCPPacketMerger> m_packet_merger_ptr;
146  std::shared_ptr<sick::data_processing::ParseTCPPacket> m_tcp_parser_ptr;
147 
148  std::map<uint16_t, CommandPtr> m_pending_commands_map;
149 
150  boost::mutex m_execution_mutex;
151 
152  uint32_t m_session_id;
154 
156 
157  bool addCommand(const uint16_t& request_id, const CommandPtr& command);
158  bool findCommand(const uint16_t& request_id, CommandPtr& command);
159  bool removeCommand(const uint16_t& request_id);
160 
161  bool
165  bool sendTelegramAndListenForAnswer(const CommandPtr& command);
166 };
167 
168 
169 } // namespace cola2
170 } // namespace sick
171 
172 #endif // SICK_SAFETYSCANNERS_COLA2_COLA2SESSION_H
bool checkIfPacketIsCompleteAndOtherwiseListenForMorePackets()
bool close()
Closes a session with the sensor. Executes the close session command.
std::shared_ptr< sick::data_processing::TCPPacketMerger > m_packet_merger_ptr
Definition: Cola2Session.h:145
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
std::shared_ptr< sick::cola2::Command > CommandPtr
Typedef for a pointer containing a command to be executed.
Definition: Cola2Session.h:78
void processPacket(const sick::datastructure::PacketBuffer &packet)
std::shared_ptr< sick::data_processing::ParseTCPPacket > m_tcp_parser_ptr
Definition: Cola2Session.h:146
bool addPacketToMerger(const sick::datastructure::PacketBuffer &packet)
bool executeCommand(const CommandPtr &command)
Executes the command passed to the function.
Cola2Session(const std::shared_ptr< communication::AsyncTCPClient > &async_tcp_client)
Constructor of the cola2 session.
bool findCommand(const uint16_t &request_id, CommandPtr &command)
void doDisconnect()
Triggers the disconnection of the tcp socket.
boost::mutex m_execution_mutex
Definition: Cola2Session.h:150
std::shared_ptr< sick::communication::AsyncTCPClient > m_async_tcp_client_ptr
Definition: Cola2Session.h:143
bool open()
Opens a session with the sensor. Executes the create session command.
bool sendTelegramAndListenForAnswer(const CommandPtr &command)
std::shared_ptr< sick::data_processing::ParseTCPPacket > m_parser_ptr
Definition: Cola2Session.h:144
bool addCommand(const uint16_t &request_id, const CommandPtr &command)
void setSessionID(const uint32_t &session_id)
Sets the current session ID.
uint16_t getNextRequestID()
Returns the next request ID. The request ID is used to match the return packages of the sensor to the...
bool removeCommand(const uint16_t &request_id)
bool startProcessingAndRemovePendingCommandAfterwards(const sick::datastructure::PacketBuffer &packet)
uint32_t getSessionID() const
Returns the current session ID.
Establishes a cola2 session with a sensor and enables execution of commands in this session...
Definition: Cola2Session.h:72
std::map< uint16_t, CommandPtr > m_pending_commands_map
Definition: Cola2Session.h:148


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Apr 2 2021 02:45:41