use super::super::*;
use crate::structures::StructureError;
use numr::dtype::DType;
use numr::runtime::Runtime;
#[derive(Clone, Debug)]
pub struct GateActuatorSnapshot<R: Runtime<DType = DType>> {
pub(super) batch: GateActuatorBatch<R>,
}
impl<R: Runtime<DType = DType>> GateActuatorSnapshot<R> {
pub fn time(&self) -> f64 {
self.batch.time()
}
pub fn data(&self) -> Result<GateActuatorSnapshotData, StructureError> {
self.batch.snapshot_data()
}
}
impl<R: Runtime<DType = DType>> GateActuatorBatch<R> {
pub fn snapshot(&self) -> GateActuatorSnapshot<R> {
GateActuatorSnapshot {
batch: self.clone(),
}
}
pub fn snapshot_data(&self) -> Result<GateActuatorSnapshotData, StructureError> {
Ok(GateActuatorSnapshotData {
schema: GATE_ACTUATOR_SNAPSHOT_SCHEMA.into(),
contract: GATE_ACTUATOR_CONTRACT_VERSION.into(),
elements: self.elements().to_vec(),
definitions: self.definitions().to_vec(),
initial_states: self.initial_states().to_vec(),
schedule: self.schedule().clone(),
time_s: self.time,
next_target_index: self.next_target,
accepted_steps: self.steps,
states: self.states()?,
last_step: self.last_step()?,
})
}
}