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 
44  datastructure::Data& data) const
45 {
46  datastructure::GeneralSystemState general_system_state;
47  if (!checkIfPreconditionsAreMet(data))
48  {
49  general_system_state.setIsEmpty(true);
50  return general_system_state;
51  }
52  // Keep our own copy of the shared_ptr to keep the iterators valid
53  const std::shared_ptr<std::vector<uint8_t> const> vec_ptr = buffer.getBuffer();
54  std::vector<uint8_t>::const_iterator data_ptr =
55  vec_ptr->begin() + data.getDataHeaderPtr()->getGeneralSystemStateBlockOffset();
56 
57  setDataInGeneralSystemState(data_ptr, general_system_state);
58  return general_system_state;
59 }
60 
62 {
64  {
65  return false;
66  }
68  {
69  return false;
70  }
71 
72  return true;
73 }
74 
76  const datastructure::Data& data) const
77 {
78  return !(data.getDataHeaderPtr()->getGeneralSystemStateBlockOffset() == 0 &&
79  data.getDataHeaderPtr()->getGeneralSystemStateBlockSize() == 0);
80 }
81 
83  const datastructure::Data& data) const
84 {
85  return !(data.getDataHeaderPtr()->isEmpty());
86 }
87 
88 
90  std::vector<uint8_t>::const_iterator data_ptr,
91  datastructure::GeneralSystemState& general_system_state) const
92 {
93  setStatusBitsInGeneralSystemState(data_ptr, general_system_state);
94  setSafeCutOffPathInGeneralSystemState(data_ptr, general_system_state);
95  setNonSafeCutOffPathInGeneralSystemState(data_ptr, general_system_state);
96  setResetRequiredCutOffPathInGeneralSystemState(data_ptr, general_system_state);
97  setCurrentMonitoringCasesInGeneralSystemState(data_ptr, general_system_state);
98  setErrorsInGeneralSystemState(data_ptr, general_system_state);
99 }
100 
102  std::vector<uint8_t>::const_iterator data_ptr,
103  datastructure::GeneralSystemState& general_system_state) const
104 {
105  uint8_t byte = read_write_helper::readUint8LittleEndian(data_ptr + 0);
106 
107  general_system_state.setRunModeActive(static_cast<bool>(byte & (0x01 << 0)));
108  general_system_state.setStandbyModeActive(static_cast<bool>(byte & (0x01 << 1)));
109  general_system_state.setContaminationWarning(static_cast<bool>(byte & (0x01 << 2)));
110  general_system_state.setContaminationError(static_cast<bool>(byte & (0x01 << 3)));
111  general_system_state.setReferenceContourStatus(static_cast<bool>(byte & (0x01 << 4)));
112  general_system_state.setManipulationStatus(static_cast<bool>(byte & (0x01 << 5)));
113  // bit 6 and 7 reserved
114 }
115 
117  std::vector<uint8_t>::const_iterator data_ptr,
118  datastructure::GeneralSystemState& general_system_state) const
119 {
120  std::vector<bool> safe_cut_off_path;
121 
122  for (uint8_t i = 0; i < 3; i++)
123  {
124  uint8_t byte = read_write_helper::readUint8LittleEndian(data_ptr + 1 + i);
125 
126  for (uint8_t j = 0; j < 8; j++)
127  {
128  // as long as there are only 20 instead of 24 cut off paths
129  if (i == 2 && j > 3)
130  {
131  break;
132  }
133  safe_cut_off_path.push_back(static_cast<bool>(byte & (0x01 << j)));
134  }
135  }
136  general_system_state.setSafeCutOffPathvector(safe_cut_off_path);
137 }
138 
140  std::vector<uint8_t>::const_iterator data_ptr,
141  datastructure::GeneralSystemState& general_system_state) const
142 {
143  std::vector<bool> non_safe_cut_off_path;
144 
145  for (uint8_t i = 0; i < 3; i++)
146  {
147  uint8_t byte = read_write_helper::readUint8LittleEndian(data_ptr + 4 + i);
148 
149  for (uint8_t j = 0; j < 8; j++)
150  {
151  // as long as there are only 20 instead of 24 cut off paths
152  if (i == 2 && j > 3)
153  {
154  break;
155  }
156  non_safe_cut_off_path.push_back(static_cast<bool>(byte & (0x01 << j)));
157  }
158  }
159  general_system_state.setNonSafeCutOffPathVector(non_safe_cut_off_path);
160 }
161 
163  std::vector<uint8_t>::const_iterator data_ptr,
164  datastructure::GeneralSystemState& general_system_state) const
165 {
166  std::vector<bool> reset_required_cutoff_path;
167 
168  for (uint8_t i = 0; i < 3; i++)
169  {
170  uint8_t byte = read_write_helper::readUint8LittleEndian(data_ptr + 7 + i);
171 
172  for (uint8_t j = 0; j < 8; j++)
173  {
174  // as long as there are only 20 instead of 24 cut off paths
175  if (i == 2 && j > 3)
176  {
177  break;
178  }
179  reset_required_cutoff_path.push_back(static_cast<bool>(byte & (0x01 << j)));
180  }
181  }
182  general_system_state.setResetRequiredCutOffPathVector(reset_required_cutoff_path);
183 }
184 
186  std::vector<uint8_t>::const_iterator data_ptr,
187  datastructure::GeneralSystemState& general_system_state) const
188 {
189  general_system_state.setCurrentMonitoringCaseNoTable1(
191  general_system_state.setCurrentMonitoringCaseNoTable2(
193  general_system_state.setCurrentMonitoringCaseNoTable3(
195  general_system_state.setCurrentMonitoringCaseNoTable4(
197 }
198 
200  std::vector<uint8_t>::const_iterator data_ptr,
201  datastructure::GeneralSystemState& general_system_state) const
202 {
203  uint8_t byte = read_write_helper::readUint8LittleEndian(data_ptr + 15);
204  general_system_state.setApplicationError(static_cast<bool>(byte & (0x01 << 0)));
205  general_system_state.setDeviceError(static_cast<bool>(byte & (0x01 << 1)));
206 }
207 
208 } // namespace data_processing
209 } // 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...
void setStatusBitsInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) 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 setCurrentMonitoringCaseNoTable4(const uint8_t &current_monitoring_case_no_table_4)
Sets the current monitoring case table 4.
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.
uint8_t readUint8LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset in big little encoding.
The data class containing all data blocks of a measurement.
Definition: Data.h:55
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 setResetRequiredCutOffPathInGeneralSystemState(std::vector< uint8_t >::const_iterator 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 setCurrentMonitoringCaseNoTable3(const uint8_t &current_monitoring_case_no_table_3)
Sets the current monitoring case table 3.
void setDataInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
void setCurrentMonitoringCasesInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
void setCurrentMonitoringCaseNoTable1(const uint8_t &current_monitoring_case_no_table_1)
Sets the current monitoring case table 1.
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 setSafeCutOffPathInGeneralSystemState(std::vector< uint8_t >::const_iterator 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 setCurrentMonitoringCaseNoTable2(const uint8_t &current_monitoring_case_no_table_2)
Sets the current monitoring case table 2.
void setErrorsInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
void setSafeCutOffPathvector(const std::vector< bool > &safe_cut_off_path_vector)
Sets the state of all safe cut-off paths.
void setContaminationWarning(bool contamination_warning)
Set if a contamination warning exists.
void setNonSafeCutOffPathInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const


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