ParseGeneralSystemState.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 {
42  m_reader_ptr = std::make_shared<sick::data_processing::ReadWriteHelper>();
43 }
44 
47  datastructure::Data& data) const
48 {
49  datastructure::GeneralSystemState general_system_state;
50  if (!checkIfPreconditionsAreMet(data))
51  {
52  general_system_state.setIsEmpty(true);
53  return general_system_state;
54  }
55  const uint8_t* data_ptr(buffer.getBuffer().data() +
56  data.getDataHeaderPtr()->getGeneralSystemStateBlockOffset());
57 
58  setDataInGeneralSystemState(data_ptr, general_system_state);
59  return general_system_state;
60 }
61 
63 {
65  {
66  return false;
67  }
69  {
70  return false;
71  }
72 
73  return true;
74 }
75 
77  const datastructure::Data& data) const
78 {
79  if (data.getDataHeaderPtr()->getGeneralSystemStateBlockOffset() == 0 &&
80  data.getDataHeaderPtr()->getGeneralSystemStateBlockSize() == 0)
81  {
82  return false;
83  }
84  return true;
85 }
86 
88  const datastructure::Data& data) const
89 {
90  if (data.getDataHeaderPtr()->isEmpty())
91  {
92  return false;
93  }
94  return true;
95 }
96 
97 
99  const uint8_t*& data_ptr, datastructure::GeneralSystemState& general_system_state) const
100 {
101  setStatusBitsInGeneralSystemState(data_ptr, general_system_state);
102  setSafeCutOffPathInGeneralSystemState(data_ptr, general_system_state);
103  setNonSafeCutOffPathInGeneralSystemState(data_ptr, general_system_state);
104  setResetRequiredCutOffPathInGeneralSystemState(data_ptr, general_system_state);
105  setCurrentMonitoringCasesInGeneralSystemState(data_ptr, general_system_state);
106  setErrorsInGeneralSystemState(data_ptr, general_system_state);
107 }
108 
110  const uint8_t*& data_ptr, datastructure::GeneralSystemState& general_system_state) const
111 {
112  uint8_t byte = m_reader_ptr->readuint8_tLittleEndian(data_ptr, 0);
113 
114  general_system_state.setRunModeActive(static_cast<bool>(byte & (0x01 << 0)));
115  general_system_state.setStandbyModeActive(static_cast<bool>(byte & (0x01 << 1)));
116  general_system_state.setContaminationWarning(static_cast<bool>(byte & (0x01 << 2)));
117  general_system_state.setContaminationError(static_cast<bool>(byte & (0x01 << 3)));
118  general_system_state.setReferenceContourStatus(static_cast<bool>(byte & (0x01 << 4)));
119  general_system_state.setManipulationStatus(static_cast<bool>(byte & (0x01 << 5)));
120  // bit 6 and 7 reserved
121 }
122 
124  const uint8_t*& data_ptr, datastructure::GeneralSystemState& general_system_state) const
125 {
126  std::vector<bool> safe_cut_off_path;
127 
128  for (uint8_t i = 0; i < 3; i++)
129  {
130  uint8_t byte = m_reader_ptr->readuint8_tLittleEndian(data_ptr, 1 + i);
131 
132  for (uint8_t j = 0; j < 8; j++)
133  {
134  // as long as there are only 20 instead of 24 cut off paths
135  if (i == 2 && j > 3)
136  {
137  break;
138  }
139  safe_cut_off_path.push_back(static_cast<bool>(byte & (0x01 << j)));
140  }
141  }
142  general_system_state.setSafeCutOffPathvector(safe_cut_off_path);
143 }
144 
146  const uint8_t*& data_ptr, datastructure::GeneralSystemState& general_system_state) const
147 {
148  std::vector<bool> non_safe_cut_off_path;
149 
150  for (uint8_t i = 0; i < 3; i++)
151  {
152  uint8_t byte = m_reader_ptr->readuint8_tLittleEndian(data_ptr, 4 + i);
153 
154  for (uint8_t j = 0; j < 8; j++)
155  {
156  // as long as there are only 20 instead of 24 cut off paths
157  if (i == 2 && j > 3)
158  {
159  break;
160  }
161  non_safe_cut_off_path.push_back(static_cast<bool>(byte & (0x01 << j)));
162  }
163  }
164  general_system_state.setNonSafeCutOffPathVector(non_safe_cut_off_path);
165 }
166 
168  const uint8_t*& data_ptr, datastructure::GeneralSystemState& general_system_state) const
169 {
170  std::vector<bool> reset_required_cutoff_path;
171 
172  for (uint8_t i = 0; i < 3; i++)
173  {
174  uint8_t byte = m_reader_ptr->readuint8_tLittleEndian(data_ptr, 7 + i);
175 
176  for (uint8_t j = 0; j < 8; j++)
177  {
178  // as long as there are only 20 instead of 24 cut off paths
179  if (i == 2 && j > 3)
180  {
181  break;
182  }
183  reset_required_cutoff_path.push_back(static_cast<bool>(byte & (0x01 << j)));
184  }
185  }
186  general_system_state.setResetRequiredCutOffPathVector(reset_required_cutoff_path);
187 }
188 
190  const uint8_t*& data_ptr, datastructure::GeneralSystemState& general_system_state) const
191 {
192  general_system_state.setCurrentMonitoringCaseNoTable_1(
193  m_reader_ptr->readuint8_tLittleEndian(data_ptr, 10));
194  general_system_state.setCurrentMonitoringCaseNoTable_2(
195  m_reader_ptr->readuint8_tLittleEndian(data_ptr, 11));
196  general_system_state.setCurrentMonitoringCaseNoTable_3(
197  m_reader_ptr->readuint8_tLittleEndian(data_ptr, 12));
198  general_system_state.setCurrentMonitoringCaseNoTable_4(
199  m_reader_ptr->readuint8_tLittleEndian(data_ptr, 13));
200 }
201 
203  const uint8_t*& data_ptr, datastructure::GeneralSystemState& general_system_state) const
204 {
205  uint8_t byte = m_reader_ptr->readuint8_tLittleEndian(data_ptr, 15);
206  general_system_state.setApplicationError(static_cast<bool>(byte & (0x01 << 0)));
207  general_system_state.setDeviceError(static_cast<bool>(byte & (0x01 << 1)));
208 }
209 
210 } // namespace data_processing
211 } // namespace sick
void setIsEmpty(bool is_empty)
Set if general system state has been enabled.
void setContaminationError(bool contamination_error)
Set if a contamination error exists.
The GeneralSystemState class. It includes a summary of the current system state, the state of the saf...
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
bool checkIfPreconditionsAreMet(const datastructure::Data &data) const
bool checkIfGeneralSystemStateIsPublished(const datastructure::Data &data) const
void setRunModeActive(bool run_mode_active)
Setter for run mode.
void setResetRequiredCutOffPathVector(const std::vector< bool > &reset_required_cut_off_path_vector)
Sets the reset state for all cut-off paths.
void setNonSafeCutOffPathVector(const std::vector< bool > &non_safe_cut_off_path_vector)
Sets the state of all non-safe cut-off paths.
void setCurrentMonitoringCasesInGeneralSystemState(const uint8_t *&data_ptr, datastructure::GeneralSystemState &general_System_state) const
void setDataInGeneralSystemState(const uint8_t *&data_ptr, datastructure::GeneralSystemState &general_System_state) const
std::shared_ptr< sick::data_processing::ReadWriteHelper > m_reader_ptr
void setCurrentMonitoringCaseNoTable_3(const uint8_t &current_monitoring_case_no_table_3)
Sets the current monitoring case table 3.
The data class containing all data blocks of a measurement.
Definition: Data.h:55
void setErrorsInGeneralSystemState(const uint8_t *&data_ptr, datastructure::GeneralSystemState &general_System_state) const
void setDeviceError(bool device_error)
Set if a device error exists.
void setReferenceContourStatus(bool reference_contour_status)
Set the reference contour status.
void setApplicationError(bool application_error)
Set if an application error exists.
void setCurrentMonitoringCaseNoTable_1(const uint8_t &current_monitoring_case_no_table_1)
Sets the current monitoring case table 1.
const VectorBuffer & getBuffer() const
Getter to return the VectorBuffer saved in the PacketBuffer.
void setSafeCutOffPathInGeneralSystemState(const uint8_t *&data_ptr, datastructure::GeneralSystemState &general_System_state) const
void setManipulationStatus(bool manipulation_status)
Set the manipulation status.
void setStandbyModeActive(bool standby_mode_active)
Setter for standby mode.
void setCurrentMonitoringCaseNoTable_2(const uint8_t &current_monitoring_case_no_table_2)
Sets the current monitoring case table 2.
datastructure::GeneralSystemState parseUDPSequence(const sick::datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Parses the udp sequence to read the general system state if enabled.
void setNonSafeCutOffPathInGeneralSystemState(const uint8_t *&data_ptr, datastructure::GeneralSystemState &general_System_state) const
bool checkIfDataContainsNeededParsedBlocks(const datastructure::Data &data) const
std::shared_ptr< DataHeader > getDataHeaderPtr() const
Gets the data header.
Definition: Data.cpp:42
void setStatusBitsInGeneralSystemState(const uint8_t *&data_ptr, datastructure::GeneralSystemState &general_System_state) const
void setCurrentMonitoringCaseNoTable_4(const uint8_t &current_monitoring_case_no_table_4)
Sets the current monitoring case table 4.
void setSafeCutOffPathvector(const std::vector< bool > &safe_cut_off_path_vector)
Sets the state of all safe cut-off paths.
void setResetRequiredCutOffPathInGeneralSystemState(const uint8_t *&data_ptr, datastructure::GeneralSystemState &general_System_state) const
void setContaminationWarning(bool contamination_warning)
Set if a contamination warning exists.


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