Included bode plot measurements, including different number of points.

This commit is contained in:
2025-10-08 15:41:41 +02:00
parent 4325bbadeb
commit 799bcf49b5

View File

@@ -8,11 +8,13 @@ use heapless::Vec;
// --- // ---
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)] #[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub enum InitImpedanceError { pub enum ImpedanceInitError {
DSPNotSet, DSPNotSet,
} }
pub type InitImpedanceResult = Result<f32, InitImpedanceError>; pub type ImpedanceInitResult = Result<f32, ImpedanceInitError>;
pub type MultiImpedanceInitResult = Result<MultiImpedanceResult, ImpedanceInitError>;
endpoints! { endpoints! {
list = ENDPOINT_LIST; list = ENDPOINT_LIST;
@@ -22,9 +24,9 @@ endpoints! {
| PingEndpoint | u32 | u32 | "ping" | | PingEndpoint | u32 | u32 | "ping" |
| GetUniqueIdEndpoint | () | [u8; 12] | "get_id" | | GetUniqueIdEndpoint | () | [u8; 12] | "get_id" |
| SetGreenLedEndpoint | f32 | () | "led/green" | | SetGreenLedEndpoint | f32 | () | "led/green" |
| StartSingleImpedanceEndpoint | StartSingleImpedance | InitImpedanceResult | "imp/start_single" | | StartSingleImpedanceEndpoint | SingleImpedanceStartRequest | ImpedanceInitResult | "imp/start_single" |
| StopSingleImpedanceEndpoint | () | bool | "imp/stop_single" | | StopSingleImpedanceEndpoint | () | bool | "imp/stop_single" |
| StartMultiImpedanceEndpoint | StartMultiImpedance | () | "imp/start_multi" | | StartMultiImpedanceEndpoint | MultiImpedanceStartRequest | MultiImpedanceInitResult | "imp/start_multi" |
| StopMultiImpedanceEndpoint | () | bool | "imp/stop_multi" | | StopMultiImpedanceEndpoint | () | bool | "imp/stop_multi" |
} }
@@ -36,12 +38,13 @@ topics! {
} }
topics! { topics! {
list = TOPICS_OUT_LIST; list = TOPICS_OUT_LIST;
direction = TopicDirection::ToClient; direction = TopicDirection::ToClient;
| TopicTy | MessageTy | Path | Cfg | | TopicTy | MessageTy | Path | Cfg |
| ------- | --------- | ---- | --- | | ------- | --------- | ---- | --- |
| SingleImpedanceOutputTopic | SingleImpedanceOutput | "imp/single" | | | SingleImpedanceOutputTopic | SingleImpedanceOutput | "imp/single" | |
| MultiImpedanceOutputTopic28 | MultiImpedanceOutput28 | "imp/multi" | | | MultiImpedanceOutputTopic | MultiImpedanceOutput | "imp/multi" | |
} }
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)] #[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
@@ -51,9 +54,25 @@ pub struct SingleImpedanceOutput {
} }
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)] #[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub struct MultiImpedanceOutput28 { pub struct MultiImpedanceOutput {
pub magnitudes: Vec<f32, 28>, pub points: MeasurementPointSet,
pub phases: Vec<f32, 28>, pub magnitudes_8: Vec<f32, 8>,
pub phases_8: Vec<f32, 8>,
pub magnitudes_18: Vec<f32, 18>,
pub phases_18: Vec<f32, 18>,
}
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub struct MultiImpedanceOutput18 {
pub magnitudes: Vec<f32, 18>,
pub phases: Vec<f32, 18>,
}
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub struct MultiImpedanceResult {
pub points: MeasurementPointSet,
pub periods_per_dft_8: Vec<f32, 8>,
pub periods_per_dft_18: Vec<f32, 18>,
} }
#[derive(Clone, Copy, Serialize, Deserialize, Schema, Debug, PartialEq)] #[derive(Clone, Copy, Serialize, Deserialize, Schema, Debug, PartialEq)]
@@ -74,34 +93,42 @@ pub enum IcdDftNum {
} }
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)] #[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub struct StartSingleImpedance { pub struct SingleImpedanceStartRequest {
pub update_frequency: u32, pub update_frequency: u32,
pub sinus_frequency: u32, pub sinus_frequency: u32,
pub dft_number: IcdDftNum, pub dft_number: IcdDftNum,
} }
#[derive(Clone, Copy, Serialize, Deserialize, Schema, Debug, PartialEq)] #[derive(Clone, Copy, Serialize, Deserialize, Schema, Debug, PartialEq)]
pub enum NumberOfPoints { pub enum MeasurementPointSet {
TwentyEight, Eight,
Eighteen,
} }
impl NumberOfPoints { impl MeasurementPointSet {
pub fn values(&self) -> &'static [f32] { pub fn values(&self) -> &'static [f32] {
match self { match self {
NumberOfPoints::TwentyEight => { MeasurementPointSet::Eight => {
&[1.0, 1.6, 2.5, 4.0, 6.3, &[10000.0, 16000.0, 25000.0, 40000.0, 63000.0,
10.0, 16.0, 25.0, 40.0, 63.0, 100000.0, 160000.0, 200000.0]
100.0, 160.0, 250.0, 400.0, 630.0, }
MeasurementPointSet::Eighteen => {
&[100.0, 160.0, 250.0, 400.0, 630.0,
1000.0, 1600.0, 2500.0, 4000.0, 6300.0, 1000.0, 1600.0, 2500.0, 4000.0, 6300.0,
10000.0, 16000.0, 25000.0, 40000.0, 63000.0, 10000.0, 16000.0, 25000.0, 40000.0, 63000.0,
100000.0, 160000.0, 200000.0] 100000.0, 160000.0, 200000.0]
} }
} }
} }
pub fn len(&self) -> usize {
match self {
MeasurementPointSet::Eight => 8,
MeasurementPointSet::Eighteen => 18,
}
}
} }
#[derive(Serialize, Deserialize, Schema, Debug, PartialEq)] #[derive(Serialize, Deserialize, Schema, Debug, PartialEq)]
pub struct StartMultiImpedance { pub struct MultiImpedanceStartRequest {
pub dft_number: IcdDftNum, pub points: MeasurementPointSet,
pub number_of_points: NumberOfPoints,
} }