Skip to main content

cimstructs/
EquivalentBranch.rs

1/// The class represents equivalent branches. In cases where a transformer phase shift is modelled and the EquivalentBranch is spanning the same nodes, the impedance quantities for the EquivalentBranch shall consider the needed phase shift.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct EquivalentBranch {
4    #[serde(flatten)]
5    pub base: super::EquivalentEquipment,
6    /// Negative sequence series resistance from terminal sequence 1 to terminal sequence 2. Used for short circuit data exchange according to IEC 60909. EquivalentBranch is a result of network reduction prior to the data exchange.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub negative_r12: Option<f64>,
9    /// Negative sequence series resistance from terminal sequence 2 to terminal sequence 1. Used for short circuit data exchange according to IEC 60909. EquivalentBranch is a result of network reduction prior to the data exchange.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub negative_r21: Option<f64>,
12    /// Negative sequence series reactance from terminal sequence 1 to terminal sequence 2. Used for short circuit data exchange according to IEC 60909. Usage : EquivalentBranch is a result of network reduction prior to the data exchange.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub negative_x12: Option<f64>,
15    /// Negative sequence series reactance from terminal sequence 2 to terminal sequence 1. Used for short circuit data exchange according to IEC 60909. Usage: EquivalentBranch is a result of network reduction prior to the data exchange.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub negative_x21: Option<f64>,
18    /// Positive sequence series resistance from terminal sequence 1 to terminal sequence 2 . Used for short circuit data exchange according to IEC 60909. EquivalentBranch is a result of network reduction prior to the data exchange.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub positive_r12: Option<f64>,
21    /// Positive sequence series resistance from terminal sequence 2 to terminal sequence 1. Used for short circuit data exchange according to IEC 60909. EquivalentBranch is a result of network reduction prior to the data exchange.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub positive_r21: Option<f64>,
24    /// Positive sequence series reactance from terminal sequence 1 to terminal sequence 2. Used for short circuit data exchange according to IEC 60909. Usage : EquivalentBranch is a result of network reduction prior to the data exchange.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub positive_x12: Option<f64>,
27    /// Positive sequence series reactance from terminal sequence 2 to terminal sequence 1. Used for short circuit data exchange according to IEC 60909. Usage : EquivalentBranch is a result of network reduction prior to the data exchange.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub positive_x21: Option<f64>,
30    /// Positive sequence series resistance of the reduced branch.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub r: Option<f64>,
33    /// Resistance from terminal sequence 2 to terminal sequence 1 .Used for steady state power flow. This attribute is optional and represent unbalanced network such as off-nominal phase shifter. If only EquivalentBranch.r is given, then EquivalentBranch.r21 is assumed equal to EquivalentBranch.r. Usage rule : EquivalentBranch is a result of network reduction prior to the data exchange.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub r21: Option<f64>,
36    /// Positive sequence series reactance of the reduced branch.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub x: Option<f64>,
39    /// Reactance from terminal sequence 2 to terminal sequence 1. Used for steady state power flow. This attribute is optional and represents an unbalanced network such as off-nominal phase shifter. If only EquivalentBranch.x is given, then EquivalentBranch.x21 is assumed equal to EquivalentBranch.x. Usage rule: EquivalentBranch is a result of network reduction prior to the data exchange.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub x21: Option<f64>,
42    /// Zero sequence series resistance from terminal sequence 1 to terminal sequence 2. Used for short circuit data exchange according to IEC 60909. EquivalentBranch is a result of network reduction prior to the data exchange.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub zero_r12: Option<f64>,
45    /// Zero sequence series resistance from terminal sequence 2 to terminal sequence 1. Used for short circuit data exchange according to IEC 60909. Usage : EquivalentBranch is a result of network reduction prior to the data exchange.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub zero_r21: Option<f64>,
48    /// Zero sequence series reactance from terminal sequence 1 to terminal sequence 2. Used for short circuit data exchange according to IEC 60909. Usage : EquivalentBranch is a result of network reduction prior to the data exchange.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub zero_x12: Option<f64>,
51    /// Zero sequence series reactance from terminal sequence 2 to terminal sequence 1. Used for short circuit data exchange according to IEC 60909. Usage : EquivalentBranch is a result of network reduction prior to the data exchange.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub zero_x21: Option<f64>,
54}
55impl crate::base::CimElement for EquivalentBranch {
56    fn mrid(&self) -> &str { &self.base.base.base.base.base.id }
57    fn type_name(&self) -> &'static str { "EquivalentBranch" }
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 = "EquivalentBranch".to_string();
65        if let Some(v) = self.negative_r12 {
66            block.fields.insert("EquivalentBranch.negativeR12".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.negative_r21 {
69            block.fields.insert("EquivalentBranch.negativeR21".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.negative_x12 {
72            block.fields.insert("EquivalentBranch.negativeX12".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.negative_x21 {
75            block.fields.insert("EquivalentBranch.negativeX21".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.positive_r12 {
78            block.fields.insert("EquivalentBranch.positiveR12".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.positive_r21 {
81            block.fields.insert("EquivalentBranch.positiveR21".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.positive_x12 {
84            block.fields.insert("EquivalentBranch.positiveX12".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.positive_x21 {
87            block.fields.insert("EquivalentBranch.positiveX21".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.r {
90            block.fields.insert("EquivalentBranch.r".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.r21 {
93            block.fields.insert("EquivalentBranch.r21".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.x {
96            block.fields.insert("EquivalentBranch.x".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.x21 {
99            block.fields.insert("EquivalentBranch.x21".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.zero_r12 {
102            block.fields.insert("EquivalentBranch.zeroR12".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.zero_r21 {
105            block.fields.insert("EquivalentBranch.zeroR21".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.zero_x12 {
108            block.fields.insert("EquivalentBranch.zeroX12".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.zero_x21 {
111            block.fields.insert("EquivalentBranch.zeroX21".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        block
114    }
115}
116
117impl EquivalentBranch {
118    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
119        let mut obj = Self::default();
120        obj.base.base.base.base.base.id.clone_from(&b.mrid);
121        for (key, val) in &b.fields {
122            match key.as_str() {
123                "EquivalentBranch.negativeR12" => {
124                    match val {
125                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.negative_r12 = Some(v); } }
126                        crate::base::FieldValue::TextList(svs) => {
127                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.negative_r12 = Some(v); } }
128                        }
129                        _ => {}
130                    }
131                }
132                "EquivalentBranch.negativeR21" => {
133                    match val {
134                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.negative_r21 = Some(v); } }
135                        crate::base::FieldValue::TextList(svs) => {
136                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.negative_r21 = Some(v); } }
137                        }
138                        _ => {}
139                    }
140                }
141                "EquivalentBranch.negativeX12" => {
142                    match val {
143                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.negative_x12 = Some(v); } }
144                        crate::base::FieldValue::TextList(svs) => {
145                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.negative_x12 = Some(v); } }
146                        }
147                        _ => {}
148                    }
149                }
150                "EquivalentBranch.negativeX21" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.negative_x21 = Some(v); } }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.negative_x21 = Some(v); } }
155                        }
156                        _ => {}
157                    }
158                }
159                "EquivalentBranch.positiveR12" => {
160                    match val {
161                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.positive_r12 = Some(v); } }
162                        crate::base::FieldValue::TextList(svs) => {
163                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.positive_r12 = Some(v); } }
164                        }
165                        _ => {}
166                    }
167                }
168                "EquivalentBranch.positiveR21" => {
169                    match val {
170                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.positive_r21 = Some(v); } }
171                        crate::base::FieldValue::TextList(svs) => {
172                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.positive_r21 = Some(v); } }
173                        }
174                        _ => {}
175                    }
176                }
177                "EquivalentBranch.positiveX12" => {
178                    match val {
179                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.positive_x12 = Some(v); } }
180                        crate::base::FieldValue::TextList(svs) => {
181                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.positive_x12 = Some(v); } }
182                        }
183                        _ => {}
184                    }
185                }
186                "EquivalentBranch.positiveX21" => {
187                    match val {
188                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.positive_x21 = Some(v); } }
189                        crate::base::FieldValue::TextList(svs) => {
190                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.positive_x21 = Some(v); } }
191                        }
192                        _ => {}
193                    }
194                }
195                "EquivalentBranch.r" => {
196                    match val {
197                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
198                        crate::base::FieldValue::TextList(svs) => {
199                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
200                        }
201                        _ => {}
202                    }
203                }
204                "EquivalentBranch.r21" => {
205                    match val {
206                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r21 = Some(v); } }
207                        crate::base::FieldValue::TextList(svs) => {
208                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r21 = Some(v); } }
209                        }
210                        _ => {}
211                    }
212                }
213                "EquivalentBranch.x" => {
214                    match val {
215                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x = Some(v); } }
216                        crate::base::FieldValue::TextList(svs) => {
217                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x = Some(v); } }
218                        }
219                        _ => {}
220                    }
221                }
222                "EquivalentBranch.x21" => {
223                    match val {
224                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x21 = Some(v); } }
225                        crate::base::FieldValue::TextList(svs) => {
226                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x21 = Some(v); } }
227                        }
228                        _ => {}
229                    }
230                }
231                "EquivalentBranch.zeroR12" => {
232                    match val {
233                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.zero_r12 = Some(v); } }
234                        crate::base::FieldValue::TextList(svs) => {
235                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.zero_r12 = Some(v); } }
236                        }
237                        _ => {}
238                    }
239                }
240                "EquivalentBranch.zeroR21" => {
241                    match val {
242                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.zero_r21 = Some(v); } }
243                        crate::base::FieldValue::TextList(svs) => {
244                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.zero_r21 = Some(v); } }
245                        }
246                        _ => {}
247                    }
248                }
249                "EquivalentBranch.zeroX12" => {
250                    match val {
251                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.zero_x12 = Some(v); } }
252                        crate::base::FieldValue::TextList(svs) => {
253                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.zero_x12 = Some(v); } }
254                        }
255                        _ => {}
256                    }
257                }
258                "EquivalentBranch.zeroX21" => {
259                    match val {
260                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.zero_x21 = Some(v); } }
261                        crate::base::FieldValue::TextList(svs) => {
262                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.zero_x21 = Some(v); } }
263                        }
264                        _ => {}
265                    }
266                }
267                "EquivalentEquipment.EquivalentNetwork" => {
268                    if let crate::base::FieldValue::Resource(sv) = val {
269                        obj.base.equivalent_network = Some(crate::base::MridRef { mrid: sv.clone() });
270                    }
271                }
272                "ConductingEquipment.BaseVoltage" => {
273                    if let crate::base::FieldValue::Resource(sv) = val {
274                        obj.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
275                    }
276                }
277                "Equipment.EquipmentContainer" => {
278                    if let crate::base::FieldValue::Resource(sv) = val {
279                        obj.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
280                    }
281                }
282                "Equipment.aggregate" => {
283                    match val {
284                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
285                        crate::base::FieldValue::TextList(svs) => {
286                            if let Some(sv) = svs.last() { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
287                        }
288                        _ => {}
289                    }
290                }
291                "Equipment.inService" => {
292                    match val {
293                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
294                        crate::base::FieldValue::TextList(svs) => {
295                            if let Some(sv) = svs.last() { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
296                        }
297                        _ => {}
298                    }
299                }
300                "Equipment.normallyInService" => {
301                    match val {
302                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
303                        crate::base::FieldValue::TextList(svs) => {
304                            if let Some(sv) = svs.last() { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
305                        }
306                        _ => {}
307                    }
308                }
309                "IdentifiedObject.description" => {
310                    match val {
311                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.description = sv.clone(); }
312                        crate::base::FieldValue::TextList(svs) => {
313                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.description = sv.clone(); }
314                        }
315                        _ => {}
316                    }
317                }
318                "IdentifiedObject.energyIdentCodeEic" => {
319                    match val {
320                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
321                        crate::base::FieldValue::TextList(svs) => {
322                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
323                        }
324                        _ => {}
325                    }
326                }
327                "IdentifiedObject.mRID" => {
328                    match val {
329                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.m_rid = sv.clone(); }
330                        crate::base::FieldValue::TextList(svs) => {
331                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.m_rid = sv.clone(); }
332                        }
333                        _ => {}
334                    }
335                }
336                "IdentifiedObject.name" => {
337                    match val {
338                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.name = sv.clone(); }
339                        crate::base::FieldValue::TextList(svs) => {
340                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.name = sv.clone(); }
341                        }
342                        _ => {}
343                    }
344                }
345                "IdentifiedObject.shortName" => {
346                    match val {
347                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.short_name = sv.clone(); }
348                        crate::base::FieldValue::TextList(svs) => {
349                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.short_name = sv.clone(); }
350                        }
351                        _ => {}
352                    }
353                }
354                _ => {}
355            }
356        }
357        obj
358    }
359}