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 }
50 
51 std::vector<uint8_t>
52 ChangeCommSettingsCommand::addTelegramData(const std::vector<uint8_t>& telegram) const
53 {
54  auto base_output = base_class::addTelegramData(telegram);
55  size_t base_length = base_output.size();
56  auto output = expandTelegram(base_output, 28);
57 
58  // Add new values after telegram
59  const auto new_data_offset_it = output.begin() + base_length + telegram.size();
60 
61  writeDataToDataPtr(new_data_offset_it);
62 
63  return output;
64 }
65 
66 void ChangeCommSettingsCommand::writeDataToDataPtr(std::vector<uint8_t>::iterator data_ptr) const
67 {
68  writeChannelToDataPtr(data_ptr);
69  writeEnabledToDataPtr(data_ptr);
71  writeIPAddresstoDataPtr(data_ptr);
72  writePortToDataPtr(data_ptr);
73  writeFrequencyToDataPtr(data_ptr);
74  writeStartAngleToDataPtr(data_ptr);
75  writeEndAngleToDataPtr(data_ptr);
76  writeFeaturesToDataPtr(data_ptr);
77 }
78 
80 {
81  return true;
82 }
83 
85 {
86  return (!base_class::processReply());
87 }
88 
89 void ChangeCommSettingsCommand::writeChannelToDataPtr(std::vector<uint8_t>::iterator data_ptr) const
90 {
92 }
93 
94 void ChangeCommSettingsCommand::writeEnabledToDataPtr(std::vector<uint8_t>::iterator data_ptr) const
95 {
97  static_cast<uint8_t>(m_settings.getEnabled()));
98 }
99 
101  std::vector<uint8_t>::iterator data_ptr) const
102 {
104 }
105 
107  std::vector<uint8_t>::iterator data_ptr) const
108 {
110 }
111 
112 void ChangeCommSettingsCommand::writePortToDataPtr(std::vector<uint8_t>::iterator data_ptr) const
113 {
115 }
116 
118  std::vector<uint8_t>::iterator data_ptr) const
119 {
121 }
122 
124  std::vector<uint8_t>::iterator data_ptr) const
125 {
127 }
128 
130  std::vector<uint8_t>::iterator data_ptr) const
131 {
133 }
134 
136  std::vector<uint8_t>::iterator data_ptr) const
137 {
139 }
140 
141 
142 } // namespace cola2
143 } // namespace sick
void writeFrequencyToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
Command for method calls to the sensor.
Definition: MethodCommand.h:46
boost::asio::ip::address_v4 getHostIp() const
Gets the IP-address of the host.
uint16_t getFeatures() const
Gets the enabled features.
void writeChannelToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
void writeStartAngleToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
void writeEInterfaceTypeToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
uint16_t getPublishingFrequency() const
Gets the publishing frequency.
void writePortToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
void writeDataToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
bool processReply()
Processes the return from the sensor. Checks if the method was acknowledged by the sensor...
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
void writeIPAddresstoDataPtr(std::vector< uint8_t >::iterator data_ptr) const
uint32_t getStartAngle() const
Gets the start angle of the scan.
std::vector< uint8_t > addTelegramData(const std::vector< uint8_t > &telegram) const
Adds the settings as data to the packetbuffer.
uint32_t getEndAngle() const
Gets the end angle of the scan.
std::vector< uint8_t > expandTelegram(const std::vector< uint8_t > &telegram, size_t additional_bytes) const
Definition: Command.cpp:121
void writeFeaturesToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
void writeUint32LittleEndian(std::vector< uint8_t >::iterator it, const uint32_t v)
Writes an unsigned 32-bit integer to a buffer at offset in little endian encoding.
bool canBeExecutedWithoutSessionID() const
Returns if the command can be executed without a session ID. Will return false for most commands exce...
void writeUint8LittleEndian(std::vector< uint8_t >::iterator it, const uint8_t v)
Writes an unsigned 8-bit integer to a buffer at offset in little endian encoding. ...
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.
std::vector< uint8_t > addTelegramData(const std::vector< uint8_t > &telegram) const
Adds the data to the telegram.
void writeEnabledToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
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.
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 writeEndAngleToDataPtr(std::vector< uint8_t >::iterator data_ptr) const
Establishes a cola2 session with a sensor and enables execution of commands in this session...
Definition: Cola2Session.h:72


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Apr 2 2021 02:45:41