first power abstraction

This commit is contained in:
Robin Müller 2023-02-05 01:18:23 +01:00
parent 20327d14c0
commit 9e2d300347
No known key found for this signature in database
GPG Key ID: BE6480244DFE612C
2 changed files with 29 additions and 0 deletions

View File

@ -34,5 +34,6 @@ pub mod pus;
pub mod res_code;
pub mod seq_count;
pub mod tmtc;
pub mod power;
pub use spacepackets;

28
satrs-core/src/power.rs Normal file
View File

@ -0,0 +1,28 @@
pub trait PowerSwitch {
fn switch_on(&mut self);
fn switch_off(&mut self);
fn is_switch_on(&self) -> bool {
self.switch_state() == SwitchState::On
}
fn switch_state(&self) -> SwitchState;
}
pub enum SwitchState {
Off = 0,
On = 1,
Unknown = 2
}
pub trait PowerSwitcher {
fn send_switch_on_cmd(&mut self, switch_nr: u16);
fn send_switch_off_cmd(&mut self, switch_nr: u16);
fn get_switch_state(&mut self, switch_nr: u16) -> SwitchState;
fn get_is_switch_on(&mut self) -> bool {
self.get_switch_state() == SwitchState::On
}
}