Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
sick::cola2::Command Class Referenceabstract

Base class for commands. Defines the base interface and does the common tasks. More...

#include <Command.h>

Inheritance diagram for sick::cola2::Command:
Inheritance graph
[legend]

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::Cola2Sessionm_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::ParseTCPPacketm_tcp_parser_ptr
 
bool m_was_successful
 

Detailed Description

Base class for commands. Defines the base interface and does the common tasks.

Definition at line 61 of file Command.h.

Constructor & Destructor Documentation

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.

Parameters
sessionThe session in which the command will be executed.
command_typeDefines what type of command will be executed in the sensor (Read, Write, Invoking a method).
command_modeSpecifies 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 ( )
inlinevirtual

We have virtual member functions, so a virtual destructor is needed.

Definition at line 79 of file Command.h.

Member Function Documentation

virtual std::vector<uint8_t> sick::cola2::Command::addTelegramData ( const std::vector< uint8_t > &  telegram) const
privatepure virtual
std::vector< uint8_t > sick::cola2::Command::addTelegramHeader ( const std::vector< uint8_t > &  telegram) const
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.

Parameters
telegramThe telegram, which will be modified with the data and header.
Returns
Completed telegram.

Definition at line 58 of file Command.cpp.

std::vector< uint8_t > sick::cola2::Command::expandTelegram ( const std::vector< uint8_t > &  telegram,
size_t  additional_bytes 
) const
protected

Definition at line 121 of file Command.cpp.

uint8_t sick::cola2::Command::getCommandMode ( ) const

Returns the command mode.

Returns
The command mode.

Definition at line 91 of file Command.cpp.

uint8_t sick::cola2::Command::getCommandType ( ) const

Returns the command type.

Returns
The command type.

Definition at line 81 of file Command.cpp.

std::vector< uint8_t > sick::cola2::Command::getDataVector ( ) const

Returns the data vector.

Returns
The data vector.

Definition at line 147 of file Command.cpp.

uint16_t sick::cola2::Command::getRequestID ( ) const

Returns the request id of the command.

Returns
The request id.

Definition at line 111 of file Command.cpp.

uint32_t sick::cola2::Command::getSessionID ( ) const

Returns the current session ID.

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.

std::vector< uint8_t > sick::cola2::Command::prepareHeader ( ) const
private

Definition at line 142 of file Command.cpp.

virtual bool sick::cola2::Command::processReply ( )
privatepure virtual
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.

Parameters
packetThe 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.

Parameters
command_modeThe 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.

Parameters
command_typeThe 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.

Parameters
dataThe 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.

Parameters
request_idThe 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.

Parameters
session_idThe 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.

Returns
If the command was successfully parsed.

Definition at line 76 of file Command.cpp.

void sick::cola2::Command::writeCola2HubCntrToDataPtr ( std::vector< uint8_t >::iterator  data_ptr) const
private

Definition at line 183 of file Command.cpp.

void sick::cola2::Command::writeCola2NoCToDataPtr ( std::vector< uint8_t >::iterator  data_ptr) const
private

Definition at line 189 of file Command.cpp.

void sick::cola2::Command::writeCola2StxToDataPtr ( std::vector< uint8_t >::iterator  data_ptr) const
private

Definition at line 170 of file Command.cpp.

void sick::cola2::Command::writeCommandModeToDataPtr ( std::vector< uint8_t >::iterator  data_ptr) const
private

Definition at line 210 of file Command.cpp.

void sick::cola2::Command::writeCommandTypeToDataPtr ( std::vector< uint8_t >::iterator  data_ptr) const
private

Definition at line 205 of file Command.cpp.

void sick::cola2::Command::writeDataToDataPtr ( std::vector< uint8_t >::iterator  data_ptr,
const std::vector< uint8_t > &  telegram 
) const
private

Definition at line 157 of file Command.cpp.

void sick::cola2::Command::writeLengthToDataPtr ( std::vector< uint8_t >::iterator  data_ptr,
const std::vector< uint8_t > &  telegram 
) const
private

Definition at line 176 of file Command.cpp.

void sick::cola2::Command::writeRequestIdToDataPtr ( std::vector< uint8_t >::iterator  data_ptr) const
private

Definition at line 200 of file Command.cpp.

void sick::cola2::Command::writeSessionIdToDataPtr ( std::vector< uint8_t >::iterator  data_ptr) const
private

Definition at line 195 of file Command.cpp.

Member Data Documentation

uint8_t sick::cola2::Command::m_command_mode
private

Definition at line 204 of file Command.h.

uint8_t sick::cola2::Command::m_command_type
private

Definition at line 205 of file Command.h.

std::vector<uint8_t> sick::cola2::Command::m_data_vector
private

Definition at line 210 of file Command.h.

boost::mutex sick::cola2::Command::m_execution_mutex
private

Definition at line 200 of file Command.h.

uint16_t sick::cola2::Command::m_request_id
private

Definition at line 208 of file Command.h.

sick::cola2::Cola2Session& sick::cola2::Command::m_session
protected

Definition at line 192 of file Command.h.

uint32_t sick::cola2::Command::m_session_id
private

Definition at line 207 of file Command.h.

std::shared_ptr<sick::data_processing::ParseTCPPacket> sick::cola2::Command::m_tcp_parser_ptr
private

Definition at line 198 of file Command.h.

bool sick::cola2::Command::m_was_successful
private

Definition at line 202 of file Command.h.


The documentation for this class was generated from the following files:


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