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;
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
sick::data_processing::ParseGeneralSystemState::setCurrentMonitoringCasesInGeneralSystemState
void setCurrentMonitoringCasesInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
Definition: ParseGeneralSystemState.cpp:185
sick::data_processing::ParseGeneralSystemState::setResetRequiredCutOffPathInGeneralSystemState
void setResetRequiredCutOffPathInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
Definition: ParseGeneralSystemState.cpp:162
sick::data_processing::ParseGeneralSystemState::setSafeCutOffPathInGeneralSystemState
void setSafeCutOffPathInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
Definition: ParseGeneralSystemState.cpp:116
sick::data_processing::ParseGeneralSystemState::checkIfGeneralSystemStateIsPublished
bool checkIfGeneralSystemStateIsPublished(const datastructure::Data &data) const
Definition: ParseGeneralSystemState.cpp:75
sick::datastructure::GeneralSystemState::setContaminationWarning
void setContaminationWarning(bool contamination_warning)
Set if a contamination warning exists.
Definition: GeneralSystemState.cpp:70
sick::datastructure::GeneralSystemState::setDeviceError
void setDeviceError(bool device_error)
Set if a device error exists.
Definition: GeneralSystemState.cpp:196
sick::data_processing::ParseGeneralSystemState::setNonSafeCutOffPathInGeneralSystemState
void setNonSafeCutOffPathInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
Definition: ParseGeneralSystemState.cpp:139
sick
Definition: ApplicationNameVariableCommand.h:43
sick::datastructure::GeneralSystemState::setCurrentMonitoringCaseNoTable1
void setCurrentMonitoringCaseNoTable1(const uint8_t &current_monitoring_case_no_table_1)
Sets the current monitoring case table 1.
Definition: GeneralSystemState.cpp:142
sick::datastructure::GeneralSystemState::setResetRequiredCutOffPathVector
void setResetRequiredCutOffPathVector(const std::vector< bool > &reset_required_cut_off_path_vector)
Sets the reset state for all cut-off paths.
Definition: GeneralSystemState.cpp:131
sick::datastructure::GeneralSystemState::setNonSafeCutOffPathVector
void setNonSafeCutOffPathVector(const std::vector< bool > &non_safe_cut_off_path_vector)
Sets the state of all non-safe cut-off paths.
Definition: GeneralSystemState.cpp:120
sick::datastructure::GeneralSystemState::setCurrentMonitoringCaseNoTable2
void setCurrentMonitoringCaseNoTable2(const uint8_t &current_monitoring_case_no_table_2)
Sets the current monitoring case table 2.
Definition: GeneralSystemState.cpp:153
sick::data_processing::ParseGeneralSystemState::setStatusBitsInGeneralSystemState
void setStatusBitsInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
Definition: ParseGeneralSystemState.cpp:101
sick::read_write_helper::readUint8LittleEndian
uint8_t readUint8LittleEndian(std::vector< uint8_t >::const_iterator it)
Read an unsigned 8-bit integer at offset in big little encoding.
Definition: ReadWriteHelper.hpp:224
sick::datastructure::Data
The data class containing all data blocks of a measurement.
Definition: Data.h:55
sick::datastructure::GeneralSystemState::setCurrentMonitoringCaseNoTable3
void setCurrentMonitoringCaseNoTable3(const uint8_t &current_monitoring_case_no_table_3)
Sets the current monitoring case table 3.
Definition: GeneralSystemState.cpp:164
sick::datastructure::GeneralSystemState::setSafeCutOffPathvector
void setSafeCutOffPathvector(const std::vector< bool > &safe_cut_off_path_vector)
Sets the state of all safe cut-off paths.
Definition: GeneralSystemState.cpp:110
sick::data_processing::ParseGeneralSystemState::checkIfPreconditionsAreMet
bool checkIfPreconditionsAreMet(const datastructure::Data &data) const
Definition: ParseGeneralSystemState.cpp:61
data
data
sick::datastructure::GeneralSystemState::setContaminationError
void setContaminationError(bool contamination_error)
Set if a contamination error exists.
Definition: GeneralSystemState.cpp:80
sick::datastructure::GeneralSystemState::setManipulationStatus
void setManipulationStatus(bool manipulation_status)
Set the manipulation status.
Definition: GeneralSystemState.cpp:100
sick::datastructure::GeneralSystemState::setStandbyModeActive
void setStandbyModeActive(bool standby_mode_active)
Setter for standby mode.
Definition: GeneralSystemState.cpp:60
sick::data_processing::ParseGeneralSystemState::setErrorsInGeneralSystemState
void setErrorsInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
Definition: ParseGeneralSystemState.cpp:199
sick::datastructure::PacketBuffer::getBuffer
std::shared_ptr< std::vector< uint8_t > const > getBuffer() const
Getter to return a copy of the data saved in the PacketBuffer.
Definition: PacketBuffer.cpp:53
sick::datastructure::GeneralSystemState::setCurrentMonitoringCaseNoTable4
void setCurrentMonitoringCaseNoTable4(const uint8_t &current_monitoring_case_no_table_4)
Sets the current monitoring case table 4.
Definition: GeneralSystemState.cpp:175
sick::data_processing::ParseGeneralSystemState::checkIfDataContainsNeededParsedBlocks
bool checkIfDataContainsNeededParsedBlocks(const datastructure::Data &data) const
Definition: ParseGeneralSystemState.cpp:82
sick::datastructure::GeneralSystemState::setRunModeActive
void setRunModeActive(bool run_mode_active)
Setter for run mode.
Definition: GeneralSystemState.cpp:50
sick::data_processing::ParseGeneralSystemState::parseUDPSequence
datastructure::GeneralSystemState parseUDPSequence(const sick::datastructure::PacketBuffer &buffer, datastructure::Data &data) const
Parses the udp sequence to read the general system state if enabled.
Definition: ParseGeneralSystemState.cpp:43
sick::datastructure::GeneralSystemState::setIsEmpty
void setIsEmpty(bool is_empty)
Set if general system state has been enabled.
Definition: GeneralSystemState.cpp:206
sick::datastructure::GeneralSystemState
The GeneralSystemState class. It includes a summary of the current system state, the state of the saf...
Definition: GeneralSystemState.h:49
sick::data_processing::ParseGeneralSystemState::ParseGeneralSystemState
ParseGeneralSystemState()
Constructor of the parser.
Definition: ParseGeneralSystemState.cpp:40
ParseGeneralSystemState.h
sick::data_processing::ParseGeneralSystemState::setDataInGeneralSystemState
void setDataInGeneralSystemState(std::vector< uint8_t >::const_iterator data_ptr, datastructure::GeneralSystemState &general_system_state) const
Definition: ParseGeneralSystemState.cpp:89
sick::datastructure::PacketBuffer
A packetbuffer for the raw data from the sensor.
Definition: PacketBuffer.h:61
sick::datastructure::GeneralSystemState::setReferenceContourStatus
void setReferenceContourStatus(bool reference_contour_status)
Set the reference contour status.
Definition: GeneralSystemState.cpp:90
sick::datastructure::GeneralSystemState::setApplicationError
void setApplicationError(bool application_error)
Set if an application error exists.
Definition: GeneralSystemState.cpp:186


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Fri Jun 21 2024 02:40:51