From dab02a1cc59b62f086eaa2e31858a1645a32d016 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 3 Apr 2024 11:53:16 +0200 Subject: [PATCH] remove re-export --- satrs/src/lib.rs | 2 - satrs/src/pus/mod.rs | 118 ++----------------------------------- satrs/src/pus/scheduler.rs | 2 +- satrs/src/request.rs | 15 +++-- 4 files changed, 14 insertions(+), 123 deletions(-) diff --git a/satrs/src/lib.rs b/satrs/src/lib.rs index ca5106b..7ba8be2 100644 --- a/satrs/src/lib.rs +++ b/satrs/src/lib.rs @@ -52,7 +52,5 @@ pub mod params; pub use spacepackets; -pub use queue::ChannelId; - /// Generic component ID type. pub type ComponentId = u64; diff --git a/satrs/src/pus/mod.rs b/satrs/src/pus/mod.rs index 23743a9..64187e4 100644 --- a/satrs/src/pus/mod.rs +++ b/satrs/src/pus/mod.rs @@ -305,7 +305,7 @@ pub trait ActiveRequestProvider { } /// This trait is an abstraction for the routing of PUS request to a dedicated -/// recipient using the generic [TargetId]. +/// recipient using the generic [ComponentId]. pub trait PusRequestRouter { type Error; @@ -439,8 +439,9 @@ pub mod alloc_mod { /// type. /// /// Having a dedicated trait for this allows maximum flexiblity and tailoring of the standard. - /// The only requirement is that a valid [TargetId] and a request instance are returned by the - /// core conversion function. + /// The only requirement is that a valid active request information instance and a request + /// are returned by the core conversion function. The active request type needs to fulfill + /// the [ActiveRequestProvider] trait bound. /// /// The user should take care of performing the error handling as well. Some of the following /// aspects might be relevant: @@ -877,117 +878,6 @@ pub mod std_mod { pub type CrossbeamTcReceiver = cb::Receiver; } - /// This is a high-level handler for the generic PUS services which need to convert PUS - /// commands into a request/reply pattern. - /// - /// It performs the following handling steps: - /// - /// 1. Retrieve the next TC packet from the [PusServiceHelper]. The [EcssTcInMemConverter] - /// allows to configure the used telecommand memory backend. - /// 2. Convert the TC to a targeted action request using the provided - /// [PusTcToRequestConverter]. The generic error type is constrained to the - /// [PusPacketHandlingError] for the concrete implementation which offers a packet handler. - /// 3. Route the action request using the provided [PusRequestRouter]. - /* - pub struct PusTargetedRequestHandler< - TcReceiver: EcssTcReceiverCore, - TmSender: EcssTmSenderCore, - TcInMemConverter: EcssTcInMemConverter, - VerificationReporter: VerificationReportingProvider, - RequestConverter: PusTcToRequestConverter, - RequestRouter: PusRequestRouter, - Request, - RoutingError = GenericRoutingError, - > { - service_helper: - PusServiceHelper, - pub request_converter: RequestConverter, - pub request_router: RequestRouter, - phantom: PhantomData, - } - - // pub trait PusReplyHandlerProvider { - // fn add_routed_request(&mut self, request_id: RequestId, active_request: ActiveRequest); - // } - impl< - TcReceiver: EcssTcReceiverCore, - TmSender: EcssTmSenderCore, - TcInMemConverter: EcssTcInMemConverter, - VerificationReporter: VerificationReportingProvider, - RequestConverter: PusTcToRequestConverter, - RequestRouter: PusRequestRouter, - Request, - RoutingError: Clone, - > - PusTargetedRequestHandler< - TcReceiver, - TmSender, - TcInMemConverter, - VerificationReporter, - RequestConverter, - RequestRouter, - Request, - RoutingError, - > - where - PusPacketHandlingError: From, - { - pub fn new( - service_helper: PusServiceHelper< - TcReceiver, - TmSender, - TcInMemConverter, - VerificationReporter, - >, - request_converter: RequestConverter, - request_router: RequestRouter, - ) -> Self { - Self { - service_helper, - request_converter, - request_router, - phantom: PhantomData, - } - } - - /// Core function to poll the next TC packet and try to handle it. - pub fn handle_one_tc(&mut self) -> Result { - let possible_packet = self.service_helper.retrieve_and_accept_next_packet()?; - if possible_packet.is_none() { - return Ok(PusPacketHandlerResult::Empty); - } - let ecss_tc_and_token = possible_packet.unwrap(); - let tc = self - .service_helper - .tc_in_mem_converter - .convert_ecss_tc_in_memory_to_reader(&ecss_tc_and_token.tc_in_memory)?; - let mut partial_error = None; - let time_stamp = get_current_cds_short_timestamp(&mut partial_error); - let (target_id, action_request) = self.request_converter.convert( - ecss_tc_and_token.token, - &tc, - &time_stamp, - &self.service_helper.common.verification_handler, - )?; - if let Err(e) = - self.request_router - .route(target_id, action_request, ecss_tc_and_token.token) - { - self.request_router.handle_error( - target_id, - ecss_tc_and_token.token, - &tc, - e.clone(), - &time_stamp, - &self.service_helper.common.verification_handler, - ); - return Err(e.into()); - } - Ok(PusPacketHandlerResult::RequestHandled) - } - } - */ - #[derive(Debug, Clone, PartialEq, Eq)] pub struct ActivePusRequestStd { target_id: ComponentId, diff --git a/satrs/src/pus/scheduler.rs b/satrs/src/pus/scheduler.rs index 0c2f4db..e223990 100644 --- a/satrs/src/pus/scheduler.rs +++ b/satrs/src/pus/scheduler.rs @@ -381,7 +381,7 @@ pub mod alloc_mod { /// a [crate::pool::PoolProvider] API. This data structure just tracks the store /// addresses and their release times and offers a convenient API to insert and release /// telecommands and perform other functionality specified by the ECSS standard in section 6.11. - /// The time is tracked as a [spacepackets::time::UnixTimestamp] but the only requirement to + /// The time is tracked as a [spacepackets::time::UnixTime] but the only requirement to /// the timekeeping of the user is that it is convertible to that timestamp. /// /// The standard also specifies that the PUS scheduler can be enabled and disabled. diff --git a/satrs/src/request.rs b/satrs/src/request.rs index 66ce5d3..be520f0 100644 --- a/satrs/src/request.rs +++ b/satrs/src/request.rs @@ -89,6 +89,10 @@ impl fmt::Display for UniqueApidTargetId { } } +/// This contains metadata information which might be useful when used together with a +/// generic message tpye. +/// +/// This could for example be used to build request/reply patterns or state tracking for request. #[derive(Debug, Copy, PartialEq, Eq, Clone)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] pub struct MessageMetadata { @@ -113,17 +117,16 @@ impl MessageMetadata { } } -/// Generic message type which is associated with a sender using a [ChannelId] and associated -/// with a request using a [RequestId]. +/// Generic message type which adds [metadata][MessageMetadata] to a generic message typ. #[derive(Debug, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub struct GenericMessage { +pub struct GenericMessage { pub requestor_info: MessageMetadata, - pub message: MSG, + pub message: Message, } -impl GenericMessage { - pub fn new(requestor_info: MessageMetadata, message: MSG) -> Self { +impl GenericMessage { + pub fn new(requestor_info: MessageMetadata, message: Message) -> Self { Self { requestor_info, message,