fixed hardware_db and improved stability and robustness of generic sal
This commit is contained in:
@@ -49,8 +49,17 @@ impl<T: PreflightAuditor + ?Sized> PreflightAuditor for Arc<T> {
|
||||
|
||||
/// Suppresses conflicting daemons (tlp, thermald).
|
||||
pub trait EnvironmentGuard: Send + Sync {
|
||||
fn suppress(&mut self) -> Result<()>;
|
||||
fn restore(&mut self) -> Result<()>;
|
||||
fn suppress(&self) -> Result<()>;
|
||||
fn restore(&self) -> Result<()>;
|
||||
}
|
||||
|
||||
impl<T: EnvironmentGuard + ?Sized> EnvironmentGuard for Arc<T> {
|
||||
fn suppress(&self) -> Result<()> {
|
||||
(**self).suppress()
|
||||
}
|
||||
fn restore(&self) -> Result<()> {
|
||||
(**self).restore()
|
||||
}
|
||||
}
|
||||
|
||||
/// Read-only interface for standardized metrics.
|
||||
@@ -97,15 +106,23 @@ impl<T: ActuatorBus + ?Sized> ActuatorBus for Arc<T> {
|
||||
|
||||
/// Concurrent monitor for catastrophic states.
|
||||
pub trait HardwareWatchdog: Send + Sync {
|
||||
fn check_emergency(&self) -> Result<bool>;
|
||||
fn get_safety_status(&self) -> Result<SafetyStatus>;
|
||||
}
|
||||
|
||||
impl<T: HardwareWatchdog + ?Sized> HardwareWatchdog for Arc<T> {
|
||||
fn check_emergency(&self) -> Result<bool> {
|
||||
(**self).check_emergency()
|
||||
fn get_safety_status(&self) -> Result<SafetyStatus> {
|
||||
(**self).get_safety_status()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum SafetyStatus {
|
||||
Nominal,
|
||||
Warning(String),
|
||||
Critical(String),
|
||||
EmergencyAbort(String),
|
||||
}
|
||||
|
||||
/// Aggregate trait for a complete platform implementation.
|
||||
pub trait PlatformSal: PreflightAuditor + SensorBus + ActuatorBus + EnvironmentGuard + HardwareWatchdog {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user