Skip to main content

cimstructs/
ExcCZ.rs

1/// Czech proportion/integral exciter.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcCZ {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Exciter output maximum limit (Efdmax) (> ExcCZ.efdmin).
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub efdmax: Option<f64>,
9    /// Exciter output minimum limit (Efdmin) (< ExcCZ.efdmax).
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub efdmin: Option<f64>,
12    /// Regulator gain (Ka).
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub ka: Option<f64>,
15    /// Exciter constant related to self-excited field (Ke).
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub ke: Option<f64>,
18    /// Regulator proportional gain (Kp).
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub kp: Option<f64>,
21    /// Regulator time constant (Ta) (>= 0).
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub ta: Option<f64>,
24    /// Regulator integral time constant (Tc) (>= 0).
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub tc: Option<f64>,
27    /// Exciter time constant, integration rate associated with exciter control (Te) (>= 0).
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub te: Option<f64>,
30    /// Voltage regulator maximum limit (Vrmax) (> ExcCZ.vrmin).
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub vrmax: Option<f64>,
33    /// Voltage regulator minimum limit (Vrmin) (< ExcCZ.vrmax).
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub vrmin: Option<f64>,
36}
37impl crate::base::CimElement for ExcCZ {
38    fn mrid(&self) -> &str { &self.base.base.base.id }
39    fn type_name(&self) -> &'static str { "ExcCZ" }
40    fn as_any(&self) -> &dyn std::any::Any { self }
41    fn to_json_value(&self) -> serde_json::Value {
42        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
43    }
44    fn to_block(&self) -> crate::base::RdfBlock {
45        let mut block = self.base.to_block();
46        block.type_name = "ExcCZ".to_string();
47        if let Some(v) = self.efdmax {
48            block.fields.insert("ExcCZ.efdmax".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.efdmin {
51            block.fields.insert("ExcCZ.efdmin".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.ka {
54            block.fields.insert("ExcCZ.ka".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.ke {
57            block.fields.insert("ExcCZ.ke".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        if let Some(v) = self.kp {
60            block.fields.insert("ExcCZ.kp".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.ta {
63            block.fields.insert("ExcCZ.ta".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.tc {
66            block.fields.insert("ExcCZ.tc".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.te {
69            block.fields.insert("ExcCZ.te".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.vrmax {
72            block.fields.insert("ExcCZ.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.vrmin {
75            block.fields.insert("ExcCZ.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        block
78    }
79}
80
81impl ExcCZ {
82    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
83        let mut obj = Self::default();
84        obj.base.base.base.id.clone_from(&b.mrid);
85        for (key, val) in &b.fields {
86            match key.as_str() {
87                "ExcCZ.efdmax" => {
88                    match val {
89                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
90                        crate::base::FieldValue::TextList(svs) => {
91                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
92                        }
93                        _ => {}
94                    }
95                }
96                "ExcCZ.efdmin" => {
97                    match val {
98                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmin = Some(v); } }
99                        crate::base::FieldValue::TextList(svs) => {
100                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmin = Some(v); } }
101                        }
102                        _ => {}
103                    }
104                }
105                "ExcCZ.ka" => {
106                    match val {
107                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
108                        crate::base::FieldValue::TextList(svs) => {
109                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
110                        }
111                        _ => {}
112                    }
113                }
114                "ExcCZ.ke" => {
115                    match val {
116                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
117                        crate::base::FieldValue::TextList(svs) => {
118                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ke = Some(v); } }
119                        }
120                        _ => {}
121                    }
122                }
123                "ExcCZ.kp" => {
124                    match val {
125                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
126                        crate::base::FieldValue::TextList(svs) => {
127                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
128                        }
129                        _ => {}
130                    }
131                }
132                "ExcCZ.ta" => {
133                    match val {
134                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
135                        crate::base::FieldValue::TextList(svs) => {
136                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
137                        }
138                        _ => {}
139                    }
140                }
141                "ExcCZ.tc" => {
142                    match val {
143                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
144                        crate::base::FieldValue::TextList(svs) => {
145                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tc = Some(v); } }
146                        }
147                        _ => {}
148                    }
149                }
150                "ExcCZ.te" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.te = Some(v); } }
155                        }
156                        _ => {}
157                    }
158                }
159                "ExcCZ.vrmax" => {
160                    match val {
161                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
162                        crate::base::FieldValue::TextList(svs) => {
163                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
164                        }
165                        _ => {}
166                    }
167                }
168                "ExcCZ.vrmin" => {
169                    match val {
170                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
171                        crate::base::FieldValue::TextList(svs) => {
172                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
173                        }
174                        _ => {}
175                    }
176                }
177                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
178                    if let crate::base::FieldValue::Resource(sv) = val {
179                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
180                    }
181                }
182                "DynamicsFunctionBlock.enabled" => {
183                    match val {
184                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
185                        crate::base::FieldValue::TextList(svs) => {
186                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
187                        }
188                        _ => {}
189                    }
190                }
191                "IdentifiedObject.description" => {
192                    match val {
193                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
194                        crate::base::FieldValue::TextList(svs) => {
195                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
196                        }
197                        _ => {}
198                    }
199                }
200                "IdentifiedObject.energyIdentCodeEic" => {
201                    match val {
202                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
203                        crate::base::FieldValue::TextList(svs) => {
204                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
205                        }
206                        _ => {}
207                    }
208                }
209                "IdentifiedObject.mRID" => {
210                    match val {
211                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
212                        crate::base::FieldValue::TextList(svs) => {
213                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
214                        }
215                        _ => {}
216                    }
217                }
218                "IdentifiedObject.name" => {
219                    match val {
220                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
221                        crate::base::FieldValue::TextList(svs) => {
222                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
223                        }
224                        _ => {}
225                    }
226                }
227                "IdentifiedObject.shortName" => {
228                    match val {
229                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
230                        crate::base::FieldValue::TextList(svs) => {
231                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
232                        }
233                        _ => {}
234                    }
235                }
236                _ => {}
237            }
238        }
239        obj
240    }
241}