Skip to main content

cimstructs/
ExcDC3A.rs

1/// Modified IEEE DC3A direct current commutator exciter with speed input, and deadband. DC old type 4.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcDC3A {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Exciter voltage at which exciter saturation is defined (Efd1) (> 0). Typical value = 2,6.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub efd1: Option<f64>,
9    /// Exciter voltage at which exciter saturation is defined (Efd2) (> 0). Typical value = 3,45.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub efd2: Option<f64>,
12    /// (Efdlim). true = exciter output limiter is active false = exciter output limiter not active. Typical value = true.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub efdlim: Option<bool>,
15    /// Maximum voltage exciter output limiter (Efdmax) (> ExcDC3A.efdmin). Typical value = 99.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub efdmax: Option<f64>,
18    /// Minimum voltage exciter output limiter (Efdmin) (< ExcDC3A.efdmax). Typical value = -99.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub efdmin: Option<f64>,
21    /// (exclim). IEEE standard is ambiguous about lower limit on exciter output. true = a lower limit of zero is applied to integrator output false = a lower limit of zero not applied to integrator output. Typical value = true.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub exclim: Option<bool>,
24    /// Exciter constant related to self-excited field (Ke). Typical value = 1.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub ke: Option<f64>,
27    /// Deadband (Kr). Typical value = 0.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub kr: Option<f64>,
30    /// Coefficient to allow different usage of the model-speed coefficient (Ks). Typical value = 0.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub ks: Option<f64>,
33    /// Fast raise/lower contact setting (Kv) (> 0). Typical value = 0,05.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub kv: Option<f64>,
36    /// Exciter saturation function value at the corresponding exciter voltage, Efd1 (Se[Efd1]) (>= 0). Typical value = 0,1.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub seefd1: Option<f64>,
39    /// Exciter saturation function value at the corresponding exciter voltage, Efd2 (Se[Efd2]) (>= 0). Typical value = 0,35.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub seefd2: Option<f64>,
42    /// Exciter time constant, integration rate associated with exciter control (Te) (> 0). Typical value = 1,83.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub te: Option<f64>,
45    /// Rheostat travel time (Trh) (> 0). Typical value = 20.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub trh: Option<f64>,
48    /// Maximum voltage regulator output (Vrmax) (> 0). Typical value = 5.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub vrmax: Option<f64>,
51    /// Minimum voltage regulator output (Vrmin) (<= 0). Typical value = 0.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub vrmin: Option<f64>,
54}
55impl crate::base::CimElement for ExcDC3A {
56    fn mrid(&self) -> &str { &self.base.base.base.id }
57    fn type_name(&self) -> &'static str { "ExcDC3A" }
58    fn as_any(&self) -> &dyn std::any::Any { self }
59    fn to_json_value(&self) -> serde_json::Value {
60        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
61    }
62    fn to_block(&self) -> crate::base::RdfBlock {
63        let mut block = self.base.to_block();
64        block.type_name = "ExcDC3A".to_string();
65        if let Some(v) = self.efd1 {
66            block.fields.insert("ExcDC3A.efd1".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.efd2 {
69            block.fields.insert("ExcDC3A.efd2".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.efdlim {
72            block.fields.insert("ExcDC3A.efdlim".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.efdmax {
75            block.fields.insert("ExcDC3A.efdmax".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.efdmin {
78            block.fields.insert("ExcDC3A.efdmin".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.exclim {
81            block.fields.insert("ExcDC3A.exclim".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.ke {
84            block.fields.insert("ExcDC3A.ke".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.kr {
87            block.fields.insert("ExcDC3A.kr".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.ks {
90            block.fields.insert("ExcDC3A.ks".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.kv {
93            block.fields.insert("ExcDC3A.kv".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.seefd1 {
96            block.fields.insert("ExcDC3A.seefd1".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.seefd2 {
99            block.fields.insert("ExcDC3A.seefd2".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.te {
102            block.fields.insert("ExcDC3A.te".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.trh {
105            block.fields.insert("ExcDC3A.trh".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.vrmax {
108            block.fields.insert("ExcDC3A.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.vrmin {
111            block.fields.insert("ExcDC3A.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        block
114    }
115}
116
117impl ExcDC3A {
118    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
119        let mut obj = Self::default();
120        obj.base.base.base.id.clone_from(&b.mrid);
121        for (key, val) in &b.fields {
122            match key.as_str() {
123                "ExcDC3A.efd1" => {
124                    match val {
125                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efd1 = Some(v); } }
126                        crate::base::FieldValue::TextList(svs) => {
127                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efd1 = Some(v); } }
128                        }
129                        _ => {}
130                    }
131                }
132                "ExcDC3A.efd2" => {
133                    match val {
134                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efd2 = Some(v); } }
135                        crate::base::FieldValue::TextList(svs) => {
136                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efd2 = Some(v); } }
137                        }
138                        _ => {}
139                    }
140                }
141                "ExcDC3A.efdlim" => {
142                    match val {
143                        crate::base::FieldValue::Text(sv) => { obj.efdlim = Some(sv.trim() == "true"); }
144                        crate::base::FieldValue::TextList(svs) => {
145                            if let Some(sv) = svs.last() { obj.efdlim = Some(sv.trim() == "true"); }
146                        }
147                        _ => {}
148                    }
149                }
150                "ExcDC3A.efdmax" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
155                        }
156                        _ => {}
157                    }
158                }
159                "ExcDC3A.efdmin" => {
160                    match val {
161                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmin = Some(v); } }
162                        crate::base::FieldValue::TextList(svs) => {
163                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmin = Some(v); } }
164                        }
165                        _ => {}
166                    }
167                }
168                "ExcDC3A.exclim" => {
169                    match val {
170                        crate::base::FieldValue::Text(sv) => { obj.exclim = Some(sv.trim() == "true"); }
171                        crate::base::FieldValue::TextList(svs) => {
172                            if let Some(sv) = svs.last() { obj.exclim = Some(sv.trim() == "true"); }
173                        }
174                        _ => {}
175                    }
176                }
177                "ExcDC3A.ke" => {
178                    match val {
179                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
180                        crate::base::FieldValue::TextList(svs) => {
181                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
182                        }
183                        _ => {}
184                    }
185                }
186                "ExcDC3A.kr" => {
187                    match val {
188                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kr = Some(v); } }
189                        crate::base::FieldValue::TextList(svs) => {
190                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kr = Some(v); } }
191                        }
192                        _ => {}
193                    }
194                }
195                "ExcDC3A.ks" => {
196                    match val {
197                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ks = Some(v); } }
198                        crate::base::FieldValue::TextList(svs) => {
199                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ks = Some(v); } }
200                        }
201                        _ => {}
202                    }
203                }
204                "ExcDC3A.kv" => {
205                    match val {
206                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kv = Some(v); } }
207                        crate::base::FieldValue::TextList(svs) => {
208                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kv = Some(v); } }
209                        }
210                        _ => {}
211                    }
212                }
213                "ExcDC3A.seefd1" => {
214                    match val {
215                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.seefd1 = Some(v); } }
216                        crate::base::FieldValue::TextList(svs) => {
217                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.seefd1 = Some(v); } }
218                        }
219                        _ => {}
220                    }
221                }
222                "ExcDC3A.seefd2" => {
223                    match val {
224                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.seefd2 = Some(v); } }
225                        crate::base::FieldValue::TextList(svs) => {
226                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.seefd2 = Some(v); } }
227                        }
228                        _ => {}
229                    }
230                }
231                "ExcDC3A.te" => {
232                    match val {
233                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
234                        crate::base::FieldValue::TextList(svs) => {
235                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
236                        }
237                        _ => {}
238                    }
239                }
240                "ExcDC3A.trh" => {
241                    match val {
242                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.trh = Some(v); } }
243                        crate::base::FieldValue::TextList(svs) => {
244                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.trh = Some(v); } }
245                        }
246                        _ => {}
247                    }
248                }
249                "ExcDC3A.vrmax" => {
250                    match val {
251                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
252                        crate::base::FieldValue::TextList(svs) => {
253                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
254                        }
255                        _ => {}
256                    }
257                }
258                "ExcDC3A.vrmin" => {
259                    match val {
260                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
261                        crate::base::FieldValue::TextList(svs) => {
262                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
263                        }
264                        _ => {}
265                    }
266                }
267                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
268                    if let crate::base::FieldValue::Resource(sv) = val {
269                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
270                    }
271                }
272                "DynamicsFunctionBlock.enabled" => {
273                    match val {
274                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
275                        crate::base::FieldValue::TextList(svs) => {
276                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
277                        }
278                        _ => {}
279                    }
280                }
281                "IdentifiedObject.description" => {
282                    match val {
283                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
284                        crate::base::FieldValue::TextList(svs) => {
285                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
286                        }
287                        _ => {}
288                    }
289                }
290                "IdentifiedObject.energyIdentCodeEic" => {
291                    match val {
292                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
293                        crate::base::FieldValue::TextList(svs) => {
294                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
295                        }
296                        _ => {}
297                    }
298                }
299                "IdentifiedObject.mRID" => {
300                    match val {
301                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
302                        crate::base::FieldValue::TextList(svs) => {
303                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
304                        }
305                        _ => {}
306                    }
307                }
308                "IdentifiedObject.name" => {
309                    match val {
310                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
311                        crate::base::FieldValue::TextList(svs) => {
312                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
313                        }
314                        _ => {}
315                    }
316                }
317                "IdentifiedObject.shortName" => {
318                    match val {
319                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
320                        crate::base::FieldValue::TextList(svs) => {
321                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
322                        }
323                        _ => {}
324                    }
325                }
326                _ => {}
327            }
328        }
329        obj
330    }
331}