ParseDerivedValues.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 
37 namespace sick {
38 namespace data_processing {
39 
41 
44  datastructure::Data& data) const
45 {
46  datastructure::DerivedValues derived_values;
47 
48 
49  if (!checkIfPreconditionsAreMet(data))
50  {
51  derived_values.setIsEmpty(true);
52  return derived_values;
53  }
54  // Keep our own copy of the shared_ptr to keep the iterators valid
55  const std::shared_ptr<std::vector<uint8_t> const> vec_ptr = buffer.getBuffer();
56  std::vector<uint8_t>::const_iterator data_ptr =
57  vec_ptr->begin() + data.getDataHeaderPtr()->getDerivedValuesBlockOffset();
58  setDataInDerivedValues(data_ptr, derived_values);
59  return derived_values;
60 }
61 
63 {
65  {
66  return false;
67  }
69  {
70  return false;
71  }
72 
73  return true;
74 }
75 
77 {
78  return !(data.getDataHeaderPtr()->getDerivedValuesBlockOffset() == 0 &&
79  data.getDataHeaderPtr()->getDerivedValuesBlockSize() == 0);
80 }
81 
83  const datastructure::Data& data) const
84 {
85  return !(data.getDataHeaderPtr()->isEmpty());
86 }
87 
88 void ParseDerivedValues::setDataInDerivedValues(std::vector<uint8_t>::const_iterator data_ptr,
89  datastructure::DerivedValues& derived_values) const
90 {
91  setMultiplicationFactorInDerivedValues(data_ptr, derived_values);
92  setNumberOfBeamsInDerivedValues(data_ptr, derived_values);
93  setScanTimeInDerivedValues(data_ptr, derived_values);
94  setStartAngleInDerivedValues(data_ptr, derived_values);
95  setAngularBeamResolutionInDerivedValues(data_ptr, derived_values);
96  setInterbeamPeriodInDerivedValues(data_ptr, derived_values);
97 }
98 
100  std::vector<uint8_t>::const_iterator data_ptr, datastructure::DerivedValues& derived_values) const
101 {
103 }
104 
106  std::vector<uint8_t>::const_iterator data_ptr, datastructure::DerivedValues& derived_values) const
107 {
108  derived_values.setNumberOfBeams(read_write_helper::readUint16LittleEndian(data_ptr + 2));
109 }
110 
112  std::vector<uint8_t>::const_iterator data_ptr, datastructure::DerivedValues& derived_values) const
113 {
114  derived_values.setScanTime(read_write_helper::readUint16LittleEndian(data_ptr + 4));
115 }
116 
118  std::vector<uint8_t>::const_iterator data_ptr, datastructure::DerivedValues& derived_values) const
119 {
120  derived_values.setStartAngle(read_write_helper::readInt32LittleEndian(data_ptr + 8));
121 }
122 
124  std::vector<uint8_t>::const_iterator data_ptr, datastructure::DerivedValues& derived_values) const
125 {
127 }
128 
130  std::vector<uint8_t>::const_iterator data_ptr, datastructure::DerivedValues& derived_values) const
131 {
132  derived_values.setInterbeamPeriod(read_write_helper::readUint32LittleEndian(data_ptr + 16));
133 }
134 
135 } // namespace data_processing
136 } // namespace sick
void setScanTime(const uint16_t &scan_time)
Sets the time of the scan.
void setAngularBeamResolution(const int32_t &angular_beam_resolution)
Set the angular resolution between beams.
void setMultiplicationFactorInDerivedValues(std::vector< uint8_t >::const_iterator data_ptr, datastructure::DerivedValues &derived_values) const
void setDataInDerivedValues(std::vector< uint8_t >::const_iterator data_ptr, datastructure::DerivedValues &derived_values) const
bool checkIfPreconditionsAreMet(const datastructure::Data &data) const
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
std::shared_ptr< std::vector< uint8_t > const > getBuffer() const
Getter to return a copy of the data saved in the PacketBuffer.
void setIsEmpty(bool is_empty)
Set if derived values are enabled.
void setNumberOfBeams(const uint16_t &number_of_beams)
Sets the number of beams for the current scan.
bool checkIfDataContainsNeededParsedBlocks(const datastructure::Data &data) const
void setStartAngleInDerivedValues(std::vector< uint8_t >::const_iterator data_ptr, datastructure::DerivedValues &derived_values) const
void setScanTimeInDerivedValues(std::vector< uint8_t >::const_iterator data_ptr, datastructure::DerivedValues &derived_values) const
void setNumberOfBeamsInDerivedValues(std::vector< uint8_t >::const_iterator data_ptr, datastructure::DerivedValues &derived_values) const
ParseDerivedValues()
Constructor of the parser.
void setMultiplicationFactor(const uint16_t &multiplication_factor)
Sets the multiplication factor.
The data class containing all data blocks of a measurement.
Definition: Data.h:55
void setInterbeamPeriodInDerivedValues(std::vector< uint8_t >::const_iterator data_ptr, datastructure::DerivedValues &derived_values) const
datastructure::DerivedValues parseUDPSequence(const datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Parsed the packet buffer and returns the derived values.
void setAngularBeamResolutionInDerivedValues(std::vector< uint8_t >::const_iterator data_ptr, datastructure::DerivedValues &derived_values) const
uint32_t readUint32LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in little endian encoding.
int32_t readInt32LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 32-bit integer at offset in little endian encoding.
bool checkIfDerivedValuesIsPublished(const datastructure::Data &data) const
The DerivedValues class Includes the derived configuration of the measurement data channel...
Definition: DerivedValues.h:48
void setStartAngle(const int32_t &start_angle)
Set the start angle of the scan.
std::shared_ptr< DataHeader > getDataHeaderPtr() const
Gets the data header.
Definition: Data.cpp:42
uint16_t readUint16LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 16-bit integer at offset in little endian encoding.
void setInterbeamPeriod(const uint32_t &interbeam_period)
Set the time between two consecutive beams.


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