Skip to main content

cimstructs/
GovGAST4.rs

1/// Generic turbogas.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct GovGAST4 {
4    #[serde(flatten)]
5    pub base: super::TurbineGovernorDynamics,
6    /// Droop (bp). Typical value = 0,05.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub bp: Option<f64>,
9    /// Compressor gain (Ktm). Typical value = 0.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub ktm: Option<f64>,
12    /// Fuel flow maximum negative error value (MNef). Typical value = -0,05.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub mnef: Option<f64>,
15    /// Fuel flow maximum positive error value (MXef). Typical value = 0,05.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub mxef: Option<f64>,
18    /// Minimum valve opening (RYMN). Typical value = 0.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub rymn: Option<f64>,
21    /// Maximum valve opening (RYMX). Typical value = 1,1.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub rymx: Option<f64>,
24    /// Maximum gate opening velocity (TA) (>= 0). Typical value = 3.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub ta: Option<f64>,
27    /// Maximum gate closing velocity (TC) (>= 0). Typical value = 0,5.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub tc: Option<f64>,
30    /// Fuel control time constant (Tcm) (>= 0). Typical value = 0,1.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub tcm: Option<f64>,
33    /// Compressor discharge volume time constant (Tm) (>= 0). Typical value = 0,2.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub tm: Option<f64>,
36    /// Time constant of fuel valve positioner (Ty) (>= 0). Typical value = 0,1.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub ty: Option<f64>,
39}
40impl crate::base::CimElement for GovGAST4 {
41    fn mrid(&self) -> &str { &self.base.base.base.id }
42    fn type_name(&self) -> &'static str { "GovGAST4" }
43    fn as_any(&self) -> &dyn std::any::Any { self }
44    fn to_json_value(&self) -> serde_json::Value {
45        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
46    }
47    fn to_block(&self) -> crate::base::RdfBlock {
48        let mut block = self.base.to_block();
49        block.type_name = "GovGAST4".to_string();
50        if let Some(v) = self.bp {
51            block.fields.insert("GovGAST4.bp".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.ktm {
54            block.fields.insert("GovGAST4.ktm".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.mnef {
57            block.fields.insert("GovGAST4.mnef".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        if let Some(v) = self.mxef {
60            block.fields.insert("GovGAST4.mxef".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.rymn {
63            block.fields.insert("GovGAST4.rymn".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.rymx {
66            block.fields.insert("GovGAST4.rymx".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.ta {
69            block.fields.insert("GovGAST4.ta".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.tc {
72            block.fields.insert("GovGAST4.tc".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.tcm {
75            block.fields.insert("GovGAST4.tcm".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.tm {
78            block.fields.insert("GovGAST4.tm".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.ty {
81            block.fields.insert("GovGAST4.ty".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        block
84    }
85}
86
87impl GovGAST4 {
88    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
89        let mut obj = Self::default();
90        obj.base.base.base.id.clone_from(&b.mrid);
91        for (key, val) in &b.fields {
92            match key.as_str() {
93                "GovGAST4.bp" => {
94                    match val {
95                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.bp = Some(v); } }
96                        crate::base::FieldValue::TextList(svs) => {
97                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.bp = Some(v); } }
98                        }
99                        _ => {}
100                    }
101                }
102                "GovGAST4.ktm" => {
103                    match val {
104                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ktm = Some(v); } }
105                        crate::base::FieldValue::TextList(svs) => {
106                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ktm = Some(v); } }
107                        }
108                        _ => {}
109                    }
110                }
111                "GovGAST4.mnef" => {
112                    match val {
113                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.mnef = Some(v); } }
114                        crate::base::FieldValue::TextList(svs) => {
115                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.mnef = Some(v); } }
116                        }
117                        _ => {}
118                    }
119                }
120                "GovGAST4.mxef" => {
121                    match val {
122                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.mxef = Some(v); } }
123                        crate::base::FieldValue::TextList(svs) => {
124                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.mxef = Some(v); } }
125                        }
126                        _ => {}
127                    }
128                }
129                "GovGAST4.rymn" => {
130                    match val {
131                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rymn = Some(v); } }
132                        crate::base::FieldValue::TextList(svs) => {
133                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rymn = Some(v); } }
134                        }
135                        _ => {}
136                    }
137                }
138                "GovGAST4.rymx" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rymx = Some(v); } }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rymx = Some(v); } }
143                        }
144                        _ => {}
145                    }
146                }
147                "GovGAST4.ta" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
152                        }
153                        _ => {}
154                    }
155                }
156                "GovGAST4.tc" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "GovGAST4.tcm" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tcm = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tcm = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "GovGAST4.tm" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tm = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tm = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "GovGAST4.ty" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ty = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ty = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "TurbineGovernorDynamics.AsynchronousMachineDynamics" => {
193                    if let crate::base::FieldValue::Resource(sv) = val {
194                        obj.base.asynchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
195                    }
196                }
197                "TurbineGovernorDynamics.SynchronousMachineDynamics" => {
198                    if let crate::base::FieldValue::Resource(sv) = val {
199                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
200                    }
201                }
202                "DynamicsFunctionBlock.enabled" => {
203                    match val {
204                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
205                        crate::base::FieldValue::TextList(svs) => {
206                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
207                        }
208                        _ => {}
209                    }
210                }
211                "IdentifiedObject.description" => {
212                    match val {
213                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
214                        crate::base::FieldValue::TextList(svs) => {
215                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
216                        }
217                        _ => {}
218                    }
219                }
220                "IdentifiedObject.energyIdentCodeEic" => {
221                    match val {
222                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
223                        crate::base::FieldValue::TextList(svs) => {
224                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
225                        }
226                        _ => {}
227                    }
228                }
229                "IdentifiedObject.mRID" => {
230                    match val {
231                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
232                        crate::base::FieldValue::TextList(svs) => {
233                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
234                        }
235                        _ => {}
236                    }
237                }
238                "IdentifiedObject.name" => {
239                    match val {
240                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
241                        crate::base::FieldValue::TextList(svs) => {
242                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
243                        }
244                        _ => {}
245                    }
246                }
247                "IdentifiedObject.shortName" => {
248                    match val {
249                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
250                        crate::base::FieldValue::TextList(svs) => {
251                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
252                        }
253                        _ => {}
254                    }
255                }
256                _ => {}
257            }
258        }
259        obj
260    }
261}