112 lines
1.9 KiB
Rust
112 lines
1.9 KiB
Rust
extern crate alloc;
|
|
|
|
use alloc::string::String;
|
|
use alloc::vec::Vec;
|
|
use bincode::{Decode, Encode};
|
|
use macros::{msg, Kind};
|
|
|
|
mod example;
|
|
pub use example::*;
|
|
mod hs;
|
|
pub use hs::*;
|
|
mod to;
|
|
pub use to::*;
|
|
mod ds;
|
|
pub use ds::*;
|
|
|
|
use crate::time::Timestamp;
|
|
|
|
#[msg]
|
|
#[derive(Copy, Eq, Hash)]
|
|
pub struct TargetMsg {
|
|
// instance is FROM for tlm, is TO for cmds
|
|
pub instance: Instance,
|
|
pub msg: MsgKind,
|
|
}
|
|
|
|
impl TargetMsg {
|
|
pub fn new(instance: Instance, msg: MsgKind) -> Self {
|
|
Self { instance, msg }
|
|
}
|
|
}
|
|
|
|
#[msg]
|
|
#[derive(Copy, Eq, Hash)]
|
|
pub enum Instance {
|
|
#[default]
|
|
None,
|
|
All,
|
|
Other,
|
|
Example,
|
|
Example2,
|
|
}
|
|
|
|
#[msg]
|
|
#[derive(Kind)]
|
|
pub enum Msg {
|
|
#[default]
|
|
None,
|
|
SubRequest,
|
|
SubList(SubList),
|
|
SetTimeCmd(u64),
|
|
ReinitApp(ReinitAppCmd),
|
|
ExampleHk(ExampleHk),
|
|
ExampleOutData(ExampleOutData),
|
|
ExampleCmd(ExampleCmd),
|
|
DsHk(DsHk),
|
|
DsOutData(DsOutData),
|
|
DsCmd(DsCmd),
|
|
HsHk(HsHk),
|
|
HsOutData(HsOutData),
|
|
HsCmd(HsCmd),
|
|
ToHk(ToHk),
|
|
ToOutData(ToOutData),
|
|
ToCmd(ToCmd),
|
|
}
|
|
|
|
#[msg]
|
|
pub struct MsgPacket {
|
|
pub instance: Instance,
|
|
pub msg: Msg,
|
|
pub timestamp: Timestamp,
|
|
}
|
|
|
|
impl MsgPacket {
|
|
pub fn to_target(&self) -> TargetMsg {
|
|
TargetMsg::new(self.instance, self.msg.kind())
|
|
}
|
|
|
|
pub fn new(instance: Instance, msg: Msg, timestamp: Timestamp) -> Self {
|
|
Self {
|
|
instance,
|
|
msg,
|
|
timestamp,
|
|
}
|
|
}
|
|
|
|
pub fn timestamp(&mut self, timestamp: Timestamp) {
|
|
self.timestamp = timestamp;
|
|
}
|
|
}
|
|
|
|
#[msg]
|
|
pub struct SubList {
|
|
pub subs: Vec<TargetMsg>,
|
|
}
|
|
|
|
#[msg]
|
|
pub struct ReinitAppCmd {
|
|
app_name: String,
|
|
}
|
|
|
|
pub type TlmSetId = u16;
|
|
|
|
#[msg]
|
|
#[derive(Copy, Eq, Hash)]
|
|
pub struct TlmSetItem {
|
|
pub target: TargetMsg,
|
|
/// decimation 0 means sends every msg, decimation 1 means sends every other, etc
|
|
pub decimation: u16,
|
|
pub counter: u16,
|
|
}
|