hydr_structures/structures/actuator/snapshot/
package.rs1use super::super::*;
4use crate::structures::StructureError;
5use numr::dtype::DType;
6use numr::runtime::Runtime;
7
8#[derive(Clone, Debug)]
10pub struct GateActuatorSnapshot<R: Runtime<DType = DType>> {
11 pub(super) batch: GateActuatorBatch<R>,
12}
13impl<R: Runtime<DType = DType>> GateActuatorSnapshot<R> {
14 pub fn time(&self) -> f64 {
16 self.batch.time()
17 }
18 pub fn data(&self) -> Result<GateActuatorSnapshotData, StructureError> {
20 self.batch.snapshot_data()
21 }
22}
23impl<R: Runtime<DType = DType>> GateActuatorBatch<R> {
24 pub fn snapshot(&self) -> GateActuatorSnapshot<R> {
26 GateActuatorSnapshot {
27 batch: self.clone(),
28 }
29 }
30 pub fn snapshot_data(&self) -> Result<GateActuatorSnapshotData, StructureError> {
32 Ok(GateActuatorSnapshotData {
33 schema: GATE_ACTUATOR_SNAPSHOT_SCHEMA.into(),
34 contract: GATE_ACTUATOR_CONTRACT_VERSION.into(),
35 elements: self.elements().to_vec(),
36 definitions: self.definitions().to_vec(),
37 initial_states: self.initial_states().to_vec(),
38 schedule: self.schedule().clone(),
39 time_s: self.time,
40 next_target_index: self.next_target,
41 accepted_steps: self.steps,
42 states: self.states()?,
43 last_step: self.last_step()?,
44 })
45 }
46}