Process waveform on event fetch

This commit is contained in:
Dominik Werder
2021-11-12 12:15:21 +01:00
parent c9f3e2f89f
commit 6b5c245319
13 changed files with 539 additions and 202 deletions

View File

@@ -511,6 +511,15 @@ impl Shape {
)))
}
}
JsVal::Object(j) => match j.get("Wave") {
Some(JsVal::Number(j)) => Ok(Shape::Wave(j.as_u64().ok_or_else(|| {
Error::with_msg_no_trace(format!("Shape from_db_jsval can not understand {:?}", v))
})? as u32)),
_ => Err(Error::with_msg_no_trace(format!(
"Shape from_db_jsval can not understand {:?}",
v
))),
},
_ => Err(Error::with_msg_no_trace(format!(
"Shape from_db_jsval can not understand {:?}",
v
@@ -1417,3 +1426,23 @@ pub struct ChannelInfo {
pub shape: Shape,
pub msg: serde_json::Value,
}
pub fn f32_close(a: f32, b: f32) -> bool {
if (a - b).abs() < 1e-5 {
true
} else if a / b > 0.9999 && a / b < 1.0001 {
true
} else {
false
}
}
pub fn f64_close(a: f64, b: f64) -> bool {
if (a - b).abs() < 1e-5 {
true
} else if a / b > 0.9999 && a / b < 1.0001 {
true
} else {
false
}
}