Skip to main content

cimstructs/
PetersenCoil.rs

1/// A variable impedance device normally used to offset line charging during single line faults in an ungrounded section of network.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct PetersenCoil {
4    #[serde(flatten)]
5    pub base: super::EarthFaultCompensator,
6    /// The mode of operation of the Petersen coil.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub mode: Option<super::base::UriRef>,
9    /// The nominal voltage for which the coil is designed.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub nominal_u: Option<f64>,
12    /// The offset current that the Petersen coil controller is operating from the resonant point. This is normally a fixed amount for which the controller is configured and could be positive or negative. Typically 0 to 60 A depending on voltage and resonance conditions.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub offset_current: Option<f64>,
15    /// The control current used to control the Petersen coil also known as the position current. Typically in the range of 20 mA to 200 mA.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub position_current: Option<f64>,
18    /// The maximum reactance.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub x_ground_max: Option<f64>,
21    /// The minimum reactance.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub x_ground_min: Option<f64>,
24    /// The nominal reactance. This is the operating point (normally over compensation) that is defined based on the resonance point in the healthy network condition. The impedance is calculated based on nominal voltage divided by position current.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub x_ground_nominal: Option<f64>,
27}
28impl crate::base::CimElement for PetersenCoil {
29    fn mrid(&self) -> &str { &self.base.base.base.base.base.id }
30    fn type_name(&self) -> &'static str { "PetersenCoil" }
31    fn as_any(&self) -> &dyn std::any::Any { self }
32    fn to_json_value(&self) -> serde_json::Value {
33        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
34    }
35    fn to_block(&self) -> crate::base::RdfBlock {
36        let mut block = self.base.to_block();
37        block.type_name = "PetersenCoil".to_string();
38        if let Some(ref v) = self.mode {
39            block.fields.insert("PetersenCoil.mode".into(), crate::base::FieldValue::Resource(v.uri.clone()));
40        }
41        if let Some(v) = self.nominal_u {
42            block.fields.insert("PetersenCoil.nominalU".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.offset_current {
45            block.fields.insert("PetersenCoil.offsetCurrent".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.position_current {
48            block.fields.insert("PetersenCoil.positionCurrent".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.x_ground_max {
51            block.fields.insert("PetersenCoil.xGroundMax".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.x_ground_min {
54            block.fields.insert("PetersenCoil.xGroundMin".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.x_ground_nominal {
57            block.fields.insert("PetersenCoil.xGroundNominal".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        block
60    }
61}
62
63impl PetersenCoil {
64    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
65        let mut obj = Self::default();
66        obj.base.base.base.base.base.id.clone_from(&b.mrid);
67        for (key, val) in &b.fields {
68            match key.as_str() {
69                "PetersenCoil.mode" => {
70                    if let crate::base::FieldValue::Resource(sv) = val {
71                        obj.mode = Some(crate::base::UriRef { uri: sv.clone() });
72                    }
73                }
74                "PetersenCoil.nominalU" => {
75                    match val {
76                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.nominal_u = Some(v); } }
77                        crate::base::FieldValue::TextList(svs) => {
78                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.nominal_u = Some(v); } }
79                        }
80                        _ => {}
81                    }
82                }
83                "PetersenCoil.offsetCurrent" => {
84                    match val {
85                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.offset_current = Some(v); } }
86                        crate::base::FieldValue::TextList(svs) => {
87                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.offset_current = Some(v); } }
88                        }
89                        _ => {}
90                    }
91                }
92                "PetersenCoil.positionCurrent" => {
93                    match val {
94                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.position_current = Some(v); } }
95                        crate::base::FieldValue::TextList(svs) => {
96                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.position_current = Some(v); } }
97                        }
98                        _ => {}
99                    }
100                }
101                "PetersenCoil.xGroundMax" => {
102                    match val {
103                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x_ground_max = Some(v); } }
104                        crate::base::FieldValue::TextList(svs) => {
105                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x_ground_max = Some(v); } }
106                        }
107                        _ => {}
108                    }
109                }
110                "PetersenCoil.xGroundMin" => {
111                    match val {
112                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x_ground_min = Some(v); } }
113                        crate::base::FieldValue::TextList(svs) => {
114                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x_ground_min = Some(v); } }
115                        }
116                        _ => {}
117                    }
118                }
119                "PetersenCoil.xGroundNominal" => {
120                    match val {
121                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x_ground_nominal = Some(v); } }
122                        crate::base::FieldValue::TextList(svs) => {
123                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x_ground_nominal = Some(v); } }
124                        }
125                        _ => {}
126                    }
127                }
128                "EarthFaultCompensator.r" => {
129                    match val {
130                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.r = Some(v); } }
131                        crate::base::FieldValue::TextList(svs) => {
132                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.r = Some(v); } }
133                        }
134                        _ => {}
135                    }
136                }
137                "ConductingEquipment.BaseVoltage" => {
138                    if let crate::base::FieldValue::Resource(sv) = val {
139                        obj.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
140                    }
141                }
142                "Equipment.EquipmentContainer" => {
143                    if let crate::base::FieldValue::Resource(sv) = val {
144                        obj.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
145                    }
146                }
147                "Equipment.aggregate" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
152                        }
153                        _ => {}
154                    }
155                }
156                "Equipment.inService" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
161                        }
162                        _ => {}
163                    }
164                }
165                "Equipment.normallyInService" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
170                        }
171                        _ => {}
172                    }
173                }
174                "IdentifiedObject.description" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.description = sv.clone(); }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.description = sv.clone(); }
179                        }
180                        _ => {}
181                    }
182                }
183                "IdentifiedObject.energyIdentCodeEic" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
188                        }
189                        _ => {}
190                    }
191                }
192                "IdentifiedObject.mRID" => {
193                    match val {
194                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.m_rid = sv.clone(); }
195                        crate::base::FieldValue::TextList(svs) => {
196                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.m_rid = sv.clone(); }
197                        }
198                        _ => {}
199                    }
200                }
201                "IdentifiedObject.name" => {
202                    match val {
203                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.name = sv.clone(); }
204                        crate::base::FieldValue::TextList(svs) => {
205                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.name = sv.clone(); }
206                        }
207                        _ => {}
208                    }
209                }
210                "IdentifiedObject.shortName" => {
211                    match val {
212                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.short_name = sv.clone(); }
213                        crate::base::FieldValue::TextList(svs) => {
214                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.short_name = sv.clone(); }
215                        }
216                        _ => {}
217                    }
218                }
219                _ => {}
220            }
221        }
222        obj
223    }
224}