22 #include <fmt/format.h>
36 namespace data_conversion_layer
38 namespace monitoring_frame
40 using namespace std::placeholders;
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);
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));
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)
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);