Skip to main content

cimstructs/
AsynchronousMachine.rs

1/// A rotating machine whose shaft rotates asynchronously with the electrical field. Also known as an induction machine with no external connection to the rotor windings, e.g. squirrel-cage induction machine.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct AsynchronousMachine {
4    #[serde(flatten)]
5    pub base: super::RotatingMachine,
6    /// Indicates the type of Asynchronous Machine (motor or generator).
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub asynchronous_machine_type: Option<super::base::UriRef>,
9    /// Indicates whether the machine is a converter fed drive. Used for short circuit data exchange according to IEC 60909.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub converter_fed_drive: Option<bool>,
12    /// Efficiency of the asynchronous machine at nominal operation as a percentage. Indicator for converter drive motors. Used for short circuit data exchange according to IEC 60909.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub efficiency: Option<f64>,
15    /// Ratio of locked-rotor current to the rated current of the motor (Ia/Ir). Used for short circuit data exchange according to IEC 60909.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub ia_ir_ratio: Option<f64>,
18    /// Nameplate data indicates if the machine is 50 Hz or 60 Hz.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub nominal_frequency: Option<f64>,
21    /// Nameplate data. Depends on the slip and number of pole pairs.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub nominal_speed: Option<f64>,
24    /// Number of pole pairs of stator. Used for short circuit data exchange according to IEC 60909.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub pole_pair_number: Option<i64>,
27    /// Rated mechanical power (Pr in IEC 60909-0). Used for short circuit data exchange according to IEC 60909.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub rated_mechanical_power: Option<f64>,
30    /// Indicates for converter drive motors if the power can be reversible. Used for short circuit data exchange according to IEC 60909.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub reversible: Option<bool>,
33    /// Locked rotor ratio (R/X). Used for short circuit data exchange according to IEC 60909.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub rx_locked_rotor_ratio: Option<f64>,
36}
37impl crate::base::CimElement for AsynchronousMachine {
38    fn mrid(&self) -> &str { &self.base.base.base.base.base.base.base.id }
39    fn type_name(&self) -> &'static str { "AsynchronousMachine" }
40    fn as_any(&self) -> &dyn std::any::Any { self }
41    fn to_json_value(&self) -> serde_json::Value {
42        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
43    }
44    fn to_block(&self) -> crate::base::RdfBlock {
45        let mut block = self.base.to_block();
46        block.type_name = "AsynchronousMachine".to_string();
47        if let Some(ref v) = self.asynchronous_machine_type {
48            block.fields.insert("AsynchronousMachine.asynchronousMachineType".into(), crate::base::FieldValue::Resource(v.uri.clone()));
49        }
50        if let Some(v) = self.converter_fed_drive {
51            block.fields.insert("AsynchronousMachine.converterFedDrive".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.efficiency {
54            block.fields.insert("AsynchronousMachine.efficiency".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.ia_ir_ratio {
57            block.fields.insert("AsynchronousMachine.iaIrRatio".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        if let Some(v) = self.nominal_frequency {
60            block.fields.insert("AsynchronousMachine.nominalFrequency".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.nominal_speed {
63            block.fields.insert("AsynchronousMachine.nominalSpeed".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.pole_pair_number {
66            block.fields.insert("AsynchronousMachine.polePairNumber".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.rated_mechanical_power {
69            block.fields.insert("AsynchronousMachine.ratedMechanicalPower".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.reversible {
72            block.fields.insert("AsynchronousMachine.reversible".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.rx_locked_rotor_ratio {
75            block.fields.insert("AsynchronousMachine.rxLockedRotorRatio".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        block
78    }
79}
80
81impl AsynchronousMachine {
82    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
83        let mut obj = Self::default();
84        obj.base.base.base.base.base.base.base.id.clone_from(&b.mrid);
85        for (key, val) in &b.fields {
86            match key.as_str() {
87                "AsynchronousMachine.asynchronousMachineType" => {
88                    if let crate::base::FieldValue::Resource(sv) = val {
89                        obj.asynchronous_machine_type = Some(crate::base::UriRef { uri: sv.clone() });
90                    }
91                }
92                "AsynchronousMachine.converterFedDrive" => {
93                    match val {
94                        crate::base::FieldValue::Text(sv) => { obj.converter_fed_drive = Some(sv.trim() == "true"); }
95                        crate::base::FieldValue::TextList(svs) => {
96                            if let Some(sv) = svs.last() { obj.converter_fed_drive = Some(sv.trim() == "true"); }
97                        }
98                        _ => {}
99                    }
100                }
101                "AsynchronousMachine.efficiency" => {
102                    match val {
103                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efficiency = Some(v); } }
104                        crate::base::FieldValue::TextList(svs) => {
105                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efficiency = Some(v); } }
106                        }
107                        _ => {}
108                    }
109                }
110                "AsynchronousMachine.iaIrRatio" => {
111                    match val {
112                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ia_ir_ratio = Some(v); } }
113                        crate::base::FieldValue::TextList(svs) => {
114                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ia_ir_ratio = Some(v); } }
115                        }
116                        _ => {}
117                    }
118                }
119                "AsynchronousMachine.nominalFrequency" => {
120                    match val {
121                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.nominal_frequency = Some(v); } }
122                        crate::base::FieldValue::TextList(svs) => {
123                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.nominal_frequency = Some(v); } }
124                        }
125                        _ => {}
126                    }
127                }
128                "AsynchronousMachine.nominalSpeed" => {
129                    match val {
130                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.nominal_speed = Some(v); } }
131                        crate::base::FieldValue::TextList(svs) => {
132                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.nominal_speed = Some(v); } }
133                        }
134                        _ => {}
135                    }
136                }
137                "AsynchronousMachine.polePairNumber" => {
138                    match val {
139                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.pole_pair_number = Some(v); } }
140                        crate::base::FieldValue::TextList(svs) => {
141                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.pole_pair_number = Some(v); } }
142                        }
143                        _ => {}
144                    }
145                }
146                "AsynchronousMachine.ratedMechanicalPower" => {
147                    match val {
148                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rated_mechanical_power = Some(v); } }
149                        crate::base::FieldValue::TextList(svs) => {
150                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rated_mechanical_power = Some(v); } }
151                        }
152                        _ => {}
153                    }
154                }
155                "AsynchronousMachine.reversible" => {
156                    match val {
157                        crate::base::FieldValue::Text(sv) => { obj.reversible = Some(sv.trim() == "true"); }
158                        crate::base::FieldValue::TextList(svs) => {
159                            if let Some(sv) = svs.last() { obj.reversible = Some(sv.trim() == "true"); }
160                        }
161                        _ => {}
162                    }
163                }
164                "AsynchronousMachine.rxLockedRotorRatio" => {
165                    match val {
166                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rx_locked_rotor_ratio = Some(v); } }
167                        crate::base::FieldValue::TextList(svs) => {
168                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rx_locked_rotor_ratio = Some(v); } }
169                        }
170                        _ => {}
171                    }
172                }
173                "RotatingMachine.GeneratingUnit" => {
174                    if let crate::base::FieldValue::Resource(sv) = val {
175                        obj.base.generating_unit = Some(crate::base::MridRef { mrid: sv.clone() });
176                    }
177                }
178                "RotatingMachine.p" => {
179                    match val {
180                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.p = Some(v); } }
181                        crate::base::FieldValue::TextList(svs) => {
182                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.p = Some(v); } }
183                        }
184                        _ => {}
185                    }
186                }
187                "RotatingMachine.q" => {
188                    match val {
189                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.q = Some(v); } }
190                        crate::base::FieldValue::TextList(svs) => {
191                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.q = Some(v); } }
192                        }
193                        _ => {}
194                    }
195                }
196                "RotatingMachine.ratedPowerFactor" => {
197                    match val {
198                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.rated_power_factor = Some(v); } }
199                        crate::base::FieldValue::TextList(svs) => {
200                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.rated_power_factor = Some(v); } }
201                        }
202                        _ => {}
203                    }
204                }
205                "RotatingMachine.ratedS" => {
206                    match val {
207                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.rated_s = Some(v); } }
208                        crate::base::FieldValue::TextList(svs) => {
209                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.rated_s = Some(v); } }
210                        }
211                        _ => {}
212                    }
213                }
214                "RotatingMachine.ratedU" => {
215                    match val {
216                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.rated_u = Some(v); } }
217                        crate::base::FieldValue::TextList(svs) => {
218                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.rated_u = Some(v); } }
219                        }
220                        _ => {}
221                    }
222                }
223                "RegulatingCondEq.RegulatingControl" => {
224                    if let crate::base::FieldValue::Resource(sv) = val {
225                        obj.base.base.regulating_control = Some(crate::base::MridRef { mrid: sv.clone() });
226                    }
227                }
228                "RegulatingCondEq.controlEnabled" => {
229                    match val {
230                        crate::base::FieldValue::Text(sv) => { obj.base.base.control_enabled = Some(sv.trim() == "true"); }
231                        crate::base::FieldValue::TextList(svs) => {
232                            if let Some(sv) = svs.last() { obj.base.base.control_enabled = Some(sv.trim() == "true"); }
233                        }
234                        _ => {}
235                    }
236                }
237                "ConductingEquipment.BaseVoltage" => {
238                    if let crate::base::FieldValue::Resource(sv) = val {
239                        obj.base.base.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
240                    }
241                }
242                "Equipment.EquipmentContainer" => {
243                    if let crate::base::FieldValue::Resource(sv) = val {
244                        obj.base.base.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
245                    }
246                }
247                "Equipment.aggregate" => {
248                    match val {
249                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.aggregate = Some(sv.trim() == "true"); }
250                        crate::base::FieldValue::TextList(svs) => {
251                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.aggregate = Some(sv.trim() == "true"); }
252                        }
253                        _ => {}
254                    }
255                }
256                "Equipment.inService" => {
257                    match val {
258                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.in_service = Some(sv.trim() == "true"); }
259                        crate::base::FieldValue::TextList(svs) => {
260                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.in_service = Some(sv.trim() == "true"); }
261                        }
262                        _ => {}
263                    }
264                }
265                "Equipment.normallyInService" => {
266                    match val {
267                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
268                        crate::base::FieldValue::TextList(svs) => {
269                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
270                        }
271                        _ => {}
272                    }
273                }
274                "IdentifiedObject.description" => {
275                    match val {
276                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.description = sv.clone(); }
277                        crate::base::FieldValue::TextList(svs) => {
278                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.description = sv.clone(); }
279                        }
280                        _ => {}
281                    }
282                }
283                "IdentifiedObject.energyIdentCodeEic" => {
284                    match val {
285                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
286                        crate::base::FieldValue::TextList(svs) => {
287                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
288                        }
289                        _ => {}
290                    }
291                }
292                "IdentifiedObject.mRID" => {
293                    match val {
294                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.m_rid = sv.clone(); }
295                        crate::base::FieldValue::TextList(svs) => {
296                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.m_rid = sv.clone(); }
297                        }
298                        _ => {}
299                    }
300                }
301                "IdentifiedObject.name" => {
302                    match val {
303                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.name = sv.clone(); }
304                        crate::base::FieldValue::TextList(svs) => {
305                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.name = sv.clone(); }
306                        }
307                        _ => {}
308                    }
309                }
310                "IdentifiedObject.shortName" => {
311                    match val {
312                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.short_name = sv.clone(); }
313                        crate::base::FieldValue::TextList(svs) => {
314                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.short_name = sv.clone(); }
315                        }
316                        _ => {}
317                    }
318                }
319                _ => {}
320            }
321        }
322        obj
323    }
324}