Class Command
Defined in File Command.h
Inheritance Relationships
Derived Types
public sick::cola2::CloseSession
(Class CloseSession)public sick::cola2::CreateSession
(Class CreateSession)public sick::cola2::MethodCommand
(Class MethodCommand)public sick::cola2::VariableCommand
(Class VariableCommand)
Class Documentation
-
class Command
Base class for commands. Defines the base interface and does the common tasks.
Subclassed by sick::cola2::CloseSession, sick::cola2::CreateSession, sick::cola2::MethodCommand, sick::cola2::VariableCommand
Public Functions
-
Command(sick::cola2::Cola2Session &session, uint16_t command_type, uint16_t command_mode)
Constructor of the command. Sets the common variables for a command to the sensor.
- Parameters:
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.
-
inline virtual ~Command()
We have virtual member functions, so a virtual destructor is needed.
-
void lockExecutionMutex()
Locks a mutex to prevent other commands being executed in parallel.
-
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.
- Parameters:
telegram – The telegram, which will be modified with the data and header.
- Returns:
Completed telegram.
-
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.
- Parameters:
packet – The incoming data package which will be processed.
-
void waitForCompletion()
Scooped call to the mutex, which will block until the reply was processed.
-
uint32_t getSessionID() const
Returns the current session ID.
- Returns:
The current session ID.
-
void setSessionID(uint32_t session_id)
Sets the session ID.
- Parameters:
session_id – The new session ID.
-
bool wasSuccessful() const
Returns if the command was successfully parsed.
- Returns:
If the command was successfully parsed.
-
uint8_t getCommandType() const
Returns the command type.
- Returns:
The command type.
-
void setCommandType(const uint8_t &command_type)
Sets the command type.
- Parameters:
command_type – The new command type.
-
uint8_t getCommandMode() const
Returns the command mode.
- Returns:
The command mode.
-
void setCommandMode(const uint8_t &command_mode)
Sets the command mode.
- Parameters:
command_mode – The new command mode.
-
uint16_t getRequestID() const
Returns the request id of the command.
- Returns:
The request id.
-
void setRequestID(const uint16_t &request_id)
Sets the request ID of the command.
- Parameters:
request_id – The new request id.
-
std::vector<uint8_t> getDataVector() const
Returns the data vector.
- Returns:
The data vector.
-
void setDataVector(const std::vector<uint8_t> &data)
Sets the data vector.
- Parameters:
data – The new data vector.
Protected Functions
-
std::vector<uint8_t> expandTelegram(const std::vector<uint8_t> &telegram, size_t additional_bytes) const
Protected Attributes
-
sick::cola2::Cola2Session &m_session
-
Command(sick::cola2::Cola2Session &session, uint16_t command_type, uint16_t command_mode)