Skip to main content

cimstructs/
ExcANS.rs

1/// Italian excitation system. It represents static field voltage or excitation current feedback excitation system.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcANS {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Governor control flag (BLINT). 0 = lead-lag regulator 1 = proportional integral regulator. Typical value = 0.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub blint: Option<i64>,
9    /// Minimum exciter current (IFMN). Typical value = -5,2.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub ifmn: Option<f64>,
12    /// Maximum exciter current (IFMX). Typical value = 6,5.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub ifmx: Option<f64>,
15    /// Exciter gain (K2). Typical value = 20.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub k2: Option<f64>,
18    /// AVR gain (K3). Typical value = 1000.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub k3: Option<f64>,
21    /// Ceiling factor (KCE). Typical value = 1.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub kce: Option<f64>,
24    /// Feedback enabling (KRVECC). 0 = open loop control 1 = closed loop control. Typical value = 1.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub krvecc: Option<i64>,
27    /// Rate feedback signal flag (KVFIF). 0 = output voltage of the exciter 1 = exciter field current. Typical value = 0.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub kvfif: Option<i64>,
30    /// Time constant (T1) (>= 0). Typical value = 20.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub t1: Option<f64>,
33    /// Time constant (T2) (>= 0). Typical value = 0,05.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub t2: Option<f64>,
36    /// Time constant (T3) (>= 0). Typical value = 1,6.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub t3: Option<f64>,
39    /// Exciter time constant (TB) (>= 0). Typical value = 0,04.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub tb: Option<f64>,
42    /// Minimum AVR output (VRMN). Typical value = -5,2.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vrmn: Option<f64>,
45    /// Maximum AVR output (VRMX). Typical value = 6,5.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub vrmx: Option<f64>,
48}
49impl crate::base::CimElement for ExcANS {
50    fn mrid(&self) -> &str { &self.base.base.base.id }
51    fn type_name(&self) -> &'static str { "ExcANS" }
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 = "ExcANS".to_string();
59        if let Some(v) = self.blint {
60            block.fields.insert("ExcANS.blint".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.ifmn {
63            block.fields.insert("ExcANS.ifmn".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.ifmx {
66            block.fields.insert("ExcANS.ifmx".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.k2 {
69            block.fields.insert("ExcANS.k2".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.k3 {
72            block.fields.insert("ExcANS.k3".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.kce {
75            block.fields.insert("ExcANS.kce".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.krvecc {
78            block.fields.insert("ExcANS.krvecc".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.kvfif {
81            block.fields.insert("ExcANS.kvfif".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.t1 {
84            block.fields.insert("ExcANS.t1".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.t2 {
87            block.fields.insert("ExcANS.t2".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.t3 {
90            block.fields.insert("ExcANS.t3".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.tb {
93            block.fields.insert("ExcANS.tb".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.vrmn {
96            block.fields.insert("ExcANS.vrmn".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.vrmx {
99            block.fields.insert("ExcANS.vrmx".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        block
102    }
103}
104
105impl ExcANS {
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                "ExcANS.blint" => {
112                    match val {
113                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.blint = Some(v); } }
114                        crate::base::FieldValue::TextList(svs) => {
115                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.blint = Some(v); } }
116                        }
117                        _ => {}
118                    }
119                }
120                "ExcANS.ifmn" => {
121                    match val {
122                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ifmn = Some(v); } }
123                        crate::base::FieldValue::TextList(svs) => {
124                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ifmn = Some(v); } }
125                        }
126                        _ => {}
127                    }
128                }
129                "ExcANS.ifmx" => {
130                    match val {
131                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ifmx = Some(v); } }
132                        crate::base::FieldValue::TextList(svs) => {
133                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ifmx = Some(v); } }
134                        }
135                        _ => {}
136                    }
137                }
138                "ExcANS.k2" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.k2 = Some(v); } }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.k2 = Some(v); } }
143                        }
144                        _ => {}
145                    }
146                }
147                "ExcANS.k3" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.k3 = Some(v); } }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.k3 = Some(v); } }
152                        }
153                        _ => {}
154                    }
155                }
156                "ExcANS.kce" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kce = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kce = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "ExcANS.krvecc" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.krvecc = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.krvecc = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "ExcANS.kvfif" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kvfif = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kvfif = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "ExcANS.t1" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "ExcANS.t2" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t2 = Some(v); } }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t2 = Some(v); } }
197                        }
198                        _ => {}
199                    }
200                }
201                "ExcANS.t3" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t3 = Some(v); } }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t3 = Some(v); } }
206                        }
207                        _ => {}
208                    }
209                }
210                "ExcANS.tb" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
215                        }
216                        _ => {}
217                    }
218                }
219                "ExcANS.vrmn" => {
220                    match val {
221                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmn = Some(v); } }
222                        crate::base::FieldValue::TextList(svs) => {
223                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmn = Some(v); } }
224                        }
225                        _ => {}
226                    }
227                }
228                "ExcANS.vrmx" => {
229                    match val {
230                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmx = Some(v); } }
231                        crate::base::FieldValue::TextList(svs) => {
232                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmx = 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}