Skip to main content

cimstructs/
BusbarSection.rs

1/// A conductor, or group of conductors, with negligible impedance, that serve to connect other conducting equipment within a single substation. Voltage measurements are typically obtained from voltage transformers that are connected to busbar sections. A bus bar section may have many physical terminals but for analysis is modelled with exactly one logical terminal.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct BusbarSection {
4    #[serde(flatten)]
5    pub base: super::Connector,
6    /// Maximum allowable peak short-circuit current of busbar (Ipmax in IEC 60909-0). Mechanical limit of the busbar in the substation itself. Used for short circuit data exchange according to IEC 60909.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub ip_max: Option<f64>,
9}
10impl crate::base::CimElement for BusbarSection {
11    fn mrid(&self) -> &str { &self.base.base.base.base.base.id }
12    fn type_name(&self) -> &'static str { "BusbarSection" }
13    fn as_any(&self) -> &dyn std::any::Any { self }
14    fn to_json_value(&self) -> serde_json::Value {
15        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
16    }
17    fn to_block(&self) -> crate::base::RdfBlock {
18        let mut block = self.base.to_block();
19        block.type_name = "BusbarSection".to_string();
20        if let Some(v) = self.ip_max {
21            block.fields.insert("BusbarSection.ipMax".into(), crate::base::FieldValue::Text(v.to_string()));
22        }
23        block
24    }
25}
26
27impl BusbarSection {
28    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
29        let mut obj = Self::default();
30        obj.base.base.base.base.base.id.clone_from(&b.mrid);
31        for (key, val) in &b.fields {
32            match key.as_str() {
33                "BusbarSection.ipMax" => {
34                    match val {
35                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ip_max = Some(v); } }
36                        crate::base::FieldValue::TextList(svs) => {
37                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ip_max = Some(v); } }
38                        }
39                        _ => {}
40                    }
41                }
42                "ConductingEquipment.BaseVoltage" => {
43                    if let crate::base::FieldValue::Resource(sv) = val {
44                        obj.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
45                    }
46                }
47                "Equipment.EquipmentContainer" => {
48                    if let crate::base::FieldValue::Resource(sv) = val {
49                        obj.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
50                    }
51                }
52                "Equipment.aggregate" => {
53                    match val {
54                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
55                        crate::base::FieldValue::TextList(svs) => {
56                            if let Some(sv) = svs.last() { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
57                        }
58                        _ => {}
59                    }
60                }
61                "Equipment.inService" => {
62                    match val {
63                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
64                        crate::base::FieldValue::TextList(svs) => {
65                            if let Some(sv) = svs.last() { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
66                        }
67                        _ => {}
68                    }
69                }
70                "Equipment.normallyInService" => {
71                    match val {
72                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
73                        crate::base::FieldValue::TextList(svs) => {
74                            if let Some(sv) = svs.last() { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
75                        }
76                        _ => {}
77                    }
78                }
79                "IdentifiedObject.description" => {
80                    match val {
81                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.description = sv.clone(); }
82                        crate::base::FieldValue::TextList(svs) => {
83                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.description = sv.clone(); }
84                        }
85                        _ => {}
86                    }
87                }
88                "IdentifiedObject.energyIdentCodeEic" => {
89                    match val {
90                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
91                        crate::base::FieldValue::TextList(svs) => {
92                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
93                        }
94                        _ => {}
95                    }
96                }
97                "IdentifiedObject.mRID" => {
98                    match val {
99                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.m_rid = sv.clone(); }
100                        crate::base::FieldValue::TextList(svs) => {
101                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.m_rid = sv.clone(); }
102                        }
103                        _ => {}
104                    }
105                }
106                "IdentifiedObject.name" => {
107                    match val {
108                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.name = sv.clone(); }
109                        crate::base::FieldValue::TextList(svs) => {
110                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.name = sv.clone(); }
111                        }
112                        _ => {}
113                    }
114                }
115                "IdentifiedObject.shortName" => {
116                    match val {
117                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.short_name = sv.clone(); }
118                        crate::base::FieldValue::TextList(svs) => {
119                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.short_name = sv.clone(); }
120                        }
121                        _ => {}
122                    }
123                }
124                _ => {}
125            }
126        }
127        obj
128    }
129}