@@ -371,7 +371,7 @@ using Slot = std::array<char, 16>;
371
371
372
372
struct SlotValues {
373
373
unsigned char id;
374
- unsigned char index ;
374
+ unsigned char slot_id ;
375
375
unsigned char type;
376
376
unsigned char slot;
377
377
};
@@ -418,7 +418,7 @@ Slot make_slot(SlotValues values) {
418
418
419
419
auto it = out.begin ();
420
420
it = append_slot_number_impl (it, values.id );
421
- it = append_slot_number_impl (it, values.index );
421
+ it = append_slot_number_impl (it, values.slot_id );
422
422
it = append_slot_number_impl (it, values.type );
423
423
append_slot_number_impl (it, values.slot );
424
424
@@ -440,11 +440,14 @@ class Magnitude {
440
440
{}
441
441
442
442
BaseSensorPtr sensor; // Sensor object, *cannot be empty*
443
+
443
444
unsigned char type; // Type of measurement, returned by the BaseSensor::type(slot)
444
445
unsigned char slot; // Sensor slot # taken by the magnitude, used to access the measurement
445
446
446
447
unsigned char index_global; // N'th magnitude of it's type, across all of the active sensors
447
- unsigned char slot_global; // Global slot aka index of the sensor, across all of the active sensors
448
+ unsigned char slot_global; // Global slot aka index of the sensor, across all of the sensors with the same ID
449
+
450
+ unsigned char slot_id; // Slot ID provided by the sensor. Expected to be varying between different instances of the sensor
448
451
449
452
Unit units { Unit::None }; // Current units of measurement
450
453
unsigned char decimals { 0u }; // Number of decimals in textual representation
@@ -1350,7 +1353,9 @@ String format_slot(const Magnitude& magnitude) {
1350
1353
const auto slot = make_slot (
1351
1354
SlotValues{
1352
1355
.id = magnitude.sensor ->id (),
1353
- .index = static_cast <unsigned char >(magnitude.slot_global + 1 ),
1356
+ .slot_id = (magnitude.slot_id != 0 )
1357
+ ? magnitude.slot_id
1358
+ : static_cast <unsigned char >(magnitude.slot_global + 1 ),
1354
1359
.type = magnitude.type ,
1355
1360
.slot = static_cast <unsigned char >(magnitude.slot + 1 ),
1356
1361
});
@@ -1770,6 +1775,7 @@ Magnitude& add(BaseSensorPtr sensor, unsigned char type, unsigned char slot) {
1770
1775
out.slot = slot;
1771
1776
out.index_global = types_count_add (type);
1772
1777
out.slot_global = instance_count_add (sensor->id ());
1778
+ out.slot_id = sensor->address_u8 (slot);
1773
1779
1774
1780
internal::magnitudes.emplace_back (std::move (out));
1775
1781
return internal::magnitudes.back ();
0 commit comments