Skip to main content

cimstructs/
ExcIEEEST5B.rs

1/// IEEE 421.5-2005 type ST5B model. The type ST5B excitation system is a variation of the type ST1A model, with alternative overexcitation and underexcitation inputs and additional limits. The block diagram in the IEEE 421.5 standard has input signal Vc and does not indicate the summation point with Vref. The implementation of the ExcIEEEST5B shall consider summation point with Vref. Reference: IEEE 421.5-2005, 7.5.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcIEEEST5B {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Rectifier regulation factor (KC) (>= 0). Typical value = 0,004.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub kc: Option<f64>,
9    /// Regulator gain (KR) (> 0). Typical value = 200.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub kr: Option<f64>,
12    /// Firing circuit time constant (T1) (>= 0). Typical value = 0,004.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub t1: Option<f64>,
15    /// Regulator lag time constant (TB1) (>= 0). Typical value = 6.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub tb1: Option<f64>,
18    /// Regulator lag time constant (TB2) (>= 0). Typical value = 0,01.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub tb2: Option<f64>,
21    /// Regulator lead time constant (TC1) (>= 0). Typical value = 0,8.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub tc1: Option<f64>,
24    /// Regulator lead time constant (TC2) (>= 0). Typical value = 0,08.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub tc2: Option<f64>,
27    /// OEL lag time constant (TOB1) (>= 0). Typical value = 2.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub tob1: Option<f64>,
30    /// OEL lag time constant (TOB2) (>= 0). Typical value = 0,08.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub tob2: Option<f64>,
33    /// OEL lead time constant (TOC1) (>= 0). Typical value = 0,1.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub toc1: Option<f64>,
36    /// OEL lead time constant (TOC2) (>= 0). Typical value = 0,08.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub toc2: Option<f64>,
39    /// UEL lag time constant (TUB1) (>= 0). Typical value = 10.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub tub1: Option<f64>,
42    /// UEL lag time constant (TUB2) (>= 0). Typical value = 0,05.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub tub2: Option<f64>,
45    /// UEL lead time constant (TUC1) (>= 0). Typical value = 2.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub tuc1: Option<f64>,
48    /// UEL lead time constant (TUC2) (>= 0). Typical value = 0,1.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub tuc2: Option<f64>,
51    /// Maximum voltage regulator output (VRMAX) (> 0). Typical value = 5.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub vrmax: Option<f64>,
54    /// Minimum voltage regulator output (VRMIN) (< 0). Typical value = -4.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub vrmin: Option<f64>,
57}
58impl crate::base::CimElement for ExcIEEEST5B {
59    fn mrid(&self) -> &str { &self.base.base.base.id }
60    fn type_name(&self) -> &'static str { "ExcIEEEST5B" }
61    fn as_any(&self) -> &dyn std::any::Any { self }
62    fn to_json_value(&self) -> serde_json::Value {
63        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
64    }
65    fn to_block(&self) -> crate::base::RdfBlock {
66        let mut block = self.base.to_block();
67        block.type_name = "ExcIEEEST5B".to_string();
68        if let Some(v) = self.kc {
69            block.fields.insert("ExcIEEEST5B.kc".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.kr {
72            block.fields.insert("ExcIEEEST5B.kr".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.t1 {
75            block.fields.insert("ExcIEEEST5B.t1".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.tb1 {
78            block.fields.insert("ExcIEEEST5B.tb1".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.tb2 {
81            block.fields.insert("ExcIEEEST5B.tb2".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.tc1 {
84            block.fields.insert("ExcIEEEST5B.tc1".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.tc2 {
87            block.fields.insert("ExcIEEEST5B.tc2".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.tob1 {
90            block.fields.insert("ExcIEEEST5B.tob1".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.tob2 {
93            block.fields.insert("ExcIEEEST5B.tob2".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.toc1 {
96            block.fields.insert("ExcIEEEST5B.toc1".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.toc2 {
99            block.fields.insert("ExcIEEEST5B.toc2".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.tub1 {
102            block.fields.insert("ExcIEEEST5B.tub1".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.tub2 {
105            block.fields.insert("ExcIEEEST5B.tub2".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.tuc1 {
108            block.fields.insert("ExcIEEEST5B.tuc1".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.tuc2 {
111            block.fields.insert("ExcIEEEST5B.tuc2".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        if let Some(v) = self.vrmax {
114            block.fields.insert("ExcIEEEST5B.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
115        }
116        if let Some(v) = self.vrmin {
117            block.fields.insert("ExcIEEEST5B.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
118        }
119        block
120    }
121}
122
123impl ExcIEEEST5B {
124    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
125        let mut obj = Self::default();
126        obj.base.base.base.id.clone_from(&b.mrid);
127        for (key, val) in &b.fields {
128            match key.as_str() {
129                "ExcIEEEST5B.kc" => {
130                    match val {
131                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
132                        crate::base::FieldValue::TextList(svs) => {
133                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kc = Some(v); } }
134                        }
135                        _ => {}
136                    }
137                }
138                "ExcIEEEST5B.kr" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kr = Some(v); } }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kr = Some(v); } }
143                        }
144                        _ => {}
145                    }
146                }
147                "ExcIEEEST5B.t1" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
152                        }
153                        _ => {}
154                    }
155                }
156                "ExcIEEEST5B.tb1" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tb1 = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tb1 = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "ExcIEEEST5B.tb2" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tb2 = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tb2 = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "ExcIEEEST5B.tc1" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tc1 = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tc1 = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "ExcIEEEST5B.tc2" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tc2 = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tc2 = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "ExcIEEEST5B.tob1" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tob1 = Some(v); } }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tob1 = Some(v); } }
197                        }
198                        _ => {}
199                    }
200                }
201                "ExcIEEEST5B.tob2" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tob2 = Some(v); } }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tob2 = Some(v); } }
206                        }
207                        _ => {}
208                    }
209                }
210                "ExcIEEEST5B.toc1" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.toc1 = Some(v); } }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.toc1 = Some(v); } }
215                        }
216                        _ => {}
217                    }
218                }
219                "ExcIEEEST5B.toc2" => {
220                    match val {
221                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.toc2 = Some(v); } }
222                        crate::base::FieldValue::TextList(svs) => {
223                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.toc2 = Some(v); } }
224                        }
225                        _ => {}
226                    }
227                }
228                "ExcIEEEST5B.tub1" => {
229                    match val {
230                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tub1 = Some(v); } }
231                        crate::base::FieldValue::TextList(svs) => {
232                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tub1 = Some(v); } }
233                        }
234                        _ => {}
235                    }
236                }
237                "ExcIEEEST5B.tub2" => {
238                    match val {
239                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tub2 = Some(v); } }
240                        crate::base::FieldValue::TextList(svs) => {
241                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tub2 = Some(v); } }
242                        }
243                        _ => {}
244                    }
245                }
246                "ExcIEEEST5B.tuc1" => {
247                    match val {
248                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tuc1 = Some(v); } }
249                        crate::base::FieldValue::TextList(svs) => {
250                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tuc1 = Some(v); } }
251                        }
252                        _ => {}
253                    }
254                }
255                "ExcIEEEST5B.tuc2" => {
256                    match val {
257                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tuc2 = Some(v); } }
258                        crate::base::FieldValue::TextList(svs) => {
259                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tuc2 = Some(v); } }
260                        }
261                        _ => {}
262                    }
263                }
264                "ExcIEEEST5B.vrmax" => {
265                    match val {
266                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
267                        crate::base::FieldValue::TextList(svs) => {
268                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
269                        }
270                        _ => {}
271                    }
272                }
273                "ExcIEEEST5B.vrmin" => {
274                    match val {
275                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
276                        crate::base::FieldValue::TextList(svs) => {
277                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
278                        }
279                        _ => {}
280                    }
281                }
282                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
283                    if let crate::base::FieldValue::Resource(sv) = val {
284                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
285                    }
286                }
287                "DynamicsFunctionBlock.enabled" => {
288                    match val {
289                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
290                        crate::base::FieldValue::TextList(svs) => {
291                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
292                        }
293                        _ => {}
294                    }
295                }
296                "IdentifiedObject.description" => {
297                    match val {
298                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
299                        crate::base::FieldValue::TextList(svs) => {
300                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
301                        }
302                        _ => {}
303                    }
304                }
305                "IdentifiedObject.energyIdentCodeEic" => {
306                    match val {
307                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
308                        crate::base::FieldValue::TextList(svs) => {
309                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
310                        }
311                        _ => {}
312                    }
313                }
314                "IdentifiedObject.mRID" => {
315                    match val {
316                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
317                        crate::base::FieldValue::TextList(svs) => {
318                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
319                        }
320                        _ => {}
321                    }
322                }
323                "IdentifiedObject.name" => {
324                    match val {
325                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
326                        crate::base::FieldValue::TextList(svs) => {
327                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
328                        }
329                        _ => {}
330                    }
331                }
332                "IdentifiedObject.shortName" => {
333                    match val {
334                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
335                        crate::base::FieldValue::TextList(svs) => {
336                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
337                        }
338                        _ => {}
339                    }
340                }
341                _ => {}
342            }
343        }
344        obj
345    }
346}