diagnostics.h
Go to the documentation of this file.
1 // Copyright (c) 2020-2021 Pilz GmbH & Co. KG
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
16 #ifndef PSEN_SCAN_V2_STANDALONE_DIAGNOSTICS_H
17 #define PSEN_SCAN_V2_STANDALONE_DIAGNOSTICS_H
18 
19 #include <array>
20 #include <string>
21 #include <map>
22 #include <vector>
23 #include <set>
24 
26 
28 {
32 namespace data_conversion_layer
33 {
34 namespace monitoring_frame
35 {
40 namespace diagnostic
41 {
45 static constexpr uint32_t RAW_CHUNK_LENGTH_FOR_ONE_DEVICE_IN_BYTES{ 9 };
46 static constexpr uint32_t RAW_CHUNK_UNUSED_OFFSET_IN_BYTES{ 4 };
47 static constexpr uint32_t RAW_CHUNK_LENGTH_IN_BYTES{
49 };
50 
51 using RawChunk = std::array<uint8_t, diagnostic::RAW_CHUNK_LENGTH_IN_BYTES>;
52 
53 enum class ErrorType
54 {
55  ossd1_oc,
58  intern,
59  win_cln_al,
61  netw_prb,
64  meas_prob,
73  encod_oor,
74  edm2_err,
75  edm1_err,
76  conf_err,
80  unused
81 };
82 
83 // clang-format off
84 
85 using Et = ErrorType;
86 using ErrorMessage = std::string;
87 
88 static const std::map<ErrorType, ErrorMessage> ERROR_CODE_TO_STRING
89 {
90  { Et::ossd1_oc, "OSSD1 Overcurrent / Short circuit." },
91  { Et::ossd_shrt_c, "Short circuit between at least two OSSDs." },
92  { Et::ossd_integr, "OSSDF1: An error has occurred when testing the OSSDs." },
93  { Et::intern, "Internal error." },
94  { Et::win_cln_al, "Alarm: The front panel of the safety laser scanner must be cleaned." },
95  { Et::power_supply, "Power supply problem." },
96  { Et::netw_prb, "Network problem." },
97  { Et::dust_crc_fl, "Dust circuit failure" },
98  { Et::ossd2_overcur, "OSSD2 Overcurrent / Short circuit." },
99  { Et::meas_prob, "Measurement Problem." },
100  { Et::incoherence, "Incoherence Error" },
101  { Et::zone_inval_trans, "INPUTCF2: Configuration error. - "
102  "In the configuration, check the configured state transitions and switching operations." },
103  { Et::zone_invalid_conf, "INPUTCF1: Error in the configuration or the wiring. - "
104  "Check whether the wiring and the configuration will match." },
105  { Et::win_cln_warn, "Warning: The front panel of the safety laser scanner must be cleaned." },
106  { Et::generic_err, "Generic Error." },
107  { Et::disp_com_prb, "Display communication problem." },
108  { Et::temp_meas_prob, "Temperature measurement problem." },
109  { Et::encod_oor, "Encoder: Out of range." },
110  { Et::edm2_err, "EDM2: Error in the External Device Monitoring." },
111  { Et::edm1_err, "EDM1: Error in the External Device Monitoring." },
112  { Et::conf_err, "WAITING_CONF: The safety laser scanner waits for a configuration (e.g. after restoring a configuration). - "
113  "Configure the safety laser scanner." },
114  { Et::out_of_range_err, "Out of range error." },
115  { Et::temp_range_err, "Temperature out of range." },
116  { Et::encoder_generic_err, "Encoder: Generic error." },
117  { Et::unused, "Unexpected error" } \
118 };
119 
120 // clang-format off
121  #define REV(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) arg8, arg7, arg6, arg5, arg4, arg3, arg2, arg1
122 
123  static constexpr std::array<std::array<ErrorType, 8>, 9> ERROR_BITS{{
124  //Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0
125  { REV(Et::ossd1_oc, Et::ossd_shrt_c, Et::ossd_integr, Et::intern, Et::intern, Et::intern, Et::intern, Et::intern) },
126  { REV(Et::win_cln_al, Et::power_supply, Et::netw_prb, Et::dust_crc_fl, Et::intern, Et::intern, Et::unused, Et::ossd2_overcur) },
127  { REV(Et::meas_prob, Et::intern, Et::intern, Et::intern, Et::incoherence, Et::zone_inval_trans, Et::zone_invalid_conf, Et::win_cln_warn) },
128  { REV(Et::intern, Et::intern, Et::intern, Et::generic_err, Et::disp_com_prb, Et::intern, Et::intern, Et::temp_meas_prob) },
129  { REV(Et::intern, Et::intern, Et::edm2_err, Et::edm1_err, Et::conf_err, Et::out_of_range_err, Et::temp_range_err, Et::intern) },
130  { REV(Et::unused, Et::unused, Et::unused, Et::unused, Et::intern, Et::intern, Et::encoder_generic_err, Et::encod_oor) },
131  { REV(Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused) },
132  { REV(Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused) },
133  { REV(Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused, Et::unused) },
134  }};
135 // clang-format on
136 
149 {
150 public:
151  using ByteLocation = size_t;
152  using BitLocation = size_t;
153  constexpr ErrorLocation(const ByteLocation& byte, const BitLocation& bit) : byte_(byte), bit_(bit){};
154 
155  inline constexpr ByteLocation byte() const
156  {
157  return byte_;
158  };
159 
160  inline constexpr BitLocation bit() const
161  {
162  return bit_;
163  };
164 
165 private:
168 };
169 
181 class Message
182 {
183 public:
184  constexpr Message(const configuration::ScannerId& id, const diagnostic::ErrorLocation& location);
185  constexpr bool operator==(const diagnostic::Message& rhs) const;
186 
187  friend RawChunk serialize(const std::vector<diagnostic::Message>& messages);
188 
190  {
191  return id_;
192  }
193 
194  constexpr ErrorLocation errorLocation() const
195  {
196  return error_location_;
197  }
198 
199  constexpr ErrorType diagnosticCode() const
200  {
202  }
203 
204 private:
207 };
208 
209 constexpr inline Message::Message(const configuration::ScannerId& id, const ErrorLocation& location)
210  : id_(id), error_location_(location)
211 {
212 }
213 
214 constexpr inline bool Message::operator==(const Message& rhs) const
215 {
216  return (error_location_.bit() == rhs.error_location_.bit() && error_location_.byte() == rhs.error_location_.byte() &&
217  id_ == rhs.id_);
218 }
219 
220 // Store ambiguous errors for additional output
221 static const std::set<Et> AMBIGUOUS_DIAGNOSTIC_CODES = { Et::unused, Et::intern };
222 
223 inline bool isAmbiguous(const ErrorType& code)
224 {
225  return AMBIGUOUS_DIAGNOSTIC_CODES.find(code) != AMBIGUOUS_DIAGNOSTIC_CODES.end();
226 }
227 
228 std::ostream& operator<<(std::ostream& os, const diagnostic::Message& msg);
229 
230 } // namespace diagnostic
231 } // namespace monitoring_frame
232 } // namespace data_conversion_layer
233 } // namespace psen_scan_v2_standalone
234 
235 #endif // PSEN_SCAN_V2_STANDALONE_DIAGNOSTICS_H
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorLocation
Defines a byte and bit position of an error in the diagnostic chunk.
Definition: diagnostics.h:148
psen_scan_v2_standalone::configuration::ScannerId
ScannerId
Definition: scanner_ids.h:27
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorLocation::byte_
ByteLocation byte_
Definition: diagnostics.h:163
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::ossd_shrt_c
@ ossd_shrt_c
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message::serialize
friend RawChunk serialize(const std::vector< diagnostic::Message > &messages)
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::netw_prb
@ netw_prb
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message::operator==
constexpr bool operator==(const diagnostic::Message &rhs) const
Definition: diagnostics.h:214
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType
ErrorType
Definition: diagnostics.h:53
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::conf_err
@ conf_err
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorLocation::BitLocation
size_t BitLocation
Definition: diagnostics.h:152
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::RawChunk
std::array< uint8_t, diagnostic::RAW_CHUNK_LENGTH_IN_BYTES > RawChunk
Definition: diagnostics.h:51
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorLocation::ByteLocation
size_t ByteLocation
Definition: diagnostics.h:151
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::power_supply
@ power_supply
psen_scan_v2_standalone::configuration::VALID_SCANNER_IDS
static constexpr std::array< ScannerId, 4 > VALID_SCANNER_IDS
Definition: scanner_ids.h:35
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message::scannerId
constexpr configuration::ScannerId scannerId() const
Definition: diagnostics.h:189
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::RAW_CHUNK_UNUSED_OFFSET_IN_BYTES
static constexpr uint32_t RAW_CHUNK_UNUSED_OFFSET_IN_BYTES
Definition: diagnostics.h:46
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorLocation::ErrorLocation
constexpr ErrorLocation(const ByteLocation &byte, const BitLocation &bit)
Definition: diagnostics.h:153
REV
#define REV(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
Definition: diagnostics.h:121
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message::errorLocation
constexpr ErrorLocation errorLocation() const
Definition: diagnostics.h:194
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::operator<<
std::ostream & operator<<(std::ostream &os, const diagnostic::Message &msg)
Definition: diagnostics.cpp:31
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message::error_location_
ErrorLocation error_location_
Definition: diagnostics.h:206
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::AMBIGUOUS_DIAGNOSTIC_CODES
static const std::set< Et > AMBIGUOUS_DIAGNOSTIC_CODES
Definition: diagnostics.h:221
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ERROR_BITS
static constexpr std::array< std::array< ErrorType, 8 >, 9 > ERROR_BITS
Definition: diagnostics.h:123
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::dust_crc_fl
@ dust_crc_fl
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::intern
@ intern
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message::diagnosticCode
constexpr ErrorType diagnosticCode() const
Definition: diagnostics.h:199
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorMessage
std::string ErrorMessage
Definition: diagnostics.h:86
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::RAW_CHUNK_LENGTH_FOR_ONE_DEVICE_IN_BYTES
static constexpr uint32_t RAW_CHUNK_LENGTH_FOR_ONE_DEVICE_IN_BYTES
Contains constants and types needed to define the diagnostic::Message.
Definition: diagnostics.h:45
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message::id_
configuration::ScannerId id_
Definition: diagnostics.h:205
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::disp_com_prb
@ disp_com_prb
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::isAmbiguous
bool isAmbiguous(const ErrorType &code)
Definition: diagnostics.h:223
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorLocation::byte
constexpr ByteLocation byte() const
Definition: diagnostics.h:155
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message
Defines an Diagnostic message by defining the ErrorLocation and a scanner ID.
Definition: diagnostics.h:181
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::ossd1_oc
@ ossd1_oc
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorLocation::bit_
BitLocation bit_
Definition: diagnostics.h:167
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::encoder_generic_err
@ encoder_generic_err
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::zone_invalid_conf
@ zone_invalid_conf
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::temp_range_err
@ temp_range_err
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::ossd2_overcur
@ ossd2_overcur
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::win_cln_al
@ win_cln_al
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorLocation::bit
constexpr BitLocation bit() const
Definition: diagnostics.h:160
scanner_ids.h
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::edm1_err
@ edm1_err
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::unused
@ unused
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::meas_prob
@ meas_prob
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::Message::Message
constexpr Message(const configuration::ScannerId &id, const diagnostic::ErrorLocation &location)
Definition: diagnostics.h:209
psen_scan_v2_standalone
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
Definition: udp_client.h:41
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::int_com_prb
@ int_com_prb
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::ossd_integr
@ ossd_integr
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::generic_err
@ generic_err
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::edm2_err
@ edm2_err
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::temp_meas_prob
@ temp_meas_prob
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::RAW_CHUNK_LENGTH_IN_BYTES
static constexpr uint32_t RAW_CHUNK_LENGTH_IN_BYTES
Definition: diagnostics.h:47
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::win_cln_warn
@ win_cln_warn
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ERROR_CODE_TO_STRING
static const std::map< ErrorType, ErrorMessage > ERROR_CODE_TO_STRING
Definition: diagnostics.h:89
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::zone_inval_trans
@ zone_inval_trans
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::out_of_range_err
@ out_of_range_err
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::encod_oor
@ encod_oor
psen_scan_v2_standalone::data_conversion_layer::monitoring_frame::diagnostic::ErrorType::incoherence
@ incoherence


psen_scan_v2
Author(s): Pilz GmbH + Co. KG
autogenerated on Sat Jun 22 2024 02:46:11