forked from StudioInfinity/dyna3
Compare commits
2 commits
6c31a25822
...
7cbd92618b
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7cbd92618b | ||
![]() |
c368a38803 |
1 changed files with 9 additions and 5 deletions
|
@ -30,8 +30,11 @@ pub struct Element {
|
||||||
pub label: String,
|
pub label: String,
|
||||||
pub color: ElementColor,
|
pub color: ElementColor,
|
||||||
pub representation: Signal<DVector<f64>>,
|
pub representation: Signal<DVector<f64>>,
|
||||||
|
|
||||||
|
// the regulators that affect this element. the ambient assembly is
|
||||||
|
// responsible for keeping this set up to date
|
||||||
pub regulators: Signal<BTreeSet<RegulatorKey>>,
|
pub regulators: Signal<BTreeSet<RegulatorKey>>,
|
||||||
|
|
||||||
// a serial number, assigned by `Element::new`, that uniquely identifies
|
// a serial number, assigned by `Element::new`, that uniquely identifies
|
||||||
// each element
|
// each element
|
||||||
pub serial: u64,
|
pub serial: u64,
|
||||||
|
@ -117,7 +120,7 @@ impl Element {
|
||||||
|
|
||||||
// to construct a `SpecifiedValue` that might be `Present`, use the associated
|
// to construct a `SpecifiedValue` that might be `Present`, use the associated
|
||||||
// function `try_from`. this ensures that `spec` is always a valid specification
|
// function `try_from`. this ensures that `spec` is always a valid specification
|
||||||
// of `value` according to the format discussed above the implementation of
|
// of `value` according to the format discussed at the implementation of
|
||||||
// `TryFrom<String>`
|
// `TryFrom<String>`
|
||||||
pub enum SpecifiedValue {
|
pub enum SpecifiedValue {
|
||||||
Absent,
|
Absent,
|
||||||
|
@ -154,7 +157,8 @@ impl SpecifiedValue {
|
||||||
// specification is empty, the `SpecifiedValue` is `Absent`. if the
|
// specification is empty, the `SpecifiedValue` is `Absent`. if the
|
||||||
// specification parses to a floating-point value `x`, the `SpecifiedValue` is
|
// specification parses to a floating-point value `x`, the `SpecifiedValue` is
|
||||||
// `Present`, with a `value` of `x`, and the specification is stored in `spec`.
|
// `Present`, with a `value` of `x`, and the specification is stored in `spec`.
|
||||||
// these are the only valid specifications; any other produces an error
|
// these are currently the only valid specifications; any other produces an
|
||||||
|
// error
|
||||||
impl TryFrom<String> for SpecifiedValue {
|
impl TryFrom<String> for SpecifiedValue {
|
||||||
type Error = ParseFloatError;
|
type Error = ParseFloatError;
|
||||||
|
|
||||||
|
@ -183,7 +187,7 @@ impl Regulator {
|
||||||
self.set_point.set(set_pt);
|
self.set_point.set(set_pt);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
Err(_) => false,
|
Err(_) => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -272,7 +276,7 @@ impl Assembly {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_regulator(&self, regulator: Regulator) {
|
fn insert_regulator(&self, regulator: Regulator) {
|
||||||
let subjects = regulator.subjects;
|
let subjects = regulator.subjects;
|
||||||
let key = self.regulators.update(|regs| regs.insert(regulator));
|
let key = self.regulators.update(|regs| regs.insert(regulator));
|
||||||
let subject_regulators = self.elements.with(
|
let subject_regulators = self.elements.with(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue