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 }
48 
49 std::vector<uint8_t> MethodCommand::addTelegramData(const std::vector<uint8_t>& telegram) const
50 {
51  auto output = expandTelegram(telegram, 2);
52  // Add new values after telegram
53  auto new_data_offset_it = output.begin() + telegram.size();
55  return output;
56 }
57 
59 {
60  return false;
61 }
62 
64 {
65  bool result = false;
66  if ((getCommandType() == 'A' && getCommandMode() == 'I') ||
67  (getCommandType() == 0x41 && getCommandMode() == 0x49))
68  {
69  ROS_INFO("Command Method Acknowledged.");
70  result = true;
71  }
72  else
73  {
74  ROS_WARN("Command Method Not Accepted.");
75  }
76  return result;
77 }
78 
80 {
81  return m_method_index;
82 }
83 
84 void MethodCommand::setMethodIndex(const uint16_t& method_index)
85 {
86  m_method_index = method_index;
87 }
88 
89 } // namespace cola2
90 } // namespace sick
sick::cola2::MethodCommand::canBeExecutedWithoutSessionID
bool canBeExecutedWithoutSessionID() const
Returns if the command can be executed without a session ID. Will return false for most commands exce...
Definition: MethodCommand.cpp:58
sick::cola2::MethodCommand::processReply
bool processReply()
Processes the return from the sensor.
Definition: MethodCommand.cpp:63
MethodCommand.h
sick
Definition: ApplicationNameVariableCommand.h:43
sick::cola2::MethodCommand::getMethodIndex
uint16_t getMethodIndex() const
Definition: MethodCommand.cpp:79
Command.h
sick::cola2::MethodCommand::m_method_index
uint16_t m_method_index
Definition: MethodCommand.h:84
sick::cola2::Cola2Session
Establishes a cola2 session with a sensor and enables execution of commands in this session.
Definition: Cola2Session.h:72
sick::cola2::MethodCommand::MethodCommand
MethodCommand(Cola2Session &session, const uint16_t &method_index)
Constructor of the method command.
Definition: MethodCommand.cpp:43
sick::cola2::MethodCommand::setMethodIndex
void setMethodIndex(const uint16_t &method_index)
Definition: MethodCommand.cpp:84
sick::read_write_helper::writeUint16LittleEndian
void writeUint16LittleEndian(std::vector< uint8_t >::iterator it, const uint16_t v)
Writes an unsigned 16-bit integer to a buffer at offset in little endian encoding.
Definition: ReadWriteHelper.hpp:138
sick::cola2::Command::getCommandType
uint8_t getCommandType() const
Returns the command type.
Definition: Command.cpp:81
Cola2Session.h
ROS_WARN
#define ROS_WARN(...)
sick::cola2::MethodCommand::addTelegramData
std::vector< uint8_t > addTelegramData(const std::vector< uint8_t > &telegram) const
Adds the data to the telegram.
Definition: MethodCommand.cpp:49
sick::cola2::Command
Base class for commands. Defines the base interface and does the common tasks.
Definition: Command.h:61
sick::cola2::Command::expandTelegram
std::vector< uint8_t > expandTelegram(const std::vector< uint8_t > &telegram, size_t additional_bytes) const
Definition: Command.cpp:121
ROS_INFO
#define ROS_INFO(...)
sick::cola2::Command::getCommandMode
uint8_t getCommandMode() const
Returns the command mode.
Definition: Command.cpp:91


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Jun 21 2024 02:40:51