Skip to main content

cimstructs/
ExcST4B.rs

1/// Modified IEEE ST4B static excitation system with maximum inner loop feedback gain Vgmax.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcST4B {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Rectifier loading factor proportional to commutating reactance (Kc) (>= 0). Typical value = 0,113.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub kc: Option<f64>,
9    /// Feedback gain constant of the inner loop field regulator (Kg) (>= 0). Typical value = 0.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub kg: Option<f64>,
12    /// Potential circuit gain coefficient (Ki) (>= 0). Typical value = 0.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub ki: Option<f64>,
15    /// Voltage regulator integral gain output (Kim). Typical value = 0.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub kim: Option<f64>,
18    /// Voltage regulator integral gain (Kir). Typical value = 10,75.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kir: Option<f64>,
21    /// Potential circuit gain coefficient (Kp) (> 0). Typical value = 9,3.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub kp: Option<f64>,
24    /// Voltage regulator proportional gain output (Kpm). Typical value = 1.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub kpm: Option<f64>,
27    /// Voltage regulator proportional gain (Kpr). Typical value = 10,75.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub kpr: Option<f64>,
30    /// Selector (LVGate). true = LVGate is part of the block diagram false = LVGate is not part of the block diagram. Typical value = false.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub lvgate: Option<bool>,
33    /// Voltage regulator time constant (Ta) (>= 0). Typical value = 0,02.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub ta: Option<f64>,
36    /// Potential circuit phase angle (thetap). Typical value = 0.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub thetap: Option<f64>,
39    /// Selector (UEL). true = UEL is part of block diagram false = UEL is not part of block diagram. Typical value = false.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub uel: Option<bool>,
42    /// Maximum excitation voltage (Vbmax) (> 0). Typical value = 11,63.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vbmax: Option<f64>,
45    /// Maximum inner loop feedback voltage (Vgmax) (>= 0). Typical value = 5,8.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vgmax: Option<f64>,
48    /// Maximum inner loop output (Vmmax) (> ExcST4B.vmmin). Typical value = 99.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub vmmax: Option<f64>,
51    /// Minimum inner loop output (Vmmin) (< ExcST4B.vmmax). Typical value = -99.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub vmmin: Option<f64>,
54    /// Maximum voltage regulator output (Vrmax) (> 0). Typical value = 1.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub vrmax: Option<f64>,
57    /// Minimum voltage regulator output (Vrmin) (< 0). Typical value = -0,87.
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub vrmin: Option<f64>,
60    /// Reactance associated with potential source (Xl) (>= 0). Typical value = 0,124.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub xl: Option<f64>,
63}
64impl crate::base::CimElement for ExcST4B {
65    fn mrid(&self) -> &str { &self.base.base.base.id }
66    fn type_name(&self) -> &'static str { "ExcST4B" }
67    fn as_any(&self) -> &dyn std::any::Any { self }
68    fn to_json_value(&self) -> serde_json::Value {
69        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
70    }
71    fn to_block(&self) -> crate::base::RdfBlock {
72        let mut block = self.base.to_block();
73        block.type_name = "ExcST4B".to_string();
74        if let Some(v) = self.kc {
75            block.fields.insert("ExcST4B.kc".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.kg {
78            block.fields.insert("ExcST4B.kg".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.ki {
81            block.fields.insert("ExcST4B.ki".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.kim {
84            block.fields.insert("ExcST4B.kim".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.kir {
87            block.fields.insert("ExcST4B.kir".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.kp {
90            block.fields.insert("ExcST4B.kp".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.kpm {
93            block.fields.insert("ExcST4B.kpm".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.kpr {
96            block.fields.insert("ExcST4B.kpr".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.lvgate {
99            block.fields.insert("ExcST4B.lvgate".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.ta {
102            block.fields.insert("ExcST4B.ta".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.thetap {
105            block.fields.insert("ExcST4B.thetap".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.uel {
108            block.fields.insert("ExcST4B.uel".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.vbmax {
111            block.fields.insert("ExcST4B.vbmax".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        if let Some(v) = self.vgmax {
114            block.fields.insert("ExcST4B.vgmax".into(), crate::base::FieldValue::Text(v.to_string()));
115        }
116        if let Some(v) = self.vmmax {
117            block.fields.insert("ExcST4B.vmmax".into(), crate::base::FieldValue::Text(v.to_string()));
118        }
119        if let Some(v) = self.vmmin {
120            block.fields.insert("ExcST4B.vmmin".into(), crate::base::FieldValue::Text(v.to_string()));
121        }
122        if let Some(v) = self.vrmax {
123            block.fields.insert("ExcST4B.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
124        }
125        if let Some(v) = self.vrmin {
126            block.fields.insert("ExcST4B.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
127        }
128        if let Some(v) = self.xl {
129            block.fields.insert("ExcST4B.xl".into(), crate::base::FieldValue::Text(v.to_string()));
130        }
131        block
132    }
133}
134
135impl ExcST4B {
136    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
137        let mut obj = Self::default();
138        obj.base.base.base.id.clone_from(&b.mrid);
139        for (key, val) in &b.fields {
140            match key.as_str() {
141                "ExcST4B.kc" => {
142                    match val {
143                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
144                        crate::base::FieldValue::TextList(svs) => {
145                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
146                        }
147                        _ => {}
148                    }
149                }
150                "ExcST4B.kg" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kg = Some(v); } }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kg = Some(v); } }
155                        }
156                        _ => {}
157                    }
158                }
159                "ExcST4B.ki" => {
160                    match val {
161                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
162                        crate::base::FieldValue::TextList(svs) => {
163                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
164                        }
165                        _ => {}
166                    }
167                }
168                "ExcST4B.kim" => {
169                    match val {
170                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kim = Some(v); } }
171                        crate::base::FieldValue::TextList(svs) => {
172                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kim = Some(v); } }
173                        }
174                        _ => {}
175                    }
176                }
177                "ExcST4B.kir" => {
178                    match val {
179                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kir = Some(v); } }
180                        crate::base::FieldValue::TextList(svs) => {
181                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kir = Some(v); } }
182                        }
183                        _ => {}
184                    }
185                }
186                "ExcST4B.kp" => {
187                    match val {
188                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
189                        crate::base::FieldValue::TextList(svs) => {
190                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
191                        }
192                        _ => {}
193                    }
194                }
195                "ExcST4B.kpm" => {
196                    match val {
197                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kpm = Some(v); } }
198                        crate::base::FieldValue::TextList(svs) => {
199                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kpm = Some(v); } }
200                        }
201                        _ => {}
202                    }
203                }
204                "ExcST4B.kpr" => {
205                    match val {
206                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kpr = Some(v); } }
207                        crate::base::FieldValue::TextList(svs) => {
208                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kpr = Some(v); } }
209                        }
210                        _ => {}
211                    }
212                }
213                "ExcST4B.lvgate" => {
214                    match val {
215                        crate::base::FieldValue::Text(sv) => { obj.lvgate = Some(sv.trim() == "true"); }
216                        crate::base::FieldValue::TextList(svs) => {
217                            if let Some(sv) = svs.last() { obj.lvgate = Some(sv.trim() == "true"); }
218                        }
219                        _ => {}
220                    }
221                }
222                "ExcST4B.ta" => {
223                    match val {
224                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
225                        crate::base::FieldValue::TextList(svs) => {
226                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
227                        }
228                        _ => {}
229                    }
230                }
231                "ExcST4B.thetap" => {
232                    match val {
233                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.thetap = Some(v); } }
234                        crate::base::FieldValue::TextList(svs) => {
235                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.thetap = Some(v); } }
236                        }
237                        _ => {}
238                    }
239                }
240                "ExcST4B.uel" => {
241                    match val {
242                        crate::base::FieldValue::Text(sv) => { obj.uel = Some(sv.trim() == "true"); }
243                        crate::base::FieldValue::TextList(svs) => {
244                            if let Some(sv) = svs.last() { obj.uel = Some(sv.trim() == "true"); }
245                        }
246                        _ => {}
247                    }
248                }
249                "ExcST4B.vbmax" => {
250                    match val {
251                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vbmax = Some(v); } }
252                        crate::base::FieldValue::TextList(svs) => {
253                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vbmax = Some(v); } }
254                        }
255                        _ => {}
256                    }
257                }
258                "ExcST4B.vgmax" => {
259                    match val {
260                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vgmax = Some(v); } }
261                        crate::base::FieldValue::TextList(svs) => {
262                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vgmax = Some(v); } }
263                        }
264                        _ => {}
265                    }
266                }
267                "ExcST4B.vmmax" => {
268                    match val {
269                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmmax = Some(v); } }
270                        crate::base::FieldValue::TextList(svs) => {
271                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmmax = Some(v); } }
272                        }
273                        _ => {}
274                    }
275                }
276                "ExcST4B.vmmin" => {
277                    match val {
278                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vmmin = Some(v); } }
279                        crate::base::FieldValue::TextList(svs) => {
280                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vmmin = Some(v); } }
281                        }
282                        _ => {}
283                    }
284                }
285                "ExcST4B.vrmax" => {
286                    match val {
287                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
288                        crate::base::FieldValue::TextList(svs) => {
289                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
290                        }
291                        _ => {}
292                    }
293                }
294                "ExcST4B.vrmin" => {
295                    match val {
296                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
297                        crate::base::FieldValue::TextList(svs) => {
298                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
299                        }
300                        _ => {}
301                    }
302                }
303                "ExcST4B.xl" => {
304                    match val {
305                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.xl = Some(v); } }
306                        crate::base::FieldValue::TextList(svs) => {
307                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.xl = Some(v); } }
308                        }
309                        _ => {}
310                    }
311                }
312                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
313                    if let crate::base::FieldValue::Resource(sv) = val {
314                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
315                    }
316                }
317                "DynamicsFunctionBlock.enabled" => {
318                    match val {
319                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
320                        crate::base::FieldValue::TextList(svs) => {
321                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
322                        }
323                        _ => {}
324                    }
325                }
326                "IdentifiedObject.description" => {
327                    match val {
328                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
329                        crate::base::FieldValue::TextList(svs) => {
330                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
331                        }
332                        _ => {}
333                    }
334                }
335                "IdentifiedObject.energyIdentCodeEic" => {
336                    match val {
337                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
338                        crate::base::FieldValue::TextList(svs) => {
339                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
340                        }
341                        _ => {}
342                    }
343                }
344                "IdentifiedObject.mRID" => {
345                    match val {
346                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
347                        crate::base::FieldValue::TextList(svs) => {
348                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
349                        }
350                        _ => {}
351                    }
352                }
353                "IdentifiedObject.name" => {
354                    match val {
355                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
356                        crate::base::FieldValue::TextList(svs) => {
357                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
358                        }
359                        _ => {}
360                    }
361                }
362                "IdentifiedObject.shortName" => {
363                    match val {
364                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
365                        crate::base::FieldValue::TextList(svs) => {
366                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
367                        }
368                        _ => {}
369                    }
370                }
371                _ => {}
372            }
373        }
374        obj
375    }
376}