VariableCommand.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 
00024 // -- END LICENSE BLOCK ------------------------------------------------
00025 
00026 //----------------------------------------------------------------------
00033 //----------------------------------------------------------------------
00034 
00035 #include <sick_safetyscanners/cola2/VariableCommand.h>
00036 
00037 #include <sick_safetyscanners/cola2/Cola2Session.h>
00038 #include <sick_safetyscanners/cola2/Command.h>
00039 
00040 namespace sick {
00041 namespace cola2 {
00042 
00043 VariableCommand::VariableCommand(Cola2Session& session, const uint16_t& variable_index)
00044   : Command(session, 0x52, 0x49) // see cola2 manual 0x52 = 'R' and  0x49 = 'I'
00045   , m_variable_index(variable_index)
00046 {
00047   m_writer_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
00048 }
00049 
00050 void VariableCommand::addTelegramData(
00051   sick::datastructure::PacketBuffer::VectorBuffer& telegram) const
00052 {
00053   uint16_t prevSize = telegram.size();
00054   telegram.resize(prevSize + 2);
00055   uint8_t* data_ptr = telegram.data() + prevSize;
00056   m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_variable_index, 0);
00057 }
00058 
00059 bool VariableCommand::canBeExecutedWithoutSessionID() const
00060 {
00061   return false;
00062 }
00063 
00064 bool VariableCommand::processReply()
00065 {
00066   if ((getCommandType() == 'R' && getCommandMode() == 'A') ||
00067       (getCommandType() == 0x52 && getCommandMode() == 0x41))
00068   {
00069     ROS_INFO("Command Variable Acknowledged.");
00070     return true;
00071   }
00072   else
00073   {
00074     ROS_WARN("Command Variable Not Accepted.");
00075     return false;
00076   }
00077 }
00078 
00079 uint16_t VariableCommand::getVariableIndex() const
00080 {
00081   return m_variable_index;
00082 }
00083 
00084 void VariableCommand::setVariableIndex(const uint16_t& variable_index)
00085 {
00086   m_variable_index = variable_index;
00087 }
00088 
00089 } // namespace cola2
00090 } // namespace sick


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Tue May 7 2019 03:27:36