Adding support for modifying IIR state

This commit is contained in:
Ryan Summers 2020-06-03 17:15:57 +02:00
parent 7cb18cf197
commit df5dcb3dc1
2 changed files with 29 additions and 0 deletions

View File

@ -627,6 +627,28 @@ const APP: () = {
], ],
modifiable_attributes: [ modifiable_attributes: [
("stabilizer/iir0/state", server::IirRequest, (|req: server::IirRequest| {
c.resources.iir_ch.lock(|iir_ch| {
if req.channel > 1 {
return Err(());
}
iir_ch[req.channel as usize] = req.iir;
Ok::<server::IirRequest, ()>(req)
})
})),
("stabilizer/iir1/state", server::IirRequest, (|req: server::IirRequest| {
c.resources.iir_ch.lock(|iir_ch| {
if req.channel > 1 {
return Err(());
}
iir_ch[req.channel as usize] = req.iir;
Ok::<server::IirRequest, ()>(req)
})
})),
("stabilizer/afe0/gain", afe::Gain, (|gain| { ("stabilizer/afe0/gain", afe::Gain, (|gain| {
Ok::<(), ()>(c.resources.afe0.set_gain(gain)) Ok::<(), ()>(c.resources.afe0.set_gain(gain))
})), })),

View File

@ -18,6 +18,7 @@ use serde_json_core::{
}; };
use super::net; use super::net;
use super::iir;
#[derive(Deserialize, Serialize, Debug)] #[derive(Deserialize, Serialize, Debug)]
pub enum Request<'a, 'b> { pub enum Request<'a, 'b> {
@ -25,6 +26,12 @@ pub enum Request<'a, 'b> {
Write{attribute: &'a str, value: &'b str}, Write{attribute: &'a str, value: &'b str},
} }
#[derive(Serialize, Deserialize)]
pub struct IirRequest {
pub channel: u8,
pub iir: iir::IIR,
}
#[derive(Serialize)] #[derive(Serialize)]
pub struct Response { pub struct Response {
code: i32, code: i32,