clean up code
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
Some checks failed
Rust/sat-rs/pipeline/pr-main There was a failure building this commit
This commit is contained in:
parent
309d0101a0
commit
f5e56c5bf8
@ -52,7 +52,9 @@ pub fn create_event_service_static(
|
|||||||
),
|
),
|
||||||
event_request_tx,
|
event_request_tx,
|
||||||
);
|
);
|
||||||
Pus5Wrapper { pus_5_handler }
|
Pus5Wrapper {
|
||||||
|
handler: pus_5_handler,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_event_service_dynamic(
|
pub fn create_event_service_dynamic(
|
||||||
@ -86,7 +88,9 @@ pub fn create_event_service_dynamic(
|
|||||||
),
|
),
|
||||||
event_request_tx,
|
event_request_tx,
|
||||||
);
|
);
|
||||||
Pus5Wrapper { pus_5_handler }
|
Pus5Wrapper {
|
||||||
|
handler: pus_5_handler,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Pus5Wrapper<
|
pub struct Pus5Wrapper<
|
||||||
@ -95,7 +99,7 @@ pub struct Pus5Wrapper<
|
|||||||
TcInMemConverter: EcssTcInMemConverter,
|
TcInMemConverter: EcssTcInMemConverter,
|
||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
> {
|
> {
|
||||||
pub pus_5_handler:
|
pub handler:
|
||||||
PusService5EventHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>,
|
PusService5EventHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +110,8 @@ impl<
|
|||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
> Pus5Wrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
|
> Pus5Wrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
|
||||||
{
|
{
|
||||||
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_5_handler.handle_one_tc(time_stamp) {
|
match self.handler.poll_and_handle_next_tc(time_stamp) {
|
||||||
Ok(result) => match result {
|
Ok(result) => match result {
|
||||||
PusPacketHandlerResult::RequestHandled => {}
|
PusPacketHandlerResult::RequestHandled => {}
|
||||||
PusPacketHandlerResult::RequestHandledPartialSuccess(e) => {
|
PusPacketHandlerResult::RequestHandledPartialSuccess(e) => {
|
||||||
|
@ -27,6 +27,7 @@ pub mod scheduler;
|
|||||||
pub mod stack;
|
pub mod stack;
|
||||||
pub mod test;
|
pub mod test;
|
||||||
|
|
||||||
|
/// Simple router structure which forwards PUS telecommands to dedicated handlers.
|
||||||
pub struct PusTcMpscRouter {
|
pub struct PusTcMpscRouter {
|
||||||
pub test_service_receiver: Sender<EcssTcAndToken>,
|
pub test_service_receiver: Sender<EcssTcAndToken>,
|
||||||
pub event_service_receiver: Sender<EcssTcAndToken>,
|
pub event_service_receiver: Sender<EcssTcAndToken>,
|
||||||
|
@ -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
|
match self
|
||||||
.pus_11_handler
|
.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 {
|
Ok(result) => match result {
|
||||||
PusPacketHandlerResult::RequestHandled => {}
|
PusPacketHandlerResult::RequestHandled => {}
|
||||||
|
@ -53,6 +53,8 @@ impl<
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn periodic_operation(&mut self) {
|
pub fn periodic_operation(&mut self) {
|
||||||
|
// Release all telecommands which reached their release time before calling the service
|
||||||
|
// handlers.
|
||||||
self.schedule_srv.release_tcs();
|
self.schedule_srv.release_tcs();
|
||||||
let time_stamp = cds::TimeProvider::from_now_with_u16_days()
|
let time_stamp = cds::TimeProvider::from_now_with_u16_days()
|
||||||
.expect("time stamp generation error")
|
.expect("time stamp generation error")
|
||||||
@ -68,9 +70,9 @@ impl<
|
|||||||
nothing_to_do = false;
|
nothing_to_do = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
is_srv_finished(self.test_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.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.handle_next_packet(&time_stamp), None);
|
is_srv_finished(self.event_srv.poll_and_handle_next_tc(&time_stamp), None);
|
||||||
is_srv_finished(
|
is_srv_finished(
|
||||||
self.action_srv_wrapper.poll_and_handle_next_tc(&time_stamp),
|
self.action_srv_wrapper.poll_and_handle_next_tc(&time_stamp),
|
||||||
Some(
|
Some(
|
||||||
|
@ -54,7 +54,7 @@ pub fn create_test_service_static(
|
|||||||
EcssTcInSharedStoreConverter::new(tc_pool, 2048),
|
EcssTcInSharedStoreConverter::new(tc_pool, 2048),
|
||||||
));
|
));
|
||||||
Service17CustomWrapper {
|
Service17CustomWrapper {
|
||||||
pus17_handler,
|
handler: pus17_handler,
|
||||||
test_srv_event_sender: event_sender,
|
test_srv_event_sender: event_sender,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ pub fn create_test_service_dynamic(
|
|||||||
EcssTcInVecConverter::default(),
|
EcssTcInVecConverter::default(),
|
||||||
));
|
));
|
||||||
Service17CustomWrapper {
|
Service17CustomWrapper {
|
||||||
pus17_handler,
|
handler: pus17_handler,
|
||||||
test_srv_event_sender: event_sender,
|
test_srv_event_sender: event_sender,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ pub struct Service17CustomWrapper<
|
|||||||
TcInMemConverter: EcssTcInMemConverter,
|
TcInMemConverter: EcssTcInMemConverter,
|
||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
> {
|
> {
|
||||||
pub pus17_handler:
|
pub handler:
|
||||||
PusService17TestHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>,
|
PusService17TestHandler<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>,
|
||||||
pub test_srv_event_sender: Sender<(EventU32, Option<Params>)>,
|
pub test_srv_event_sender: Sender<(EventU32, Option<Params>)>,
|
||||||
}
|
}
|
||||||
@ -111,8 +111,8 @@ impl<
|
|||||||
VerificationReporter: VerificationReportingProvider,
|
VerificationReporter: VerificationReportingProvider,
|
||||||
> Service17CustomWrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
|
> Service17CustomWrapper<TcReceiver, TmSender, TcInMemConverter, VerificationReporter>
|
||||||
{
|
{
|
||||||
pub fn handle_next_packet(&mut self, time_stamp: &[u8]) -> bool {
|
pub fn poll_and_handle_next_packet(&mut self, time_stamp: &[u8]) -> bool {
|
||||||
let res = self.pus17_handler.handle_one_tc(time_stamp);
|
let res = self.handler.poll_and_handle_next_tc(time_stamp);
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
warn!("PUS17 handler failed with error {:?}", res.unwrap_err());
|
warn!("PUS17 handler failed with error {:?}", res.unwrap_err());
|
||||||
return true;
|
return true;
|
||||||
@ -133,7 +133,7 @@ impl<
|
|||||||
}
|
}
|
||||||
PusPacketHandlerResult::CustomSubservice(subservice, token) => {
|
PusPacketHandlerResult::CustomSubservice(subservice, token) => {
|
||||||
let (tc, _) = PusTcReader::new(
|
let (tc, _) = PusTcReader::new(
|
||||||
self.pus17_handler
|
self.handler
|
||||||
.service_helper
|
.service_helper
|
||||||
.tc_in_mem_converter
|
.tc_in_mem_converter
|
||||||
.tc_slice_raw(),
|
.tc_slice_raw(),
|
||||||
@ -148,19 +148,19 @@ impl<
|
|||||||
.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
|
||||||
.pus17_handler
|
.handler
|
||||||
.service_helper
|
.service_helper
|
||||||
.verif_reporter()
|
.verif_reporter()
|
||||||
.start_success(token, &stamp_buf)
|
.start_success(token, &stamp_buf)
|
||||||
.expect("Error sending start success");
|
.expect("Error sending start success");
|
||||||
self.pus17_handler
|
self.handler
|
||||||
.service_helper
|
.service_helper
|
||||||
.verif_reporter()
|
.verif_reporter()
|
||||||
.completion_success(start_token, &stamp_buf)
|
.completion_success(start_token, &stamp_buf)
|
||||||
.expect("Error sending completion success");
|
.expect("Error sending completion success");
|
||||||
} else {
|
} else {
|
||||||
let fail_data = [tc.subservice()];
|
let fail_data = [tc.subservice()];
|
||||||
self.pus17_handler
|
self.handler
|
||||||
.service_helper
|
.service_helper
|
||||||
.verif_reporter()
|
.verif_reporter()
|
||||||
.start_failure(
|
.start_failure(
|
||||||
|
@ -46,7 +46,7 @@ impl<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_one_tc(
|
pub fn poll_and_handle_next_tc(
|
||||||
&mut self,
|
&mut self,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
||||||
@ -213,7 +213,7 @@ mod tests {
|
|||||||
impl SimplePusPacketHandler for Pus5HandlerWithStoreTester {
|
impl SimplePusPacketHandler for Pus5HandlerWithStoreTester {
|
||||||
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
||||||
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ impl<
|
|||||||
&self.scheduler
|
&self.scheduler
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_one_tc(
|
pub fn poll_and_handle_next_tc(
|
||||||
&mut self,
|
&mut self,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
sched_tc_pool: &mut (impl PoolProvider + ?Sized),
|
sched_tc_pool: &mut (impl PoolProvider + ?Sized),
|
||||||
@ -279,7 +279,7 @@ mod tests {
|
|||||||
pub fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
pub fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
||||||
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
|
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
|
||||||
self.handler
|
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();
|
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
|
||||||
test_harness
|
test_harness
|
||||||
.handler
|
.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();
|
.unwrap();
|
||||||
test_harness.check_next_verification_tm(1, request_id);
|
test_harness.check_next_verification_tm(1, request_id);
|
||||||
test_harness.check_next_verification_tm(3, request_id);
|
test_harness.check_next_verification_tm(3, request_id);
|
||||||
|
@ -47,7 +47,7 @@ impl<
|
|||||||
Self { service_helper }
|
Self { service_helper }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_one_tc(
|
pub fn poll_and_handle_next_tc(
|
||||||
&mut self,
|
&mut self,
|
||||||
time_stamp: &[u8],
|
time_stamp: &[u8],
|
||||||
) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
||||||
@ -212,7 +212,7 @@ mod tests {
|
|||||||
impl SimplePusPacketHandler for Pus17HandlerWithStoreTester {
|
impl SimplePusPacketHandler for Pus17HandlerWithStoreTester {
|
||||||
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
||||||
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
|
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 {
|
impl SimplePusPacketHandler for Pus17HandlerWithVecTester {
|
||||||
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
fn handle_one_tc(&mut self) -> Result<PusPacketHandlerResult, PusPacketHandlingError> {
|
||||||
let time_stamp = cds::TimeProvider::new_with_u16_days(0, 0).to_vec().unwrap();
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user