Skip to main content

cimstructs/
ExcDC3A1.rs

1/// Modified old IEEE type 3 excitation system.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcDC3A1 {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// (exclim). true = lower limit of zero is applied to integrator output false = lower limit of zero not applied to integrator output. Typical value = true.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub exclim: Option<bool>,
9    /// Voltage regulator gain (Ka) (> 0). Typical value = 300.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub ka: Option<f64>,
12    /// Exciter constant related to self-excited field (Ke). Typical value = 1.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub ke: Option<f64>,
15    /// Excitation control system stabilizer gain (Kf) (>= 0). Typical value = 0,1.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub kf: Option<f64>,
18    /// Potential circuit gain coefficient (Ki) (>= 0). Typical value = 4,83.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub ki: Option<f64>,
21    /// Potential circuit gain coefficient (Kp) (>= 0). Typical value = 4,37.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub kp: Option<f64>,
24    /// Voltage regulator time constant (Ta) (> 0). Typical value = 0,01.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub ta: Option<f64>,
27    /// Exciter time constant, integration rate associated with exciter control (Te) (> 0). Typical value = 1,83.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub te: Option<f64>,
30    /// Excitation control system stabilizer time constant (Tf) (>= 0). Typical value = 0,675.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub tf: Option<f64>,
33    /// Available exciter voltage limiter (Vb1max) (> 0). Typical value = 11,63.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub vb1max: Option<f64>,
36    /// Vb limiter indicator. true = exciter Vbmax limiter is active false = Vb1max is active. Typical value = true.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub vblim: Option<bool>,
39    /// Available exciter voltage limiter (Vbmax) (> 0). Typical value = 11,63.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub vbmax: Option<f64>,
42    /// Maximum voltage regulator output (Vrmax) (> ExcDC3A1.vrmin). Typical value = 5.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vrmax: Option<f64>,
45    /// Minimum voltage regulator output (Vrmin) (< 0 and < ExcDC3A1.vrmax). Typical value = 0.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vrmin: Option<f64>,
48}
49impl crate::base::CimElement for ExcDC3A1 {
50    fn mrid(&self) -> &str { &self.base.base.base.id }
51    fn type_name(&self) -> &'static str { "ExcDC3A1" }
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 = "ExcDC3A1".to_string();
59        if let Some(v) = self.exclim {
60            block.fields.insert("ExcDC3A1.exclim".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.ka {
63            block.fields.insert("ExcDC3A1.ka".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.ke {
66            block.fields.insert("ExcDC3A1.ke".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.kf {
69            block.fields.insert("ExcDC3A1.kf".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.ki {
72            block.fields.insert("ExcDC3A1.ki".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.kp {
75            block.fields.insert("ExcDC3A1.kp".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.ta {
78            block.fields.insert("ExcDC3A1.ta".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.te {
81            block.fields.insert("ExcDC3A1.te".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.tf {
84            block.fields.insert("ExcDC3A1.tf".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.vb1max {
87            block.fields.insert("ExcDC3A1.vb1max".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.vblim {
90            block.fields.insert("ExcDC3A1.vblim".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.vbmax {
93            block.fields.insert("ExcDC3A1.vbmax".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.vrmax {
96            block.fields.insert("ExcDC3A1.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.vrmin {
99            block.fields.insert("ExcDC3A1.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        block
102    }
103}
104
105impl ExcDC3A1 {
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                "ExcDC3A1.exclim" => {
112                    match val {
113                        crate::base::FieldValue::Text(sv) => { obj.exclim = Some(sv.trim() == "true"); }
114                        crate::base::FieldValue::TextList(svs) => {
115                            if let Some(sv) = svs.last() { obj.exclim = Some(sv.trim() == "true"); }
116                        }
117                        _ => {}
118                    }
119                }
120                "ExcDC3A1.ka" => {
121                    match val {
122                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
123                        crate::base::FieldValue::TextList(svs) => {
124                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
125                        }
126                        _ => {}
127                    }
128                }
129                "ExcDC3A1.ke" => {
130                    match val {
131                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
132                        crate::base::FieldValue::TextList(svs) => {
133                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
134                        }
135                        _ => {}
136                    }
137                }
138                "ExcDC3A1.kf" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
143                        }
144                        _ => {}
145                    }
146                }
147                "ExcDC3A1.ki" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
152                        }
153                        _ => {}
154                    }
155                }
156                "ExcDC3A1.kp" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "ExcDC3A1.ta" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "ExcDC3A1.te" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "ExcDC3A1.tf" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "ExcDC3A1.vb1max" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vb1max = Some(v); } }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vb1max = Some(v); } }
197                        }
198                        _ => {}
199                    }
200                }
201                "ExcDC3A1.vblim" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { obj.vblim = Some(sv.trim() == "true"); }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { obj.vblim = Some(sv.trim() == "true"); }
206                        }
207                        _ => {}
208                    }
209                }
210                "ExcDC3A1.vbmax" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vbmax = Some(v); } }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vbmax = Some(v); } }
215                        }
216                        _ => {}
217                    }
218                }
219                "ExcDC3A1.vrmax" => {
220                    match val {
221                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
222                        crate::base::FieldValue::TextList(svs) => {
223                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
224                        }
225                        _ => {}
226                    }
227                }
228                "ExcDC3A1.vrmin" => {
229                    match val {
230                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
231                        crate::base::FieldValue::TextList(svs) => {
232                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
233                        }
234                        _ => {}
235                    }
236                }
237                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
238                    if let crate::base::FieldValue::Resource(sv) = val {
239                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
240                    }
241                }
242                "DynamicsFunctionBlock.enabled" => {
243                    match val {
244                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
245                        crate::base::FieldValue::TextList(svs) => {
246                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
247                        }
248                        _ => {}
249                    }
250                }
251                "IdentifiedObject.description" => {
252                    match val {
253                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
254                        crate::base::FieldValue::TextList(svs) => {
255                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
256                        }
257                        _ => {}
258                    }
259                }
260                "IdentifiedObject.energyIdentCodeEic" => {
261                    match val {
262                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
263                        crate::base::FieldValue::TextList(svs) => {
264                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
265                        }
266                        _ => {}
267                    }
268                }
269                "IdentifiedObject.mRID" => {
270                    match val {
271                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
272                        crate::base::FieldValue::TextList(svs) => {
273                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
274                        }
275                        _ => {}
276                    }
277                }
278                "IdentifiedObject.name" => {
279                    match val {
280                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
281                        crate::base::FieldValue::TextList(svs) => {
282                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
283                        }
284                        _ => {}
285                    }
286                }
287                "IdentifiedObject.shortName" => {
288                    match val {
289                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
290                        crate::base::FieldValue::TextList(svs) => {
291                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
292                        }
293                        _ => {}
294                    }
295                }
296                _ => {}
297            }
298        }
299        obj
300    }
301}