forked from StudioInfinity/dyna3
Consolidate set point data
This commit is contained in:
parent
befadd25c9
commit
6c31a25822
2 changed files with 97 additions and 53 deletions
|
|
@ -10,9 +10,10 @@ use crate::{
|
|||
AppState,
|
||||
assembly,
|
||||
assembly::{
|
||||
ElementKey,
|
||||
Regulator,
|
||||
RegulatorKey,
|
||||
ElementKey
|
||||
SpecifiedValue::*
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -20,14 +21,16 @@ use crate::{
|
|||
#[component(inline_props)]
|
||||
fn RegulatorInput(regulator: Regulator) -> View {
|
||||
let valid = create_signal(true);
|
||||
let value = create_signal(regulator.get_set_point_spec_clone_untracked());
|
||||
let value = create_signal(
|
||||
regulator.set_point.with_untracked(|set_pt| set_pt.spec())
|
||||
);
|
||||
|
||||
// this closure resets the input value to the regulator's set point
|
||||
// specification, which is always a valid specification
|
||||
// specification
|
||||
let reset_value = move || {
|
||||
batch(|| {
|
||||
valid.set(true);
|
||||
value.set(regulator.get_set_point_spec_clone());
|
||||
value.set(regulator.set_point.with(|set_pt| set_pt.spec()));
|
||||
})
|
||||
};
|
||||
|
||||
|
|
@ -40,10 +43,12 @@ fn RegulatorInput(regulator: Regulator) -> View {
|
|||
r#type="text",
|
||||
class=move || {
|
||||
if valid.get() {
|
||||
match regulator.set_point.get() {
|
||||
Some(_) => "regulator-input constraint",
|
||||
None => "regulator-input"
|
||||
}
|
||||
regulator.set_point.with(|set_pt| {
|
||||
match set_pt {
|
||||
Absent => "regulator-input",
|
||||
Present { .. } => "regulator-input constraint"
|
||||
}
|
||||
})
|
||||
} else {
|
||||
"regulator-input invalid"
|
||||
}
|
||||
|
|
@ -51,7 +56,7 @@ fn RegulatorInput(regulator: Regulator) -> View {
|
|||
placeholder=regulator.measurement.with(|result| result.to_string()),
|
||||
bind:value=value,
|
||||
on:change=move |_| valid.set(
|
||||
regulator.try_specify_set_point(value.get_clone_untracked())
|
||||
regulator.try_set(value.get_clone_untracked())
|
||||
),
|
||||
on:keydown={
|
||||
move |event: KeyboardEvent| {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue