diff --git a/satrs/src/mode.rs b/satrs/src/mode.rs index 1b4d636..471b36d 100644 --- a/satrs/src/mode.rs +++ b/satrs/src/mode.rs @@ -336,26 +336,51 @@ pub mod alloc_mod { } impl< - REQUEST, - S0: MessageSenderProvider, - R0: MessageReceiverProvider, - S1: MessageSenderProvider, - R1: MessageReceiverProvider, - > RequestAndReplySenderAndReceiver + Request, + ReqSender: MessageSenderProvider, + ReqReceiver: MessageReceiverProvider, + ReqSenderStore: MessageSenderStoreProvider, + Reply, + ReplySender: MessageSenderProvider, + ReplyReceiver: MessageReceiverProvider, + ReplySenderStore: MessageSenderStoreProvider, + > + RequestAndReplySenderAndReceiver< + Request, + ReqSender, + ReqReceiver, + ReqSenderStore, + Reply, + ReplySender, + ReplyReceiver, + ReplySenderStore, + > { - pub fn add_reply_target(&mut self, target_id: ComponentId, reply_sender: S1) { - self.reply_sender_map + pub fn add_reply_target(&mut self, target_id: ComponentId, reply_sender: ReplySender) { + self.reply_sender_store .add_message_target(target_id, reply_sender) } } impl< - REQUEST, - S0: MessageSenderProvider, - R0: MessageReceiverProvider, - S1: MessageSenderProvider, - R1: MessageReceiverProvider, - > ModeReplySender for RequestAndReplySenderAndReceiver + Request, + ReqSender: MessageSenderProvider, + ReqReceiver: MessageReceiverProvider, + ReqSenderStore: MessageSenderStoreProvider, + ReplySender: MessageSenderProvider, + ReplyReceiver: MessageReceiverProvider, + ReplySenderStore: MessageSenderStoreProvider, + > ModeReplySender + for RequestAndReplySenderAndReceiver< + Request, + ReqSender, + ReqReceiver, + ReqSenderStore, + ModeReply, + ReplySender, + ReplyReceiver, + ReplySenderStore, + > { fn local_channel_id(&self) -> ComponentId { self.local_channel_id_generic() @@ -364,24 +389,35 @@ pub mod alloc_mod { fn send_mode_reply( &self, requestor_info: MessageMetadata, - request: ModeReply, + reply: ModeReply, ) -> Result<(), GenericTargetedMessagingError> { - self.reply_sender_map.send_mode_reply( + self.reply_sender_store.send_message( MessageMetadata::new(requestor_info.request_id(), self.local_channel_id()), requestor_info.sender_id(), - request, + reply, ) } } impl< - REQUEST, - S0: MessageSenderProvider, - R0: MessageReceiverProvider, - S1: MessageSenderProvider, - R1: MessageReceiverProvider, + Request, + ReqSender: MessageSenderProvider, + ReqReceiver: MessageReceiverProvider, + ReqSenderStore: MessageSenderStoreProvider, + ReplySender: MessageSenderProvider, + ReplyReceiver: MessageReceiverProvider, + ReplySenderStore: MessageSenderStoreProvider, > ModeReplyReceiver - for RequestAndReplySenderAndReceiver + for RequestAndReplySenderAndReceiver< + Request, + ReqSender, + ReqReceiver, + ReqSenderStore, + ModeReply, + ReplySender, + ReplyReceiver, + ReplySenderStore, + > { fn try_recv_mode_reply( &self, @@ -448,8 +484,23 @@ pub mod alloc_mod { /// Helper type defintion for a mode handler object which can both send mode requests and /// process mode requests. - pub type ModeInterface = - RequestAndReplySenderAndReceiver; + pub type ModeInterface< + ReqSender, + ReqReceiver, + ReqSenderStore, + ReplySender, + ReplyReceiver, + ReplySenderStore, + > = RequestAndReplySenderAndReceiver< + ModeRequest, + ReqSender, + ReqReceiver, + ReqSenderStore, + ModeReply, + ReplySender, + ReplyReceiver, + ReplySenderStore, + >; impl> MessageSenderMap { pub fn send_mode_request( @@ -508,27 +559,50 @@ pub mod alloc_mod { } impl< - REPLY, - S0: MessageSenderProvider, - R0: MessageReceiverProvider, - S1: MessageSenderProvider, - R1: MessageReceiverProvider, - > RequestAndReplySenderAndReceiver + ReqSender: MessageSenderProvider, + ReqReceiver: MessageReceiverProvider, + ReqSenderStore: MessageSenderStoreProvider, + Reply, + ReplySender: MessageSenderProvider, + ReplyReceiver: MessageReceiverProvider, + ReplySenderStore: MessageSenderStoreProvider, + > + RequestAndReplySenderAndReceiver< + ModeRequest, + ReqSender, + ReqReceiver, + ReqSenderStore, + Reply, + ReplySender, + ReplyReceiver, + ReplySenderStore, + > { - pub fn add_request_target(&mut self, target_id: ComponentId, request_sender: S0) { - self.request_sender_map + pub fn add_request_target(&mut self, target_id: ComponentId, request_sender: ReqSender) { + self.request_sender_store .add_message_target(target_id, request_sender) } } impl< - REPLY, - S0: MessageSenderProvider, - R0: MessageReceiverProvider, - S1: MessageSenderProvider, - R1: MessageReceiverProvider, + ReqSender: MessageSenderProvider, + ReqReceiver: MessageReceiverProvider, + ReqSenderStore: MessageSenderStoreProvider, + Reply, + ReplySender: MessageSenderProvider, + ReplyReceiver: MessageReceiverProvider, + ReplySenderStore: MessageSenderStoreProvider, > ModeRequestSender - for RequestAndReplySenderAndReceiver + for RequestAndReplySenderAndReceiver< + ModeRequest, + ReqSender, + ReqReceiver, + ReqSenderStore, + Reply, + ReplySender, + ReplyReceiver, + ReplySenderStore, + > { fn local_channel_id(&self) -> ComponentId { self.local_channel_id_generic() @@ -540,7 +614,7 @@ pub mod alloc_mod { target_id: ComponentId, request: ModeRequest, ) -> Result<(), GenericTargetedMessagingError> { - self.request_sender_map.send_mode_request( + self.request_sender_store.send_message( MessageMetadata::new(request_id, self.local_channel_id()), target_id, request, @@ -549,13 +623,24 @@ pub mod alloc_mod { } impl< - REPLY, - S0: MessageSenderProvider, - R0: MessageReceiverProvider, - S1: MessageSenderProvider, - R1: MessageReceiverProvider, + ReqSender: MessageSenderProvider, + ReqReceiver: MessageReceiverProvider, + ReqSenderStore: MessageSenderStoreProvider, + Reply, + ReplySender: MessageSenderProvider, + ReplyReceiver: MessageReceiverProvider, + ReplySenderStore: MessageSenderStoreProvider, > ModeRequestReceiver - for RequestAndReplySenderAndReceiver + for RequestAndReplySenderAndReceiver< + ModeRequest, + ReqSender, + ReqReceiver, + ReqSenderStore, + Reply, + ReplySender, + ReplyReceiver, + ReplySenderStore, + > { fn try_recv_mode_request( &self, @@ -573,15 +658,15 @@ pub mod std_mod { use super::*; - pub type ModeRequestHandlerOneParentMpsc = ModeRequestHandlerInterface< + pub type ModeRequestHandlerMpsc = ModeRequestHandlerInterface< mpsc::Sender>, mpsc::Receiver>, - OneMessageSender>>, + MessageSenderList>>, >; - pub type ModeRequestHandlerOneParentMpscBounded = ModeRequestHandlerInterface< + pub type ModeRequestHandlerMpscBounded = ModeRequestHandlerInterface< mpsc::SyncSender>, mpsc::Receiver>, - OneMessageSender>>, + MessageSenderList>>, >; pub type ModeRequestorOneChildMpsc = ModeRequestorInterface< @@ -592,36 +677,34 @@ pub mod std_mod { pub type ModeRequestorOneChildBoundedMpsc = ModeRequestorInterface< mpsc::SyncSender>, mpsc::Receiver>, - OneMessageSender< - ModeRequest, - mpsc::SyncSender>, - >, + OneMessageSender>>, >; - pub type ModeRequestorMultiChildListMpsc = ModeRequestorInterface< + pub type ModeRequestorChildListMpsc = ModeRequestorInterface< mpsc::Sender>, mpsc::Receiver>, MessageSenderList>>, >; - pub type ModeRequestorMultiChildListBoundedMpsc = ModeRequestorInterface< + pub type ModeRequestorChildListBoundedMpsc = ModeRequestorInterface< mpsc::SyncSender>, mpsc::Receiver>, - MessageSenderList< - ModeRequest, - mpsc::SyncSender>, - >, + MessageSenderList>>, >; - pub type ModeRequestorAndHandlerOneParentMpsc = ModeInterface< + pub type ModeRequestorAndHandlerMpsc = ModeInterface< mpsc::Sender>, - mpsc::Receiver>, + mpsc::Receiver>, + MessageSenderList>>, mpsc::Sender>, - mpsc::Receiver>, - >; - pub type ModeRequestorAndHandlerOneParentMpscBounded = ModeInterface< - mpsc::SyncSender>, mpsc::Receiver>, - mpsc::SyncSender>, + MessageSenderList>>, + >; + pub type ModeRequestorAndHandlerMpscBounded = ModeInterface< + mpsc::SyncSender>, mpsc::Receiver>, + MessageSenderList>>, + mpsc::SyncSender>, + mpsc::Receiver>, + MessageSenderList>>, >; } diff --git a/satrs/src/pus/mode.rs b/satrs/src/pus/mode.rs index 75bf40c..fea2bff 100644 --- a/satrs/src/pus/mode.rs +++ b/satrs/src/pus/mode.rs @@ -52,7 +52,8 @@ mod tests { fn test_simple_mode_requestor() { let (reply_sender, reply_receiver) = mpsc::channel(); let (request_sender, request_receiver) = mpsc::channel(); - let mut mode_requestor = ModeRequestorOneChildMpsc::new(TEST_COMPONENT_ID_0, reply_receiver); + let mut mode_requestor = + ModeRequestorOneChildMpsc::new(TEST_COMPONENT_ID_0, reply_receiver); mode_requestor.add_message_target(TEST_COMPONENT_ID_1, request_sender); // Send a request and verify it arrives at the receiver. diff --git a/satrs/src/request.rs b/satrs/src/request.rs index ab80e90..027486c 100644 --- a/satrs/src/request.rs +++ b/satrs/src/request.rs @@ -149,9 +149,9 @@ pub trait MessageReceiverProvider { fn try_recv(&self) -> Result>, GenericTargetedMessagingError>; } -pub struct MessageWithSenderIdReceiver>( - pub R, - PhantomData, +pub struct MessageWithSenderIdReceiver>( + pub Receiver, + PhantomData, ); impl> From for MessageWithSenderIdReceiver { @@ -208,6 +208,7 @@ pub trait MessageSenderStoreProvider: Default { #[cfg(feature = "alloc")] pub mod alloc_mod { use crate::queue::GenericSendError; + use std::convert::From; use super::*; use hashbrown::HashMap; @@ -226,10 +227,10 @@ pub mod alloc_mod { } } - impl> MessageSenderStoreProvider - for OneMessageSender + impl> MessageSenderStoreProvider + for OneMessageSender { - fn add_message_target(&mut self, target_id: ComponentId, message_sender: S) { + fn add_message_target(&mut self, target_id: ComponentId, message_sender: Sender) { if self.id_and_sender.is_some() { return; } @@ -263,10 +264,10 @@ pub mod alloc_mod { } } - impl> MessageSenderStoreProvider - for MessageSenderList + impl> MessageSenderStoreProvider + for MessageSenderList { - fn add_message_target(&mut self, target_id: ComponentId, message_sender: S) { + fn add_message_target(&mut self, target_id: ComponentId, message_sender: Sender) { self.0.push((target_id, message_sender)); } @@ -274,7 +275,7 @@ pub mod alloc_mod { &self, requestor_info: MessageMetadata, target_channel_id: ComponentId, - message: MSG, + message: Msg, ) -> Result<(), GenericTargetedMessagingError> { for (current_id, sender) in &self.0 { if *current_id == target_channel_id { @@ -297,10 +298,10 @@ pub mod alloc_mod { } } - impl> MessageSenderStoreProvider - for MessageSenderMap + impl> MessageSenderStoreProvider + for MessageSenderMap { - fn add_message_target(&mut self, target_id: ComponentId, message_sender: S) { + fn add_message_target(&mut self, target_id: ComponentId, message_sender: Sender) { self.0.insert(target_id, message_sender); } @@ -308,7 +309,7 @@ pub mod alloc_mod { &self, requestor_info: MessageMetadata, target_channel_id: ComponentId, - message: MSG, + message: Msg, ) -> Result<(), GenericTargetedMessagingError> { if self.0.contains_key(&target_channel_id) { return self @@ -383,42 +384,58 @@ pub mod alloc_mod { } pub struct RequestAndReplySenderAndReceiver< - REQUEST, - REPLY, - S0: MessageSenderProvider, - R0: MessageReceiverProvider, - S1: MessageSenderProvider, - R1: MessageReceiverProvider, + Request, + ReqSender: MessageSenderProvider, + ReqReceiver: MessageReceiverProvider, + ReqSenderStore: MessageSenderStoreProvider, + Reply, + ReplySender: MessageSenderProvider, + ReplyReceiver: MessageReceiverProvider, + ReplySenderStore: MessageSenderStoreProvider, > { pub local_channel_id: ComponentId, // These 2 are a functional group. - pub request_sender_map: MessageSenderMap, - pub reply_receiver: MessageWithSenderIdReceiver, + pub request_sender_store: ReqSenderStore, + pub reply_receiver: MessageWithSenderIdReceiver, // These 2 are a functional group. - pub request_receiver: MessageWithSenderIdReceiver, - pub reply_sender_map: MessageSenderMap, + pub request_receiver: MessageWithSenderIdReceiver, + pub reply_sender_store: ReplySenderStore, + phantom: PhantomData<(ReqSender, ReplySender)>, } impl< - REQUEST, - REPLY, - S0: MessageSenderProvider, - R0: MessageReceiverProvider, - S1: MessageSenderProvider, - R1: MessageReceiverProvider, - > RequestAndReplySenderAndReceiver + Request, + ReqSender: MessageSenderProvider, + ReqReceiver: MessageReceiverProvider, + ReqSenderStore: MessageSenderStoreProvider, + Reply, + ReplySender: MessageSenderProvider, + ReplyReceiver: MessageReceiverProvider, + ReplySenderStore: MessageSenderStoreProvider, + > + RequestAndReplySenderAndReceiver< + Request, + ReqSender, + ReqReceiver, + ReqSenderStore, + Reply, + ReplySender, + ReplyReceiver, + ReplySenderStore, + > { pub fn new( local_channel_id: ComponentId, - request_receiver: R1, - reply_receiver: R0, + request_receiver: ReqReceiver, + reply_receiver: ReplyReceiver, ) -> Self { Self { local_channel_id, request_receiver: request_receiver.into(), reply_receiver: reply_receiver.into(), - request_sender_map: Default::default(), - reply_sender_map: Default::default(), + request_sender_store: Default::default(), + reply_sender_store: Default::default(), + phantom: PhantomData, } } diff --git a/satrs/src/tmtc/tm_helper.rs b/satrs/src/tmtc/tm_helper.rs index c8c488e..af61904 100644 --- a/satrs/src/tmtc/tm_helper.rs +++ b/satrs/src/tmtc/tm_helper.rs @@ -17,37 +17,37 @@ impl PusTmWithCdsShortHelper { } #[cfg(feature = "std")] - pub fn create_pus_tm_timestamp_now<'a>( - &'a mut self, + pub fn create_pus_tm_timestamp_now<'time, 'src_data>( + &'time mut self, service: u8, subservice: u8, - source_data: &'a [u8], + source_data: &'src_data [u8], seq_count: u16, - ) -> PusTmCreator { + ) -> PusTmCreator<'time, 'src_data> { let time_stamp = CdsTime::now_with_u16_days().unwrap(); time_stamp.write_to_bytes(&mut self.cds_short_buf).unwrap(); self.create_pus_tm_common(service, subservice, source_data, seq_count) } - pub fn create_pus_tm_with_stamper<'a>( - &'a mut self, + pub fn create_pus_tm_with_stamper<'time, 'src_data>( + &'time mut self, service: u8, subservice: u8, - source_data: &'a [u8], + source_data: &'src_data [u8], stamper: &CdsTime, seq_count: u16, - ) -> PusTmCreator { + ) -> PusTmCreator<'time, 'src_data> { stamper.write_to_bytes(&mut self.cds_short_buf).unwrap(); self.create_pus_tm_common(service, subservice, source_data, seq_count) } - fn create_pus_tm_common<'a>( - &'a self, + fn create_pus_tm_common<'time, 'src_data>( + &'time self, service: u8, subservice: u8, - source_data: &'a [u8], + source_data: &'src_data [u8], seq_count: u16, - ) -> PusTmCreator { + ) -> PusTmCreator<'time, 'src_data> { let reply_header = SpHeader::new_for_unseg_tm(self.apid, seq_count, 0); let tc_header = PusTmSecondaryHeader::new_simple(service, subservice, &self.cds_short_buf); PusTmCreator::new(reply_header, tc_header, source_data, true) diff --git a/satrs/tests/mode_tree.rs b/satrs/tests/mode_tree.rs index 93d3213..00412ed 100644 --- a/satrs/tests/mode_tree.rs +++ b/satrs/tests/mode_tree.rs @@ -1,8 +1,12 @@ use core::cell::Cell; -use satrs::mode::{Mode, ModeError, ModeProvider, ModeReplyReceiver, ModeReplySender, ModeRequestHandler, ModeRequestHandlerOneParentMpscBounded, ModeRequestReceiver, ModeRequestSender, ModeRequestorAndHandlerOneParentMpscBounded, ModeRequestorOneChildBoundedMpsc}; +use satrs::mode::{ + Mode, ModeError, ModeProvider, ModeReplyReceiver, ModeReplySender, ModeRequestHandler, + ModeRequestHandlerMpscBounded, ModeRequestReceiver, ModeRequestorAndHandlerMpscBounded, + ModeRequestorOneChildBoundedMpsc, +}; use satrs::mode_tree::{ - connect_mode_nodes, ModeChild, ModeNode, ModeParent, ModeStoreProvider, SequenceTableMapTable, - TargetTableEntry, + connect_mode_nodes, ModeChild, ModeNode, ModeParent, ModeStoreProvider, SequenceTableEntry, + SequenceTableMapTable, TargetTableEntry, }; use satrs::mode_tree::{ ModeStoreVec, SequenceModeTables, SequenceTablesMapValue, TargetModeTables, @@ -187,17 +191,17 @@ impl ModeParent for PusModeService { } struct AcsSubsystem { - pub mode_node: ModeRequestorAndHandlerOneParentMpscBounded, + pub mode_node: ModeRequestorAndHandlerMpscBounded, pub mode_requestor_info: Option, pub mode_and_submode: ModeAndSubmode, pub target_mode_and_submode: Option, pub subsystem_helper: SubsystemHelper, pub mode_req_handler_mock: ModeRequestHandlerMock, - pub mode_msgs_recvd: u32, + pub mode_req_recvd: u32, } impl AcsSubsystem { - pub fn new(mode_node: ModeRequestorAndHandlerOneParentMpscBounded) -> Self { + pub fn new(mode_node: ModeRequestorAndHandlerMpscBounded) -> Self { Self { mode_node, mode_requestor_info: None, @@ -205,23 +209,23 @@ impl AcsSubsystem { target_mode_and_submode: None, subsystem_helper: Default::default(), mode_req_handler_mock: Default::default(), - mode_msgs_recvd: 0, + mode_req_recvd: 0, } } - pub fn get_and_clear_num_mode_msgs(&mut self) -> u32 { - let tmp = self.mode_msgs_recvd; - self.mode_msgs_recvd = 0; + pub fn get_and_clear_num_mode_requests(&mut self) -> u32 { + let tmp = self.mode_req_recvd; + self.mode_req_recvd = 0; tmp } pub fn run(&mut self) { if let Some(request) = self.mode_node.try_recv_mode_request().unwrap() { - self.mode_msgs_recvd += 1; + self.mode_req_recvd += 1; self.handle_mode_request(request) .expect("mode messaging error"); } - if let Some(_reply) = self.mode_node.try_recv_mode_reply().unwrap(){ + if let Some(_reply) = self.mode_node.try_recv_mode_reply().unwrap() { // TODO: Implementation. } } @@ -298,7 +302,7 @@ impl ModeRequestHandler for AcsSubsystem { } let request_id = requestor_info.map_or(0, |info| info.request_id()); self.mode_node - .request_sender_map + .request_sender_store .0 .iter() .for_each(|(_, sender)| { @@ -354,7 +358,7 @@ impl ModeRequestHandler for AcsSubsystem { } struct MgmAssembly { - pub mode_node: ModeRequestorAndHandlerOneParentMpscBounded, + pub mode_node: ModeRequestorAndHandlerMpscBounded, pub mode_requestor_info: Option, pub mode_and_submode: ModeAndSubmode, pub target_mode_and_submode: Option, @@ -363,7 +367,7 @@ struct MgmAssembly { } impl MgmAssembly { - pub fn new(mode_node: ModeRequestorAndHandlerOneParentMpscBounded) -> Self { + pub fn new(mode_node: ModeRequestorAndHandlerMpscBounded) -> Self { Self { mode_node, mode_requestor_info: None, @@ -386,6 +390,7 @@ impl MgmAssembly { pub fn check_mode_requests(&mut self) -> Result<(), GenericTargetedMessagingError> { if let Some(request) = self.mode_node.try_recv_mode_request()? { + self.mode_msgs_recvd += 1; self.handle_mode_request(request).unwrap(); } Ok(()) @@ -469,7 +474,7 @@ impl ModeRequestHandler for MgmAssembly { } let request_id = requestor_info.map_or(0, |info| info.request_id()); self.mode_node - .request_sender_map + .request_sender_store .0 .iter() .for_each(|(_, sender)| { @@ -524,17 +529,17 @@ impl ModeRequestHandler for MgmAssembly { struct DeviceManager { name: &'static str, pub id: ComponentId, - pub mode_node: ModeRequestorAndHandlerOneParentMpscBounded, + pub mode_node: ModeRequestorAndHandlerMpscBounded, pub mode_and_submode: ModeAndSubmode, pub mode_req_mock: ModeRequestHandlerMock, - pub mode_msgs_recvd: u32, + pub mode_req_recvd: u32, } impl DeviceManager { pub fn new( name: &'static str, id: ComponentId, - mode_node: ModeRequestorAndHandlerOneParentMpscBounded, + mode_node: ModeRequestorAndHandlerMpscBounded, ) -> Self { Self { name, @@ -542,13 +547,13 @@ impl DeviceManager { mode_node, mode_and_submode: UNKNOWN_MODE, mode_req_mock: Default::default(), - mode_msgs_recvd: 0, + mode_req_recvd: 0, } } - pub fn get_and_clear_num_mode_msgs(&mut self) -> u32 { - let tmp = self.mode_msgs_recvd; - self.mode_msgs_recvd = 0; + pub fn get_and_clear_num_mode_requests(&mut self) -> u32 { + let tmp = self.mode_req_recvd; + self.mode_req_recvd = 0; tmp } @@ -558,6 +563,7 @@ impl DeviceManager { pub fn check_mode_requests(&mut self) -> Result<(), ModeError> { if let Some(request) = self.mode_node.try_recv_mode_request()? { + self.mode_req_recvd += 1; self.handle_mode_request(request)? } Ok(()) @@ -619,7 +625,7 @@ impl ModeRequestHandler for DeviceManager { } let request_id = requestor_info.map_or(0, |info| info.request_id()); self.mode_node - .request_sender_map + .request_sender_store .0 .iter() .for_each(|(_, sender)| { @@ -674,7 +680,7 @@ impl ModeRequestHandler for DeviceManager { struct CommonDevice { name: &'static str, pub id: ComponentId, - pub mode_node: ModeRequestHandlerOneParentMpscBounded, + pub mode_node: ModeRequestHandlerMpscBounded, pub mode_and_submode: ModeAndSubmode, pub mode_req_mock: ModeRequestHandlerMock, pub num_mode_msgs_recvd: u32, @@ -684,7 +690,7 @@ impl CommonDevice { pub fn new( name: &'static str, id: ComponentId, - mode_node: ModeRequestHandlerOneParentMpscBounded, + mode_node: ModeRequestHandlerMpscBounded, ) -> Self { Self { name, @@ -804,7 +810,7 @@ pub struct AnnounceModeInfo { } pub struct AcsController { - pub mode_node: ModeRequestHandlerOneParentMpscBounded, + pub mode_node: ModeRequestHandlerMpscBounded, pub mode_and_submode: ModeAndSubmode, pub announce_mode_queue: RefCell>, pub mode_req_mock: ModeRequestHandlerMock, @@ -953,36 +959,36 @@ impl TreeTestbench { ); // Mode requestors and handlers. - let mgm_assy_node = ModeRequestorAndHandlerOneParentMpscBounded::new( + let mgm_assy_node = ModeRequestorAndHandlerMpscBounded::new( TestComponentId::MagnetometerAssembly as ComponentId, request_receiver_mgm_assy, reply_receiver_mgm_assy, ); - let mgt_dev_mgmt_node = ModeRequestorAndHandlerOneParentMpscBounded::new( + let mgt_dev_mgmt_node = ModeRequestorAndHandlerMpscBounded::new( TestComponentId::MgtDevManager as ComponentId, request_receiver_mgt_man, reply_receiver_mgt_man, ); - let acs_subsystem_node = ModeRequestorAndHandlerOneParentMpscBounded::new( + let acs_subsystem_node = ModeRequestorAndHandlerMpscBounded::new( TestComponentId::AcsSubsystem as ComponentId, request_receiver_acs_subsystem, reply_receiver_acs_subsystem, ); // Request handlers only. - let mgm_dev_node_0 = ModeRequestHandlerOneParentMpscBounded::new( + let mgm_dev_node_0 = ModeRequestHandlerMpscBounded::new( TestComponentId::MagnetometerDevice0 as ComponentId, request_receiver_mgm_dev_0, ); - let mgm_dev_node_1 = ModeRequestHandlerOneParentMpscBounded::new( + let mgm_dev_node_1 = ModeRequestHandlerMpscBounded::new( TestComponentId::MagnetometerDevice1 as ComponentId, request_receiver_mgm_dev_1, ); - let mgt_dev_node = ModeRequestHandlerOneParentMpscBounded::new( + let mgt_dev_node = ModeRequestHandlerMpscBounded::new( TestComponentId::MagnetorquerDevice as ComponentId, request_receiver_mgt_dev, ); - let acs_ctrl_node = ModeRequestHandlerOneParentMpscBounded::new( + let acs_ctrl_node = ModeRequestHandlerMpscBounded::new( TestComponentId::AcsController as ComponentId, request_receiver_acs_ctrl, ); @@ -1036,9 +1042,35 @@ impl TreeTestbench { ModeAndSubmode::new(DefaultMode::NORMAL as u32, 0), true, )); - let sequence_tbl_safe_0 = SequenceTableMapTable::new("SAFE_SEQ_0_TBL"); - let sequence_tbl_safe_1 = SequenceTableMapTable::new("SAFE_SEQ_1_TBL"); - let sequence_tbl_safe = SequenceTablesMapValue::new("SAFE_SEQ_TBL"); + target_table_safe.add_entry(TargetTableEntry::new_with_precise_submode( + "MGT_MAN_NML", + TestComponentId::MgtDevManager as u64, + ModeAndSubmode::new(DefaultMode::NORMAL as u32, 0), + true, + )); + let mut sequence_tbl_safe_0 = SequenceTableMapTable::new("SAFE_SEQ_0_TBL"); + sequence_tbl_safe_0.add_entry(SequenceTableEntry::new( + "SAFE_SEQ_0_MGM_A", + TestComponentId::MagnetometerAssembly as u64, + ModeAndSubmode::new(DefaultMode::NORMAL as Mode, 0), + false, + )); + sequence_tbl_safe_0.add_entry(SequenceTableEntry::new( + "SAFE_SEQ_0_MGT_MAN", + TestComponentId::MgtDevManager as u64, + ModeAndSubmode::new(DefaultMode::NORMAL as Mode, 0), + false, + )); + let mut sequence_tbl_safe_1 = SequenceTableMapTable::new("SAFE_SEQ_1_TBL"); + sequence_tbl_safe_1.add_entry(SequenceTableEntry::new( + "SAFE_SEQ_1_ACS_CTRL", + TestComponentId::AcsController as u64, + ModeAndSubmode::new(AcsMode::IDLE as Mode, 0), + false, + )); + let mut sequence_tbl_safe = SequenceTablesMapValue::new("SAFE_SEQ_TBL"); + sequence_tbl_safe.add_sequence_table(sequence_tbl_safe_0); + sequence_tbl_safe.add_sequence_table(sequence_tbl_safe_1); acs_subsystem.add_target_and_sequence_table( AcsMode::SAFE as u32, target_table_safe, @@ -1154,6 +1186,7 @@ fn announce_recursively() { tb.mgm_devs[1].run(); tb.mgt_dev.run(); } + assert_eq!(tb.subsystem.get_and_clear_num_mode_requests(), 1); let mut announces = tb .subsystem .mode_req_handler_mock @@ -1164,6 +1197,7 @@ fn announce_recursively() { assert_eq!(tb.ctrl.mode_req_mock.start_transition_calls.len(), 0); assert_eq!(tb.ctrl.mode_and_submode(), UNKNOWN_MODE); assert_eq!(announces.len(), 1); + assert_eq!(tb.mgm_assy.get_and_clear_num_mode_msgs(), 1); announces = tb.mgm_assy.mode_req_mock.announce_mode_calls.borrow_mut(); assert_eq!(tb.mgm_assy.mode_req_mock.start_transition_calls.len(), 0); assert_eq!(tb.mgm_assy.mode_and_submode(), UNKNOWN_MODE); @@ -1181,6 +1215,7 @@ fn announce_recursively() { assert_eq!(tb.mgt_dev.mode_req_mock.start_transition_calls.len(), 0); assert_eq!(tb.mgt_dev.mode_and_submode(), UNKNOWN_MODE); assert_eq!(announces.len(), 1); + assert_eq!(tb.mgt_manager.get_and_clear_num_mode_requests(), 1); announces = tb .mgt_manager .mode_req_mock