Skip to main content

cimstructs/
ACLineSegment.rs

1/// A wire or combination of wires, with consistent electrical characteristics, building a single electrical system, used to carry alternating current between points in the power system. For symmetrical, transposed three phase lines, it is sufficient to use attributes of the line segment, which describe impedances and admittances for the entire length of the segment. Additionally impedances can be computed by using length and associated per length impedances. The BaseVoltage at the two ends of ACLineSegments in a Line shall have the same BaseVoltage.nominalVoltage. However, boundary lines may have slightly different BaseVoltage.nominalVoltages and variation is allowed. Larger voltage difference in general requires use of an equivalent branch.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ACLineSegment {
4    #[serde(flatten)]
5    pub base: super::Conductor,
6    /// Zero sequence shunt (charging) susceptance, uniformly distributed, of the entire line section.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub b0ch: Option<f64>,
9    /// Positive sequence shunt (charging) susceptance, uniformly distributed, of the entire line section. This value represents the full charging over the full length of the line.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub bch: Option<f64>,
12    /// Zero sequence shunt (charging) conductance, uniformly distributed, of the entire line section.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub g0ch: Option<f64>,
15    /// Positive sequence shunt (charging) conductance, uniformly distributed, of the entire line section.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub gch: Option<f64>,
18    /// Positive sequence series resistance of the entire line section.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub r: Option<f64>,
21    /// Zero sequence series resistance of the entire line section.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub r0: Option<f64>,
24    /// Maximum permitted temperature at the end of SC for the calculation of minimum short-circuit currents. Used for short circuit data exchange according to IEC 60909.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub short_circuit_end_temperature: Option<f64>,
27    /// Positive sequence series reactance of the entire line section.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub x: Option<f64>,
30    /// Zero sequence series reactance of the entire line section.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub x0: Option<f64>,
33}
34impl crate::base::CimElement for ACLineSegment {
35    fn mrid(&self) -> &str { &self.base.base.base.base.base.id }
36    fn type_name(&self) -> &'static str { "ACLineSegment" }
37    fn as_any(&self) -> &dyn std::any::Any { self }
38    fn to_json_value(&self) -> serde_json::Value {
39        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
40    }
41    fn to_block(&self) -> crate::base::RdfBlock {
42        let mut block = self.base.to_block();
43        block.type_name = "ACLineSegment".to_string();
44        if let Some(v) = self.b0ch {
45            block.fields.insert("ACLineSegment.b0ch".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.bch {
48            block.fields.insert("ACLineSegment.bch".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.g0ch {
51            block.fields.insert("ACLineSegment.g0ch".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.gch {
54            block.fields.insert("ACLineSegment.gch".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.r {
57            block.fields.insert("ACLineSegment.r".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        if let Some(v) = self.r0 {
60            block.fields.insert("ACLineSegment.r0".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.short_circuit_end_temperature {
63            block.fields.insert("ACLineSegment.shortCircuitEndTemperature".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.x {
66            block.fields.insert("ACLineSegment.x".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.x0 {
69            block.fields.insert("ACLineSegment.x0".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        block
72    }
73}
74
75impl ACLineSegment {
76    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
77        let mut obj = Self::default();
78        obj.base.base.base.base.base.id.clone_from(&b.mrid);
79        for (key, val) in &b.fields {
80            match key.as_str() {
81                "ACLineSegment.b0ch" => {
82                    match val {
83                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.b0ch = Some(v); } }
84                        crate::base::FieldValue::TextList(svs) => {
85                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.b0ch = Some(v); } }
86                        }
87                        _ => {}
88                    }
89                }
90                "ACLineSegment.bch" => {
91                    match val {
92                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.bch = Some(v); } }
93                        crate::base::FieldValue::TextList(svs) => {
94                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.bch = Some(v); } }
95                        }
96                        _ => {}
97                    }
98                }
99                "ACLineSegment.g0ch" => {
100                    match val {
101                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.g0ch = Some(v); } }
102                        crate::base::FieldValue::TextList(svs) => {
103                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.g0ch = Some(v); } }
104                        }
105                        _ => {}
106                    }
107                }
108                "ACLineSegment.gch" => {
109                    match val {
110                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.gch = Some(v); } }
111                        crate::base::FieldValue::TextList(svs) => {
112                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.gch = Some(v); } }
113                        }
114                        _ => {}
115                    }
116                }
117                "ACLineSegment.r" => {
118                    match val {
119                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
120                        crate::base::FieldValue::TextList(svs) => {
121                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
122                        }
123                        _ => {}
124                    }
125                }
126                "ACLineSegment.r0" => {
127                    match val {
128                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r0 = Some(v); } }
129                        crate::base::FieldValue::TextList(svs) => {
130                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r0 = Some(v); } }
131                        }
132                        _ => {}
133                    }
134                }
135                "ACLineSegment.shortCircuitEndTemperature" => {
136                    match val {
137                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.short_circuit_end_temperature = Some(v); } }
138                        crate::base::FieldValue::TextList(svs) => {
139                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.short_circuit_end_temperature = Some(v); } }
140                        }
141                        _ => {}
142                    }
143                }
144                "ACLineSegment.x" => {
145                    match val {
146                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x = Some(v); } }
147                        crate::base::FieldValue::TextList(svs) => {
148                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x = Some(v); } }
149                        }
150                        _ => {}
151                    }
152                }
153                "ACLineSegment.x0" => {
154                    match val {
155                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x0 = Some(v); } }
156                        crate::base::FieldValue::TextList(svs) => {
157                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x0 = Some(v); } }
158                        }
159                        _ => {}
160                    }
161                }
162                "Conductor.length" => {
163                    match val {
164                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.length = Some(v); } }
165                        crate::base::FieldValue::TextList(svs) => {
166                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.length = Some(v); } }
167                        }
168                        _ => {}
169                    }
170                }
171                "ConductingEquipment.BaseVoltage" => {
172                    if let crate::base::FieldValue::Resource(sv) = val {
173                        obj.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
174                    }
175                }
176                "Equipment.EquipmentContainer" => {
177                    if let crate::base::FieldValue::Resource(sv) = val {
178                        obj.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
179                    }
180                }
181                "Equipment.aggregate" => {
182                    match val {
183                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
184                        crate::base::FieldValue::TextList(svs) => {
185                            if let Some(sv) = svs.last() { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
186                        }
187                        _ => {}
188                    }
189                }
190                "Equipment.inService" => {
191                    match val {
192                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
193                        crate::base::FieldValue::TextList(svs) => {
194                            if let Some(sv) = svs.last() { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
195                        }
196                        _ => {}
197                    }
198                }
199                "Equipment.normallyInService" => {
200                    match val {
201                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
202                        crate::base::FieldValue::TextList(svs) => {
203                            if let Some(sv) = svs.last() { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
204                        }
205                        _ => {}
206                    }
207                }
208                "IdentifiedObject.description" => {
209                    match val {
210                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.description = sv.clone(); }
211                        crate::base::FieldValue::TextList(svs) => {
212                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.description = sv.clone(); }
213                        }
214                        _ => {}
215                    }
216                }
217                "IdentifiedObject.energyIdentCodeEic" => {
218                    match val {
219                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
220                        crate::base::FieldValue::TextList(svs) => {
221                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
222                        }
223                        _ => {}
224                    }
225                }
226                "IdentifiedObject.mRID" => {
227                    match val {
228                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.m_rid = sv.clone(); }
229                        crate::base::FieldValue::TextList(svs) => {
230                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.m_rid = sv.clone(); }
231                        }
232                        _ => {}
233                    }
234                }
235                "IdentifiedObject.name" => {
236                    match val {
237                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.name = sv.clone(); }
238                        crate::base::FieldValue::TextList(svs) => {
239                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.name = sv.clone(); }
240                        }
241                        _ => {}
242                    }
243                }
244                "IdentifiedObject.shortName" => {
245                    match val {
246                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.short_name = sv.clone(); }
247                        crate::base::FieldValue::TextList(svs) => {
248                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.short_name = sv.clone(); }
249                        }
250                        _ => {}
251                    }
252                }
253                _ => {}
254            }
255        }
256        obj
257    }
258}