start adding ACS subsystem
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#[derive(
|
||||
serde::Serialize,
|
||||
serde::Deserialize,
|
||||
Debug,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
num_enum::IntoPrimitive,
|
||||
num_enum::TryFromPrimitive,
|
||||
)]
|
||||
#[repr(u32)]
|
||||
pub enum Mode {
|
||||
Passive,
|
||||
Safe,
|
||||
Idle,
|
||||
}
|
||||
|
||||
pub mod request {
|
||||
use super::Mode;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModeRequest {
|
||||
SetMode(Mode),
|
||||
ReadMode,
|
||||
}
|
||||
}
|
||||
|
||||
pub mod response {
|
||||
use super::Mode;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModeReport {
|
||||
/// Mode of the assembly.
|
||||
Mode(super::Mode),
|
||||
/// Children are in wrong mode after commanding.
|
||||
WrongMode([Option<Mode>; 2]),
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ pub mod request {
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Copy, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct MgmData {
|
||||
pub struct SensorData {
|
||||
pub valid: bool,
|
||||
pub x: f32,
|
||||
pub y: f32,
|
||||
@@ -50,11 +50,11 @@ pub struct MgmData {
|
||||
}
|
||||
|
||||
pub mod response {
|
||||
use crate::{DeviceMode, Message, mgm::MgmData};
|
||||
use crate::{DeviceMode, Message, acs::mgm::SensorData};
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Debug)]
|
||||
pub enum HkResponse {
|
||||
MgmData(MgmData),
|
||||
MgmData(SensorData),
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Copy)]
|
||||
+40
-11
@@ -1,9 +1,12 @@
|
||||
use core::str::FromStr;
|
||||
|
||||
use num_enum::TryFromPrimitive as _;
|
||||
use satrs::mode::ModeRaw;
|
||||
|
||||
use crate::DeviceMode;
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum AssemblyMode {
|
||||
pub enum Mode {
|
||||
/// The assembly mode ressembles the modes of the devices it controls. It also tries to keep
|
||||
/// the children in the correct mode by re-commanding them into the correct mode.
|
||||
Device(DeviceMode),
|
||||
@@ -11,22 +14,48 @@ pub enum AssemblyMode {
|
||||
NoModeKeeping,
|
||||
}
|
||||
|
||||
impl FromStr for AssemblyMode {
|
||||
impl From<Mode> for ModeRaw {
|
||||
fn from(value: Mode) -> Self {
|
||||
match value {
|
||||
Mode::Device(device_mode) => device_mode.into(),
|
||||
Mode::NoModeKeeping => 5,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<ModeRaw> for Mode {
|
||||
type Error = ();
|
||||
|
||||
fn try_from(value: ModeRaw) -> Result<Self, Self::Error> {
|
||||
match DeviceMode::try_from_primitive(value) {
|
||||
Ok(val) => Ok(Mode::Device(val)),
|
||||
Err(_) => {
|
||||
if value == 5 {
|
||||
Ok(Mode::NoModeKeeping)
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Mode {
|
||||
type Err = ();
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s.to_lowercase().as_str() {
|
||||
"off" => Ok(AssemblyMode::Device(DeviceMode::Off)),
|
||||
"on" => Ok(AssemblyMode::Device(DeviceMode::On)),
|
||||
"normal" => Ok(AssemblyMode::Device(DeviceMode::Normal)),
|
||||
"no_mode_keeping" => Ok(AssemblyMode::NoModeKeeping),
|
||||
"off" => Ok(Mode::Device(DeviceMode::Off)),
|
||||
"on" => Ok(Mode::Device(DeviceMode::On)),
|
||||
"normal" => Ok(Mode::Device(DeviceMode::Normal)),
|
||||
"no_mode_keeping" => Ok(Mode::NoModeKeeping),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod request {
|
||||
use crate::{HkRequestType, Message, mgm_assembly::AssemblyMode};
|
||||
use crate::{HkRequestType, Message, acs::mgm_assembly::Mode};
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, serde::Serialize, serde::Deserialize)]
|
||||
pub enum HkId {
|
||||
@@ -35,7 +64,7 @@ pub mod request {
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModeRequest {
|
||||
SetMode(AssemblyMode),
|
||||
SetMode(Mode),
|
||||
ReadMode,
|
||||
}
|
||||
|
||||
@@ -75,9 +104,9 @@ pub mod response {
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModeReport {
|
||||
pub enum ModeResponse {
|
||||
/// Mode of the assembly.
|
||||
Mode(super::AssemblyMode),
|
||||
Mode(super::Mode),
|
||||
/// Timeout failure setting the children modes.
|
||||
SetModeTimeout([Option<DeviceMode>; 2]),
|
||||
/// Children are in wrong mode after commanding.
|
||||
@@ -89,7 +118,7 @@ pub mod response {
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Response {
|
||||
Ok,
|
||||
Mode(ModeReport),
|
||||
Mode(ModeResponse),
|
||||
}
|
||||
|
||||
impl Response {
|
||||
@@ -0,0 +1,38 @@
|
||||
#[derive(
|
||||
serde::Serialize,
|
||||
serde::Deserialize,
|
||||
Debug,
|
||||
Clone,
|
||||
Copy,
|
||||
PartialEq,
|
||||
Eq,
|
||||
num_enum::IntoPrimitive,
|
||||
num_enum::TryFromPrimitive,
|
||||
)]
|
||||
#[repr(u32)]
|
||||
pub enum Mode {
|
||||
Off,
|
||||
Normal,
|
||||
}
|
||||
|
||||
pub mod request {
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModeRequest {
|
||||
SetMode(Mode),
|
||||
ReadMode,
|
||||
}
|
||||
}
|
||||
|
||||
pub mod response {
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModeReport {
|
||||
/// Mode of the assembly.
|
||||
Mode(super::Mode),
|
||||
/// Children are in wrong mode after commanding.
|
||||
WrongMode([Option<Mode>; 2]),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
pub mod ctrl;
|
||||
pub mod mgm;
|
||||
pub mod mgm_assembly;
|
||||
pub mod mgt;
|
||||
pub mod subsystem;
|
||||
@@ -0,0 +1,88 @@
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Mode {
|
||||
Off,
|
||||
Safe,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ModeChild {
|
||||
MgmAssembly,
|
||||
Mgt,
|
||||
Controller,
|
||||
}
|
||||
|
||||
impl Mode {
|
||||
/// Each subsystem mode has a fallback mode to allow clean transitions.
|
||||
pub const fn fallback_mode(&self) -> Self {
|
||||
match self {
|
||||
Mode::Off => Mode::Safe,
|
||||
Mode::Safe => Mode::Safe,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod request {
|
||||
use crate::Message;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModeRequest {
|
||||
SetMode(super::Mode),
|
||||
ReadMode,
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Debug)]
|
||||
pub enum Request {
|
||||
Ping,
|
||||
Mode(ModeRequest),
|
||||
}
|
||||
|
||||
impl Request {
|
||||
fn message_type(&self) -> crate::MessageType {
|
||||
match self {
|
||||
Request::Ping => crate::MessageType::Verification,
|
||||
Request::Mode(_mode) => crate::MessageType::Mode,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Message for Request {
|
||||
fn message_type(&self) -> crate::MessageType {
|
||||
self.message_type()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod response {
|
||||
use crate::Message;
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
pub enum ModeResponse {
|
||||
/// Mode of the subsystem.
|
||||
Mode(super::Mode),
|
||||
/// Command timeout when commanding a child.
|
||||
CommandTimeout(super::ModeChild),
|
||||
/// Can not keep mode because a child changed mode unexpectedly.
|
||||
CanNotKeepMode(super::ModeChild),
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Debug)]
|
||||
pub enum Response {
|
||||
Ok,
|
||||
Mode(ModeResponse),
|
||||
}
|
||||
|
||||
impl Response {
|
||||
fn message_type(&self) -> crate::MessageType {
|
||||
match self {
|
||||
Response::Ok => crate::MessageType::Verification,
|
||||
Response::Mode(_mode_report) => crate::MessageType::Mode,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Message for Response {
|
||||
fn message_type(&self) -> crate::MessageType {
|
||||
self.message_type()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,9 @@ use spacepackets::{
|
||||
time::cds::{CdsTime, MIN_CDS_FIELD_LEN},
|
||||
};
|
||||
|
||||
pub mod acs;
|
||||
pub mod ccsds;
|
||||
pub mod control;
|
||||
pub mod mgm;
|
||||
pub mod mgm_assembly;
|
||||
pub mod pcdu;
|
||||
|
||||
#[derive(
|
||||
@@ -30,8 +29,10 @@ pub enum ComponentId {
|
||||
|
||||
AcsSubsystem,
|
||||
AcsMgmAssembly,
|
||||
AcsController,
|
||||
AcsMgm0,
|
||||
AcsMgm1,
|
||||
AcsMgt,
|
||||
|
||||
EpsSubsystem,
|
||||
EpsPcdu,
|
||||
@@ -160,7 +161,18 @@ pub trait Message {
|
||||
/// The states are related both to the physical and the logical state of the device. Some
|
||||
/// device handlers control the power supply of their own device and an off state might also
|
||||
/// mean that the device is physically off.
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq, Eq, Copy, Clone)]
|
||||
#[derive(
|
||||
serde::Serialize,
|
||||
serde::Deserialize,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Copy,
|
||||
Clone,
|
||||
num_enum::IntoPrimitive,
|
||||
num_enum::TryFromPrimitive,
|
||||
)]
|
||||
#[repr(u32)]
|
||||
pub enum DeviceMode {
|
||||
Off = 0,
|
||||
On = 1,
|
||||
|
||||
Reference in New Issue
Block a user