fmi_schema/fmi3/
attribute_groups.rs

1use yaserde_derive::{YaDeserialize, YaSerialize};
2
3#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
4pub struct RealBaseAttributes {
5    #[yaserde(attribute = true)]
6    pub quantity: Option<String>,
7    #[yaserde(attribute = true)]
8    pub unit: Option<String>,
9    #[yaserde(attribute = true, rename = "displayUnit")]
10    pub display_unit: Option<String>,
11    #[yaserde(attribute = true, rename = "relativeQuantity")]
12    pub relative_quantity: Option<bool>,
13    #[yaserde(attribute = true, rename = "unbounded")]
14    pub unbounded: Option<bool>,
15}
16
17macro_rules! float_attrs {
18    ($name:ident, $type:ty) => {
19        #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
20        pub struct $name {
21            #[yaserde(attribute = true)]
22            pub min: Option<$type>,
23            #[yaserde(attribute = true)]
24            pub max: Option<$type>,
25            #[yaserde(attribute = true)]
26            pub nominal: Option<$type>,
27        }
28    };
29}
30float_attrs!(Float32Attributes, f32);
31float_attrs!(Float64Attributes, f64);
32
33#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
34pub struct IntegerBaseAttributes {
35    #[yaserde(attribute = true)]
36    quantity: Option<String>,
37}
38
39macro_rules! integer_attrs {
40    ($name:ident, $type:ty) => {
41        #[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
42        #[yaserde(rename = "$name")]
43        pub struct $name {
44            #[yaserde(attribute = true)]
45            pub min: Option<$type>,
46            #[yaserde(attribute = true)]
47            pub max: Option<$type>,
48        }
49    };
50}
51
52integer_attrs!(Int8Attributes, i8);
53integer_attrs!(UInt8Attributes, u8);
54integer_attrs!(Int16Attributes, i16);
55integer_attrs!(UInt16Attributes, u16);
56integer_attrs!(Int32Attributes, i32);
57integer_attrs!(UInt32Attributes, u32);
58integer_attrs!(Int64Attributes, i64);
59integer_attrs!(UInt64Attributes, u64);
60
61#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
62pub struct RealVariableAttributes {
63    /// If present, then the variable with this attribute is the derivative of the variable with value reference given in derivative.
64    #[yaserde(attribute = true)]
65    pub derivative: Option<u32>,
66    /// Only used in Model Exchange, ignored for the other interface types. May only be present for a continuous-time state.
67    /// If `true`, state may be reinitialized by the FMU in Event Mode.
68    /// If `false`, state will not be reinitialized.
69    #[yaserde(attribute = true)]
70    pub reinit: Option<bool>,
71}
72
73#[derive(Default, PartialEq, Debug, YaSerialize, YaDeserialize)]
74pub struct EnumerationAttributes {
75    #[yaserde(attribute = true)]
76    pub min: Option<i64>,
77    #[yaserde(attribute = true)]
78    pub max: Option<i64>,
79}