From 75fda42f4fd90c7d50af9ae0576000481c9e1c17 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 26 Feb 2024 10:53:33 +0100 Subject: [PATCH 1/2] fixed for scheduler --- satrs/CHANGELOG.md | 5 +++++ satrs/src/pus/scheduler.rs | 43 +++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/satrs/CHANGELOG.md b/satrs/CHANGELOG.md index 861c79b..290d551 100644 --- a/satrs/CHANGELOG.md +++ b/satrs/CHANGELOG.md @@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - `SenderTable` -> `SenderMapProvider` - There is an `EventManagerWithMpsc` and a `EventManagerWithBoundedMpsc` helper type now. +## Fixed + +- Update deprecated API for `PusScheduler::insert_wrapped_tc_cds_short` + and `PusScheduler::insert_wrapped_tc_cds_long`. + # [v0.2.0-rc.0] 2024-02-21 ## Added diff --git a/satrs/src/pus/scheduler.rs b/satrs/src/pus/scheduler.rs index e55028c..f455230 100644 --- a/satrs/src/pus/scheduler.rs +++ b/satrs/src/pus/scheduler.rs @@ -340,18 +340,12 @@ pub fn generate_insert_telecommand_app_data( #[cfg(feature = "alloc")] pub mod alloc_mod { + use alloc::{collections::{btree_map::{Entry, Range}, BTreeMap}, vec::Vec}; + use spacepackets::time::cds::{self, DaysLen24Bits}; + + use crate::pool::StoreAddr; + use super::*; - use crate::pool::{PoolProvider, StoreAddr, StoreError}; - use alloc::collections::btree_map::{Entry, Range}; - use alloc::collections::BTreeMap; - use alloc::vec; - use alloc::vec::Vec; - use core::time::Duration; - use spacepackets::ecss::scheduling::TimeWindowType; - use spacepackets::ecss::tc::{PusTc, PusTcReader}; - use spacepackets::ecss::PusPacket; - use spacepackets::time::cds::DaysLen24Bits; - use spacepackets::time::{cds, CcsdsTimeProvider, UnixTimestamp}; #[cfg(feature = "std")] use std::time::SystemTimeError; @@ -461,7 +455,7 @@ pub mod alloc_mod { } match self.tc_map.entry(time_stamp) { Entry::Vacant(e) => { - e.insert(vec![info]); + e.insert(alloc::vec![info]); } Entry::Occupied(mut v) => { v.get_mut().push(info); @@ -498,7 +492,7 @@ pub mod alloc_mod { /// short timestamp with 16-bit length of days field. pub fn insert_wrapped_tc_cds_short( &mut self, - pus_tc: &PusTc, + pus_tc: &(impl IsPusTelecommand + PusPacket + GenericPusTcSecondaryHeader), pool: &mut (impl PoolProvider + ?Sized), ) -> Result { self.insert_wrapped_tc::(pus_tc, pool) @@ -508,7 +502,7 @@ pub mod alloc_mod { /// long timestamp with a 24-bit length of days field. pub fn insert_wrapped_tc_cds_long( &mut self, - pus_tc: &PusTc, + pus_tc: &(impl IsPusTelecommand + PusPacket + GenericPusTcSecondaryHeader), pool: &mut (impl PoolProvider + ?Sized), ) -> Result { self.insert_wrapped_tc::>(pus_tc, pool) @@ -530,7 +524,7 @@ pub mod alloc_mod { let range = self.retrieve_by_time_filter(time_window); let mut del_packets = 0; let mut res_if_fails = None; - let mut keys_to_delete = Vec::new(); + let mut keys_to_delete = alloc::vec::Vec::new(); for time_bucket in range { for tc in time_bucket.1 { match pool.delete(tc.addr) { @@ -561,7 +555,10 @@ pub mod alloc_mod { } /// Retrieve a range over all scheduled commands. - pub fn retrieve_all(&mut self) -> Range<'_, UnixTimestamp, Vec> { + pub fn retrieve_all( + &mut self, + ) -> alloc::collections::btree_map::Range<'_, UnixTimestamp, alloc::vec::Vec> + { self.tc_map.range(..) } @@ -572,7 +569,8 @@ pub mod alloc_mod { pub fn retrieve_by_time_filter( &mut self, time_window: TimeWindow, - ) -> Range<'_, UnixTimestamp, Vec> { + ) -> Range<'_, UnixTimestamp, alloc::vec::Vec> + { match time_window.time_window_type() { TimeWindowType::SelectAll => self.tc_map.range(..), TimeWindowType::TimeTagToTimeTag => { @@ -761,9 +759,9 @@ pub mod alloc_mod { mut releaser: R, tc_store: &(impl PoolProvider + ?Sized), tc_buf: &mut [u8], - ) -> Result, (Vec, StoreError)> { + ) -> Result, (alloc::vec::Vec, StoreError)> { let tcs_to_release = self.telecommands_to_release(); - let mut released_tcs = Vec::new(); + let mut released_tcs = alloc::vec::Vec::new(); for tc in tcs_to_release { for info in tc.1 { tc_store @@ -778,7 +776,10 @@ pub mod alloc_mod { } /// Retrieve all telecommands which should be release based on the current time. - pub fn telecommands_to_release(&self) -> Range<'_, UnixTimestamp, Vec> { + pub fn telecommands_to_release( + &self, + ) -> Range<'_, UnixTimestamp, Vec> + { self.tc_map.range(..=self.current_time) } } @@ -835,7 +836,7 @@ pub mod alloc_mod { } match self.tc_map.entry(time_stamp) { Entry::Vacant(e) => { - e.insert(vec![info]); + e.insert(alloc::vec![info]); } Entry::Occupied(mut v) => { v.get_mut().push(info); From a7ca00317fb047723fb43cac2b21f1d999f1dfd3 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 26 Feb 2024 11:00:48 +0100 Subject: [PATCH 2/2] cargo fmt --- satrs/src/pus/scheduler.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/satrs/src/pus/scheduler.rs b/satrs/src/pus/scheduler.rs index f455230..cebcf2c 100644 --- a/satrs/src/pus/scheduler.rs +++ b/satrs/src/pus/scheduler.rs @@ -340,7 +340,13 @@ pub fn generate_insert_telecommand_app_data( #[cfg(feature = "alloc")] pub mod alloc_mod { - use alloc::{collections::{btree_map::{Entry, Range}, BTreeMap}, vec::Vec}; + use alloc::{ + collections::{ + btree_map::{Entry, Range}, + BTreeMap, + }, + vec::Vec, + }; use spacepackets::time::cds::{self, DaysLen24Bits}; use crate::pool::StoreAddr; @@ -569,8 +575,7 @@ pub mod alloc_mod { pub fn retrieve_by_time_filter( &mut self, time_window: TimeWindow, - ) -> Range<'_, UnixTimestamp, alloc::vec::Vec> - { + ) -> Range<'_, UnixTimestamp, alloc::vec::Vec> { match time_window.time_window_type() { TimeWindowType::SelectAll => self.tc_map.range(..), TimeWindowType::TimeTagToTimeTag => { @@ -776,10 +781,7 @@ pub mod alloc_mod { } /// Retrieve all telecommands which should be release based on the current time. - pub fn telecommands_to_release( - &self, - ) -> Range<'_, UnixTimestamp, Vec> - { + pub fn telecommands_to_release(&self) -> Range<'_, UnixTimestamp, Vec> { self.tc_map.range(..=self.current_time) } }