MethodCommand.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 MethodCommand::MethodCommand(Cola2Session& session, const uint16_t& method_index)
44  : Command(session, 0x4D, 0x49) // see cola2 manual 0x4D = 'M' and 0x49 = 'I'
45  , m_method_index(method_index)
46 {
47  m_writer_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
48 }
49 
51 {
52  uint16_t prevSize = telegram.size();
53  telegram.resize(prevSize + 2);
54  uint8_t* data_ptr = telegram.data() + prevSize;
55  m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_method_index, 0);
56 }
57 
59 {
60  return false;
61 }
62 
64 {
65  if ((getCommandType() == 'A' && getCommandMode() == 'I') ||
66  (getCommandType() == 0x41 && getCommandMode() == 0x49))
67  {
68  ROS_INFO("Command Method Acknowledged.");
69  return true;
70  }
71  else
72  {
73  ROS_WARN("Command Method Not Accepted.");
74  return false;
75  }
76 }
77 
79 {
80  return m_method_index;
81 }
82 
83 void MethodCommand::setMethodIndex(const uint16_t& method_index)
84 {
85  m_method_index = method_index;
86 }
87 
88 } // namespace cola2
89 } // namespace sick
void addTelegramData(sick::datastructure::PacketBuffer::VectorBuffer &telegram) const
Adds the data to the telegram.
uint8_t getCommandType() const
Returns the command type.
Definition: Command.cpp:82
Base class for commands. Defines the base interface and does the common tasks.
Definition: Command.h:61
#define ROS_WARN(...)
uint16_t getMethodIndex() const
void setMethodIndex(const uint16_t &method_index)
#define ROS_INFO(...)
MethodCommand(Cola2Session &session, const uint16_t &method_index)
Constructor of the method command.
uint8_t getCommandMode() const
Returns the command mode.
Definition: Command.cpp:92
bool processReply()
Processes the return from the sensor.
std::vector< uint8_t > VectorBuffer
Typedef for a vector buffer, to sort the incoming packets.
Definition: PacketBuffer.h:71
bool canBeExecutedWithoutSessionID() const
Returns if the command can be executed without a session ID. Will return false for most commands exce...
Establishes a cola2 session with a sensor and enables execution of commands in this session...
Definition: Cola2Session.h:72
std::shared_ptr< sick::data_processing::ReadWriteHelper > m_writer_ptr
Definition: MethodCommand.h:84


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