1use std::fmt::Display;
2
3#[derive(Default, Debug, Clone, clap::ValueEnum)]
4pub enum SolverArg {
5 #[clap(name = "euler")]
7 #[default]
8 Euler,
9}
10
11#[derive(Default, Debug, clap::Args)]
12pub struct ModelExchangeOptions {
14 #[command(flatten)]
15 pub common: CommonOptions,
16
17 #[arg(long, default_value = "euler")]
19 pub solver: SolverArg,
20}
21
22#[derive(Default, Debug, clap::Args)]
23pub struct CoSimulationOptions {
25 #[command(flatten)]
26 pub common: CommonOptions,
27
28 #[arg(long)]
30 pub event_mode_used: bool,
31
32 #[arg(long)]
34 pub early_return_allowed: bool,
35}
36
37#[derive(Debug, clap::Subcommand)]
38pub enum Interface {
39 #[cfg(feature = "me")]
40 #[command(alias = "me")]
41 ModelExchange(ModelExchangeOptions),
42
43 #[cfg(feature = "cs")]
44 #[command(alias = "cs")]
45 CoSimulation(CoSimulationOptions),
46
47 #[cfg(feature = "se")]
49 ScheduledExecution(CommonOptions),
50}
51
52impl Default for Interface {
53 fn default() -> Self {
54 #[cfg(all(not(feature = "me"), feature = "cs"))]
56 {
57 Self::CoSimulation(Default::default())
58 }
59
60 #[cfg(all(feature = "me", feature = "cs"))]
62 {
63 Self::CoSimulation(Default::default())
64 }
65
66 #[cfg(all(feature = "me", not(feature = "cs")))]
68 {
69 Self::ModelExchange(Default::default())
70 }
71 }
72}
73
74impl Display for Interface {
75 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
76 match self {
77 #[cfg(feature = "me")]
78 Self::ModelExchange(_) => write!(f, "ModelExchange"),
79 #[cfg(feature = "cs")]
80 Self::CoSimulation(_) => write!(f, "CoSimulation"),
81 #[cfg(feature = "se")]
82 Self::ScheduledExecution(_) => write!(f, "ScheduledExecution"),
83 }
84 }
85}
86
87#[derive(Default, Debug, clap::Args)]
88pub struct CommonOptions {
89 #[arg(long)]
91 pub initial_fmu_state_file: Option<std::path::PathBuf>,
92
93 #[arg(long)]
95 pub final_fmu_state_file: Option<std::path::PathBuf>,
96
97 #[arg(short = 'v')]
102 pub initial_values: Vec<String>,
103
104 #[arg(short = 'd')]
107 pub print_left_limit: bool,
108
109 #[arg(long = "print-all")]
111 pub print_all_variables: bool,
112
113 #[arg(long = "ss")]
119 pub step_size: Option<f64>,
120
121 #[arg(long = "output-interval")]
122 pub output_interval: Option<f64>,
123
124 #[arg(short = 'n', default_value = "500")]
128 pub num_steps: usize,
129
130 #[arg(short = 's')]
133 pub start_time: Option<f64>,
134
135 #[arg(short = 'f')]
138 pub stop_time: Option<f64>,
139
140 #[arg(long)]
142 pub tolerance: Option<f64>,
143}
144
145#[derive(Default, Debug, clap::Parser)]
147#[command(version, about)]
148pub struct FmiSimOptions {
149 #[command(subcommand)]
151 pub interface: Interface,
152 #[arg(long)]
154 pub model: std::path::PathBuf,
155 #[arg(short = 'i', long)]
157 pub input_file: Option<std::path::PathBuf>,
158 #[arg(short = 'o', long)]
160 pub output_file: Option<std::path::PathBuf>,
161 #[arg(short = 'c', default_value = ",")]
163 pub separator: char,
164 #[arg(short = 'm')]
167 pub mangle_names: bool,
168}