FDIR extensions and improvements for MGM device handler
This commit is contained in:
@@ -62,11 +62,11 @@ pub struct SensorData {
|
||||
#[strum_discriminants(derive(num_enum::IntoPrimitive))]
|
||||
#[repr(u16)]
|
||||
pub enum Event {
|
||||
/// The SPI fault counter exceeded its threshold, the component was marked faulty and
|
||||
/// commanded off.
|
||||
/// The SPI fault counter exceeded its threshold. Followed by a recovery event.
|
||||
SpiFaultThresholdExceeded,
|
||||
/// A commanded or autonomous mode transition completed.
|
||||
ModeChanged(crate::DeviceMode),
|
||||
Recovery(satrs::fdir::RecoveryEvent),
|
||||
}
|
||||
|
||||
impl crate::Message for Event {
|
||||
@@ -77,7 +77,10 @@ impl crate::Message for Event {
|
||||
|
||||
impl crate::EventId for Event {
|
||||
fn event_id(&self) -> u16 {
|
||||
EventDiscriminants::from(self).into()
|
||||
match self {
|
||||
Event::Recovery(event) => crate::recovery_event_id(*event),
|
||||
_ => EventDiscriminants::from(self).into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -175,6 +175,14 @@ pub trait EventId {
|
||||
fn event_id(&self) -> u16;
|
||||
}
|
||||
|
||||
/// Start of the event ID range for generic FDIR events, which are embedded into the event types
|
||||
/// of the components. These events have the same ID for all components.
|
||||
pub const FDIR_EVENT_ID_BASE: u16 = 0x100;
|
||||
|
||||
pub const fn recovery_event_id(event: satrs::fdir::RecoveryEvent) -> u16 {
|
||||
FDIR_EVENT_ID_BASE + event as u16
|
||||
}
|
||||
|
||||
/// Generic device mode which covers the requirements of most devices.
|
||||
///
|
||||
/// The states are related both to the physical and the logical state of the device. Some
|
||||
|
||||
Reference in New Issue
Block a user