Base class for commands. Defines the base interface and does the common tasks. More...
#include <Command.h>
Public Member Functions | |
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. | |
void | constructTelegram (sick::datastructure::PacketBuffer::VectorBuffer &telegram) const |
Adds the data to the telegram and afterwards the header with the correct length. | |
uint8_t | getCommandMode () const |
Returns the command mode. | |
uint8_t | getCommandType () const |
Returns the command type. | |
std::vector< uint8_t > | getDataVector () const |
Returns the data vector. | |
uint16_t | getRequestID () const |
Returns the request id of the command. | |
uint32_t | getSessionID () const |
Returns the current session ID. | |
void | lockExecutionMutex () |
Locks a mutex to prevent other commands being executed in parallel. | |
void | processReplyBase (const sick::datastructure::PacketBuffer::VectorBuffer &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. | |
void | setCommandMode (const uint8_t &command_mode) |
Sets the command mode. | |
void | setCommandType (const uint8_t &command_type) |
Sets the command type. | |
void | setDataVector (const std::vector< uint8_t > &data) |
Sets the data vector. | |
void | setRequestID (const uint16_t &request_id) |
Sets the request ID of the command. | |
void | setSessionID (const uint32_t &session_id) |
Sets the session ID. | |
void | waitForCompletion () |
Scooped call to the mutex, which will block until the reply was processed. | |
bool | wasSuccessful () const |
Returns if the command was successfully parsed. | |
virtual | ~Command () |
We have virtual member functions, so a virtual destructor is needed. | |
Protected Attributes | |
sick::cola2::Cola2Session & | m_session |
Private Member Functions | |
virtual void | addTelegramData (sick::datastructure::PacketBuffer::VectorBuffer &telegram) const =0 |
void | addTelegramHeader (sick::datastructure::PacketBuffer::VectorBuffer &telegram) const |
sick::datastructure::PacketBuffer::VectorBuffer | prepareHeader () const |
virtual bool | processReply ()=0 |
void | writeCola2HubCntrToDataPtr (uint8_t *&data_ptr) const |
void | writeCola2NoCToDataPtr (uint8_t *&data_ptr) const |
void | writeCola2StxToDataPtr (uint8_t *&data_ptr) const |
void | writeCommandModeToDataPtr (uint8_t *&data_ptr) const |
void | writeCommandTypeToDataPtr (uint8_t *&data_ptr) const |
void | writeDataToDataPtr (uint8_t *&data_ptr, datastructure::PacketBuffer::VectorBuffer &telegram) const |
void | writeLengthToDataPtr (uint8_t *&data_ptr, datastructure::PacketBuffer::VectorBuffer &telegram) const |
void | writeRequestIdToDataPtr (uint8_t *&data_ptr) const |
void | writeSessionIdToDataPtr (uint8_t *&data_ptr) const |
Private Attributes | |
uint8_t | m_command_mode |
uint8_t | m_command_type |
std::vector< uint8_t > | m_data_vector |
boost::mutex | m_execution_mutex |
uint16_t | m_request_id |
uint32_t | m_session_id |
std::shared_ptr < sick::data_processing::ParseTCPPacket > | m_tcp_parser_ptr |
bool | m_was_successful |
std::shared_ptr < sick::data_processing::ReadWriteHelper > | m_writer_ptr |
Base class for commands. Defines the base interface and does the common tasks.
sick::cola2::Command::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.
session | The session in which the command will be executed. |
command_type | Defines what type of command will be executed in the sensor (Read, Write, Invoking a method). |
command_mode | Specifies the mode of the command. If the request is by index or name. |
Definition at line 43 of file Command.cpp.
virtual sick::cola2::Command::~Command | ( | ) | [inline, virtual] |
virtual void sick::cola2::Command::addTelegramData | ( | sick::datastructure::PacketBuffer::VectorBuffer & | telegram | ) | const [private, pure virtual] |
Implemented in sick::cola2::FieldGeometryVariableCommand, sick::cola2::FieldHeaderVariableCommand, sick::cola2::ChangeCommSettingsCommand, sick::cola2::MeasurementPersistentConfigVariableCommand, sick::cola2::MonitoringCaseVariableCommand, sick::cola2::MeasurementCurrentConfigVariableCommand, sick::cola2::MonitoringCaseTableHeaderVariableCommand, sick::cola2::TypeCodeVariableCommand, sick::cola2::DeviceNameVariableCommand, sick::cola2::CloseSession, sick::cola2::CreateSession, sick::cola2::MethodCommand, and sick::cola2::VariableCommand.
void sick::cola2::Command::addTelegramHeader | ( | sick::datastructure::PacketBuffer::VectorBuffer & | telegram | ) | const [private] |
Definition at line 122 of file Command.cpp.
void sick::cola2::Command::constructTelegram | ( | sick::datastructure::PacketBuffer::VectorBuffer & | telegram | ) | const |
Adds the data to the telegram and afterwards the header with the correct length.
telegram | The telegram, which will be modified with the data and header. |
Definition at line 59 of file Command.cpp.
uint8_t sick::cola2::Command::getCommandMode | ( | ) | const |
uint8_t sick::cola2::Command::getCommandType | ( | ) | const |
std::vector< uint8_t > sick::cola2::Command::getDataVector | ( | ) | const |
uint16_t sick::cola2::Command::getRequestID | ( | ) | const |
Returns the request id of the command.
Definition at line 112 of file Command.cpp.
uint32_t sick::cola2::Command::getSessionID | ( | ) | const |
Returns the current session ID.
Definition at line 102 of file Command.cpp.
Locks a mutex to prevent other commands being executed in parallel.
Definition at line 54 of file Command.cpp.
sick::datastructure::PacketBuffer::VectorBuffer sick::cola2::Command::prepareHeader | ( | ) | const [private] |
Definition at line 130 of file Command.cpp.
virtual bool sick::cola2::Command::processReply | ( | ) | [private, pure virtual] |
Implemented in sick::cola2::ChangeCommSettingsCommand, sick::cola2::FieldGeometryVariableCommand, sick::cola2::FieldHeaderVariableCommand, sick::cola2::MeasurementPersistentConfigVariableCommand, sick::cola2::MonitoringCaseVariableCommand, sick::cola2::MeasurementCurrentConfigVariableCommand, sick::cola2::MonitoringCaseTableHeaderVariableCommand, sick::cola2::TypeCodeVariableCommand, sick::cola2::DeviceNameVariableCommand, sick::cola2::CloseSession, sick::cola2::MethodCommand, sick::cola2::VariableCommand, and sick::cola2::CreateSession.
void sick::cola2::Command::processReplyBase | ( | const sick::datastructure::PacketBuffer::VectorBuffer & | 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.
packet | The incoming data package which will be processed. |
Definition at line 65 of file Command.cpp.
void sick::cola2::Command::setCommandMode | ( | const uint8_t & | command_mode | ) |
Sets the command mode.
command_mode | The new command mode. |
Definition at line 97 of file Command.cpp.
void sick::cola2::Command::setCommandType | ( | const uint8_t & | command_type | ) |
Sets the command type.
command_type | The new command type. |
Definition at line 87 of file Command.cpp.
void sick::cola2::Command::setDataVector | ( | const std::vector< uint8_t > & | data | ) |
Sets the data vector.
data | The new data vector. |
Definition at line 142 of file Command.cpp.
void sick::cola2::Command::setRequestID | ( | const uint16_t & | request_id | ) |
Sets the request ID of the command.
request_id | The new request id. |
Definition at line 117 of file Command.cpp.
void sick::cola2::Command::setSessionID | ( | const uint32_t & | session_id | ) |
Sets the session ID.
session_id | The new session ID. |
Definition at line 107 of file Command.cpp.
Scooped call to the mutex, which will block until the reply was processed.
Definition at line 72 of file Command.cpp.
bool sick::cola2::Command::wasSuccessful | ( | ) | const |
Returns if the command was successfully parsed.
Definition at line 77 of file Command.cpp.
void sick::cola2::Command::writeCola2HubCntrToDataPtr | ( | uint8_t *& | data_ptr | ) | const [private] |
Definition at line 173 of file Command.cpp.
void sick::cola2::Command::writeCola2NoCToDataPtr | ( | uint8_t *& | data_ptr | ) | const [private] |
Definition at line 179 of file Command.cpp.
void sick::cola2::Command::writeCola2StxToDataPtr | ( | uint8_t *& | data_ptr | ) | const [private] |
Definition at line 160 of file Command.cpp.
void sick::cola2::Command::writeCommandModeToDataPtr | ( | uint8_t *& | data_ptr | ) | const [private] |
Definition at line 200 of file Command.cpp.
void sick::cola2::Command::writeCommandTypeToDataPtr | ( | uint8_t *& | data_ptr | ) | const [private] |
Definition at line 195 of file Command.cpp.
void sick::cola2::Command::writeDataToDataPtr | ( | uint8_t *& | data_ptr, |
datastructure::PacketBuffer::VectorBuffer & | telegram | ||
) | const [private] |
Definition at line 147 of file Command.cpp.
void sick::cola2::Command::writeLengthToDataPtr | ( | uint8_t *& | data_ptr, |
datastructure::PacketBuffer::VectorBuffer & | telegram | ||
) | const [private] |
Definition at line 166 of file Command.cpp.
void sick::cola2::Command::writeRequestIdToDataPtr | ( | uint8_t *& | data_ptr | ) | const [private] |
Definition at line 190 of file Command.cpp.
void sick::cola2::Command::writeSessionIdToDataPtr | ( | uint8_t *& | data_ptr | ) | const [private] |
Definition at line 185 of file Command.cpp.
uint8_t sick::cola2::Command::m_command_mode [private] |
uint8_t sick::cola2::Command::m_command_type [private] |
std::vector<uint8_t> sick::cola2::Command::m_data_vector [private] |
boost::mutex sick::cola2::Command::m_execution_mutex [private] |
uint16_t sick::cola2::Command::m_request_id [private] |
sick::cola2::Cola2Session& sick::cola2::Command::m_session [protected] |
uint32_t sick::cola2::Command::m_session_id [private] |
std::shared_ptr<sick::data_processing::ParseTCPPacket> sick::cola2::Command::m_tcp_parser_ptr [private] |
bool sick::cola2::Command::m_was_successful [private] |
std::shared_ptr<sick::data_processing::ReadWriteHelper> sick::cola2::Command::m_writer_ptr [private] |
Reimplemented in sick::cola2::ChangeCommSettingsCommand, sick::cola2::FieldGeometryVariableCommand, sick::cola2::FieldHeaderVariableCommand, sick::cola2::MeasurementPersistentConfigVariableCommand, sick::cola2::MonitoringCaseVariableCommand, sick::cola2::MeasurementCurrentConfigVariableCommand, sick::cola2::MonitoringCaseTableHeaderVariableCommand, sick::cola2::TypeCodeVariableCommand, sick::cola2::DeviceNameVariableCommand, sick::cola2::MethodCommand, sick::cola2::VariableCommand, and sick::cola2::CreateSession.