power_abstractions + request id schedule implementation #32

Merged
muellerr merged 8 commits from power_abstractions into main 2023-02-14 16:00:19 +01:00
8 changed files with 19 additions and 25 deletions
Showing only changes of commit ec46d94dc7 - Show all commits

View File

@ -25,6 +25,7 @@ pub mod events;
#[cfg_attr(doc_cfg, doc(cfg(feature = "std")))] #[cfg_attr(doc_cfg, doc(cfg(feature = "std")))]
pub mod executable; pub mod executable;
pub mod hal; pub mod hal;
pub mod hk;
pub mod objects; pub mod objects;
pub mod params; pub mod params;
#[cfg(feature = "alloc")] #[cfg(feature = "alloc")]
@ -32,10 +33,9 @@ pub mod params;
pub mod pool; pub mod pool;
pub mod power; pub mod power;
pub mod pus; pub mod pus;
pub mod request;
pub mod res_code; pub mod res_code;
pub mod seq_count; pub mod seq_count;
pub mod tmtc; pub mod tmtc;
pub mod request;
pub mod hk;
pub use spacepackets; pub use spacepackets;

View File

@ -45,7 +45,6 @@ pub trait PowerSwitcherCommandSender {
) -> Result<(), <T as PowerSwitch>::Error> { ) -> Result<(), <T as PowerSwitch>::Error> {
switch.switch_off() switch.switch_off()
} }
} }
pub trait PowerSwitchInfo { pub trait PowerSwitchInfo {
@ -72,22 +71,21 @@ pub trait PowerSwitchProvider: PowerSwitcherCommandSender + PowerSwitchInfo {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::boxed::Box;
use crate::power::PowerSwitcherCommandSender; use crate::power::PowerSwitcherCommandSender;
use std::boxed::Box;
struct Pcdu { struct Pcdu {
switch_rx: std::sync::mpsc::Receiver<(SwitchId, u16)> switch_rx: std::sync::mpsc::Receiver<(SwitchId, u16)>,
} }
enum DeviceState { enum DeviceState {
OFF, OFF,
SwitchingPower, SwitchingPower,
ON, ON,
SETUP, SETUP,
IDLE IDLE,
} }
struct MyComplexDevice { struct MyComplexDevice {
power_switcher: Box<dyn PowerSwitcherCommandSender<Error=()>>, power_switcher: Box<dyn PowerSwitcherCommandSender<Error = ()>>,
switch_id: SwitchId, switch_id: SwitchId,
some_state: u16, some_state: u16,
dev_state: DeviceState, dev_state: DeviceState,
@ -101,7 +99,9 @@ mod tests {
let mode = 1; let mode = 1;
if mode == 1 { if mode == 1 {
if self.dev_state == DeviceState::OFF { if self.dev_state == DeviceState::OFF {
self.power_switcher.send_switch_on_cmd(self.switch_id).expect("sending siwthc cmd failed"); self.power_switcher
.send_switch_on_cmd(self.switch_id)
.expect("sending siwthc cmd failed");
self.dev_state = DeviceState::SwitchingPower; self.dev_state = DeviceState::SwitchingPower;
} }
if self.dev_state == DeviceState::SwitchingPower { if self.dev_state == DeviceState::SwitchingPower {
@ -113,4 +113,4 @@ mod tests {
} }
} }
} }
} }

View File

@ -0,0 +1 @@

View File

@ -1,9 +1,4 @@
use satrs_core::tmtc::AddressableId;
#[derive(Debug, Copy, Clone, PartialEq, Eq)] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum AcsHkIds { pub enum AcsHkIds {
TestMgmSet = 1, TestMgmSet = 1,
} }

View File

@ -1,5 +1,5 @@
use satrs_core::events::{EventU32TypedSev, SeverityInfo};
use std::net::Ipv4Addr; use std::net::Ipv4Addr;
use satrs_core::events::{EventU32, EventU32TypedSev, Severity, SeverityInfo};
use satrs_mib::res_code::{ResultU16, ResultU16Info}; use satrs_mib::res_code::{ResultU16, ResultU16Info};
use satrs_mib::resultcode; use satrs_mib::resultcode;
@ -51,5 +51,3 @@ pub mod hk_err {
#[resultcode] #[resultcode]
pub const COLLECTION_INTERVAL_MISSING: ResultU16 = ResultU16::const_new(GroupId::Hk as u8, 3); pub const COLLECTION_INTERVAL_MISSING: ResultU16 = ResultU16::const_new(GroupId::Hk as u8, 3);
} }

View File

@ -4,7 +4,7 @@ mod pus;
mod requests; mod requests;
mod tmtc; mod tmtc;
use crate::hk::{AcsHkIds}; use crate::hk::AcsHkIds;
use crate::requests::{Request, RequestWithToken}; use crate::requests::{Request, RequestWithToken};
use crate::tmtc::{ use crate::tmtc::{
core_tmtc_task, OtherArgs, PusTcSource, TcArgs, TcStore, TmArgs, TmFunnel, TmStore, PUS_APID, core_tmtc_task, OtherArgs, PusTcSource, TcArgs, TcStore, TmArgs, TmFunnel, TmStore, PUS_APID,
@ -13,6 +13,7 @@ use satrs_core::event_man::{
EventManagerWithMpscQueue, MpscEventReceiver, MpscEventU32SendProvider, SendEventProvider, EventManagerWithMpscQueue, MpscEventReceiver, MpscEventU32SendProvider, SendEventProvider,
}; };
use satrs_core::events::EventU32; use satrs_core::events::EventU32;
use satrs_core::hk::HkRequest;
use satrs_core::pool::{LocalPool, PoolCfg, StoreAddr}; use satrs_core::pool::{LocalPool, PoolCfg, StoreAddr};
use satrs_core::pus::event_man::{ use satrs_core::pus::event_man::{
DefaultPusMgmtBackendProvider, EventReporter, EventRequest, EventRequestWithToken, DefaultPusMgmtBackendProvider, EventReporter, EventRequest, EventRequestWithToken,
@ -37,7 +38,6 @@ use std::sync::mpsc::{channel, TryRecvError};
use std::sync::{mpsc, Arc, RwLock}; use std::sync::{mpsc, Arc, RwLock};
use std::thread; use std::thread;
use std::time::Duration; use std::time::Duration;
use satrs_core::hk::HkRequest;
#[derive(Clone)] #[derive(Clone)]
struct EventTmSender { struct EventTmSender {
@ -245,7 +245,6 @@ fn main() {
HkRequest::Disable(_) => {} HkRequest::Disable(_) => {}
HkRequest::ModifyCollectionInterval(_, _) => {} HkRequest::ModifyCollectionInterval(_, _) => {}
}, },
_ => {}
} }
let started_token = reporter_aocs let started_token = reporter_aocs
.start_success(request.1, Some(&timestamp)) .start_success(request.1, Some(&timestamp))

View File

@ -1,6 +1,8 @@
use crate::requests::{Request, RequestWithToken}; use crate::requests::{Request, RequestWithToken};
use crate::tmtc::{PusTcSource, TmStore}; use crate::tmtc::{PusTcSource, TmStore};
use satrs_core::events::EventU32; use satrs_core::events::EventU32;
use satrs_core::hk::{CollectionIntervalFactor, HkRequest};
use satrs_core::params::Params;
use satrs_core::pool::StoreAddr; use satrs_core::pool::StoreAddr;
use satrs_core::pus::event; use satrs_core::pus::event;
use satrs_core::pus::event_man::{EventRequest, EventRequestWithToken}; use satrs_core::pus::event_man::{EventRequest, EventRequestWithToken};
@ -21,8 +23,6 @@ use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::rc::Rc; use std::rc::Rc;
use std::sync::mpsc::Sender; use std::sync::mpsc::Sender;
use satrs_core::hk::{CollectionIntervalFactor, HkRequest};
use satrs_core::params::Params;
pub struct PusReceiver { pub struct PusReceiver {
pub tm_helper: PusTmWithCdsShortHelper, pub tm_helper: PusTmWithCdsShortHelper,
@ -133,7 +133,9 @@ impl PusReceiver {
} }
128 => { 128 => {
self.update_time_stamp(); self.update_time_stamp();
self.event_sender.send((TEST_EVENT.into(), None)).expect("Sending test event failed"); self.event_sender
.send((TEST_EVENT.into(), None))
.expect("Sending test event failed");
let start_token = self let start_token = self
.verif_reporter .verif_reporter
.start_success(token, Some(&self.time_stamp)) .start_success(token, Some(&self.time_stamp))

View File

@ -4,7 +4,6 @@ use satrs_core::pus::verification::{TcStateAccepted, VerificationToken};
#[derive(Copy, Clone, Eq, PartialEq, Debug)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum Request { pub enum Request {
HkRequest(HkRequest), HkRequest(HkRequest),
ModeRequest
} }
#[derive(Copy, Clone, Eq, PartialEq, Debug)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]