that seems to work

This commit is contained in:
Robin Müller 2022-10-23 23:15:11 +02:00
parent fe363d2962
commit 6fe3738364
No known key found for this signature in database
GPG Key ID: 9C287E88FED11DF3
2 changed files with 25 additions and 2 deletions

View File

@ -18,7 +18,7 @@ pub enum Severity {
HIGH = 3, HIGH = 3,
} }
pub trait EventProvider: PartialEq + Eq + Copy + Clone + Hash { pub trait EventProvider: EcssEnumeration + PartialEq + Eq + Copy + Clone + Hash {
type Raw; type Raw;
type GroupId; type GroupId;
type UniqueId; type UniqueId;

View File

@ -1,6 +1,9 @@
use crate::events::EventProvider; use crate::events::EventProvider;
use alloc::boxed::Box;
use hashbrown::HashSet; use hashbrown::HashSet;
use crate::pus::event::EventReporter;
use crate::pus::{EcssTmError, EcssTmSender};
#[cfg(feature = "heapless")] #[cfg(feature = "heapless")]
pub use heapless_mod::*; pub use heapless_mod::*;
@ -84,4 +87,24 @@ pub mod heapless_mod {
} }
} }
pub struct PusEventManager {} pub struct PusEventManager<BackendError, Provider: EventProvider> {
reporter: EventReporter,
backend: Box<dyn PusEventMgmtBackendProvider<Provider, Error = BackendError>>,
}
impl<BackendError, Provider: EventProvider> PusEventManager<BackendError, Provider> {
pub fn handle_event<E>(
&mut self,
sender: &mut (impl EcssTmSender<E> + ?Sized),
time_stamp: &[u8],
event: Provider,
aux_data: Option<&[u8]>,
) -> Result<bool, EcssTmError<E>> {
if !self.backend.event_enabled(&event) {
return Ok(false);
}
self.reporter
.event_info(sender, time_stamp, event, aux_data)
.map(|_| true)
}
}