22 #include <fmt/format.h> 36 namespace data_conversion_layer
38 namespace monitoring_frame
53 : device_status_(device_status)
55 , working_mode_(working_mode)
56 , transaction_type_(transaction_type)
57 , scanner_id_(scanner_id)
58 , from_theta_(from_theta)
59 , resolution_(resolution)
63 static constexpr
double toMeter(
const uint16_t& value)
67 return std::numeric_limits<double>::infinity();
69 return static_cast<double>(value) / 1000.;
75 uint16_t retval{ value };
76 return static_cast<double>(retval & 0b0011111111111111);
84 ss.write(data.data(), num_bytes);
96 switch (static_cast<AdditionalFieldHeaderID>(additional_header.id()))
102 additional_header.length(),
105 uint32_t scan_counter_read_buffer;
106 raw_processing::read<uint32_t>(ss, scan_counter_read_buffer);
111 const size_t num_measurements{
static_cast<size_t>(additional_header.length()) /
126 additional_header.length(),
129 uint8_t zone_set_read_buffer;
130 raw_processing::read<uint8_t>(ss, zone_set_read_buffer);
138 additional_header.length(),
149 const size_t num_measurements{
static_cast<size_t>(additional_header.length()) /
158 fmt::format(
"Header Id {:#04x} unknown. Cannot read additional field of monitoring frame on position {}.",
159 additional_header.id(),
163 return msg_builder.
build();
168 auto const id = raw_processing::read<AdditionalFieldHeader::Id>(is);
169 auto length = raw_processing::read<AdditionalFieldHeader::Length>(is);
171 if (length >= max_num_bytes)
174 fmt::format(
"Length given in header of additional field is too large: {}, id: {:#04x}", length,
id));
190 std::array<uint8_t, 3 * (RAW_CHUNK_LENGTH_RESERVED_IN_BYTES + RAW_CHUNK_PHYSICAL_INPUT_SIGNALS_IN_BYTES)>>(is);
192 raw_processing::read<std::array<uint8_t, RAW_CHUNK_LENGTH_RESERVED_IN_BYTES>>(is);
195 raw_processing::read<std::array<uint8_t, RAW_CHUNK_LENGTH_RESERVED_IN_BYTES>>(is);
206 std::vector<diagnostic::Message> diagnostic_messages;
209 raw_processing::read<std::array<uint8_t, diagnostic::RAW_CHUNK_UNUSED_OFFSET_IN_BYTES>>(is);
215 const auto raw_byte = raw_processing::read<uint8_t>(is);
216 const std::bitset<8> raw_bits(raw_byte);
218 for (
size_t bit_n = 0; bit_n < raw_bits.size(); ++bit_n)
222 diagnostic_messages.push_back(
diagnostic::Message(static_cast<configuration::ScannerId>(scanner_id),
228 return diagnostic_messages;
234 const auto device_status = raw_processing::read<FixedFields::DeviceStatus>(is);
235 const auto op_code = raw_processing::read<FixedFields::OpCode>(is);
236 const auto working_mode = raw_processing::read<FixedFields::WorkingMode>(is);
237 const auto transaction_type = raw_processing::read<FixedFields::TransactionType>(is);
238 const auto scanner_id = raw_processing::read<configuration::ScannerId>(is);
240 const auto from_theta = raw_processing::read<int16_t, FixedFields::FromTheta>(is);
241 const auto resolution = raw_processing::read<int16_t, FixedFields::Resolution>(is);
247 0.1,
"monitoring_frame::Message",
"Unexpected opcode during deserialization of MonitoringFrame.");
266 return FixedFields(device_status, op_code, working_mode, transaction_type, scanner_id, from_theta, resolution);
static constexpr uint32_t RAW_CHUNK_LENGTH_IN_BYTES
void read(std::istream &is, T &data)
static constexpr uint16_t SIGNAL_TOO_LATE
MessageBuilder & scanCounter(uint32_t scan_counter)
MessageBuilder & intensities(const std::vector< double > &intensities)
static constexpr uint32_t ONLINE_WORKING_MODE
Higher level data type representing a single monitoring frame.
The information included in every single monitoring frame.
Defines an Diagnostic message by defining the ErrorLocation and a scanner ID.
std::vector< diagnostic::Message > deserializeMessages(std::istream &is)
static constexpr uint16_t NUMBER_OF_BYTES_SCAN_COUNTER
FromTheta fromTheta() const
static constexpr uint16_t NO_SIGNAL_ARRIVED
configuration::ScannerId scannerId() const
monitoring_frame::Message deserialize(const data_conversion_layer::RawData &data, const std::size_t &num_bytes)
AdditionalFieldHeader readAdditionalField(std::istream &is, const std::size_t &max_num_bytes)
MessageBuilder & fromTheta(const util::TenthOfDegree &from_theta)
static constexpr std::array< ScannerId, 4 > VALID_SCANNER_IDS
MessageBuilder & measurements(const std::vector< double > &measurements)
Resolution resolution() const
FixedFields readFixedFields(std::istream &is)
MessageBuilder & diagnosticMessages(const std::vector< diagnostic::Message > &diagnostic_messages)
static constexpr uint32_t RAW_CHUNK_LENGTH_FOR_ONE_DEVICE_IN_BYTES
Contains constants and types needed to define the diagnostic::Message.
MessageBuilder & activeZoneset(uint8_t active_zoneset)
static constexpr uint16_t NUMBER_OF_BYTES_SINGLE_MEASUREMENT
PinData deserializePins(std::istream &is)
FixedFields(DeviceStatus device_status, OpCode op_code, WorkingMode working_mode, TransactionType transaction_type, configuration::ScannerId scanner_id, FromTheta from_theta, Resolution resolution)
Represents the IO PIN field of a monitoring frame.
std::vector< char > RawData
Exception thrown on problems with the additional fields with fixed size.
MessageBuilder & iOPinData(const io::PinData &io_pin_data)
void deserializePinField(std::istream &is, std::array< std::bitset< 8 >, ChunkSize > &pin_states)
static constexpr std::array< std::array< ErrorType, 8 >, 9 > ERROR_BITS
#define PSENSCAN_ERROR_THROTTLE(period, name,...)
MessageBuilder & scannerId(configuration::ScannerId scanner_id)
Root namespace in which the software components to communicate with the scanner (firmware-version: 2)...
MessageBuilder & resolution(const util::TenthOfDegree &resolution)
static constexpr uint16_t NUMBER_OF_BYTES_ZONE_SET
static constexpr double toMeter(const uint16_t &value)
static constexpr double toIntensities(const uint16_t &value)
Definition for the type and length of an additional field in a monitoring frame.
static constexpr uint8_t MAX_SCANNER_ID
static constexpr uint32_t GUI_MONITORING_TRANSACTION
Exception thrown on problems during the extraction of the measurement data.
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
AdditionalFieldHeader(Id id, Length length)
static constexpr uint32_t OP_CODE_MONITORING_FRAME
Defines a byte and bit position of an error in the diagnostic chunk.
std::array< std::bitset< 8 >, NUMBER_OF_OUTPUT_BYTES > output_state
std::array< std::bitset< 8 >, NUMBER_OF_INPUT_BYTES > input_state
Helper class representing angles in tenth of degree.