reactive_graph_std_numeric/behaviour/entity/gate/
mod.rs

1pub use function::NumericGateFunction;
2
3pub mod behaviour_f64;
4pub mod function;
5
6#[cfg(test)]
7pub mod tests {
8    use reactive_graph_graph::prelude::*;
9    use reactive_graph_reactive_model_impl::ReactiveEntity;
10    use reactive_graph_reactive_model_impl::ReactiveProperties;
11    use serde_json::json;
12    use uuid::Uuid;
13
14    use reactive_graph_std_numeric_model::COMPONENT_NUMERIC_GATE;
15    use reactive_graph_std_numeric_model::NumericGateProperties::LHS;
16    use reactive_graph_std_numeric_model::NumericGateProperties::RHS;
17    use reactive_graph_std_result_model::COMPONENT_RESULT_NUMBER;
18    use reactive_graph_std_result_model::ResultNumberF64Properties::RESULT;
19
20    pub fn numeric_gate(ty: &EntityTypeId) -> ReactiveEntity {
21        let id = Uuid::new_v4();
22        let properties = PropertyInstances::new()
23            .property(LHS, json!(0.0))
24            .property(RHS, json!(0.0))
25            .property(RESULT, json!(0.0));
26        let components = ComponentTypeIds::new()
27            .component(COMPONENT_NUMERIC_GATE.clone())
28            .component(COMPONENT_RESULT_NUMBER.clone());
29
30        ReactiveEntity::builder()
31            .ty(ty)
32            .id(id)
33            .properties(ReactiveProperties::new_with_id_from_properties(id, properties))
34            .components(components)
35            .build()
36    }
37}