ChangeCommSettingsCommand.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 
00036 #include <sick_safetyscanners/cola2/ChangeCommSettingsCommand.h>
00037 
00038 #include <sick_safetyscanners/cola2/Cola2Session.h>
00039 #include <sick_safetyscanners/cola2/Command.h>
00040 
00041 namespace sick {
00042 namespace cola2 {
00043 
00044 ChangeCommSettingsCommand::ChangeCommSettingsCommand(
00045   Cola2Session& session, const sick::datastructure::CommSettings& settings)
00046   : MethodCommand(session, 0x00b0)
00047   , m_settings(settings)
00048 {
00049   m_writer_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
00050 }
00051 
00052 void ChangeCommSettingsCommand::addTelegramData(
00053   sick::datastructure::PacketBuffer::VectorBuffer& telegram) const
00054 {
00055   base_class::addTelegramData(telegram);
00056 
00057   uint8_t* data_ptr = prepareTelegramAndGetDataPtr(telegram);
00058 
00059   writeDataToDataPtr(data_ptr);
00060 }
00061 
00062 uint8_t* ChangeCommSettingsCommand::prepareTelegramAndGetDataPtr(
00063   sick::datastructure::PacketBuffer::VectorBuffer& telegram) const
00064 {
00065   uint16_t prevSize = telegram.size();
00066   telegram.resize(prevSize + 28);
00067   return telegram.data() + prevSize;
00068 }
00069 
00070 void ChangeCommSettingsCommand::writeDataToDataPtr(uint8_t*& data_ptr) const
00071 {
00072   writeChannelToDataPtr(data_ptr);
00073   writeEnabledToDataPtr(data_ptr);
00074   writeEInterfaceTypeToDataPtr(data_ptr);
00075   writeIPAddresstoDataPtr(data_ptr);
00076   writePortToDataPtr(data_ptr);
00077   writeFrequencyToDataPtr(data_ptr);
00078   writeStartAngleToDataPtr(data_ptr);
00079   writeEndAngleToDataPtr(data_ptr);
00080   writeFeaturesToDataPtr(data_ptr);
00081 }
00082 
00083 bool ChangeCommSettingsCommand::canBeExecutedWithoutSessionID() const
00084 {
00085   return true;
00086 }
00087 
00088 bool ChangeCommSettingsCommand::processReply()
00089 {
00090   if (!base_class::processReply())
00091   {
00092     return false;
00093   }
00094   return true;
00095 }
00096 
00097 void ChangeCommSettingsCommand::writeChannelToDataPtr(uint8_t*& data_ptr) const
00098 {
00099   m_writer_ptr->writeuint8_tLittleEndian(data_ptr, m_settings.getChannel(), 0);
00100 }
00101 
00102 void ChangeCommSettingsCommand::writeEnabledToDataPtr(uint8_t*& data_ptr) const
00103 {
00104   m_writer_ptr->writeuint8_tLittleEndian(data_ptr, m_settings.getEnabled(), 4);
00105 }
00106 
00107 void ChangeCommSettingsCommand::writeEInterfaceTypeToDataPtr(uint8_t*& data_ptr) const
00108 {
00109   m_writer_ptr->writeuint8_tLittleEndian(data_ptr, m_settings.getEInterfaceType(), 5);
00110 }
00111 
00112 void ChangeCommSettingsCommand::writeIPAddresstoDataPtr(uint8_t*& data_ptr) const
00113 {
00114   m_writer_ptr->writeuint32_tLittleEndian(data_ptr, m_settings.getHostIp().to_ulong(), 8);
00115 }
00116 
00117 void ChangeCommSettingsCommand::writePortToDataPtr(uint8_t*& data_ptr) const
00118 {
00119   m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_settings.getHostUdpPort(), 12);
00120 }
00121 
00122 void ChangeCommSettingsCommand::writeFrequencyToDataPtr(uint8_t*& data_ptr) const
00123 {
00124   m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_settings.getPublishingFrequency(), 14);
00125 }
00126 
00127 void ChangeCommSettingsCommand::writeStartAngleToDataPtr(uint8_t*& data_ptr) const
00128 {
00129   m_writer_ptr->writeuint32_tLittleEndian(data_ptr, m_settings.getStartAngle(), 16);
00130 }
00131 
00132 void ChangeCommSettingsCommand::writeEndAngleToDataPtr(uint8_t*& data_ptr) const
00133 {
00134   m_writer_ptr->writeuint32_tLittleEndian(data_ptr, m_settings.getEndAngle(), 20);
00135 }
00136 
00137 void ChangeCommSettingsCommand::writeFeaturesToDataPtr(uint8_t*& data_ptr) const
00138 {
00139   m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_settings.getFeatures(), 24);
00140 }
00141 
00142 
00143 } // namespace cola2
00144 } // namespace sick


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