hydr_structures/structures/gate/trajectory/
accuracy.rs1use crate::structures::{StructureError, StructureInputErrorKind};
4
5#[derive(Clone, Copy, Debug, PartialEq)]
7pub struct GateMotionLimits {
8 pub maximum_opening_speed_m_per_s: f64,
10 pub maximum_closing_speed_m_per_s: f64,
12}
13impl GateMotionLimits {
14 pub(super) fn check(self) -> Result<(), StructureError> {
15 check(
16 self.maximum_opening_speed_m_per_s,
17 "maximum_opening_speed_m_per_s",
18 )?;
19 check(
20 self.maximum_closing_speed_m_per_s,
21 "maximum_closing_speed_m_per_s",
22 )
23 }
24}
25#[derive(Clone, Copy, Debug, PartialEq)]
27pub struct GateTrajectoryAccuracy {
28 pub maximum_absolute_opening_error_m: f64,
30 pub maximum_relative_opening_error: f64,
32}
33impl GateTrajectoryAccuracy {
34 pub(super) fn check(self) -> Result<(), StructureError> {
35 check(
36 self.maximum_absolute_opening_error_m,
37 "maximum_absolute_opening_error_m",
38 )?;
39 check(
40 self.maximum_relative_opening_error,
41 "maximum_relative_opening_error",
42 )
43 }
44}
45fn check(value: f64, name: &str) -> Result<(), StructureError> {
46 if !value.is_finite() || value < 0.0 {
47 return Err(StructureError::input(
48 StructureInputErrorKind::Definition,
49 format!("{name}={value}: supply an explicit finite nonnegative limit"),
50 ));
51 }
52 Ok(())
53}