VariableCommand.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 
24 // -- END LICENSE BLOCK ------------------------------------------------
25 
26 //----------------------------------------------------------------------
33 //----------------------------------------------------------------------
34 
36 
39 
40 namespace sick {
41 namespace cola2 {
42 
43 VariableCommand::VariableCommand(Cola2Session& session, const uint16_t& variable_index)
44  : Command(session, 0x52, 0x49) // see cola2 manual 0x52 = 'R' and 0x49 = 'I'
45  , m_variable_index(variable_index)
46 {
47  m_writer_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
48 }
49 
52 {
53  uint16_t prevSize = telegram.size();
54  telegram.resize(prevSize + 2);
55  uint8_t* data_ptr = telegram.data() + prevSize;
56  m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_variable_index, 0);
57 }
58 
60 {
61  return false;
62 }
63 
65 {
66  if ((getCommandType() == 'R' && getCommandMode() == 'A') ||
67  (getCommandType() == 0x52 && getCommandMode() == 0x41))
68  {
69  ROS_INFO("Command Variable Acknowledged.");
70  return true;
71  }
72  else
73  {
74  ROS_WARN("Command Variable Not Accepted.");
75  return false;
76  }
77 }
78 
80 {
81  return m_variable_index;
82 }
83 
84 void VariableCommand::setVariableIndex(const uint16_t& variable_index)
85 {
86  m_variable_index = variable_index;
87 }
88 
89 } // namespace cola2
90 } // namespace sick
uint16_t getVariableIndex() const
uint8_t getCommandType() const
Returns the command type.
Definition: Command.cpp:82
void addTelegramData(sick::datastructure::PacketBuffer::VectorBuffer &telegram) const
Adds the data to the telegram.
Base class for commands. Defines the base interface and does the common tasks.
Definition: Command.h:61
#define ROS_WARN(...)
VariableCommand(Cola2Session &session, const uint16_t &method_index)
Constructor of the command.
#define ROS_INFO(...)
bool processReply()
Processes the return from the sensor.
uint8_t getCommandMode() const
Returns the command mode.
Definition: Command.cpp:92
std::shared_ptr< sick::data_processing::ReadWriteHelper > m_writer_ptr
bool canBeExecutedWithoutSessionID() const
Returns if the command can be executed without a session ID. Will return false for most commands exce...
void setVariableIndex(const uint16_t &variable_index)
std::vector< uint8_t > VectorBuffer
Typedef for a vector buffer, to sort the incoming packets.
Definition: PacketBuffer.h:71
Establishes a cola2 session with a sensor and enables execution of commands in this session...
Definition: Cola2Session.h:72


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Thu May 9 2019 02:41:08