54 lignes
1.6 KiB
Rust
54 lignes
1.6 KiB
Rust
//! Gestionnaire de Diagnostics et Métriques de Santé Système (DiagManager)
|
|
|
|
use crate::boot::ResetReason;
|
|
|
|
/// Structure de métriques et compteurs de santé système
|
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
|
pub struct SystemDiagnostics {
|
|
pub last_reset_reason: ResetReason,
|
|
pub davis_packets_received: u32,
|
|
pub davis_crc_errors: u32,
|
|
pub davis_sync_losses: u16,
|
|
pub radio169_transmissions: u32,
|
|
pub radio169_rx_commands: u16,
|
|
pub queue_overflows: u32,
|
|
pub last_vbat_mv: u16,
|
|
pub last_die_temp_deci_c: i16,
|
|
}
|
|
|
|
impl SystemDiagnostics {
|
|
pub const fn new(reset_reason: ResetReason) -> Self {
|
|
Self {
|
|
last_reset_reason: reset_reason,
|
|
davis_packets_received: 0,
|
|
davis_crc_errors: 0,
|
|
davis_sync_losses: 0,
|
|
radio169_transmissions: 0,
|
|
radio169_rx_commands: 0,
|
|
queue_overflows: 0,
|
|
last_vbat_mv: 0,
|
|
last_die_temp_deci_c: 0,
|
|
}
|
|
}
|
|
|
|
pub fn record_davis_rx(&mut self) {
|
|
self.davis_packets_received = self.davis_packets_received.saturating_add(1);
|
|
}
|
|
|
|
pub fn record_davis_crc_error(&mut self) {
|
|
self.davis_crc_errors = self.davis_crc_errors.saturating_add(1);
|
|
}
|
|
|
|
pub fn record_davis_sync_loss(&mut self) {
|
|
self.davis_sync_losses = self.davis_sync_losses.saturating_add(1);
|
|
}
|
|
|
|
pub fn record_169_tx(&mut self) {
|
|
self.radio169_transmissions = self.radio169_transmissions.saturating_add(1);
|
|
}
|
|
|
|
pub fn record_169_cmd(&mut self) {
|
|
self.radio169_rx_commands = self.radio169_rx_commands.saturating_add(1);
|
|
}
|
|
}
|