Skip to main content

cimstructs/
ExcPIC.rs

1/// Proportional/integral regulator excitation system. This model can be used to represent excitation systems with a proportional-integral (PI) voltage regulator controller.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcPIC {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Field voltage value 1 (E1). Typical value = 0.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub e1: Option<f64>,
9    /// Field voltage value 2 (E2). Typical value = 0.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub e2: Option<f64>,
12    /// Exciter maximum limit (Efdmax) (> ExcPIC.efdmin). Typical value = 8.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub efdmax: Option<f64>,
15    /// Exciter minimum limit (Efdmin) (< ExcPIC.efdmax). Typical value = -0,87.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub efdmin: Option<f64>,
18    /// PI controller gain (Ka). Typical value = 3,15.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub ka: Option<f64>,
21    /// Exciter regulation factor (Kc). Typical value = 0,08.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub kc: Option<f64>,
24    /// Exciter constant (Ke). Typical value = 0.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub ke: Option<f64>,
27    /// Rate feedback gain (Kf). Typical value = 0.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub kf: Option<f64>,
30    /// Current source gain (Ki). Typical value = 0.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub ki: Option<f64>,
33    /// Potential source gain (Kp). Typical value = 6,5.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub kp: Option<f64>,
36    /// Saturation factor at E1 (Se1). Typical value = 0.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub se1: Option<f64>,
39    /// Saturation factor at E2 (Se2). Typical value = 0.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub se2: Option<f64>,
42    /// PI controller time constant (Ta1) (>= 0). Typical value = 1.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub ta1: Option<f64>,
45    /// Voltage regulator time constant (Ta2) (>= 0). Typical value = 0,01.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub ta2: Option<f64>,
48    /// Lead time constant (Ta3) (>= 0). Typical value = 0.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub ta3: Option<f64>,
51    /// Lag time constant (Ta4) (>= 0). Typical value = 0.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub ta4: Option<f64>,
54    /// Exciter time constant (Te) (>= 0). Typical value = 0.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub te: Option<f64>,
57    /// Rate feedback time constant (Tf1) (>= 0). Typical value = 0.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub tf1: Option<f64>,
60    /// Rate feedback lag time constant (Tf2) (>= 0). Typical value = 0.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub tf2: Option<f64>,
63    /// PI maximum limit (Vr1). Typical value = 1.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub vr1: Option<f64>,
66    /// PI minimum limit (Vr2). Typical value = -0,87.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub vr2: Option<f64>,
69    /// Voltage regulator maximum limit (Vrmax) (> ExcPIC.vrmin). Typical value = 1.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub vrmax: Option<f64>,
72    /// Voltage regulator minimum limit (Vrmin) (< ExcPIC.vrmax). Typical value = -0,87.
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub vrmin: Option<f64>,
75}
76impl crate::base::CimElement for ExcPIC {
77    fn mrid(&self) -> &str { &self.base.base.base.id }
78    fn type_name(&self) -> &'static str { "ExcPIC" }
79    fn as_any(&self) -> &dyn std::any::Any { self }
80    fn to_json_value(&self) -> serde_json::Value {
81        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
82    }
83    fn to_block(&self) -> crate::base::RdfBlock {
84        let mut block = self.base.to_block();
85        block.type_name = "ExcPIC".to_string();
86        if let Some(v) = self.e1 {
87            block.fields.insert("ExcPIC.e1".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.e2 {
90            block.fields.insert("ExcPIC.e2".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.efdmax {
93            block.fields.insert("ExcPIC.efdmax".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.efdmin {
96            block.fields.insert("ExcPIC.efdmin".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.ka {
99            block.fields.insert("ExcPIC.ka".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.kc {
102            block.fields.insert("ExcPIC.kc".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.ke {
105            block.fields.insert("ExcPIC.ke".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.kf {
108            block.fields.insert("ExcPIC.kf".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.ki {
111            block.fields.insert("ExcPIC.ki".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        if let Some(v) = self.kp {
114            block.fields.insert("ExcPIC.kp".into(), crate::base::FieldValue::Text(v.to_string()));
115        }
116        if let Some(v) = self.se1 {
117            block.fields.insert("ExcPIC.se1".into(), crate::base::FieldValue::Text(v.to_string()));
118        }
119        if let Some(v) = self.se2 {
120            block.fields.insert("ExcPIC.se2".into(), crate::base::FieldValue::Text(v.to_string()));
121        }
122        if let Some(v) = self.ta1 {
123            block.fields.insert("ExcPIC.ta1".into(), crate::base::FieldValue::Text(v.to_string()));
124        }
125        if let Some(v) = self.ta2 {
126            block.fields.insert("ExcPIC.ta2".into(), crate::base::FieldValue::Text(v.to_string()));
127        }
128        if let Some(v) = self.ta3 {
129            block.fields.insert("ExcPIC.ta3".into(), crate::base::FieldValue::Text(v.to_string()));
130        }
131        if let Some(v) = self.ta4 {
132            block.fields.insert("ExcPIC.ta4".into(), crate::base::FieldValue::Text(v.to_string()));
133        }
134        if let Some(v) = self.te {
135            block.fields.insert("ExcPIC.te".into(), crate::base::FieldValue::Text(v.to_string()));
136        }
137        if let Some(v) = self.tf1 {
138            block.fields.insert("ExcPIC.tf1".into(), crate::base::FieldValue::Text(v.to_string()));
139        }
140        if let Some(v) = self.tf2 {
141            block.fields.insert("ExcPIC.tf2".into(), crate::base::FieldValue::Text(v.to_string()));
142        }
143        if let Some(v) = self.vr1 {
144            block.fields.insert("ExcPIC.vr1".into(), crate::base::FieldValue::Text(v.to_string()));
145        }
146        if let Some(v) = self.vr2 {
147            block.fields.insert("ExcPIC.vr2".into(), crate::base::FieldValue::Text(v.to_string()));
148        }
149        if let Some(v) = self.vrmax {
150            block.fields.insert("ExcPIC.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
151        }
152        if let Some(v) = self.vrmin {
153            block.fields.insert("ExcPIC.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
154        }
155        block
156    }
157}
158
159impl ExcPIC {
160    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
161        let mut obj = Self::default();
162        obj.base.base.base.id.clone_from(&b.mrid);
163        for (key, val) in &b.fields {
164            match key.as_str() {
165                "ExcPIC.e1" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.e1 = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.e1 = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "ExcPIC.e2" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.e2 = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.e2 = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "ExcPIC.efdmax" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "ExcPIC.efdmin" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmin = Some(v); } }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmin = Some(v); } }
197                        }
198                        _ => {}
199                    }
200                }
201                "ExcPIC.ka" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
206                        }
207                        _ => {}
208                    }
209                }
210                "ExcPIC.kc" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
215                        }
216                        _ => {}
217                    }
218                }
219                "ExcPIC.ke" => {
220                    match val {
221                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
222                        crate::base::FieldValue::TextList(svs) => {
223                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
224                        }
225                        _ => {}
226                    }
227                }
228                "ExcPIC.kf" => {
229                    match val {
230                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
231                        crate::base::FieldValue::TextList(svs) => {
232                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
233                        }
234                        _ => {}
235                    }
236                }
237                "ExcPIC.ki" => {
238                    match val {
239                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
240                        crate::base::FieldValue::TextList(svs) => {
241                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
242                        }
243                        _ => {}
244                    }
245                }
246                "ExcPIC.kp" => {
247                    match val {
248                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
249                        crate::base::FieldValue::TextList(svs) => {
250                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
251                        }
252                        _ => {}
253                    }
254                }
255                "ExcPIC.se1" => {
256                    match val {
257                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.se1 = Some(v); } }
258                        crate::base::FieldValue::TextList(svs) => {
259                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.se1 = Some(v); } }
260                        }
261                        _ => {}
262                    }
263                }
264                "ExcPIC.se2" => {
265                    match val {
266                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.se2 = Some(v); } }
267                        crate::base::FieldValue::TextList(svs) => {
268                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.se2 = Some(v); } }
269                        }
270                        _ => {}
271                    }
272                }
273                "ExcPIC.ta1" => {
274                    match val {
275                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta1 = Some(v); } }
276                        crate::base::FieldValue::TextList(svs) => {
277                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta1 = Some(v); } }
278                        }
279                        _ => {}
280                    }
281                }
282                "ExcPIC.ta2" => {
283                    match val {
284                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta2 = Some(v); } }
285                        crate::base::FieldValue::TextList(svs) => {
286                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta2 = Some(v); } }
287                        }
288                        _ => {}
289                    }
290                }
291                "ExcPIC.ta3" => {
292                    match val {
293                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta3 = Some(v); } }
294                        crate::base::FieldValue::TextList(svs) => {
295                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta3 = Some(v); } }
296                        }
297                        _ => {}
298                    }
299                }
300                "ExcPIC.ta4" => {
301                    match val {
302                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta4 = Some(v); } }
303                        crate::base::FieldValue::TextList(svs) => {
304                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta4 = Some(v); } }
305                        }
306                        _ => {}
307                    }
308                }
309                "ExcPIC.te" => {
310                    match val {
311                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
312                        crate::base::FieldValue::TextList(svs) => {
313                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
314                        }
315                        _ => {}
316                    }
317                }
318                "ExcPIC.tf1" => {
319                    match val {
320                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf1 = Some(v); } }
321                        crate::base::FieldValue::TextList(svs) => {
322                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf1 = Some(v); } }
323                        }
324                        _ => {}
325                    }
326                }
327                "ExcPIC.tf2" => {
328                    match val {
329                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf2 = Some(v); } }
330                        crate::base::FieldValue::TextList(svs) => {
331                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf2 = Some(v); } }
332                        }
333                        _ => {}
334                    }
335                }
336                "ExcPIC.vr1" => {
337                    match val {
338                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vr1 = Some(v); } }
339                        crate::base::FieldValue::TextList(svs) => {
340                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vr1 = Some(v); } }
341                        }
342                        _ => {}
343                    }
344                }
345                "ExcPIC.vr2" => {
346                    match val {
347                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vr2 = Some(v); } }
348                        crate::base::FieldValue::TextList(svs) => {
349                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vr2 = Some(v); } }
350                        }
351                        _ => {}
352                    }
353                }
354                "ExcPIC.vrmax" => {
355                    match val {
356                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
357                        crate::base::FieldValue::TextList(svs) => {
358                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
359                        }
360                        _ => {}
361                    }
362                }
363                "ExcPIC.vrmin" => {
364                    match val {
365                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
366                        crate::base::FieldValue::TextList(svs) => {
367                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
368                        }
369                        _ => {}
370                    }
371                }
372                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
373                    if let crate::base::FieldValue::Resource(sv) = val {
374                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
375                    }
376                }
377                "DynamicsFunctionBlock.enabled" => {
378                    match val {
379                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
380                        crate::base::FieldValue::TextList(svs) => {
381                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
382                        }
383                        _ => {}
384                    }
385                }
386                "IdentifiedObject.description" => {
387                    match val {
388                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
389                        crate::base::FieldValue::TextList(svs) => {
390                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
391                        }
392                        _ => {}
393                    }
394                }
395                "IdentifiedObject.energyIdentCodeEic" => {
396                    match val {
397                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
398                        crate::base::FieldValue::TextList(svs) => {
399                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
400                        }
401                        _ => {}
402                    }
403                }
404                "IdentifiedObject.mRID" => {
405                    match val {
406                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
407                        crate::base::FieldValue::TextList(svs) => {
408                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
409                        }
410                        _ => {}
411                    }
412                }
413                "IdentifiedObject.name" => {
414                    match val {
415                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
416                        crate::base::FieldValue::TextList(svs) => {
417                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
418                        }
419                        _ => {}
420                    }
421                }
422                "IdentifiedObject.shortName" => {
423                    match val {
424                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
425                        crate::base::FieldValue::TextList(svs) => {
426                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
427                        }
428                        _ => {}
429                    }
430                }
431                _ => {}
432            }
433        }
434        obj
435    }
436}