Skip to main content

cimstructs/
ExcAVR7.rs

1/// IVO excitation system.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcAVR7 {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Lead coefficient (A1). Typical value = 0,5.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub a1: Option<f64>,
9    /// Lag coefficient (A2). Typical value = 0,5.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub a2: Option<f64>,
12    /// Lead coefficient (A3). Typical value = 0,5.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub a3: Option<f64>,
15    /// Lag coefficient (A4). Typical value = 0,5.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub a4: Option<f64>,
18    /// Lead coefficient (A5). Typical value = 0,5.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub a5: Option<f64>,
21    /// Lag coefficient (A6). Typical value = 0,5.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub a6: Option<f64>,
24    /// Gain (K1). Typical value = 1.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub k1: Option<f64>,
27    /// Gain (K3). Typical value = 3.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub k3: Option<f64>,
30    /// Gain (K5). Typical value = 1.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub k5: Option<f64>,
33    /// Lead time constant (T1) (>= 0). Typical value = 0,05.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub t1: Option<f64>,
36    /// Lag time constant (T2) (>= 0). Typical value = 0,1.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub t2: Option<f64>,
39    /// Lead time constant (T3) (>= 0). Typical value = 0,1.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub t3: Option<f64>,
42    /// Lag time constant (T4) (>= 0). Typical value = 0,1.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub t4: Option<f64>,
45    /// Lead time constant (T5) (>= 0). Typical value = 0,1.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub t5: Option<f64>,
48    /// Lag time constant (T6) (>= 0). Typical value = 0,1.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub t6: Option<f64>,
51    /// Lead-lag maximum limit (Vmax1) (> ExcAVR7.vmin1). Typical value = 5.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub vmax1: Option<f64>,
54    /// Lead-lag maximum limit (Vmax3) (> ExcAVR7.vmin3). Typical value = 5.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub vmax3: Option<f64>,
57    /// Lead-lag maximum limit (Vmax5) (> ExcAVR7.vmin5). Typical value = 5.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub vmax5: Option<f64>,
60    /// Lead-lag minimum limit (Vmin1) (< ExcAVR7.vmax1). Typical value = -5.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub vmin1: Option<f64>,
63    /// Lead-lag minimum limit (Vmin3) (< ExcAVR7.vmax3). Typical value = -5.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub vmin3: Option<f64>,
66    /// Lead-lag minimum limit (Vmin5) (< ExcAVR7.vmax5). Typical value = -2.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub vmin5: Option<f64>,
69}
70impl crate::base::CimElement for ExcAVR7 {
71    fn mrid(&self) -> &str { &self.base.base.base.id }
72    fn type_name(&self) -> &'static str { "ExcAVR7" }
73    fn as_any(&self) -> &dyn std::any::Any { self }
74    fn to_json_value(&self) -> serde_json::Value {
75        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
76    }
77    fn to_block(&self) -> crate::base::RdfBlock {
78        let mut block = self.base.to_block();
79        block.type_name = "ExcAVR7".to_string();
80        if let Some(v) = self.a1 {
81            block.fields.insert("ExcAVR7.a1".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.a2 {
84            block.fields.insert("ExcAVR7.a2".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.a3 {
87            block.fields.insert("ExcAVR7.a3".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.a4 {
90            block.fields.insert("ExcAVR7.a4".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.a5 {
93            block.fields.insert("ExcAVR7.a5".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.a6 {
96            block.fields.insert("ExcAVR7.a6".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.k1 {
99            block.fields.insert("ExcAVR7.k1".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.k3 {
102            block.fields.insert("ExcAVR7.k3".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.k5 {
105            block.fields.insert("ExcAVR7.k5".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.t1 {
108            block.fields.insert("ExcAVR7.t1".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.t2 {
111            block.fields.insert("ExcAVR7.t2".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        if let Some(v) = self.t3 {
114            block.fields.insert("ExcAVR7.t3".into(), crate::base::FieldValue::Text(v.to_string()));
115        }
116        if let Some(v) = self.t4 {
117            block.fields.insert("ExcAVR7.t4".into(), crate::base::FieldValue::Text(v.to_string()));
118        }
119        if let Some(v) = self.t5 {
120            block.fields.insert("ExcAVR7.t5".into(), crate::base::FieldValue::Text(v.to_string()));
121        }
122        if let Some(v) = self.t6 {
123            block.fields.insert("ExcAVR7.t6".into(), crate::base::FieldValue::Text(v.to_string()));
124        }
125        if let Some(v) = self.vmax1 {
126            block.fields.insert("ExcAVR7.vmax1".into(), crate::base::FieldValue::Text(v.to_string()));
127        }
128        if let Some(v) = self.vmax3 {
129            block.fields.insert("ExcAVR7.vmax3".into(), crate::base::FieldValue::Text(v.to_string()));
130        }
131        if let Some(v) = self.vmax5 {
132            block.fields.insert("ExcAVR7.vmax5".into(), crate::base::FieldValue::Text(v.to_string()));
133        }
134        if let Some(v) = self.vmin1 {
135            block.fields.insert("ExcAVR7.vmin1".into(), crate::base::FieldValue::Text(v.to_string()));
136        }
137        if let Some(v) = self.vmin3 {
138            block.fields.insert("ExcAVR7.vmin3".into(), crate::base::FieldValue::Text(v.to_string()));
139        }
140        if let Some(v) = self.vmin5 {
141            block.fields.insert("ExcAVR7.vmin5".into(), crate::base::FieldValue::Text(v.to_string()));
142        }
143        block
144    }
145}
146
147impl ExcAVR7 {
148    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
149        let mut obj = Self::default();
150        obj.base.base.base.id.clone_from(&b.mrid);
151        for (key, val) in &b.fields {
152            match key.as_str() {
153                "ExcAVR7.a1" => {
154                    match val {
155                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.a1 = Some(v); } }
156                        crate::base::FieldValue::TextList(svs) => {
157                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.a1 = Some(v); } }
158                        }
159                        _ => {}
160                    }
161                }
162                "ExcAVR7.a2" => {
163                    match val {
164                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.a2 = Some(v); } }
165                        crate::base::FieldValue::TextList(svs) => {
166                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.a2 = Some(v); } }
167                        }
168                        _ => {}
169                    }
170                }
171                "ExcAVR7.a3" => {
172                    match val {
173                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.a3 = Some(v); } }
174                        crate::base::FieldValue::TextList(svs) => {
175                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.a3 = Some(v); } }
176                        }
177                        _ => {}
178                    }
179                }
180                "ExcAVR7.a4" => {
181                    match val {
182                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.a4 = Some(v); } }
183                        crate::base::FieldValue::TextList(svs) => {
184                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.a4 = Some(v); } }
185                        }
186                        _ => {}
187                    }
188                }
189                "ExcAVR7.a5" => {
190                    match val {
191                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.a5 = Some(v); } }
192                        crate::base::FieldValue::TextList(svs) => {
193                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.a5 = Some(v); } }
194                        }
195                        _ => {}
196                    }
197                }
198                "ExcAVR7.a6" => {
199                    match val {
200                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.a6 = Some(v); } }
201                        crate::base::FieldValue::TextList(svs) => {
202                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.a6 = Some(v); } }
203                        }
204                        _ => {}
205                    }
206                }
207                "ExcAVR7.k1" => {
208                    match val {
209                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.k1 = Some(v); } }
210                        crate::base::FieldValue::TextList(svs) => {
211                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.k1 = Some(v); } }
212                        }
213                        _ => {}
214                    }
215                }
216                "ExcAVR7.k3" => {
217                    match val {
218                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.k3 = Some(v); } }
219                        crate::base::FieldValue::TextList(svs) => {
220                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.k3 = Some(v); } }
221                        }
222                        _ => {}
223                    }
224                }
225                "ExcAVR7.k5" => {
226                    match val {
227                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.k5 = Some(v); } }
228                        crate::base::FieldValue::TextList(svs) => {
229                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.k5 = Some(v); } }
230                        }
231                        _ => {}
232                    }
233                }
234                "ExcAVR7.t1" => {
235                    match val {
236                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
237                        crate::base::FieldValue::TextList(svs) => {
238                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
239                        }
240                        _ => {}
241                    }
242                }
243                "ExcAVR7.t2" => {
244                    match val {
245                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t2 = Some(v); } }
246                        crate::base::FieldValue::TextList(svs) => {
247                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t2 = Some(v); } }
248                        }
249                        _ => {}
250                    }
251                }
252                "ExcAVR7.t3" => {
253                    match val {
254                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t3 = Some(v); } }
255                        crate::base::FieldValue::TextList(svs) => {
256                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t3 = Some(v); } }
257                        }
258                        _ => {}
259                    }
260                }
261                "ExcAVR7.t4" => {
262                    match val {
263                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t4 = Some(v); } }
264                        crate::base::FieldValue::TextList(svs) => {
265                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t4 = Some(v); } }
266                        }
267                        _ => {}
268                    }
269                }
270                "ExcAVR7.t5" => {
271                    match val {
272                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t5 = Some(v); } }
273                        crate::base::FieldValue::TextList(svs) => {
274                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t5 = Some(v); } }
275                        }
276                        _ => {}
277                    }
278                }
279                "ExcAVR7.t6" => {
280                    match val {
281                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t6 = Some(v); } }
282                        crate::base::FieldValue::TextList(svs) => {
283                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t6 = Some(v); } }
284                        }
285                        _ => {}
286                    }
287                }
288                "ExcAVR7.vmax1" => {
289                    match val {
290                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmax1 = Some(v); } }
291                        crate::base::FieldValue::TextList(svs) => {
292                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmax1 = Some(v); } }
293                        }
294                        _ => {}
295                    }
296                }
297                "ExcAVR7.vmax3" => {
298                    match val {
299                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmax3 = Some(v); } }
300                        crate::base::FieldValue::TextList(svs) => {
301                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmax3 = Some(v); } }
302                        }
303                        _ => {}
304                    }
305                }
306                "ExcAVR7.vmax5" => {
307                    match val {
308                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmax5 = Some(v); } }
309                        crate::base::FieldValue::TextList(svs) => {
310                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmax5 = Some(v); } }
311                        }
312                        _ => {}
313                    }
314                }
315                "ExcAVR7.vmin1" => {
316                    match val {
317                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmin1 = Some(v); } }
318                        crate::base::FieldValue::TextList(svs) => {
319                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmin1 = Some(v); } }
320                        }
321                        _ => {}
322                    }
323                }
324                "ExcAVR7.vmin3" => {
325                    match val {
326                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmin3 = Some(v); } }
327                        crate::base::FieldValue::TextList(svs) => {
328                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmin3 = Some(v); } }
329                        }
330                        _ => {}
331                    }
332                }
333                "ExcAVR7.vmin5" => {
334                    match val {
335                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmin5 = Some(v); } }
336                        crate::base::FieldValue::TextList(svs) => {
337                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmin5 = Some(v); } }
338                        }
339                        _ => {}
340                    }
341                }
342                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
343                    if let crate::base::FieldValue::Resource(sv) = val {
344                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
345                    }
346                }
347                "DynamicsFunctionBlock.enabled" => {
348                    match val {
349                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
350                        crate::base::FieldValue::TextList(svs) => {
351                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
352                        }
353                        _ => {}
354                    }
355                }
356                "IdentifiedObject.description" => {
357                    match val {
358                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
359                        crate::base::FieldValue::TextList(svs) => {
360                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
361                        }
362                        _ => {}
363                    }
364                }
365                "IdentifiedObject.energyIdentCodeEic" => {
366                    match val {
367                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
368                        crate::base::FieldValue::TextList(svs) => {
369                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
370                        }
371                        _ => {}
372                    }
373                }
374                "IdentifiedObject.mRID" => {
375                    match val {
376                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
377                        crate::base::FieldValue::TextList(svs) => {
378                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
379                        }
380                        _ => {}
381                    }
382                }
383                "IdentifiedObject.name" => {
384                    match val {
385                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
386                        crate::base::FieldValue::TextList(svs) => {
387                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
388                        }
389                        _ => {}
390                    }
391                }
392                "IdentifiedObject.shortName" => {
393                    match val {
394                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
395                        crate::base::FieldValue::TextList(svs) => {
396                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
397                        }
398                        _ => {}
399                    }
400                }
401                _ => {}
402            }
403        }
404        obj
405    }
406}