Merge pull request 'this makes a bit more sense' (#152) from naming-improvement-pus-actions into main
All checks were successful
Rust/sat-rs/pipeline/head This commit looks good

Reviewed-on: #152
This commit is contained in:
Robin Müller 2024-04-10 15:37:39 +02:00
commit 1ad74ee1d5
2 changed files with 29 additions and 29 deletions

View File

@ -3,7 +3,7 @@ use satrs::action::{ActionRequest, ActionRequestVariant};
use satrs::params::WritableToBeBytes; use satrs::params::WritableToBeBytes;
use satrs::pool::SharedStaticMemoryPool; use satrs::pool::SharedStaticMemoryPool;
use satrs::pus::action::{ use satrs::pus::action::{
ActionReplyVariant, ActivePusActionRequestStd, DefaultActiveActionRequestMap, PusActionReply, ActionReplyPus, ActionReplyVariant, ActivePusActionRequestStd, DefaultActiveActionRequestMap,
}; };
use satrs::pus::verification::{ use satrs::pus::verification::{
FailParams, FailParamsWithStep, TcStateAccepted, TcStateStarted, VerificationReporter, FailParams, FailParamsWithStep, TcStateAccepted, TcStateStarted, VerificationReporter,
@ -42,12 +42,12 @@ impl Default for ActionReplyHandler {
} }
} }
impl PusReplyHandler<ActivePusActionRequestStd, PusActionReply> for ActionReplyHandler { impl PusReplyHandler<ActivePusActionRequestStd, ActionReplyPus> for ActionReplyHandler {
type Error = EcssTmtcError; type Error = EcssTmtcError;
fn handle_unrequested_reply( fn handle_unrequested_reply(
&mut self, &mut self,
reply: &GenericMessage<PusActionReply>, reply: &GenericMessage<ActionReplyPus>,
_tm_sender: &impl EcssTmSenderCore, _tm_sender: &impl EcssTmSenderCore,
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
warn!("received unexpected reply for service 8: {reply:?}"); warn!("received unexpected reply for service 8: {reply:?}");
@ -56,7 +56,7 @@ impl PusReplyHandler<ActivePusActionRequestStd, PusActionReply> for ActionReplyH
fn handle_reply( fn handle_reply(
&mut self, &mut self,
reply: &GenericMessage<PusActionReply>, reply: &GenericMessage<ActionReplyPus>,
active_request: &ActivePusActionRequestStd, active_request: &ActivePusActionRequestStd,
tm_sender: &(impl EcssTmSenderCore + ?Sized), tm_sender: &(impl EcssTmSenderCore + ?Sized),
verification_handler: &impl VerificationReportingProvider, verification_handler: &impl VerificationReportingProvider,
@ -199,7 +199,7 @@ pub fn create_action_service_static(
tc_pool: SharedStaticMemoryPool, tc_pool: SharedStaticMemoryPool,
pus_action_rx: mpsc::Receiver<EcssTcAndToken>, pus_action_rx: mpsc::Receiver<EcssTcAndToken>,
action_router: GenericRequestRouter, action_router: GenericRequestRouter,
reply_receiver: mpsc::Receiver<GenericMessage<PusActionReply>>, reply_receiver: mpsc::Receiver<GenericMessage<ActionReplyPus>>,
) -> ActionServiceWrapper<MpscTmInSharedPoolSenderBounded, EcssTcInSharedStoreConverter> { ) -> ActionServiceWrapper<MpscTmInSharedPoolSenderBounded, EcssTcInSharedStoreConverter> {
let action_request_handler = PusTargetedRequestService::new( let action_request_handler = PusTargetedRequestService::new(
PusServiceHelper::new( PusServiceHelper::new(
@ -226,7 +226,7 @@ pub fn create_action_service_dynamic(
tm_funnel_tx: mpsc::Sender<PusTmAsVec>, tm_funnel_tx: mpsc::Sender<PusTmAsVec>,
pus_action_rx: mpsc::Receiver<EcssTcAndToken>, pus_action_rx: mpsc::Receiver<EcssTcAndToken>,
action_router: GenericRequestRouter, action_router: GenericRequestRouter,
reply_receiver: mpsc::Receiver<GenericMessage<PusActionReply>>, reply_receiver: mpsc::Receiver<GenericMessage<ActionReplyPus>>,
) -> ActionServiceWrapper<MpscTmAsVecSender, EcssTcInVecConverter> { ) -> ActionServiceWrapper<MpscTmAsVecSender, EcssTcInVecConverter> {
let action_request_handler = PusTargetedRequestService::new( let action_request_handler = PusTargetedRequestService::new(
PusServiceHelper::new( PusServiceHelper::new(
@ -259,7 +259,7 @@ pub struct ActionServiceWrapper<TmSender: EcssTmSenderCore, TcInMemConverter: Ec
DefaultActiveActionRequestMap, DefaultActiveActionRequestMap,
ActivePusActionRequestStd, ActivePusActionRequestStd,
ActionRequest, ActionRequest,
PusActionReply, ActionReplyPus,
>, >,
} }
@ -339,7 +339,7 @@ mod tests {
DefaultActiveActionRequestMap, DefaultActiveActionRequestMap,
ActivePusActionRequestStd, ActivePusActionRequestStd,
ActionRequest, ActionRequest,
PusActionReply, ActionReplyPus,
> >
{ {
pub fn new_for_action(owner_id: ComponentId, target_id: ComponentId) -> Self { 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 { if let CompositeRequest::Action(action_req) = req.message {
assert_eq!(action_req.action_id, action_id); assert_eq!(action_req.action_id, action_id);
assert_eq!(action_req.variant, ActionRequestVariant::NoData); 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 testbench
.reply_tx .reply_tx
.send(GenericMessage::new(req.requestor_info, action_reply)) .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 (req_id, active_req) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]);
let active_action_req = let active_action_req =
ActivePusActionRequestStd::new_from_common_req(action_id, active_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 generic_reply = GenericMessage::new(MessageMetadata::new(req_id.into(), 0), reply);
let result = testbench.handle_reply(&generic_reply, &active_action_req, &[]); let result = testbench.handle_reply(&generic_reply, &active_action_req, &[]);
assert!(result.is_ok()); assert!(result.is_ok());
@ -636,7 +636,7 @@ mod tests {
let active_action_req = let active_action_req =
ActivePusActionRequestStd::new_from_common_req(action_id, active_req); ActivePusActionRequestStd::new_from_common_req(action_id, active_req);
let error_code = ResultU16::new(2, 3); let error_code = ResultU16::new(2, 3);
let reply = PusActionReply::new( let reply = ActionReplyPus::new(
action_id, action_id,
ActionReplyVariant::CompletionFailed { ActionReplyVariant::CompletionFailed {
error_code, error_code,
@ -663,7 +663,7 @@ mod tests {
let (req_id, active_req) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]); let (req_id, active_req) = testbench.add_tc(TEST_APID, TEST_UNIQUE_ID_0, &[]);
let active_action_req = let active_action_req =
ActivePusActionRequestStd::new_from_common_req(action_id, active_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 generic_reply = GenericMessage::new(MessageMetadata::new(req_id.into(), 0), reply);
let result = testbench.handle_reply(&generic_reply, &active_action_req, &[]); let result = testbench.handle_reply(&generic_reply, &active_action_req, &[]);
assert!(result.is_ok()); assert!(result.is_ok());
@ -690,7 +690,7 @@ mod tests {
let active_action_req = let active_action_req =
ActivePusActionRequestStd::new_from_common_req(action_id, active_req); ActivePusActionRequestStd::new_from_common_req(action_id, active_req);
let error_code = ResultU16::new(2, 3); let error_code = ResultU16::new(2, 3);
let reply = PusActionReply::new( let reply = ActionReplyPus::new(
action_id, action_id,
ActionReplyVariant::StepFailed { ActionReplyVariant::StepFailed {
error_code, error_code,
@ -720,7 +720,7 @@ mod tests {
fn reply_handling_unrequested_reply() { fn reply_handling_unrequested_reply() {
let mut testbench = let mut testbench =
ReplyHandlerTestbench::new(TEST_COMPONENT_ID_0.id(), ActionReplyHandler::default()); 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 = let unrequested_reply =
GenericMessage::new(MessageMetadata::new(10_u32, 15_u64), action_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 // Right now this function does not do a lot. We simply check that it does not panic or do

View File

@ -41,18 +41,18 @@ pub enum ActionReplyVariant {
} }
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]
pub struct PusActionReply { pub struct ActionReplyPus {
pub action_id: ActionId, pub action_id: ActionId,
pub variant: ActionReplyVariant, pub variant: ActionReplyVariant,
} }
impl PusActionReply { impl ActionReplyPus {
pub fn new(action_id: ActionId, variant: ActionReplyVariant) -> Self { pub fn new(action_id: ActionId, variant: ActionReplyVariant) -> Self {
Self { action_id, variant } Self { action_id, variant }
} }
} }
pub type GenericActionReplyPus = GenericMessage<PusActionReply>; pub type GenericActionReplyPus = GenericMessage<ActionReplyPus>;
impl GenericActionReplyPus { impl GenericActionReplyPus {
pub fn new_action_reply( pub fn new_action_reply(
@ -60,7 +60,7 @@ impl GenericActionReplyPus {
action_id: ActionId, action_id: ActionId,
reply: ActionReplyVariant, reply: ActionReplyVariant,
) -> Self { ) -> 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, ComponentId,
}; };
use super::PusActionReply; use super::ActionReplyPus;
/// Helper type definition for a mode handler which can handle mode requests. /// Helper type definition for a mode handler which can handle mode requests.
pub type ActionRequestHandlerInterface<S, R> = pub type ActionRequestHandlerInterface<S, R> =
MessageSenderAndReceiver<PusActionReply, ActionRequest, S, R>; MessageSenderAndReceiver<ActionReplyPus, ActionRequest, S, R>;
impl<S: MessageSender<PusActionReply>, R: MessageReceiver<ActionRequest>> impl<S: MessageSender<ActionReplyPus>, R: MessageReceiver<ActionRequest>>
ActionRequestHandlerInterface<S, R> ActionRequestHandlerInterface<S, R>
{ {
pub fn try_recv_action_request( pub fn try_recv_action_request(
@ -95,7 +95,7 @@ pub mod alloc_mod {
&self, &self,
request_id: RequestId, request_id: RequestId,
target_id: ComponentId, target_id: ComponentId,
reply: PusActionReply, reply: ActionReplyPus,
) -> Result<(), GenericTargetedMessagingError> { ) -> Result<(), GenericTargetedMessagingError> {
self.send_message(request_id, target_id, reply) 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 /// Helper type defintion for a mode handler object which can send mode requests and receive
/// mode replies. /// mode replies.
pub type ActionRequestorInterface<S, R> = pub type ActionRequestorInterface<S, R> =
MessageSenderAndReceiver<ActionRequest, PusActionReply, S, R>; MessageSenderAndReceiver<ActionRequest, ActionReplyPus, S, R>;
impl<S: MessageSender<ActionRequest>, R: MessageReceiver<PusActionReply>> impl<S: MessageSender<ActionRequest>, R: MessageReceiver<ActionReplyPus>>
ActionRequestorInterface<S, R> ActionRequestorInterface<S, R>
{ {
pub fn try_recv_action_reply( pub fn try_recv_action_reply(
&self, &self,
) -> Result<Option<GenericMessage<PusActionReply>>, GenericTargetedMessagingError> { ) -> Result<Option<GenericMessage<ActionReplyPus>>, GenericTargetedMessagingError> {
self.try_recv_message() self.try_recv_message()
} }
@ -179,21 +179,21 @@ pub mod std_mod {
pub type DefaultActiveActionRequestMap = DefaultActiveRequestMap<ActivePusActionRequestStd>; pub type DefaultActiveActionRequestMap = DefaultActiveRequestMap<ActivePusActionRequestStd>;
pub type ActionRequestHandlerMpsc = ActionRequestHandlerInterface< pub type ActionRequestHandlerMpsc = ActionRequestHandlerInterface<
mpsc::Sender<GenericMessage<PusActionReply>>, mpsc::Sender<GenericMessage<ActionReplyPus>>,
mpsc::Receiver<GenericMessage<ActionRequest>>, mpsc::Receiver<GenericMessage<ActionRequest>>,
>; >;
pub type ActionRequestHandlerMpscBounded = ActionRequestHandlerInterface< pub type ActionRequestHandlerMpscBounded = ActionRequestHandlerInterface<
mpsc::SyncSender<GenericMessage<PusActionReply>>, mpsc::SyncSender<GenericMessage<ActionReplyPus>>,
mpsc::Receiver<GenericMessage<ActionRequest>>, mpsc::Receiver<GenericMessage<ActionRequest>>,
>; >;
pub type ActionRequestorMpsc = ActionRequestorInterface< pub type ActionRequestorMpsc = ActionRequestorInterface<
mpsc::Sender<GenericMessage<ActionRequest>>, mpsc::Sender<GenericMessage<ActionRequest>>,
mpsc::Receiver<GenericMessage<PusActionReply>>, mpsc::Receiver<GenericMessage<ActionReplyPus>>,
>; >;
pub type ActionRequestorBoundedMpsc = ActionRequestorInterface< pub type ActionRequestorBoundedMpsc = ActionRequestorInterface<
mpsc::SyncSender<GenericMessage<ActionRequest>>, mpsc::SyncSender<GenericMessage<ActionRequest>>,
mpsc::Receiver<GenericMessage<PusActionReply>>, mpsc::Receiver<GenericMessage<ActionReplyPus>>,
>; >;
/* /*