From 89a7de355f3fba7e32addcf3af6c57add00cc00d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 21 Jan 2023 13:18:57 +0100 Subject: [PATCH] continue scheduler --- Cargo.lock | 4 ++-- satrs-core/Cargo.toml | 2 +- satrs-core/src/pus/scheduling.rs | 40 +++++++++++++++++++++++++------- spacepackets | 2 +- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2072b15..c16a4e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -568,7 +568,7 @@ dependencies = [ "postcard", "serde", "serde_json", - "spacepackets 0.5.0 (git+https://egit.irs.uni-stuttgart.de/rust/spacepackets.git?rev=1e9079307273e414a6333bf575322c1eb302c93e)", + "spacepackets 0.5.0 (git+https://egit.irs.uni-stuttgart.de/rust/spacepackets.git?rev=74e489bd074)", "zerocopy", ] @@ -698,7 +698,7 @@ dependencies = [ [[package]] name = "spacepackets" version = "0.5.0" -source = "git+https://egit.irs.uni-stuttgart.de/rust/spacepackets.git?rev=1e9079307273e414a6333bf575322c1eb302c93e#1e9079307273e414a6333bf575322c1eb302c93e" +source = "git+https://egit.irs.uni-stuttgart.de/rust/spacepackets.git?rev=74e489bd074#74e489bd074bbd8139a1c8740aa1670a2ef9b671" dependencies = [ "chrono", "crc", diff --git a/satrs-core/Cargo.toml b/satrs-core/Cargo.toml index 2ee6224..88bd2c4 100644 --- a/satrs-core/Cargo.toml +++ b/satrs-core/Cargo.toml @@ -56,7 +56,7 @@ optional = true git = "https://egit.irs.uni-stuttgart.de/rust/spacepackets.git" # path = "../spacepackets" # version = "0.4.0" -rev = "1e9079307273e414a6333bf575322c1eb302c93e" +rev = "74e489bd074" default-features = false diff --git a/satrs-core/src/pus/scheduling.rs b/satrs-core/src/pus/scheduling.rs index e204b95..76507f5 100644 --- a/satrs-core/src/pus/scheduling.rs +++ b/satrs-core/src/pus/scheduling.rs @@ -1,14 +1,40 @@ use crate::pool::StoreAddr; -use spacepackets::time::cds; -use spacepackets::time::cds::TimeProvider; use std::collections::BTreeMap; +use spacepackets::time::UnixTimestamp; +#[derive(Debug)] pub struct PusScheduler { - tc_map: BTreeMap, + tc_map: BTreeMap, + current_time: UnixTimestamp, + enabled: bool } impl PusScheduler { - pub fn insert_tc(&mut self, time_stamp: TimeProvider, addr: StoreAddr) { + pub fn new(init_current_time: UnixTimestamp) -> Self { + PusScheduler { + tc_map: Default::default(), + current_time: init_current_time, + enabled: true + } + } + + pub fn is_enabled(&self) -> bool { + self.enabled + } + + pub fn enable(&mut self) { + self.enabled = true; + } + + pub fn disable(&mut self) { + self.enabled = false; + } + + pub fn update_time(&mut self, current_time: UnixTimestamp) { + self.current_time = current_time; + } + + pub fn insert_tc(&mut self, time_stamp: UnixTimestamp, addr: StoreAddr) { self.tc_map.insert(time_stamp, addr); } } @@ -19,9 +45,7 @@ mod tests { use std::collections::BTreeMap; #[test] - fn wtf() { - let scheduler = PusScheduler { - tc_map: BTreeMap::new(), - }; + fn basic() { + let scheduler = PusScheduler::new(); } } diff --git a/spacepackets b/spacepackets index 1e90793..74e489b 160000 --- a/spacepackets +++ b/spacepackets @@ -1 +1 @@ -Subproject commit 1e9079307273e414a6333bf575322c1eb302c93e +Subproject commit 74e489bd074bbd8139a1c8740aa1670a2ef9b671