clean up code
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Robin Müller 2024-03-21 13:17:27 +01:00
parent 309d0101a0
commit f5e56c5bf8
Signed by: muellerr
GPG Key ID: A649FB78196E3849
8 changed files with 34 additions and 27 deletions

View File

@ -52,7 +52,9 @@ pub fn create_event_service_static(
),
event_request_tx,
);
Pus5Wrapper { pus_5_handler }
Pus5Wrapper {
handler: pus_5_handler,
}
}
pub fn create_event_service_dynamic(
@ -86,7 +88,9 @@ pub fn create_event_service_dynamic(
),
event_request_tx,
);
Pus5Wrapper { pus_5_handler }
Pus5Wrapper {
handler: pus_5_handler,
}
}
pub struct Pus5Wrapper<
@ -95,7 +99,7 @@ pub struct Pus5Wrapper<
TcInMemConverter: EcssTcInMemConverter,
VerificationReporter: VerificationReportingProvider,
> {
pub pus_5_handler:
pub handler:
PusService5EventHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>,
}
@ -106,8 +110,8 @@ impl<
VerificationReporter: VerificationReportingProvider,
> Pus5Wrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
{
pub fn handle_next_packet(&mut self, time_stamp: &[u8]) -> bool {
match self.pus_5_handler.handle_one_tc(time_stamp) {
pub fn poll_and_handle_next_tc(&mut self, time_stamp: &[u8]) -> bool {
match self.handler.poll_and_handle_next_tc(time_stamp) {
Ok(result) => match result {
PusPacketHandlerResult::RequestHandled => {}
PusPacketHandlerResult::RequestHandledPartialSuccess(e) => {

View File

@ -27,6 +27,7 @@ pub mod scheduler;
pub mod stack;
pub mod test;
/// Simple router structure which forwards PUS telecommands to dedicated handlers.
pub struct PusTcMpscRouter {
pub test_service_receiver: Sender<EcssTcAndToken>,
pub event_service_receiver: Sender<EcssTcAndToken>,

View File

@ -103,10 +103,10 @@ impl<
}
}
pub fn handle_next_packet(&mut self, time_stamp: &[u8]) -> bool {
pub fn poll_and_handle_next_tc(&mut self, time_stamp: &[u8]) -> bool {
match self
.pus_11_handler
.handle_one_tc(time_stamp, &mut self.sched_tc_pool)
.poll_and_handle_next_tc(time_stamp, &mut self.sched_tc_pool)
{
Ok(result) => match result {
PusPacketHandlerResult::RequestHandled => {}

View File

@ -53,6 +53,8 @@ impl<
}
pub fn periodic_operation(&mut self) {
// Release all telecommands which reached their release time before calling the service
// handlers.
self.schedule_srv.release_tcs();
let time_stamp = cds::TimeProvider::from_now_with_u16_days()
.expect("time stamp generation error")
@ -68,9 +70,9 @@ impl<
nothing_to_do = false;
}
};
is_srv_finished(self.test_srv.handle_next_packet(&time_stamp), None);
is_srv_finished(self.schedule_srv.handle_next_packet(&time_stamp), None);
is_srv_finished(self.event_srv.handle_next_packet(&time_stamp), None);
is_srv_finished(self.test_srv.poll_and_handle_next_packet(&time_stamp), None);
is_srv_finished(self.schedule_srv.poll_and_handle_next_tc(&time_stamp), None);
is_srv_finished(self.event_srv.poll_and_handle_next_tc(&time_stamp), None);
is_srv_finished(
self.action_srv_wrapper.poll_and_handle_next_tc(&time_stamp),
Some(

View File

@ -54,7 +54,7 @@ pub fn create_test_service_static(
EcssTcInSharedStoreConverter::new(tc_pool, 2048),
));
Service17CustomWrapper {
pus17_handler,
handler: pus17_handler,
test_srv_event_sender: event_sender,
}
}
@ -88,7 +88,7 @@ pub fn create_test_service_dynamic(
EcssTcInVecConverter::default(),
));
Service17CustomWrapper {
pus17_handler,
handler: pus17_handler,
test_srv_event_sender: event_sender,
}
}
@ -99,7 +99,7 @@ pub struct Service17CustomWrapper<
TcInMemConverter: EcssTcInMemConverter,
VerificationReporter: VerificationReportingProvider,
> {
pub pus17_handler:
pub handler:
PusService17TestHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>,
pub test_srv_event_sender: Sender<(EventU32, Option<Params>)>,
}
@ -111,8 +111,8 @@ impl<
VerificationReporter: VerificationReportingProvider,
> Service17CustomWrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
{
pub fn handle_next_packet(&mut self, time_stamp: &[u8]) -> bool {
let res = self.pus17_handler.handle_one_tc(time_stamp);
pub fn poll_and_handle_next_packet(&mut self, time_stamp: &[u8]) -> bool {
let res = self.handler.poll_and_handle_next_tc(time_stamp);
if res.is_err() {
warn!("PUS17 handler failed with error {:?}", res.unwrap_err());
return true;
@ -133,7 +133,7 @@ impl<
}
PusPacketHandlerResult::CustomSubservice(subservice, token) => {
let (tc, _) = PusTcReader::new(
self.pus17_handler
self.handler
.service_helper
.tc_in_mem_converter
.tc_slice_raw(),
@ -148,19 +148,19 @@ impl<
.send((TEST_EVENT.into(), None))
.expect("Sending test event failed");
let start_token = self
.pus17_handler
.handler
.service_helper
.verif_reporter()
.start_success(token, &stamp_buf)
.expect("Error sending start success");
self.pus17_handler
self.handler
.service_helper
.verif_reporter()
.completion_success(start_token, &stamp_buf)
.expect("Error sending completion success");
} else {
let fail_data = [tc.subservice()];
self.pus17_handler
self.handler
.service_helper
.verif_reporter()
.start_failure(

View File

@ -46,7 +46,7 @@ impl<
}
}
pub fn handle_one_tc(
pub fn poll_and_handle_next_tc(
&mut self,
time_stamp: &[u8],
) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
@ -213,7 +213,7 @@ mod tests {
impl SimplePusPacketHandler for Pus5HandlerWithStoreTester {
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
self.handler.handle_one_tc(&time_stamp)
self.handler.poll_and_handle_next_tc(&time_stamp)
}
}

View File

@ -73,7 +73,7 @@ impl<
&self.scheduler
}
pub fn handle_one_tc(
pub fn poll_and_handle_next_tc(
&mut self,
time_stamp: &[u8],
sched_tc_pool: &mut (impl PoolProvider + ?Sized),
@ -279,7 +279,7 @@ mod tests {
pub fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
self.handler
.handle_one_tc(&time_stamp, &mut self.sched_tc_pool)
.poll_and_handle_next_tc(&time_stamp, &mut self.sched_tc_pool)
}
}
@ -351,7 +351,7 @@ mod tests {
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
test_harness
.handler
.handle_one_tc(&time_stamp, &mut test_harness.sched_tc_pool)
.poll_and_handle_next_tc(&time_stamp, &mut test_harness.sched_tc_pool)
.unwrap();
test_harness.check_next_verification_tm(1, request_id);
test_harness.check_next_verification_tm(3, request_id);

View File

@ -47,7 +47,7 @@ impl<
Self { service_helper }
}
pub fn handle_one_tc(
pub fn poll_and_handle_next_tc(
&mut self,
time_stamp: &[u8],
) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
@ -212,7 +212,7 @@ mod tests {
impl SimplePusPacketHandler for Pus17HandlerWithStoreTester {
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
self.handler.handle_one_tc(&time_stamp)
self.handler.poll_and_handle_next_tc(&time_stamp)
}
}
@ -254,7 +254,7 @@ mod tests {
impl SimplePusPacketHandler for Pus17HandlerWithVecTester {
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
self.handler.handle_one_tc(&time_stamp)
self.handler.poll_and_handle_next_tc(&time_stamp)
}
}