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. More... | |
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. More... | |
uint8_t | getCommandMode () const |
Returns the command mode. More... | |
uint8_t | getCommandType () const |
Returns the command type. More... | |
std::vector< uint8_t > | getDataVector () const |
Returns the data vector. More... | |
uint16_t | getRequestID () const |
Returns the request id of the command. More... | |
uint32_t | getSessionID () const |
Returns the current session ID. More... | |
void | lockExecutionMutex () |
Locks a mutex to prevent other commands being executed in parallel. More... | |
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. More... | |
void | setCommandMode (const uint8_t &command_mode) |
Sets the command mode. More... | |
void | setCommandType (const uint8_t &command_type) |
Sets the command type. More... | |
void | setDataVector (const std::vector< uint8_t > &data) |
Sets the data vector. More... | |
void | setRequestID (const uint16_t &request_id) |
Sets the request ID of the command. More... | |
void | setSessionID (const uint32_t &session_id) |
Sets the session ID. More... | |
void | waitForCompletion () |
Scooped call to the mutex, which will block until the reply was processed. More... | |
bool | wasSuccessful () const |
Returns if the command was successfully parsed. More... | |
virtual | ~Command () |
We have virtual member functions, so a virtual destructor is needed. More... | |
Protected Member Functions | |
std::vector< uint8_t > | expandTelegram (const std::vector< uint8_t > &telegram, size_t additional_bytes) const |
Protected Attributes | |
sick::cola2::Cola2Session & | m_session |
Private Member Functions | |
virtual std::vector< uint8_t > | addTelegramData (const std::vector< uint8_t > &telegram) const =0 |
std::vector< uint8_t > | addTelegramHeader (const std::vector< uint8_t > &telegram) const |
std::vector< uint8_t > | prepareHeader () const |
virtual bool | processReply ()=0 |
void | writeCola2HubCntrToDataPtr (std::vector< uint8_t >::iterator data_ptr) const |
void | writeCola2NoCToDataPtr (std::vector< uint8_t >::iterator data_ptr) const |
void | writeCola2StxToDataPtr (std::vector< uint8_t >::iterator data_ptr) const |
void | writeCommandModeToDataPtr (std::vector< uint8_t >::iterator data_ptr) const |
void | writeCommandTypeToDataPtr (std::vector< uint8_t >::iterator data_ptr) const |
void | writeDataToDataPtr (std::vector< uint8_t >::iterator data_ptr, const std::vector< uint8_t > &telegram) const |
void | writeLengthToDataPtr (std::vector< uint8_t >::iterator data_ptr, const std::vector< uint8_t > &telegram) const |
void | writeRequestIdToDataPtr (std::vector< uint8_t >::iterator data_ptr) const |
void | writeSessionIdToDataPtr (std::vector< uint8_t >::iterator 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 |
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.
|
inlinevirtual |
|
privatepure virtual |
|
private |
Definition at line 132 of file Command.cpp.
std::vector< uint8_t > sick::cola2::Command::constructTelegram | ( | const std::vector< uint8_t > & | 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 58 of file Command.cpp.
|
protected |
Definition at line 121 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 111 of file Command.cpp.
uint32_t sick::cola2::Command::getSessionID | ( | ) | const |
Returns the current session ID.
Definition at line 101 of file Command.cpp.
void sick::cola2::Command::lockExecutionMutex | ( | ) |
Locks a mutex to prevent other commands being executed in parallel.
Definition at line 53 of file Command.cpp.
|
private |
Definition at line 142 of file Command.cpp.
|
privatepure virtual |
Implemented in sick::cola2::ChangeCommSettingsCommand, sick::cola2::FindMeCommand, sick::cola2::FieldGeometryVariableCommand, sick::cola2::FieldHeaderVariableCommand, sick::cola2::MeasurementPersistentConfigVariableCommand, sick::cola2::MonitoringCaseVariableCommand, sick::cola2::MeasurementCurrentConfigVariableCommand, sick::cola2::MonitoringCaseTableHeaderVariableCommand, sick::cola2::ApplicationNameVariableCommand, sick::cola2::CloseSession, sick::cola2::ConfigMetadataVariableCommand, sick::cola2::FirmwareVersionVariableCommand, sick::cola2::RequiredUserActionVariableCommand, sick::cola2::StatusOverviewVariableCommand, sick::cola2::DeviceStatusVariableCommand, sick::cola2::FieldSetsVariableCommand, sick::cola2::UserNameVariableCommand, sick::cola2::MethodCommand, sick::cola2::OrderNumberVariableCommand, sick::cola2::ProjectNameVariableCommand, sick::cola2::SerialNumberVariableCommand, sick::cola2::TypeCodeVariableCommand, sick::cola2::VariableCommand, sick::cola2::CreateSession, and sick::cola2::DeviceNameVariableCommand.
void sick::cola2::Command::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.
packet | The incoming data package which will be processed. |
Definition at line 64 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 96 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 86 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 152 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 116 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 106 of file Command.cpp.
void sick::cola2::Command::waitForCompletion | ( | ) |
Scooped call to the mutex, which will block until the reply was processed.
Definition at line 71 of file Command.cpp.
bool sick::cola2::Command::wasSuccessful | ( | ) | const |
Returns if the command was successfully parsed.
Definition at line 76 of file Command.cpp.
|
private |
Definition at line 183 of file Command.cpp.
|
private |
Definition at line 189 of file Command.cpp.
|
private |
Definition at line 170 of file Command.cpp.
|
private |
Definition at line 210 of file Command.cpp.
|
private |
Definition at line 205 of file Command.cpp.
|
private |
Definition at line 157 of file Command.cpp.
|
private |
Definition at line 176 of file Command.cpp.
|
private |
Definition at line 200 of file Command.cpp.
|
private |
Definition at line 195 of file Command.cpp.
|
private |
|
private |
|
protected |
|
private |