pub struct ProfileCollector { /* private fields */ }Expand description
No-allocation collector for one logical 1–10 step heater-profile scan.
Call Self::ingest_batch after every hardware poll. In parallel mode,
invalid intermediate/dummy conversions are held as a pending value; the
gas-valid conversion wins, or the last invalid conversion is retained when
the gas index advances or Self::finish is called. A gas-index rollover
freezes the collector so fields from two scans can never be mixed.
Implementations§
Source§impl ProfileCollector
impl ProfileCollector
Sourcepub const fn new(
mode: OperationMode,
expected_steps: u8,
) -> Result<Self, ProfileCollectorError>
pub const fn new( mode: OperationMode, expected_steps: u8, ) -> Result<Self, ProfileCollectorError>
Construct an empty collector for one sequential or parallel profile.
§Errors
Returns an error for a zero/over-length profile or a non-profile mode.
Sourcepub fn ingest_batch(&mut self, fields: &Measurements, observed_offset_us: u32)
pub fn ingest_batch(&mut self, fields: &Measurements, observed_offset_us: u32)
Feed all newly available fields from one hardware read, oldest first.
All fields in the batch receive the same host-observed read offset.
Call Self::ingest individually if the application has finer timing.
Sourcepub fn ingest(&mut self, measurement: Measurement, observed_offset_us: u32)
pub fn ingest(&mut self, measurement: Measurement, observed_offset_us: u32)
Feed one newly read field into the collector.
Sourcepub fn finish(&mut self, reason: ProfileFinishReason)
pub fn finish(&mut self, reason: ProfileFinishReason)
Finalize a bounded polling attempt and retain a last invalid parallel conversion when no gas-valid conversion arrived before the deadline.
Sourcepub const fn expected_steps(&self) -> u8
pub const fn expected_steps(&self) -> u8
Configured number of profile steps.
Sourcepub const fn observed_steps(&self) -> u32
pub const fn observed_steps(&self) -> u32
Number of heater steps for which a terminal field was retained.
Sourcepub const fn steps(&self) -> &[Option<ProfileStep>; 10]
pub const fn steps(&self) -> &[Option<ProfileStep>; 10]
Fixed-capacity slots indexed by heater/gas index.
Sourcepub fn step(&self, gas_index: u8) -> Option<&ProfileStep>
pub fn step(&self, gas_index: u8) -> Option<&ProfileStep>
Return one retained step by gas index.
Sourcepub const fn observed_mask(&self) -> u16
pub const fn observed_mask(&self) -> u16
Bitmap of expected heater steps for which a terminal field was kept.
Sourcepub const fn gas_valid_mask(&self) -> u16
pub const fn gas_valid_mask(&self) -> u16
Bitmap of retained steps with the gas-valid bit set.
Sourcepub const fn heater_stable_mask(&self) -> u16
pub const fn heater_stable_mask(&self) -> u16
Bitmap of retained steps with the heater-stable bit set.
Sourcepub const fn duplicate_mask(&self) -> u16
pub const fn duplicate_mask(&self) -> u16
Bitmap of valid gas indexes for which a duplicate field was seen.
Sourcepub const fn observed_field_count(&self) -> u16
pub const fn observed_field_count(&self) -> u16
Saturating count of every new-status field supplied to the collector.
This includes duplicates, invalid indexes, out-of-order fields, and fields ignored after collection froze, making polling behavior fully observable even when a field is not retained as a profile step.
Sourcepub const fn observed_field_count_overflowed(&self) -> bool
pub const fn observed_field_count_overflowed(&self) -> bool
Whether Self::observed_field_count saturated at u16::MAX.
Sourcepub const fn missing_mask(&self) -> u16
pub const fn missing_mask(&self) -> u16
Bitmap of expected steps for which no terminal field was retained.
Sourcepub const fn gas_invalid_mask(&self) -> u16
pub const fn gas_invalid_mask(&self) -> u16
Bitmap of observed steps that did not have valid gas data.
Sourcepub const fn is_structurally_complete(&self) -> bool
pub const fn is_structurally_complete(&self) -> bool
Whether every configured step has a retained terminal field.
Sourcepub const fn all_steps_gas_valid(&self) -> bool
pub const fn all_steps_gas_valid(&self) -> bool
Whether every configured step has yielded a gas-valid conversion.
This is the safe condition for explicitly stopping a repeating parallel scan without confusing dummy fields with completed steps.
Sourcepub const fn all_steps_heater_stable(&self) -> bool
pub const fn all_steps_heater_stable(&self) -> bool
Whether all retained profile steps report heater stability.
Sourcepub const fn is_frozen(&self) -> bool
pub const fn is_frozen(&self) -> bool
Whether this collector stopped accepting fields after a profile wrap
or an explicit Self::finish call.
Sourcepub const fn finish_reason(&self) -> Option<ProfileFinishReason>
pub const fn finish_reason(&self) -> Option<ProfileFinishReason>
Why this profile stopped accepting measurements, if it has finished.
Sourcepub const fn counters(&self) -> &ProfileCounters
pub const fn counters(&self) -> &ProfileCounters
Loss, duplicate, rollover, and invalid-index accounting.
Trait Implementations§
Source§impl Clone for ProfileCollector
impl Clone for ProfileCollector
impl Copy for ProfileCollector
Source§impl Debug for ProfileCollector
impl Debug for ProfileCollector
impl Eq for ProfileCollector
Source§impl Format for ProfileCollectorwhere
OperationMode: Format,
[Option<ProfileStep>; 10]: Format,
Option<ProfileStep>: Format,
Option<u8>: Format,
[Option<Fingerprint>; 3]: Format,
Option<ProfileFinishReason>: Format,
ProfileCounters: Format,
Available on crate feature defmt only.
impl Format for ProfileCollectorwhere
OperationMode: Format,
[Option<ProfileStep>; 10]: Format,
Option<ProfileStep>: Format,
Option<u8>: Format,
[Option<Fingerprint>; 3]: Format,
Option<ProfileFinishReason>: Format,
ProfileCounters: Format,
defmt only.