ChangeCommSettingsCommand.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 
35 
37 
40 
41 namespace sick {
42 namespace cola2 {
43 
45  Cola2Session& session, const sick::datastructure::CommSettings& settings)
46  : MethodCommand(session, 0x00b0)
47  , m_settings(settings)
48 {
49  m_writer_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
50 }
51 
54 {
56 
57  uint8_t* data_ptr = prepareTelegramAndGetDataPtr(telegram);
58 
59  writeDataToDataPtr(data_ptr);
60 }
61 
64 {
65  uint16_t prevSize = telegram.size();
66  telegram.resize(prevSize + 28);
67  return telegram.data() + prevSize;
68 }
69 
70 void ChangeCommSettingsCommand::writeDataToDataPtr(uint8_t*& data_ptr) const
71 {
72  writeChannelToDataPtr(data_ptr);
73  writeEnabledToDataPtr(data_ptr);
75  writeIPAddresstoDataPtr(data_ptr);
76  writePortToDataPtr(data_ptr);
77  writeFrequencyToDataPtr(data_ptr);
78  writeStartAngleToDataPtr(data_ptr);
79  writeEndAngleToDataPtr(data_ptr);
80  writeFeaturesToDataPtr(data_ptr);
81 }
82 
84 {
85  return true;
86 }
87 
89 {
91  {
92  return false;
93  }
94  return true;
95 }
96 
98 {
99  m_writer_ptr->writeuint8_tLittleEndian(data_ptr, m_settings.getChannel(), 0);
100 }
101 
103 {
104  m_writer_ptr->writeuint8_tLittleEndian(data_ptr, m_settings.getEnabled(), 4);
105 }
106 
108 {
109  m_writer_ptr->writeuint8_tLittleEndian(data_ptr, m_settings.getEInterfaceType(), 5);
110 }
111 
113 {
114  m_writer_ptr->writeuint32_tLittleEndian(data_ptr, m_settings.getHostIp().to_ulong(), 8);
115 }
116 
117 void ChangeCommSettingsCommand::writePortToDataPtr(uint8_t*& data_ptr) const
118 {
119  m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_settings.getHostUdpPort(), 12);
120 }
121 
123 {
124  m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_settings.getPublishingFrequency(), 14);
125 }
126 
128 {
129  m_writer_ptr->writeuint32_tLittleEndian(data_ptr, m_settings.getStartAngle(), 16);
130 }
131 
133 {
134  m_writer_ptr->writeuint32_tLittleEndian(data_ptr, m_settings.getEndAngle(), 20);
135 }
136 
138 {
139  m_writer_ptr->writeuint16_tLittleEndian(data_ptr, m_settings.getFeatures(), 24);
140 }
141 
142 
143 } // namespace cola2
144 } // namespace sick
Command for method calls to the sensor.
Definition: MethodCommand.h:46
void writeEnabledToDataPtr(uint8_t *&data_ptr) const
boost::asio::ip::address_v4 getHostIp() const
Gets the IP-address of the host.
uint16_t getFeatures() const
Gets the enabled features.
void addTelegramData(sick::datastructure::PacketBuffer::VectorBuffer &telegram) const
Adds the data to the telegram.
uint16_t getPublishingFrequency() const
Gets the publishing frequency.
bool processReply()
Processes the return from the sensor. Checks if the method was acknowledged by the sensor...
void writeIPAddresstoDataPtr(uint8_t *&data_ptr) const
uint8_t getEInterfaceType() const
Gets the eInterface type.
sick::datastructure::CommSettings m_settings
Containing the communication settings for the sensor which can be changed on runtime.
Definition: CommSettings.h:48
uint32_t getStartAngle() const
Gets the start angle of the scan.
void writeDataToDataPtr(uint8_t *&data_ptr) const
uint32_t getEndAngle() const
Gets the end angle of the scan.
uint8_t * prepareTelegramAndGetDataPtr(sick::datastructure::PacketBuffer::VectorBuffer &telegram) const
void addTelegramData(sick::datastructure::PacketBuffer::VectorBuffer &telegram) const
Adds the settings as data to the packetbuffer.
bool canBeExecutedWithoutSessionID() const
Returns if the command can be executed without a session ID. Will return false for most commands exce...
bool getEnabled() const
Gets if the channel is enabled.
uint8_t getChannel() const
Gets the channel of the data.
bool processReply()
Processes the return from the sensor.
void writeFeaturesToDataPtr(uint8_t *&data_ptr) const
void writeEndAngleToDataPtr(uint8_t *&data_ptr) const
void writeEInterfaceTypeToDataPtr(uint8_t *&data_ptr) const
void writeStartAngleToDataPtr(uint8_t *&data_ptr) const
std::shared_ptr< sick::data_processing::ReadWriteHelper > m_writer_ptr
void writeFrequencyToDataPtr(uint8_t *&data_ptr) const
uint16_t getHostUdpPort() const
Gets the host udp port.
ChangeCommSettingsCommand(Cola2Session &session, const datastructure::CommSettings &settings)
Constructor of the Command, takes the current session and the new set of parameters for the sensor...
void writePortToDataPtr(uint8_t *&data_ptr) const
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
void writeChannelToDataPtr(uint8_t *&data_ptr) const


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