simplified struct further
This commit is contained in:
parent
943ae821de
commit
3f862b18c7
@ -33,13 +33,8 @@ use std::sync::mpsc::Sender;
|
|||||||
pub struct PusReceiver {
|
pub struct PusReceiver {
|
||||||
pub tm_helper: PusTmWithCdsShortHelper,
|
pub tm_helper: PusTmWithCdsShortHelper,
|
||||||
pub tm_args: PusTmArgs,
|
pub tm_args: PusTmArgs,
|
||||||
#[allow(dead_code)]
|
pub tc_args: PusTcArgs,
|
||||||
tc_source: PusTcSource,
|
|
||||||
stamp_helper: TimeStampHelper,
|
stamp_helper: TimeStampHelper,
|
||||||
event_request_tx: Sender<EventRequestWithToken>,
|
|
||||||
event_sender: Sender<(EventU32, Option<Params>)>,
|
|
||||||
request_map: HashMap<u32, Sender<RequestWithToken>>,
|
|
||||||
scheduler: Rc<RefCell<PusScheduler>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct PusTmArgs {
|
pub struct PusTmArgs {
|
||||||
@ -51,6 +46,12 @@ pub struct PusTmArgs {
|
|||||||
pub verif_reporter: StdVerifReporterWithSender,
|
pub verif_reporter: StdVerifReporterWithSender,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PusTmArgs {
|
||||||
|
fn vr(&mut self) -> &mut StdVerifReporterWithSender {
|
||||||
|
&mut self.verif_reporter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct PusTcArgs {
|
pub struct PusTcArgs {
|
||||||
pub event_request_tx: Sender<EventRequestWithToken>,
|
pub event_request_tx: Sender<EventRequestWithToken>,
|
||||||
/// Request routing helper. Maps targeted request to their recipient.
|
/// Request routing helper. Maps targeted request to their recipient.
|
||||||
@ -93,12 +94,8 @@ impl PusReceiver {
|
|||||||
Self {
|
Self {
|
||||||
tm_helper: PusTmWithCdsShortHelper::new(apid),
|
tm_helper: PusTmWithCdsShortHelper::new(apid),
|
||||||
tm_args: tm_arguments,
|
tm_args: tm_arguments,
|
||||||
tc_source: tc_arguments.tc_source,
|
tc_args: tc_arguments,
|
||||||
event_request_tx: tc_arguments.event_request_tx,
|
|
||||||
event_sender: tc_arguments.event_sender,
|
|
||||||
request_map: tc_arguments.request_map,
|
|
||||||
stamp_helper: TimeStampHelper::new(),
|
stamp_helper: TimeStampHelper::new(),
|
||||||
scheduler: tc_arguments.scheduler,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,7 +113,7 @@ impl PusServiceProvider for PusReceiver {
|
|||||||
self.stamp_helper.update_from_now();
|
self.stamp_helper.update_from_now();
|
||||||
let accepted_token = self
|
let accepted_token = self
|
||||||
.tm_args
|
.tm_args
|
||||||
.verif_reporter
|
.vr()
|
||||||
.acceptance_success(init_token, Some(self.stamp_helper.stamp()))
|
.acceptance_success(init_token, Some(self.stamp_helper.stamp()))
|
||||||
.expect("Acceptance success failure");
|
.expect("Acceptance success failure");
|
||||||
let service = PusServiceId::try_from(service);
|
let service = PusServiceId::try_from(service);
|
||||||
@ -189,7 +186,7 @@ impl PusReceiver {
|
|||||||
.expect("Error sending completion success");
|
.expect("Error sending completion success");
|
||||||
}
|
}
|
||||||
128 => {
|
128 => {
|
||||||
self.event_sender
|
self.tc_args.event_sender
|
||||||
.send((TEST_EVENT.into(), None))
|
.send((TEST_EVENT.into(), None))
|
||||||
.expect("Sending test event failed");
|
.expect("Sending test event failed");
|
||||||
let start_token = self
|
let start_token = self
|
||||||
@ -250,7 +247,7 @@ impl PusReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let addressable_id = AddressableId::from_raw_be(user_data).unwrap();
|
let addressable_id = AddressableId::from_raw_be(user_data).unwrap();
|
||||||
if !self.request_map.contains_key(&addressable_id.target_id) {
|
if !self.tc_args.request_map.contains_key(&addressable_id.target_id) {
|
||||||
self.tm_args
|
self.tm_args
|
||||||
.verif_reporter
|
.verif_reporter
|
||||||
.start_failure(
|
.start_failure(
|
||||||
@ -265,7 +262,7 @@ impl PusReceiver {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let send_request = |request: HkRequest| {
|
let send_request = |request: HkRequest| {
|
||||||
let sender = self.request_map.get(&addressable_id.target_id).unwrap();
|
let sender = self.tc_args.request_map.get(&addressable_id.target_id).unwrap();
|
||||||
sender
|
sender
|
||||||
.send(RequestWithToken(Request::HkRequest(request), token))
|
.send(RequestWithToken(Request::HkRequest(request), token))
|
||||||
.unwrap_or_else(|_| panic!("Sending HK request {request:?} failed"));
|
.unwrap_or_else(|_| panic!("Sending HK request {request:?} failed"));
|
||||||
@ -341,7 +338,7 @@ impl PusReceiver {
|
|||||||
&mut self.tm_args.verif_reporter,
|
&mut self.tm_args.verif_reporter,
|
||||||
self.stamp_helper.stamp(),
|
self.stamp_helper.stamp(),
|
||||||
);
|
);
|
||||||
self.event_request_tx
|
self.tc_args.event_request_tx
|
||||||
.send(EventRequestWithToken {
|
.send(EventRequestWithToken {
|
||||||
request: EventRequest::Enable(event_id),
|
request: EventRequest::Enable(event_id),
|
||||||
token: start_token,
|
token: start_token,
|
||||||
@ -353,7 +350,7 @@ impl PusReceiver {
|
|||||||
&mut self.tm_args.verif_reporter,
|
&mut self.tm_args.verif_reporter,
|
||||||
self.stamp_helper.stamp(),
|
self.stamp_helper.stamp(),
|
||||||
);
|
);
|
||||||
self.event_request_tx
|
self.tc_args.event_request_tx
|
||||||
.send(EventRequestWithToken {
|
.send(EventRequestWithToken {
|
||||||
request: EventRequest::Disable(event_id),
|
request: EventRequest::Disable(event_id),
|
||||||
token: start_token,
|
token: start_token,
|
||||||
@ -413,7 +410,7 @@ impl PusReceiver {
|
|||||||
.start_success(token, Some(self.stamp_helper.stamp()))
|
.start_success(token, Some(self.stamp_helper.stamp()))
|
||||||
.expect("Error sending start success");
|
.expect("Error sending start success");
|
||||||
|
|
||||||
let mut scheduler = self.scheduler.borrow_mut();
|
let mut scheduler = self.tc_args.scheduler.borrow_mut();
|
||||||
scheduler.enable();
|
scheduler.enable();
|
||||||
if scheduler.is_enabled() {
|
if scheduler.is_enabled() {
|
||||||
self.tm_args
|
self.tm_args
|
||||||
@ -431,7 +428,7 @@ impl PusReceiver {
|
|||||||
.start_success(token, Some(self.stamp_helper.stamp()))
|
.start_success(token, Some(self.stamp_helper.stamp()))
|
||||||
.expect("Error sending start success");
|
.expect("Error sending start success");
|
||||||
|
|
||||||
let mut scheduler = self.scheduler.borrow_mut();
|
let mut scheduler = self.tc_args.scheduler.borrow_mut();
|
||||||
scheduler.disable();
|
scheduler.disable();
|
||||||
if !scheduler.is_enabled() {
|
if !scheduler.is_enabled() {
|
||||||
self.tm_args
|
self.tm_args
|
||||||
@ -450,13 +447,14 @@ impl PusReceiver {
|
|||||||
.expect("Error sending start success");
|
.expect("Error sending start success");
|
||||||
|
|
||||||
let mut pool = self
|
let mut pool = self
|
||||||
|
.tc_args
|
||||||
.tc_source
|
.tc_source
|
||||||
.tc_store
|
.tc_store
|
||||||
.pool
|
.pool
|
||||||
.write()
|
.write()
|
||||||
.expect("Locking pool failed");
|
.expect("Locking pool failed");
|
||||||
|
|
||||||
let mut scheduler = self.scheduler.borrow_mut();
|
let mut scheduler = self.tc_args.scheduler.borrow_mut();
|
||||||
scheduler
|
scheduler
|
||||||
.reset(pool.as_mut())
|
.reset(pool.as_mut())
|
||||||
.expect("Error resetting TC Pool");
|
.expect("Error resetting TC Pool");
|
||||||
@ -475,12 +473,13 @@ impl PusReceiver {
|
|||||||
.expect("error sending start success");
|
.expect("error sending start success");
|
||||||
|
|
||||||
let mut pool = self
|
let mut pool = self
|
||||||
|
.tc_args
|
||||||
.tc_source
|
.tc_source
|
||||||
.tc_store
|
.tc_store
|
||||||
.pool
|
.pool
|
||||||
.write()
|
.write()
|
||||||
.expect("locking pool failed");
|
.expect("locking pool failed");
|
||||||
let mut scheduler = self.scheduler.borrow_mut();
|
let mut scheduler = self.tc_args.scheduler.borrow_mut();
|
||||||
scheduler
|
scheduler
|
||||||
.insert_wrapped_tc::<TimeProvider>(pus_tc, pool.as_mut())
|
.insert_wrapped_tc::<TimeProvider>(pus_tc, pool.as_mut())
|
||||||
.expect("insertion of activity into pool failed");
|
.expect("insertion of activity into pool failed");
|
||||||
@ -550,7 +549,7 @@ impl PusReceiver {
|
|||||||
let mode_request = Request::ModeRequest(ModeRequest::SetMode(
|
let mode_request = Request::ModeRequest(ModeRequest::SetMode(
|
||||||
ModeCommand::new(target_id, mode_submode),
|
ModeCommand::new(target_id, mode_submode),
|
||||||
));
|
));
|
||||||
match self.request_map.get(&target_id) {
|
match self.tc_args.request_map.get(&target_id) {
|
||||||
None => {}
|
None => {}
|
||||||
Some(sender_to_recipient) => {
|
Some(sender_to_recipient) => {
|
||||||
sender_to_recipient
|
sender_to_recipient
|
||||||
|
Loading…
Reference in New Issue
Block a user