From f96fe6bdc0fe74db22a22bd98d5436ed0ce1f849 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 10 Apr 2024 15:19:08 +0200 Subject: [PATCH] this makes a bit more sense --- satrs-example/src/pus/action.rs | 28 ++++++++++++++-------------- satrs/src/pus/action.rs | 30 +++++++++++++++--------------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/satrs-example/src/pus/action.rs b/satrs-example/src/pus/action.rs index 59859fc..2967350 100644 --- a/satrs-example/src/pus/action.rs +++ b/satrs-example/src/pus/action.rs @@ -3,7 +3,7 @@ use satrs::action::{ActionRequest, ActionRequestVariant}; use satrs::params::WritableToBeBytes; use satrs::pool::SharedStaticMemoryPool; use satrs::pus::action::{ - ActionReplyVariant, ActivePusActionRequestStd, DefaultActiveActionRequestMap, PusActionReply, + ActionReplyPus, ActionReplyVariant, ActivePusActionRequestStd, DefaultActiveActionRequestMap, }; use satrs::pus::verification::{ FailParams, FailParamsWithStep, TcStateAccepted, TcStateStarted, VerificationReporter, @@ -42,12 +42,12 @@ impl Default for ActionReplyHandler { } } -impl PusReplyHandler for ActionReplyHandler { +impl PusReplyHandler for ActionReplyHandler { type Error = EcssTmtcError; fn handle_unrequested_reply( &mut self, - reply: &GenericMessage, + reply: &GenericMessage, _tm_sender: &impl EcssTmSenderCore, ) -> Result<(), Self::Error> { warn!("received unexpected reply for service 8: {reply:?}"); @@ -56,7 +56,7 @@ impl PusReplyHandler for ActionReplyH fn handle_reply( &mut self, - reply: &GenericMessage, + reply: &GenericMessage, active_request: &ActivePusActionRequestStd, tm_sender: &(impl EcssTmSenderCore + ?Sized), verification_handler: &impl VerificationReportingProvider, @@ -199,7 +199,7 @@ pub fn create_action_service_static( tc_pool: SharedStaticMemoryPool, pus_action_rx: mpsc::Receiver, action_router: GenericRequestRouter, - reply_receiver: mpsc::Receiver>, + reply_receiver: mpsc::Receiver>, ) -> ActionServiceWrapper { let action_request_handler = PusTargetedRequestService::new( PusServiceHelper::new( @@ -226,7 +226,7 @@ pub fn create_action_service_dynamic( tm_funnel_tx: mpsc::Sender, pus_action_rx: mpsc::Receiver, action_router: GenericRequestRouter, - reply_receiver: mpsc::Receiver>, + reply_receiver: mpsc::Receiver>, ) -> ActionServiceWrapper { let action_request_handler = PusTargetedRequestService::new( PusServiceHelper::new( @@ -259,7 +259,7 @@ pub struct ActionServiceWrapper, } @@ -339,7 +339,7 @@ mod tests { DefaultActiveActionRequestMap, ActivePusActionRequestStd, ActionRequest, - PusActionReply, + ActionReplyPus, > { pub fn new_for_action(owner_id: ComponentId, target_id: ComponentId) -> Self { @@ -495,7 +495,7 @@ mod tests { if let CompositeRequest::Action(action_req) = req.message { assert_eq!(action_req.action_id, action_id); assert_eq!(action_req.variant, ActionRequestVariant::NoData); - let action_reply = PusActionReply::new(action_id, ActionReplyVariant::Completed); + let action_reply = ActionReplyPus::new(action_id, ActionReplyVariant::Completed); testbench .reply_tx .send(GenericMessage::new(req.requestor_info, action_reply)) @@ -615,7 +615,7 @@ mod tests { let (req_id, active_req) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]); let active_action_req = ActivePusActionRequestStd::new_from_common_req(action_id, active_req); - let reply = PusActionReply::new(action_id, ActionReplyVariant::Completed); + let reply = ActionReplyPus::new(action_id, ActionReplyVariant::Completed); let generic_reply = GenericMessage::new(MessageMetadata::new(req_id.into(), 0), reply); let result = testbench.handle_reply(&generic_reply, &active_action_req, &[]); assert!(result.is_ok()); @@ -636,7 +636,7 @@ mod tests { let active_action_req = ActivePusActionRequestStd::new_from_common_req(action_id, active_req); let error_code = ResultU16::new(2, 3); - let reply = PusActionReply::new( + let reply = ActionReplyPus::new( action_id, ActionReplyVariant::CompletionFailed { error_code, @@ -663,7 +663,7 @@ mod tests { let (req_id, active_req) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]); let active_action_req = ActivePusActionRequestStd::new_from_common_req(action_id, active_req); - let reply = PusActionReply::new(action_id, ActionReplyVariant::StepSuccess { step: 1 }); + let reply = ActionReplyPus::new(action_id, ActionReplyVariant::StepSuccess { step: 1 }); let generic_reply = GenericMessage::new(MessageMetadata::new(req_id.into(), 0), reply); let result = testbench.handle_reply(&generic_reply, &active_action_req, &[]); assert!(result.is_ok()); @@ -690,7 +690,7 @@ mod tests { let active_action_req = ActivePusActionRequestStd::new_from_common_req(action_id, active_req); let error_code = ResultU16::new(2, 3); - let reply = PusActionReply::new( + let reply = ActionReplyPus::new( action_id, ActionReplyVariant::StepFailed { error_code, @@ -720,7 +720,7 @@ mod tests { fn reply_handling_unrequested_reply() { let mut testbench = ReplyHandlerTestbench::new(TEST_COMPONENT_ID_0.id(), ActionReplyHandler::default()); - let action_reply = PusActionReply::new(5_u32, ActionReplyVariant::Completed); + let action_reply = ActionReplyPus::new(5_u32, ActionReplyVariant::Completed); let unrequested_reply = GenericMessage::new(MessageMetadata::new(10_u32, 15_u64), action_reply); // Right now this function does not do a lot. We simply check that it does not panic or do diff --git a/satrs/src/pus/action.rs b/satrs/src/pus/action.rs index 875621f..07713a0 100644 --- a/satrs/src/pus/action.rs +++ b/satrs/src/pus/action.rs @@ -41,18 +41,18 @@ pub enum ActionReplyVariant { } #[derive(Debug, PartialEq, Clone)] -pub struct PusActionReply { +pub struct ActionReplyPus { pub action_id: ActionId, pub variant: ActionReplyVariant, } -impl PusActionReply { +impl ActionReplyPus { pub fn new(action_id: ActionId, variant: ActionReplyVariant) -> Self { Self { action_id, variant } } } -pub type GenericActionReplyPus = GenericMessage; +pub type GenericActionReplyPus = GenericMessage; impl GenericActionReplyPus { pub fn new_action_reply( @@ -60,7 +60,7 @@ impl GenericActionReplyPus { action_id: ActionId, reply: ActionReplyVariant, ) -> Self { - Self::new(requestor_info, PusActionReply::new(action_id, reply)) + Self::new(requestor_info, ActionReplyPus::new(action_id, reply)) } } @@ -76,13 +76,13 @@ pub mod alloc_mod { ComponentId, }; - use super::PusActionReply; + use super::ActionReplyPus; /// Helper type definition for a mode handler which can handle mode requests. pub type ActionRequestHandlerInterface = - MessageSenderAndReceiver; + MessageSenderAndReceiver; - impl, R: MessageReceiver> + impl, R: MessageReceiver> ActionRequestHandlerInterface { pub fn try_recv_action_request( @@ -95,7 +95,7 @@ pub mod alloc_mod { &self, request_id: RequestId, target_id: ComponentId, - reply: PusActionReply, + reply: ActionReplyPus, ) -> Result<(), GenericTargetedMessagingError> { self.send_message(request_id, target_id, reply) } @@ -104,14 +104,14 @@ pub mod alloc_mod { /// Helper type defintion for a mode handler object which can send mode requests and receive /// mode replies. pub type ActionRequestorInterface = - MessageSenderAndReceiver; + MessageSenderAndReceiver; - impl, R: MessageReceiver> + impl, R: MessageReceiver> ActionRequestorInterface { pub fn try_recv_action_reply( &self, - ) -> Result>, GenericTargetedMessagingError> { + ) -> Result>, GenericTargetedMessagingError> { self.try_recv_message() } @@ -179,21 +179,21 @@ pub mod std_mod { pub type DefaultActiveActionRequestMap = DefaultActiveRequestMap; pub type ActionRequestHandlerMpsc = ActionRequestHandlerInterface< - mpsc::Sender>, + mpsc::Sender>, mpsc::Receiver>, >; pub type ActionRequestHandlerMpscBounded = ActionRequestHandlerInterface< - mpsc::SyncSender>, + mpsc::SyncSender>, mpsc::Receiver>, >; pub type ActionRequestorMpsc = ActionRequestorInterface< mpsc::Sender>, - mpsc::Receiver>, + mpsc::Receiver>, >; pub type ActionRequestorBoundedMpsc = ActionRequestorInterface< mpsc::SyncSender>, - mpsc::Receiver>, + mpsc::Receiver>, >; /*