ParseFieldHeaderData.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 
38 
39 namespace sick {
40 namespace data_processing {
41 
43 {
44  m_reader_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
45 }
46 
47 
49  datastructure::FieldData& field_data) const
50 {
51  const uint8_t* data_ptr(buffer.getBuffer().data());
52  bool valid = isValid(data_ptr);
53  field_data.setIsValid(valid);
54 
55  if (valid)
56  {
57  setFieldType(data_ptr, field_data);
58  uint16_t set_index = readSetIndex(data_ptr);
59  field_data.setFieldSetIndex(set_index);
60  }
61  return true;
62 }
63 
64 bool ParseFieldHeaderData::isValid(const uint8_t*& data_ptr) const
65 {
66  bool res = false;
67  uint8_t byte = m_reader_ptr->readuint8_t(data_ptr, 0);
68  if (byte == 'R' || byte == 'Y')
69  {
70  res = true;
71  }
72 
73  return res;
74 }
75 
76 void ParseFieldHeaderData::setFieldType(const uint8_t*& data_ptr,
77  datastructure::FieldData& field_data) const
78 {
79  uint8_t field_type = readFieldType(data_ptr);
80  field_data.setIsWarningField(false);
81  field_data.setIsProtectiveField(false);
82  if (field_type == 4 || field_type == 14)
83  {
84  field_data.setIsProtectiveField(true);
85  }
86  else if (field_type == 5 || field_type == 15)
87  {
88  field_data.setIsWarningField(true);
89  }
90 }
91 
92 
93 uint8_t ParseFieldHeaderData::readFieldType(const uint8_t*& data_ptr) const
94 {
95  return m_reader_ptr->readuint8_t(data_ptr, 73);
96 }
97 
98 uint16_t ParseFieldHeaderData::readSetIndex(const uint8_t*& data_ptr) const
99 {
100  return m_reader_ptr->readuint16_tLittleEndian(data_ptr, 82);
101 }
102 
103 
104 } // namespace data_processing
105 } // namespace sick
bool isValid(const uint8_t *&data_ptr) const
void setIsValid(bool is_valid)
Sets if the field data is valid.
Definition: FieldData.cpp:47
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
Field data for warning and protective fields.
Definition: FieldData.h:48
uint8_t readFieldType(const uint8_t *&data_ptr) const
void setIsProtectiveField(bool is_protective_field)
Set if a field is protective field.
Definition: FieldData.cpp:77
const VectorBuffer & getBuffer() const
Getter to return the VectorBuffer saved in the PacketBuffer.
uint16_t readSetIndex(const uint8_t *&data_ptr) const
void setIsWarningField(bool is_warning_field)
Set if a field is a warning field.
Definition: FieldData.cpp:67
def field_type(f)
std::shared_ptr< sick::data_processing::ReadWriteHelper > m_reader_ptr
void setFieldType(const uint8_t *&data_ptr, datastructure::FieldData &field_data) const
bool parseTCPSequence(const datastructure::PacketBuffer &buffer, datastructure::FieldData &field_data) const
Parses a tcp sequence to read the header for a warning or protective field.
void setFieldSetIndex(uint16_t &field_set_index)
Sets the index of the field set where the field belongs to.
Definition: FieldData.cpp:57


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