Skip to main content

cimstructs/
ExcBBC.rs

1/// Transformer fed static excitation system (static with ABB regulator). This model represents a static excitation system in which a gated thyristor bridge fed by a transformer at the main generator terminals feeds the main generator directly.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ExcBBC {
4    #[serde(flatten)]
5    pub base: super::ExcitationSystemDynamics,
6    /// Maximum open circuit exciter voltage (Efdmax) (> ExcBBC.efdmin). Typical value = 5.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub efdmax: Option<f64>,
9    /// Minimum open circuit exciter voltage (Efdmin) (< ExcBBC.efdmax). Typical value = -5.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub efdmin: Option<f64>,
12    /// Steady state gain (K) (not = 0). Typical value = 300.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub k: Option<f64>,
15    /// Supplementary signal routing selector (switch). true = Vs connected to 3rd summing point false = Vs connected to 1st summing point (see diagram). Typical value = false.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub switch_: Option<bool>,
18    /// Controller time constant (T1) (>= 0). Typical value = 6.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub t1: Option<f64>,
21    /// Controller time constant (T2) (>= 0). Typical value = 1.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub t2: Option<f64>,
24    /// Lead/lag time constant (T3) (>= 0). If = 0, block is bypassed. Typical value = 0,05.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub t3: Option<f64>,
27    /// Lead/lag time constant (T4) (>= 0). If = 0, block is bypassed. Typical value = 0,01.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub t4: Option<f64>,
30    /// Maximum control element output (Vrmax) (> ExcBBC.vrmin). Typical value = 5.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub vrmax: Option<f64>,
33    /// Minimum control element output (Vrmin) (< ExcBBC.vrmax). Typical value = -5.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub vrmin: Option<f64>,
36    /// Effective excitation transformer reactance (Xe) (>= 0). Xe models the regulation of the transformer/rectifier unit. Typical value = 0,05.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub xe: Option<f64>,
39}
40impl crate::base::CimElement for ExcBBC {
41    fn mrid(&self) -> &str { &self.base.base.base.id }
42    fn type_name(&self) -> &'static str { "ExcBBC" }
43    fn as_any(&self) -> &dyn std::any::Any { self }
44    fn to_json_value(&self) -> serde_json::Value {
45        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
46    }
47    fn to_block(&self) -> crate::base::RdfBlock {
48        let mut block = self.base.to_block();
49        block.type_name = "ExcBBC".to_string();
50        if let Some(v) = self.efdmax {
51            block.fields.insert("ExcBBC.efdmax".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.efdmin {
54            block.fields.insert("ExcBBC.efdmin".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.k {
57            block.fields.insert("ExcBBC.k".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        if let Some(v) = self.switch_ {
60            block.fields.insert("ExcBBC.switch".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.t1 {
63            block.fields.insert("ExcBBC.t1".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.t2 {
66            block.fields.insert("ExcBBC.t2".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.t3 {
69            block.fields.insert("ExcBBC.t3".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.t4 {
72            block.fields.insert("ExcBBC.t4".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.vrmax {
75            block.fields.insert("ExcBBC.vrmax".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.vrmin {
78            block.fields.insert("ExcBBC.vrmin".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.xe {
81            block.fields.insert("ExcBBC.xe".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        block
84    }
85}
86
87impl ExcBBC {
88    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
89        let mut obj = Self::default();
90        obj.base.base.base.id.clone_from(&b.mrid);
91        for (key, val) in &b.fields {
92            match key.as_str() {
93                "ExcBBC.efdmax" => {
94                    match val {
95                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
96                        crate::base::FieldValue::TextList(svs) => {
97                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmax = Some(v); } }
98                        }
99                        _ => {}
100                    }
101                }
102                "ExcBBC.efdmin" => {
103                    match val {
104                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdmin = Some(v); } }
105                        crate::base::FieldValue::TextList(svs) => {
106                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdmin = Some(v); } }
107                        }
108                        _ => {}
109                    }
110                }
111                "ExcBBC.k" => {
112                    match val {
113                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.k = Some(v); } }
114                        crate::base::FieldValue::TextList(svs) => {
115                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.k = Some(v); } }
116                        }
117                        _ => {}
118                    }
119                }
120                "ExcBBC.switch" => {
121                    match val {
122                        crate::base::FieldValue::Text(sv) => { obj.switch_ = Some(sv.trim() == "true"); }
123                        crate::base::FieldValue::TextList(svs) => {
124                            if let Some(sv) = svs.last() { obj.switch_ = Some(sv.trim() == "true"); }
125                        }
126                        _ => {}
127                    }
128                }
129                "ExcBBC.t1" => {
130                    match val {
131                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
132                        crate::base::FieldValue::TextList(svs) => {
133                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
134                        }
135                        _ => {}
136                    }
137                }
138                "ExcBBC.t2" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t2 = Some(v); } }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t2 = Some(v); } }
143                        }
144                        _ => {}
145                    }
146                }
147                "ExcBBC.t3" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t3 = Some(v); } }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t3 = Some(v); } }
152                        }
153                        _ => {}
154                    }
155                }
156                "ExcBBC.t4" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t4 = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t4 = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "ExcBBC.vrmax" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmax = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "ExcBBC.vrmin" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vrmin = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "ExcBBC.xe" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.xe = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.xe = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "ExcitationSystemDynamics.SynchronousMachineDynamics" => {
193                    if let crate::base::FieldValue::Resource(sv) = val {
194                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
195                    }
196                }
197                "DynamicsFunctionBlock.enabled" => {
198                    match val {
199                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
200                        crate::base::FieldValue::TextList(svs) => {
201                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
202                        }
203                        _ => {}
204                    }
205                }
206                "IdentifiedObject.description" => {
207                    match val {
208                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
209                        crate::base::FieldValue::TextList(svs) => {
210                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
211                        }
212                        _ => {}
213                    }
214                }
215                "IdentifiedObject.energyIdentCodeEic" => {
216                    match val {
217                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
218                        crate::base::FieldValue::TextList(svs) => {
219                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
220                        }
221                        _ => {}
222                    }
223                }
224                "IdentifiedObject.mRID" => {
225                    match val {
226                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
227                        crate::base::FieldValue::TextList(svs) => {
228                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
229                        }
230                        _ => {}
231                    }
232                }
233                "IdentifiedObject.name" => {
234                    match val {
235                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
236                        crate::base::FieldValue::TextList(svs) => {
237                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
238                        }
239                        _ => {}
240                    }
241                }
242                "IdentifiedObject.shortName" => {
243                    match val {
244                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
245                        crate::base::FieldValue::TextList(svs) => {
246                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
247                        }
248                        _ => {}
249                    }
250                }
251                _ => {}
252            }
253        }
254        obj
255    }
256}