Skip to main content

cimstructs/
UnderexcLimIEEE1.rs

1/// Type UEL1 model which has a circular limit boundary when plotted in terms of machine reactive power vs. real power output. Reference: IEEE UEL1 421.5-2005, 10.1.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct UnderexcLimIEEE1 {
4    #[serde(flatten)]
5    pub base: super::UnderexcitationLimiterDynamics,
6    /// UEL centre setting (KUC). Typical value = 1,38.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub kuc: Option<f64>,
9    /// UEL excitation system stabilizer gain (KUF). Typical value = 3,3.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub kuf: Option<f64>,
12    /// UEL integral gain (KUI). Typical value = 0.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub kui: Option<f64>,
15    /// UEL proportional gain (KUL). Typical value = 100.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub kul: Option<f64>,
18    /// UEL radius setting (KUR). Typical value = 1,95.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kur: Option<f64>,
21    /// UEL lead time constant (TU1) (>= 0). Typical value = 0.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub tu1: Option<f64>,
24    /// UEL lag time constant (TU2) (>= 0). Typical value = 0,05.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub tu2: Option<f64>,
27    /// UEL lead time constant (TU3) (>= 0). Typical value = 0.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub tu3: Option<f64>,
30    /// UEL lag time constant (TU4) (>= 0). Typical value = 0.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub tu4: Option<f64>,
33    /// UEL maximum limit for operating point phasor magnitude (VUCMAX). Typical value = 5,8.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub vucmax: Option<f64>,
36    /// UEL integrator output maximum limit (VUIMAX) (> UnderexcLimIEEE1.vuimin).
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub vuimax: Option<f64>,
39    /// UEL integrator output minimum limit (VUIMIN) (< UnderexcLimIEEE1.vuimax).
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub vuimin: Option<f64>,
42    /// UEL output maximum limit (VULMAX) (> UnderexcLimIEEE1.vulmin). Typical value = 18.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vulmax: Option<f64>,
45    /// UEL output minimum limit (VULMIN) (< UnderexcLimIEEE1.vulmax). Typical value = -18.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vulmin: Option<f64>,
48    /// UEL maximum limit for radius phasor magnitude (VURMAX). Typical value = 5,8.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub vurmax: Option<f64>,
51}
52impl crate::base::CimElement for UnderexcLimIEEE1 {
53    fn mrid(&self) -> &str { &self.base.base.base.id }
54    fn type_name(&self) -> &'static str { "UnderexcLimIEEE1" }
55    fn as_any(&self) -> &dyn std::any::Any { self }
56    fn to_json_value(&self) -> serde_json::Value {
57        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
58    }
59    fn to_block(&self) -> crate::base::RdfBlock {
60        let mut block = self.base.to_block();
61        block.type_name = "UnderexcLimIEEE1".to_string();
62        if let Some(v) = self.kuc {
63            block.fields.insert("UnderexcLimIEEE1.kuc".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.kuf {
66            block.fields.insert("UnderexcLimIEEE1.kuf".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.kui {
69            block.fields.insert("UnderexcLimIEEE1.kui".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.kul {
72            block.fields.insert("UnderexcLimIEEE1.kul".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.kur {
75            block.fields.insert("UnderexcLimIEEE1.kur".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.tu1 {
78            block.fields.insert("UnderexcLimIEEE1.tu1".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.tu2 {
81            block.fields.insert("UnderexcLimIEEE1.tu2".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.tu3 {
84            block.fields.insert("UnderexcLimIEEE1.tu3".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.tu4 {
87            block.fields.insert("UnderexcLimIEEE1.tu4".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.vucmax {
90            block.fields.insert("UnderexcLimIEEE1.vucmax".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.vuimax {
93            block.fields.insert("UnderexcLimIEEE1.vuimax".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.vuimin {
96            block.fields.insert("UnderexcLimIEEE1.vuimin".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.vulmax {
99            block.fields.insert("UnderexcLimIEEE1.vulmax".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.vulmin {
102            block.fields.insert("UnderexcLimIEEE1.vulmin".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.vurmax {
105            block.fields.insert("UnderexcLimIEEE1.vurmax".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        block
108    }
109}
110
111impl UnderexcLimIEEE1 {
112    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
113        let mut obj = Self::default();
114        obj.base.base.base.id.clone_from(&b.mrid);
115        for (key, val) in &b.fields {
116            match key.as_str() {
117                "UnderexcLimIEEE1.kuc" => {
118                    match val {
119                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kuc = Some(v); } }
120                        crate::base::FieldValue::TextList(svs) => {
121                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kuc = Some(v); } }
122                        }
123                        _ => {}
124                    }
125                }
126                "UnderexcLimIEEE1.kuf" => {
127                    match val {
128                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kuf = Some(v); } }
129                        crate::base::FieldValue::TextList(svs) => {
130                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kuf = Some(v); } }
131                        }
132                        _ => {}
133                    }
134                }
135                "UnderexcLimIEEE1.kui" => {
136                    match val {
137                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kui = Some(v); } }
138                        crate::base::FieldValue::TextList(svs) => {
139                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kui = Some(v); } }
140                        }
141                        _ => {}
142                    }
143                }
144                "UnderexcLimIEEE1.kul" => {
145                    match val {
146                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kul = Some(v); } }
147                        crate::base::FieldValue::TextList(svs) => {
148                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kul = Some(v); } }
149                        }
150                        _ => {}
151                    }
152                }
153                "UnderexcLimIEEE1.kur" => {
154                    match val {
155                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kur = Some(v); } }
156                        crate::base::FieldValue::TextList(svs) => {
157                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kur = Some(v); } }
158                        }
159                        _ => {}
160                    }
161                }
162                "UnderexcLimIEEE1.tu1" => {
163                    match val {
164                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tu1 = Some(v); } }
165                        crate::base::FieldValue::TextList(svs) => {
166                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tu1 = Some(v); } }
167                        }
168                        _ => {}
169                    }
170                }
171                "UnderexcLimIEEE1.tu2" => {
172                    match val {
173                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tu2 = Some(v); } }
174                        crate::base::FieldValue::TextList(svs) => {
175                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tu2 = Some(v); } }
176                        }
177                        _ => {}
178                    }
179                }
180                "UnderexcLimIEEE1.tu3" => {
181                    match val {
182                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tu3 = Some(v); } }
183                        crate::base::FieldValue::TextList(svs) => {
184                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tu3 = Some(v); } }
185                        }
186                        _ => {}
187                    }
188                }
189                "UnderexcLimIEEE1.tu4" => {
190                    match val {
191                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tu4 = Some(v); } }
192                        crate::base::FieldValue::TextList(svs) => {
193                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tu4 = Some(v); } }
194                        }
195                        _ => {}
196                    }
197                }
198                "UnderexcLimIEEE1.vucmax" => {
199                    match val {
200                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vucmax = Some(v); } }
201                        crate::base::FieldValue::TextList(svs) => {
202                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vucmax = Some(v); } }
203                        }
204                        _ => {}
205                    }
206                }
207                "UnderexcLimIEEE1.vuimax" => {
208                    match val {
209                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vuimax = Some(v); } }
210                        crate::base::FieldValue::TextList(svs) => {
211                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vuimax = Some(v); } }
212                        }
213                        _ => {}
214                    }
215                }
216                "UnderexcLimIEEE1.vuimin" => {
217                    match val {
218                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vuimin = Some(v); } }
219                        crate::base::FieldValue::TextList(svs) => {
220                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vuimin = Some(v); } }
221                        }
222                        _ => {}
223                    }
224                }
225                "UnderexcLimIEEE1.vulmax" => {
226                    match val {
227                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vulmax = Some(v); } }
228                        crate::base::FieldValue::TextList(svs) => {
229                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vulmax = Some(v); } }
230                        }
231                        _ => {}
232                    }
233                }
234                "UnderexcLimIEEE1.vulmin" => {
235                    match val {
236                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vulmin = Some(v); } }
237                        crate::base::FieldValue::TextList(svs) => {
238                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vulmin = Some(v); } }
239                        }
240                        _ => {}
241                    }
242                }
243                "UnderexcLimIEEE1.vurmax" => {
244                    match val {
245                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vurmax = Some(v); } }
246                        crate::base::FieldValue::TextList(svs) => {
247                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vurmax = Some(v); } }
248                        }
249                        _ => {}
250                    }
251                }
252                "UnderexcitationLimiterDynamics.ExcitationSystemDynamics" => {
253                    if let crate::base::FieldValue::Resource(sv) = val {
254                        obj.base.excitation_system_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
255                    }
256                }
257                "DynamicsFunctionBlock.enabled" => {
258                    match val {
259                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
260                        crate::base::FieldValue::TextList(svs) => {
261                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
262                        }
263                        _ => {}
264                    }
265                }
266                "IdentifiedObject.description" => {
267                    match val {
268                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
269                        crate::base::FieldValue::TextList(svs) => {
270                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
271                        }
272                        _ => {}
273                    }
274                }
275                "IdentifiedObject.energyIdentCodeEic" => {
276                    match val {
277                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
278                        crate::base::FieldValue::TextList(svs) => {
279                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
280                        }
281                        _ => {}
282                    }
283                }
284                "IdentifiedObject.mRID" => {
285                    match val {
286                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
287                        crate::base::FieldValue::TextList(svs) => {
288                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
289                        }
290                        _ => {}
291                    }
292                }
293                "IdentifiedObject.name" => {
294                    match val {
295                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
296                        crate::base::FieldValue::TextList(svs) => {
297                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
298                        }
299                        _ => {}
300                    }
301                }
302                "IdentifiedObject.shortName" => {
303                    match val {
304                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
305                        crate::base::FieldValue::TextList(svs) => {
306                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
307                        }
308                        _ => {}
309                    }
310                }
311                _ => {}
312            }
313        }
314        obj
315    }
316}