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_command_map_mutex;
151  boost::mutex m_execution_mutex;
152 
153  uint32_t m_session_id;
155 
157 
158  bool addCommand(const uint16_t& request_id, const CommandPtr& command);
159  bool findCommand(const uint16_t& request_id, CommandPtr& command);
160  bool removeCommand(const uint16_t& request_id);
161 
162  bool
166  bool sendTelegramAndListenForAnswer(const CommandPtr& command);
167 };
168 
169 
170 } // namespace cola2
171 } // namespace sick
172 
173 #endif // SICK_SAFETYSCANNERS_COLA2_COLA2SESSION_H
sick::cola2::Cola2Session::CommandPtr
std::shared_ptr< sick::cola2::Command > CommandPtr
Typedef for a pointer containing a command to be executed.
Definition: Cola2Session.h:78
sick::cola2::Cola2Session::addPacketToMerger
bool addPacketToMerger(const sick::datastructure::PacketBuffer &packet)
Definition: Cola2Session.cpp:107
sick::cola2::Cola2Session::m_last_request_id
uint16_t m_last_request_id
Definition: Cola2Session.h:154
sick
Definition: ApplicationNameVariableCommand.h:43
sick::cola2::Cola2Session::Cola2Session
Cola2Session(const std::shared_ptr< communication::AsyncTCPClient > &async_tcp_client)
Constructor of the cola2 session.
Definition: Cola2Session.cpp:40
AsyncTCPClient.h
TCPPacketMerger.h
sick::cola2::Cola2Session::m_command_map_mutex
boost::mutex m_command_map_mutex
Definition: Cola2Session.h:150
Command.h
CloseSession.h
sick::cola2::Cola2Session::close
bool close()
Closes a session with the sensor. Executes the close session command.
Definition: Cola2Session.cpp:56
sick::cola2::Cola2Session
Establishes a cola2 session with a sensor and enables execution of commands in this session.
Definition: Cola2Session.h:72
sick::cola2::Cola2Session::m_tcp_parser_ptr
std::shared_ptr< sick::data_processing::ParseTCPPacket > m_tcp_parser_ptr
Definition: Cola2Session.h:146
sick::cola2::Cola2Session::doDisconnect
void doDisconnect()
Triggers the disconnection of the tcp socket.
Definition: Cola2Session.cpp:62
sick::cola2::Cola2Session::findCommand
bool findCommand(const uint16_t &request_id, CommandPtr &command)
Definition: Cola2Session.cpp:153
sick::cola2::Cola2Session::sendTelegramAndListenForAnswer
bool sendTelegramAndListenForAnswer(const CommandPtr &command)
Definition: Cola2Session.cpp:74
sick::cola2::Cola2Session::executeCommand
bool executeCommand(const CommandPtr &command)
Executes the command passed to the function.
Definition: Cola2Session.cpp:67
sick::cola2::Cola2Session::open
bool open()
Opens a session with the sensor. Executes the create session command.
Definition: Cola2Session.cpp:50
sick::cola2::Cola2Session::m_execution_mutex
boost::mutex m_execution_mutex
Definition: Cola2Session.h:151
sick::cola2::Cola2Session::m_async_tcp_client_ptr
std::shared_ptr< sick::communication::AsyncTCPClient > m_async_tcp_client_ptr
Definition: Cola2Session.h:143
sick::cola2::Cola2Session::m_session_id
uint32_t m_session_id
Definition: Cola2Session.h:153
sick::cola2::Cola2Session::setSessionID
void setSessionID(const uint32_t &session_id)
Sets the current session ID.
Definition: Cola2Session.cpp:90
sick::cola2::Cola2Session::getNextRequestID
uint16_t getNextRequestID()
Returns the next request ID. The request ID is used to match the return packages of the sensor to the...
Definition: Cola2Session.cpp:178
PacketBuffer.h
ParseTCPPacket.h
sick::cola2::Cola2Session::m_parser_ptr
std::shared_ptr< sick::data_processing::ParseTCPPacket > m_parser_ptr
Definition: Cola2Session.h:144
sick::cola2::Cola2Session::removeCommand
bool removeCommand(const uint16_t &request_id)
Definition: Cola2Session.cpp:165
sick::cola2::Cola2Session::getSessionID
uint32_t getSessionID() const
Returns the current session ID.
Definition: Cola2Session.cpp:85
sick::datastructure::PacketBuffer
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
sick::cola2::Cola2Session::m_pending_commands_map
std::map< uint16_t, CommandPtr > m_pending_commands_map
Definition: Cola2Session.h:148
sick::cola2::Cola2Session::addCommand
bool addCommand(const uint16_t &request_id, const CommandPtr &command)
Definition: Cola2Session.cpp:141
sick::cola2::Cola2Session::startProcessingAndRemovePendingCommandAfterwards
bool startProcessingAndRemovePendingCommandAfterwards(const sick::datastructure::PacketBuffer &packet)
Definition: Cola2Session.cpp:128
CreateSession.h
sick::cola2::Cola2Session::m_packet_merger_ptr
std::shared_ptr< sick::data_processing::TCPPacketMerger > m_packet_merger_ptr
Definition: Cola2Session.h:145
sick::cola2::Cola2Session::checkIfPacketIsCompleteAndOtherwiseListenForMorePackets
bool checkIfPacketIsCompleteAndOtherwiseListenForMorePackets()
Definition: Cola2Session.cpp:117
sick::cola2::Cola2Session::processPacket
void processPacket(const sick::datastructure::PacketBuffer &packet)
Definition: Cola2Session.cpp:95


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Jun 21 2024 02:40:51