Skip to main content

cimstructs/
ExcIEEEST6B.rs

1/// IEEE 421.5-2005 type ST6B model. This model consists of a PI voltage regulator with an inner loop field voltage regulator and pre-control. The field voltage regulator implements a proportional control. The pre-control and the delay in the feedback circuit increase the dynamic response. Reference: IEEE 421.5-2005, 7.6.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcIEEEST6B {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Exciter output current limit reference (ILR) (> 0). Typical value = 4,164.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub ilr: Option<f64>,
9    /// Exciter output current limit adjustment (KCI) (> 0). Typical value = 1,0577.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub kci: Option<f64>,
12    /// Pre-control gain constant of the inner loop field regulator (KFF). Typical value = 1.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub kff: Option<f64>,
15    /// Feedback gain constant of the inner loop field regulator (KG) (>= 0). Typical value = 1.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub kg: Option<f64>,
18    /// Voltage regulator integral gain (KIA) (> 0). Typical value = 45,094.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kia: Option<f64>,
21    /// Exciter output current limiter gain (KLR) (> 0). Typical value = 17,33.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub klr: Option<f64>,
24    /// Forward gain constant of the inner loop field regulator (KM). Typical value = 1.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub km: Option<f64>,
27    /// Voltage regulator proportional gain (KPA) (> 0). Typical value = 18,038.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub kpa: Option<f64>,
30    /// OEL input selector (OELin). Typical value = noOELinput.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub oelin: Option<super::base::UriRef>,
33    /// Feedback time constant of inner loop field voltage regulator (TG) (>= 0). Typical value = 0,02.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub tg: Option<f64>,
36    /// Maximum voltage regulator output (VAMAX) (> 0). Typical value = 4,81.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub vamax: Option<f64>,
39    /// Minimum voltage regulator output (VAMIN) (< 0). Typical value = -3,85.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub vamin: Option<f64>,
42    /// Maximum voltage regulator output (VRMAX) (> 0). Typical value = 4,81.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vrmax: Option<f64>,
45    /// Minimum voltage regulator output (VRMIN) (< 0). Typical value = -3,85.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vrmin: Option<f64>,
48}
49impl crate::base::CimElement for ExcIEEEST6B {
50    fn mrid(&self) -> &str { &self.base.base.base.id }
51    fn type_name(&self) -> &'static str { "ExcIEEEST6B" }
52    fn as_any(&self) -> &dyn std::any::Any { self }
53    fn to_json_value(&self) -> serde_json::Value {
54        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
55    }
56    fn to_block(&self) -> crate::base::RdfBlock {
57        let mut block = self.base.to_block();
58        block.type_name = "ExcIEEEST6B".to_string();
59        if let Some(v) = self.ilr {
60            block.fields.insert("ExcIEEEST6B.ilr".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.kci {
63            block.fields.insert("ExcIEEEST6B.kci".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.kff {
66            block.fields.insert("ExcIEEEST6B.kff".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.kg {
69            block.fields.insert("ExcIEEEST6B.kg".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.kia {
72            block.fields.insert("ExcIEEEST6B.kia".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.klr {
75            block.fields.insert("ExcIEEEST6B.klr".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.km {
78            block.fields.insert("ExcIEEEST6B.km".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.kpa {
81            block.fields.insert("ExcIEEEST6B.kpa".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(ref v) = self.oelin {
84            block.fields.insert("ExcIEEEST6B.oelin".into(), crate::base::FieldValue::Resource(v.uri.clone()));
85        }
86        if let Some(v) = self.tg {
87            block.fields.insert("ExcIEEEST6B.tg".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.vamax {
90            block.fields.insert("ExcIEEEST6B.vamax".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.vamin {
93            block.fields.insert("ExcIEEEST6B.vamin".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.vrmax {
96            block.fields.insert("ExcIEEEST6B.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.vrmin {
99            block.fields.insert("ExcIEEEST6B.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        block
102    }
103}
104
105impl ExcIEEEST6B {
106    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
107        let mut obj = Self::default();
108        obj.base.base.base.id.clone_from(&b.mrid);
109        for (key, val) in &b.fields {
110            match key.as_str() {
111                "ExcIEEEST6B.ilr" => {
112                    match val {
113                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ilr = Some(v); } }
114                        crate::base::FieldValue::TextList(svs) => {
115                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ilr = Some(v); } }
116                        }
117                        _ => {}
118                    }
119                }
120                "ExcIEEEST6B.kci" => {
121                    match val {
122                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kci = Some(v); } }
123                        crate::base::FieldValue::TextList(svs) => {
124                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kci = Some(v); } }
125                        }
126                        _ => {}
127                    }
128                }
129                "ExcIEEEST6B.kff" => {
130                    match val {
131                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kff = Some(v); } }
132                        crate::base::FieldValue::TextList(svs) => {
133                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kff = Some(v); } }
134                        }
135                        _ => {}
136                    }
137                }
138                "ExcIEEEST6B.kg" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kg = Some(v); } }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kg = Some(v); } }
143                        }
144                        _ => {}
145                    }
146                }
147                "ExcIEEEST6B.kia" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kia = Some(v); } }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kia = Some(v); } }
152                        }
153                        _ => {}
154                    }
155                }
156                "ExcIEEEST6B.klr" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.klr = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.klr = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "ExcIEEEST6B.km" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.km = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.km = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "ExcIEEEST6B.kpa" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kpa = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kpa = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "ExcIEEEST6B.oelin" => {
184                    if let crate::base::FieldValue::Resource(sv) = val {
185                        obj.oelin = Some(crate::base::UriRef { uri: sv.clone() });
186                    }
187                }
188                "ExcIEEEST6B.tg" => {
189                    match val {
190                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tg = Some(v); } }
191                        crate::base::FieldValue::TextList(svs) => {
192                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tg = Some(v); } }
193                        }
194                        _ => {}
195                    }
196                }
197                "ExcIEEEST6B.vamax" => {
198                    match val {
199                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vamax = Some(v); } }
200                        crate::base::FieldValue::TextList(svs) => {
201                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vamax = Some(v); } }
202                        }
203                        _ => {}
204                    }
205                }
206                "ExcIEEEST6B.vamin" => {
207                    match val {
208                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vamin = Some(v); } }
209                        crate::base::FieldValue::TextList(svs) => {
210                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vamin = Some(v); } }
211                        }
212                        _ => {}
213                    }
214                }
215                "ExcIEEEST6B.vrmax" => {
216                    match val {
217                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
218                        crate::base::FieldValue::TextList(svs) => {
219                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
220                        }
221                        _ => {}
222                    }
223                }
224                "ExcIEEEST6B.vrmin" => {
225                    match val {
226                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
227                        crate::base::FieldValue::TextList(svs) => {
228                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
229                        }
230                        _ => {}
231                    }
232                }
233                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
234                    if let crate::base::FieldValue::Resource(sv) = val {
235                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
236                    }
237                }
238                "DynamicsFunctionBlock.enabled" => {
239                    match val {
240                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
241                        crate::base::FieldValue::TextList(svs) => {
242                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
243                        }
244                        _ => {}
245                    }
246                }
247                "IdentifiedObject.description" => {
248                    match val {
249                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
250                        crate::base::FieldValue::TextList(svs) => {
251                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
252                        }
253                        _ => {}
254                    }
255                }
256                "IdentifiedObject.energyIdentCodeEic" => {
257                    match val {
258                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
259                        crate::base::FieldValue::TextList(svs) => {
260                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
261                        }
262                        _ => {}
263                    }
264                }
265                "IdentifiedObject.mRID" => {
266                    match val {
267                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
268                        crate::base::FieldValue::TextList(svs) => {
269                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
270                        }
271                        _ => {}
272                    }
273                }
274                "IdentifiedObject.name" => {
275                    match val {
276                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
277                        crate::base::FieldValue::TextList(svs) => {
278                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
279                        }
280                        _ => {}
281                    }
282                }
283                "IdentifiedObject.shortName" => {
284                    match val {
285                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
286                        crate::base::FieldValue::TextList(svs) => {
287                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
288                        }
289                        _ => {}
290                    }
291                }
292                _ => {}
293            }
294        }
295        obj
296    }
297}