first power abstraction
This commit is contained in:
parent
20327d14c0
commit
9e2d300347
@ -34,5 +34,6 @@ pub mod pus;
|
|||||||
pub mod res_code;
|
pub mod res_code;
|
||||||
pub mod seq_count;
|
pub mod seq_count;
|
||||||
pub mod tmtc;
|
pub mod tmtc;
|
||||||
|
pub mod power;
|
||||||
|
|
||||||
pub use spacepackets;
|
pub use spacepackets;
|
||||||
|
28
satrs-core/src/power.rs
Normal file
28
satrs-core/src/power.rs
Normal 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
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user