Skip to main content

cimstructs/
ExcNI.rs

1/// Bus or solid fed SCR (silicon-controlled rectifier) bridge excitation system model type NI (NVE).
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcNI {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Fed by selector (BusFedSelector). true = bus fed (switch is closed) false = solid fed (switch is open). Typical value = true.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub bus_fed_selector: Option<bool>,
9    /// Voltage regulator gain (Ka) (> 0). Typical value = 210.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub ka: Option<f64>,
12    /// Excitation control system stabilizer gain (Kf) (> 0). Typical value 0,01.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub kf: Option<f64>,
15    /// rc / rfd (R) (>= 0). 0 means exciter has negative current capability > 0 means exciter does not have negative current capability. Typical value = 5.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub r: Option<f64>,
18    /// Voltage regulator time constant (Ta) (> 0). Typical value = 0,02.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub ta: Option<f64>,
21    /// Excitation control system stabilizer time constant (Tf1) (> 0). Typical value = 1,0.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub tf1: Option<f64>,
24    /// Excitation control system stabilizer time constant (Tf2) (> 0). Typical value = 0,1.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub tf2: Option<f64>,
27    /// Time constant (Tr) (>= 0). Typical value = 0,02.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub tr: Option<f64>,
30    /// Maximum voltage regulator ouput (Vrmax) (> ExcNI.vrmin). Typical value = 5,0.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub vrmax: Option<f64>,
33    /// Minimum voltage regulator ouput (Vrmin) (< ExcNI.vrmax). Typical value = -2,0.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub vrmin: Option<f64>,
36}
37impl crate::base::CimElement for ExcNI {
38    fn mrid(&self) -> &str { &self.base.base.base.id }
39    fn type_name(&self) -> &'static str { "ExcNI" }
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 = "ExcNI".to_string();
47        if let Some(v) = self.bus_fed_selector {
48            block.fields.insert("ExcNI.busFedSelector".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.ka {
51            block.fields.insert("ExcNI.ka".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.kf {
54            block.fields.insert("ExcNI.kf".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.r {
57            block.fields.insert("ExcNI.r".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        if let Some(v) = self.ta {
60            block.fields.insert("ExcNI.ta".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.tf1 {
63            block.fields.insert("ExcNI.tf1".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.tf2 {
66            block.fields.insert("ExcNI.tf2".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.tr {
69            block.fields.insert("ExcNI.tr".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.vrmax {
72            block.fields.insert("ExcNI.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.vrmin {
75            block.fields.insert("ExcNI.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        block
78    }
79}
80
81impl ExcNI {
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                "ExcNI.busFedSelector" => {
88                    match val {
89                        crate::base::FieldValue::Text(sv) => { obj.bus_fed_selector = Some(sv.trim() == "true"); }
90                        crate::base::FieldValue::TextList(svs) => {
91                            if let Some(sv) = svs.last() { obj.bus_fed_selector = Some(sv.trim() == "true"); }
92                        }
93                        _ => {}
94                    }
95                }
96                "ExcNI.ka" => {
97                    match val {
98                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
99                        crate::base::FieldValue::TextList(svs) => {
100                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ka = Some(v); } }
101                        }
102                        _ => {}
103                    }
104                }
105                "ExcNI.kf" => {
106                    match val {
107                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
108                        crate::base::FieldValue::TextList(svs) => {
109                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kf = Some(v); } }
110                        }
111                        _ => {}
112                    }
113                }
114                "ExcNI.r" => {
115                    match val {
116                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
117                        crate::base::FieldValue::TextList(svs) => {
118                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
119                        }
120                        _ => {}
121                    }
122                }
123                "ExcNI.ta" => {
124                    match val {
125                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
126                        crate::base::FieldValue::TextList(svs) => {
127                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
128                        }
129                        _ => {}
130                    }
131                }
132                "ExcNI.tf1" => {
133                    match val {
134                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf1 = Some(v); } }
135                        crate::base::FieldValue::TextList(svs) => {
136                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf1 = Some(v); } }
137                        }
138                        _ => {}
139                    }
140                }
141                "ExcNI.tf2" => {
142                    match val {
143                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tf2 = Some(v); } }
144                        crate::base::FieldValue::TextList(svs) => {
145                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tf2 = Some(v); } }
146                        }
147                        _ => {}
148                    }
149                }
150                "ExcNI.tr" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tr = Some(v); } }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tr = Some(v); } }
155                        }
156                        _ => {}
157                    }
158                }
159                "ExcNI.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                "ExcNI.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}