fixed for scheduler
Some checks failed
Rust/sat-rs/pipeline/head There was a failure building this commit

This commit is contained in:
Robin Müller 2024-02-26 10:53:33 +01:00
parent faf0f6f6c6
commit 75fda42f4f
Signed by: muellerr
GPG Key ID: A649FB78196E3849
2 changed files with 27 additions and 21 deletions

View File

@ -16,6 +16,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `SenderTable` -> `SenderMapProvider` - `SenderTable` -> `SenderMapProvider`
- There is an `EventManagerWithMpsc` and a `EventManagerWithBoundedMpsc` helper type now. - 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 # [v0.2.0-rc.0] 2024-02-21
## Added ## Added

View File

@ -340,18 +340,12 @@ pub fn generate_insert_telecommand_app_data(
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
pub mod alloc_mod { 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 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")] #[cfg(feature = "std")]
use std::time::SystemTimeError; use std::time::SystemTimeError;
@ -461,7 +455,7 @@ pub mod alloc_mod {
} }
match self.tc_map.entry(time_stamp) { match self.tc_map.entry(time_stamp) {
Entry::Vacant(e) => { Entry::Vacant(e) => {
e.insert(vec![info]); e.insert(alloc::vec![info]);
} }
Entry::Occupied(mut v) => { Entry::Occupied(mut v) => {
v.get_mut().push(info); v.get_mut().push(info);
@ -498,7 +492,7 @@ pub mod alloc_mod {
/// short timestamp with 16-bit length of days field. /// short timestamp with 16-bit length of days field.
pub fn insert_wrapped_tc_cds_short( pub fn insert_wrapped_tc_cds_short(
&mut self, &mut self,
pus_tc: &PusTc, pus_tc: &(impl IsPusTelecommand + PusPacket + GenericPusTcSecondaryHeader),
pool: &mut (impl PoolProvider + ?Sized), pool: &mut (impl PoolProvider + ?Sized),
) -> Result<TcInfo, ScheduleError> { ) -> Result<TcInfo, ScheduleError> {
self.insert_wrapped_tc::<cds::TimeProvider>(pus_tc, pool) self.insert_wrapped_tc::<cds::TimeProvider>(pus_tc, pool)
@ -508,7 +502,7 @@ pub mod alloc_mod {
/// long timestamp with a 24-bit length of days field. /// long timestamp with a 24-bit length of days field.
pub fn insert_wrapped_tc_cds_long( pub fn insert_wrapped_tc_cds_long(
&mut self, &mut self,
pus_tc: &PusTc, pus_tc: &(impl IsPusTelecommand + PusPacket + GenericPusTcSecondaryHeader),
pool: &mut (impl PoolProvider + ?Sized), pool: &mut (impl PoolProvider + ?Sized),
) -> Result<TcInfo, ScheduleError> { ) -> Result<TcInfo, ScheduleError> {
self.insert_wrapped_tc::<cds::TimeProvider<DaysLen24Bits>>(pus_tc, pool) self.insert_wrapped_tc::<cds::TimeProvider<DaysLen24Bits>>(pus_tc, pool)
@ -530,7 +524,7 @@ pub mod alloc_mod {
let range = self.retrieve_by_time_filter(time_window); let range = self.retrieve_by_time_filter(time_window);
let mut del_packets = 0; let mut del_packets = 0;
let mut res_if_fails = None; 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 time_bucket in range {
for tc in time_bucket.1 { for tc in time_bucket.1 {
match pool.delete(tc.addr) { match pool.delete(tc.addr) {
@ -561,7 +555,10 @@ pub mod alloc_mod {
} }
/// Retrieve a range over all scheduled commands. /// Retrieve a range over all scheduled commands.
pub fn retrieve_all(&mut self) -> Range<'_, UnixTimestamp, Vec<TcInfo>> { pub fn retrieve_all(
&mut self,
) -> alloc::collections::btree_map::Range<'_, UnixTimestamp, alloc::vec::Vec<TcInfo>>
{
self.tc_map.range(..) self.tc_map.range(..)
} }
@ -572,7 +569,8 @@ pub mod alloc_mod {
pub fn retrieve_by_time_filter<TimeProvider: CcsdsTimeProvider>( pub fn retrieve_by_time_filter<TimeProvider: CcsdsTimeProvider>(
&mut self, &mut self,
time_window: TimeWindow<TimeProvider>, time_window: TimeWindow<TimeProvider>,
) -> Range<'_, UnixTimestamp, Vec<TcInfo>> { ) -> Range<'_, UnixTimestamp, alloc::vec::Vec<TcInfo>>
{
match time_window.time_window_type() { match time_window.time_window_type() {
TimeWindowType::SelectAll => self.tc_map.range(..), TimeWindowType::SelectAll => self.tc_map.range(..),
TimeWindowType::TimeTagToTimeTag => { TimeWindowType::TimeTagToTimeTag => {
@ -761,9 +759,9 @@ pub mod alloc_mod {
mut releaser: R, mut releaser: R,
tc_store: &(impl PoolProvider + ?Sized), tc_store: &(impl PoolProvider + ?Sized),
tc_buf: &mut [u8], tc_buf: &mut [u8],
) -> Result<Vec<TcInfo>, (Vec<TcInfo>, StoreError)> { ) -> Result<alloc::vec::Vec<TcInfo>, (alloc::vec::Vec<TcInfo>, StoreError)> {
let tcs_to_release = self.telecommands_to_release(); 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 tc in tcs_to_release {
for info in tc.1 { for info in tc.1 {
tc_store tc_store
@ -778,7 +776,10 @@ pub mod alloc_mod {
} }
/// Retrieve all telecommands which should be release based on the current time. /// Retrieve all telecommands which should be release based on the current time.
pub fn telecommands_to_release(&self) -> Range<'_, UnixTimestamp, Vec<TcInfo>> { pub fn telecommands_to_release(
&self,
) -> Range<'_, UnixTimestamp, Vec<TcInfo>>
{
self.tc_map.range(..=self.current_time) self.tc_map.range(..=self.current_time)
} }
} }
@ -835,7 +836,7 @@ pub mod alloc_mod {
} }
match self.tc_map.entry(time_stamp) { match self.tc_map.entry(time_stamp) {
Entry::Vacant(e) => { Entry::Vacant(e) => {
e.insert(vec![info]); e.insert(alloc::vec![info]);
} }
Entry::Occupied(mut v) => { Entry::Occupied(mut v) => {
v.get_mut().push(info); v.get_mut().push(info);