fmi_schema/fmi2/
interface_type.rs1use yaserde_derive::{YaDeserialize, YaSerialize};
2
3#[derive(Default, Debug, YaSerialize, YaDeserialize)]
4#[yaserde(tag = "File")]
5pub struct File {
6 #[yaserde(attribute = true)]
9 pub name: String,
10}
11
12#[derive(Default, Debug, YaSerialize, YaDeserialize)]
13#[yaserde(tag = "SourceFiles")]
14pub struct SourceFiles {
15 #[yaserde(rename = "File")]
16 pub files: Vec<File>,
17}
18
19#[derive(Default, Debug, YaSerialize, YaDeserialize)]
22pub struct ModelExchange {
23 #[yaserde(attribute = true, rename = "modelIdentifier")]
25 pub model_identifier: String,
26
27 #[yaserde(attribute = true, rename = "needsExecutionTool")]
30 pub needs_execution_tool: Option<bool>,
31
32 #[yaserde(attribute = true, rename = "completedIntegratorStepNotNeeded")]
33 pub completed_integrator_step_not_needed: Option<bool>,
34
35 #[yaserde(attribute = true, rename = "canBeInstantiatedOnlyOncePerProcess")]
36 pub can_be_instantiated_only_once_per_process: Option<bool>,
37
38 #[yaserde(attribute = true, rename = "canNotUseMemoryManagementFunctions")]
39 pub can_not_use_memory_management_functions: Option<bool>,
40
41 #[yaserde(attribute = true, rename = "canGetAndSetFMUstate")]
42 pub can_get_and_set_fmu_state: Option<bool>,
43
44 #[yaserde(attribute = true, rename = "canSerializeFMUstate")]
45 pub can_serialize_fmu_state: Option<bool>,
46
47 #[yaserde(attribute = true, rename = "providesDirectionalDerivative")]
50 pub provides_directional_derivative: Option<bool>,
51
52 #[yaserde(rename = "SourceFiles")]
56 pub source_files: Option<SourceFiles>,
57}
58
59#[derive(Default, Debug, YaSerialize, YaDeserialize)]
60pub struct CoSimulation {
61 #[yaserde(attribute = true, rename = "modelIdentifier")]
63 pub model_identifier: String,
64
65 #[yaserde(attribute = true, rename = "needsExecutionTool")]
68 pub needs_execution_tool: Option<bool>,
69
70 #[yaserde(attribute = true, rename = "canHandleVariableCommunicationStepSize")]
71 pub can_handle_variable_communication_step_size: Option<bool>,
72
73 #[yaserde(attribute = true, rename = "canInterpolateInputs")]
74 pub can_interpolate_inputs: Option<bool>,
75
76 #[yaserde(attribute = true, rename = "maxOutputDerivativeOrder")]
77 pub max_output_derivative_order: Option<u32>,
78
79 #[yaserde(attribute = true, rename = "canRunAsynchronuously")]
80 pub can_run_asynchronuously: Option<bool>,
81
82 #[yaserde(attribute = true, rename = "canBeInstantiatedOnlyOncePerProcess")]
83 pub can_be_instantiated_only_once_per_process: Option<bool>,
84
85 #[yaserde(attribute = true, rename = "canNotUseMemoryManagementFunctions")]
86 pub can_not_use_memory_management_functions: Option<bool>,
87
88 #[yaserde(attribute = true, rename = "canGetAndSetFMUstate")]
89 pub can_get_and_set_fmu_state: Option<bool>,
90
91 #[yaserde(attribute = true, rename = "canSerializeFMUstate")]
92 pub can_serialize_fmu_state: Option<bool>,
93
94 #[yaserde(attribute = true, rename = "providesDirectionalDerivative")]
96 pub provides_directional_derivative: Option<bool>,
97
98 #[yaserde(rename = "SourceFiles")]
102 pub source_files: Option<SourceFiles>,
103}
104
105#[cfg(test)]
106mod tests {
107 use crate::fmi2::ModelExchange;
108
109 #[test]
110 fn test_model_exchange() {
111 let s = r##"<ModelExchange modelIdentifier="MyLibrary_SpringMassDamper"/>"##;
112 let me: ModelExchange = yaserde::de::from_str(s).unwrap();
113 assert!(me.model_identifier == "MyLibrary_SpringMassDamper");
114 }
115}