35 #ifndef SICK_SAFETYSCANNERS_COLA2_COMMAND_H 36 #define SICK_SAFETYSCANNERS_COLA2_COMMAND_H 47 #include <boost/thread/mutex.hpp> 73 const uint16_t& command_type,
74 const uint16_t& command_mode);
93 std::vector<uint8_t>
constructTelegram(
const std::vector<uint8_t>& telegram)
const;
194 std::vector<uint8_t>
expandTelegram(
const std::vector<uint8_t>& telegram,
195 size_t additional_bytes)
const;
213 virtual std::vector<uint8_t>
addTelegramData(
const std::vector<uint8_t>& telegram)
const = 0;
215 std::vector<uint8_t>
addTelegramHeader(
const std::vector<uint8_t>& telegram)
const;
219 const std::vector<uint8_t>& telegram)
const;
227 const std::vector<uint8_t>& telegram)
const;
235 #endif // SICK_SAFETYSCANNERS_COLA2_COMMAND_H void setCommandMode(const uint8_t &command_mode)
Sets the command mode.
void setSessionID(const uint32_t &session_id)
Sets the session ID.
void setDataVector(const std::vector< uint8_t > &data)
Sets the data vector.
std::vector< uint8_t > constructTelegram(const std::vector< uint8_t > &telegram) const
Adds the data to the telegram and afterwards the header with the correct length.
void writeRequestIdToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
std::vector< uint8_t > getDataVector() const
Returns the data vector.
uint16_t getRequestID() const
Returns the request id of the command.
void writeCola2NoCToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
void writeCommandTypeToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
boost::mutex m_execution_mutex
uint8_t getCommandType() const
Returns the command type.
void setRequestID(const uint16_t &request_id)
Sets the request ID of the command.
void writeCommandModeToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
void setCommandType(const uint8_t &command_type)
Sets the command type.
Base class for commands. Defines the base interface and does the common tasks.
Command(sick::cola2::Cola2Session &session, const uint16_t &command_type, const uint16_t &command_mode)
Constructor of the command. Sets the common variables for a command to the sensor.
uint32_t getSessionID() const
Returns the current session ID.
std::vector< uint8_t > prepareHeader() const
std::shared_ptr< sick::data_processing::ParseTCPPacket > m_tcp_parser_ptr
void waitForCompletion()
Scooped call to the mutex, which will block until the reply was processed.
void writeLengthToDataPtr(std::vector< uint8_t >::iterator data_ptr, const std::vector< uint8_t > &telegram) const
std::vector< uint8_t > expandTelegram(const std::vector< uint8_t > &telegram, size_t additional_bytes) const
void writeSessionIdToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
sick::cola2::Cola2Session & m_session
void processReplyBase(const std::vector< uint8_t > &packet)
Parses the da incoming data package and then processes it with the inherited processReply. Afterwards the mutex will be unlocked to allow new commands to be send.
uint8_t getCommandMode() const
Returns the command mode.
void lockExecutionMutex()
Locks a mutex to prevent other commands being executed in parallel.
void writeCola2HubCntrToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
void writeDataToDataPtr(std::vector< uint8_t >::iterator data_ptr, const std::vector< uint8_t > &telegram) const
std::vector< uint8_t > addTelegramHeader(const std::vector< uint8_t > &telegram) const
std::vector< uint8_t > m_data_vector
Establishes a cola2 session with a sensor and enables execution of commands in this session...
bool wasSuccessful() const
Returns if the command was successfully parsed.
virtual ~Command()
We have virtual member functions, so a virtual destructor is needed.
virtual bool processReply()=0
virtual std::vector< uint8_t > addTelegramData(const std::vector< uint8_t > &telegram) const =0
void writeCola2StxToDataPtr(std::vector< uint8_t >::iterator data_ptr) const