Generalize constraints to observables #48

Merged
glen merged 25 commits from Vectornaut/dyna3:observables_on_main into main 2025-03-10 23:43:25 +00:00
2 changed files with 9 additions and 13 deletions
Showing only changes of commit 6eeeb1c6fd - Show all commits

View file

@ -124,16 +124,6 @@ pub struct Regulator {
pub set_point: Signal<SpecifiedValue>
}
impl Regulator {
/* TO DO */
// if it's called for, add a `set` method that takes a bare SpecifiedValue
pub fn set_if_ok<E>(&self, set_pt_result: Result<SpecifiedValue, E>) {
if let Ok(set_pt) = set_pt_result {
self.set_point.set(set_pt);
}
}
}
// the velocity is expressed in uniform coordinates
pub struct ElementMotion<'a> {
pub key: ElementKey,

View file

@ -57,9 +57,15 @@ fn RegulatorInput(regulator: Regulator) -> View {
placeholder=regulator.measurement.with(|result| result.to_string()),
bind:value=value,
on:change=move |_| {
let set_pt_result = SpecifiedValue::try_from(value.get_clone_untracked());
valid.set(set_pt_result.is_ok());
regulator.set_if_ok(set_pt_result);
valid.set(
match SpecifiedValue::try_from(value.get_clone_untracked()) {
Ok(set_pt) => {
regulator.set_point.set(set_pt);
true
}
Err(_) => false
}
)
},
on:keydown={
move |event: KeyboardEvent| {