cimstructs/
SynchronousMachine.rs1#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct SynchronousMachine {
4 #[serde(flatten)]
5 pub base: super::RotatingMachine,
6 #[serde(skip_serializing_if = "Option::is_none")]
8 pub initial_reactive_capability_curve: Option<super::base::MridRef>,
9 #[serde(skip_serializing_if = "Option::is_none")]
11 pub earthing: Option<bool>,
12 #[serde(skip_serializing_if = "Option::is_none")]
14 pub earthing_star_point_r: Option<f64>,
15 #[serde(skip_serializing_if = "Option::is_none")]
17 pub earthing_star_point_x: Option<f64>,
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub ikk: Option<f64>,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub max_q: Option<f64>,
24 #[serde(skip_serializing_if = "Option::is_none")]
26 pub min_q: Option<f64>,
27 #[serde(skip_serializing_if = "Option::is_none")]
29 pub mu: Option<f64>,
30 #[serde(skip_serializing_if = "Option::is_none")]
32 pub operating_mode: Option<super::base::UriRef>,
33 #[serde(skip_serializing_if = "Option::is_none")]
35 pub q_percent: Option<f64>,
36 #[serde(skip_serializing_if = "Option::is_none")]
38 pub r: Option<f64>,
39 #[serde(skip_serializing_if = "Option::is_none")]
41 pub r0: Option<f64>,
42 #[serde(skip_serializing_if = "Option::is_none")]
44 pub r2: Option<f64>,
45 #[serde(skip_serializing_if = "Option::is_none")]
47 pub reference_priority: Option<i64>,
48 #[serde(skip_serializing_if = "Option::is_none")]
50 pub sat_direct_subtrans_x: Option<f64>,
51 #[serde(skip_serializing_if = "Option::is_none")]
53 pub sat_direct_sync_x: Option<f64>,
54 #[serde(skip_serializing_if = "Option::is_none")]
56 pub sat_direct_trans_x: Option<f64>,
57 #[serde(skip_serializing_if = "Option::is_none")]
59 pub short_circuit_rotor_type: Option<super::base::UriRef>,
60 #[serde(skip_serializing_if = "Option::is_none")]
62 pub type_: Option<super::base::UriRef>,
63 #[serde(skip_serializing_if = "Option::is_none")]
65 pub voltage_regulation_range: Option<f64>,
66 #[serde(skip_serializing_if = "Option::is_none")]
68 pub x0: Option<f64>,
69 #[serde(skip_serializing_if = "Option::is_none")]
71 pub x2: Option<f64>,
72}
73impl crate::base::CimElement for SynchronousMachine {
74 fn mrid(&self) -> &str { &self.base.base.base.base.base.base.base.id }
75 fn type_name(&self) -> &'static str { "SynchronousMachine" }
76 fn as_any(&self) -> &dyn std::any::Any { self }
77 fn to_json_value(&self) -> serde_json::Value {
78 serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
79 }
80 fn to_block(&self) -> crate::base::RdfBlock {
81 let mut block = self.base.to_block();
82 block.type_name = "SynchronousMachine".to_string();
83 if let Some(ref v) = self.initial_reactive_capability_curve {
84 block.fields.insert("SynchronousMachine.InitialReactiveCapabilityCurve".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
85 }
86 if let Some(v) = self.earthing {
87 block.fields.insert("SynchronousMachine.earthing".into(), crate::base::FieldValue::Text(v.to_string()));
88 }
89 if let Some(v) = self.earthing_star_point_r {
90 block.fields.insert("SynchronousMachine.earthingStarPointR".into(), crate::base::FieldValue::Text(v.to_string()));
91 }
92 if let Some(v) = self.earthing_star_point_x {
93 block.fields.insert("SynchronousMachine.earthingStarPointX".into(), crate::base::FieldValue::Text(v.to_string()));
94 }
95 if let Some(v) = self.ikk {
96 block.fields.insert("SynchronousMachine.ikk".into(), crate::base::FieldValue::Text(v.to_string()));
97 }
98 if let Some(v) = self.max_q {
99 block.fields.insert("SynchronousMachine.maxQ".into(), crate::base::FieldValue::Text(v.to_string()));
100 }
101 if let Some(v) = self.min_q {
102 block.fields.insert("SynchronousMachine.minQ".into(), crate::base::FieldValue::Text(v.to_string()));
103 }
104 if let Some(v) = self.mu {
105 block.fields.insert("SynchronousMachine.mu".into(), crate::base::FieldValue::Text(v.to_string()));
106 }
107 if let Some(ref v) = self.operating_mode {
108 block.fields.insert("SynchronousMachine.operatingMode".into(), crate::base::FieldValue::Resource(v.uri.clone()));
109 }
110 if let Some(v) = self.q_percent {
111 block.fields.insert("SynchronousMachine.qPercent".into(), crate::base::FieldValue::Text(v.to_string()));
112 }
113 if let Some(v) = self.r {
114 block.fields.insert("SynchronousMachine.r".into(), crate::base::FieldValue::Text(v.to_string()));
115 }
116 if let Some(v) = self.r0 {
117 block.fields.insert("SynchronousMachine.r0".into(), crate::base::FieldValue::Text(v.to_string()));
118 }
119 if let Some(v) = self.r2 {
120 block.fields.insert("SynchronousMachine.r2".into(), crate::base::FieldValue::Text(v.to_string()));
121 }
122 if let Some(v) = self.reference_priority {
123 block.fields.insert("SynchronousMachine.referencePriority".into(), crate::base::FieldValue::Text(v.to_string()));
124 }
125 if let Some(v) = self.sat_direct_subtrans_x {
126 block.fields.insert("SynchronousMachine.satDirectSubtransX".into(), crate::base::FieldValue::Text(v.to_string()));
127 }
128 if let Some(v) = self.sat_direct_sync_x {
129 block.fields.insert("SynchronousMachine.satDirectSyncX".into(), crate::base::FieldValue::Text(v.to_string()));
130 }
131 if let Some(v) = self.sat_direct_trans_x {
132 block.fields.insert("SynchronousMachine.satDirectTransX".into(), crate::base::FieldValue::Text(v.to_string()));
133 }
134 if let Some(ref v) = self.short_circuit_rotor_type {
135 block.fields.insert("SynchronousMachine.shortCircuitRotorType".into(), crate::base::FieldValue::Resource(v.uri.clone()));
136 }
137 if let Some(ref v) = self.type_ {
138 block.fields.insert("SynchronousMachine.type".into(), crate::base::FieldValue::Resource(v.uri.clone()));
139 }
140 if let Some(v) = self.voltage_regulation_range {
141 block.fields.insert("SynchronousMachine.voltageRegulationRange".into(), crate::base::FieldValue::Text(v.to_string()));
142 }
143 if let Some(v) = self.x0 {
144 block.fields.insert("SynchronousMachine.x0".into(), crate::base::FieldValue::Text(v.to_string()));
145 }
146 if let Some(v) = self.x2 {
147 block.fields.insert("SynchronousMachine.x2".into(), crate::base::FieldValue::Text(v.to_string()));
148 }
149 block
150 }
151}
152
153impl SynchronousMachine {
154 pub fn from_block(b: &crate::base::RdfBlock) -> Self {
155 let mut obj = Self::default();
156 obj.base.base.base.base.base.base.base.id.clone_from(&b.mrid);
157 for (key, val) in &b.fields {
158 match key.as_str() {
159 "SynchronousMachine.InitialReactiveCapabilityCurve" => {
160 if let crate::base::FieldValue::Resource(sv) = val {
161 obj.initial_reactive_capability_curve = Some(crate::base::MridRef { mrid: sv.clone() });
162 }
163 }
164 "SynchronousMachine.earthing" => {
165 match val {
166 crate::base::FieldValue::Text(sv) => { obj.earthing = Some(sv.trim() == "true"); }
167 crate::base::FieldValue::TextList(svs) => {
168 if let Some(sv) = svs.last() { obj.earthing = Some(sv.trim() == "true"); }
169 }
170 _ => {}
171 }
172 }
173 "SynchronousMachine.earthingStarPointR" => {
174 match val {
175 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.earthing_star_point_r = Some(v); } }
176 crate::base::FieldValue::TextList(svs) => {
177 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.earthing_star_point_r = Some(v); } }
178 }
179 _ => {}
180 }
181 }
182 "SynchronousMachine.earthingStarPointX" => {
183 match val {
184 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.earthing_star_point_x = Some(v); } }
185 crate::base::FieldValue::TextList(svs) => {
186 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.earthing_star_point_x = Some(v); } }
187 }
188 _ => {}
189 }
190 }
191 "SynchronousMachine.ikk" => {
192 match val {
193 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ikk = Some(v); } }
194 crate::base::FieldValue::TextList(svs) => {
195 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ikk = Some(v); } }
196 }
197 _ => {}
198 }
199 }
200 "SynchronousMachine.maxQ" => {
201 match val {
202 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.max_q = Some(v); } }
203 crate::base::FieldValue::TextList(svs) => {
204 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.max_q = Some(v); } }
205 }
206 _ => {}
207 }
208 }
209 "SynchronousMachine.minQ" => {
210 match val {
211 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.min_q = Some(v); } }
212 crate::base::FieldValue::TextList(svs) => {
213 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.min_q = Some(v); } }
214 }
215 _ => {}
216 }
217 }
218 "SynchronousMachine.mu" => {
219 match val {
220 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.mu = Some(v); } }
221 crate::base::FieldValue::TextList(svs) => {
222 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.mu = Some(v); } }
223 }
224 _ => {}
225 }
226 }
227 "SynchronousMachine.operatingMode" => {
228 if let crate::base::FieldValue::Resource(sv) = val {
229 obj.operating_mode = Some(crate::base::UriRef { uri: sv.clone() });
230 }
231 }
232 "SynchronousMachine.qPercent" => {
233 match val {
234 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.q_percent = Some(v); } }
235 crate::base::FieldValue::TextList(svs) => {
236 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.q_percent = Some(v); } }
237 }
238 _ => {}
239 }
240 }
241 "SynchronousMachine.r" => {
242 match val {
243 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
244 crate::base::FieldValue::TextList(svs) => {
245 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
246 }
247 _ => {}
248 }
249 }
250 "SynchronousMachine.r0" => {
251 match val {
252 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r0 = Some(v); } }
253 crate::base::FieldValue::TextList(svs) => {
254 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r0 = Some(v); } }
255 }
256 _ => {}
257 }
258 }
259 "SynchronousMachine.r2" => {
260 match val {
261 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r2 = Some(v); } }
262 crate::base::FieldValue::TextList(svs) => {
263 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r2 = Some(v); } }
264 }
265 _ => {}
266 }
267 }
268 "SynchronousMachine.referencePriority" => {
269 match val {
270 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.reference_priority = Some(v); } }
271 crate::base::FieldValue::TextList(svs) => {
272 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.reference_priority = Some(v); } }
273 }
274 _ => {}
275 }
276 }
277 "SynchronousMachine.satDirectSubtransX" => {
278 match val {
279 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.sat_direct_subtrans_x = Some(v); } }
280 crate::base::FieldValue::TextList(svs) => {
281 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.sat_direct_subtrans_x = Some(v); } }
282 }
283 _ => {}
284 }
285 }
286 "SynchronousMachine.satDirectSyncX" => {
287 match val {
288 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.sat_direct_sync_x = Some(v); } }
289 crate::base::FieldValue::TextList(svs) => {
290 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.sat_direct_sync_x = Some(v); } }
291 }
292 _ => {}
293 }
294 }
295 "SynchronousMachine.satDirectTransX" => {
296 match val {
297 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.sat_direct_trans_x = Some(v); } }
298 crate::base::FieldValue::TextList(svs) => {
299 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.sat_direct_trans_x = Some(v); } }
300 }
301 _ => {}
302 }
303 }
304 "SynchronousMachine.shortCircuitRotorType" => {
305 if let crate::base::FieldValue::Resource(sv) = val {
306 obj.short_circuit_rotor_type = Some(crate::base::UriRef { uri: sv.clone() });
307 }
308 }
309 "SynchronousMachine.type" => {
310 if let crate::base::FieldValue::Resource(sv) = val {
311 obj.type_ = Some(crate::base::UriRef { uri: sv.clone() });
312 }
313 }
314 "SynchronousMachine.voltageRegulationRange" => {
315 match val {
316 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.voltage_regulation_range = Some(v); } }
317 crate::base::FieldValue::TextList(svs) => {
318 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.voltage_regulation_range = Some(v); } }
319 }
320 _ => {}
321 }
322 }
323 "SynchronousMachine.x0" => {
324 match val {
325 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x0 = Some(v); } }
326 crate::base::FieldValue::TextList(svs) => {
327 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x0 = Some(v); } }
328 }
329 _ => {}
330 }
331 }
332 "SynchronousMachine.x2" => {
333 match val {
334 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x2 = Some(v); } }
335 crate::base::FieldValue::TextList(svs) => {
336 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x2 = Some(v); } }
337 }
338 _ => {}
339 }
340 }
341 "RotatingMachine.GeneratingUnit" => {
342 if let crate::base::FieldValue::Resource(sv) = val {
343 obj.base.generating_unit = Some(crate::base::MridRef { mrid: sv.clone() });
344 }
345 }
346 "RotatingMachine.p" => {
347 match val {
348 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.p = Some(v); } }
349 crate::base::FieldValue::TextList(svs) => {
350 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.p = Some(v); } }
351 }
352 _ => {}
353 }
354 }
355 "RotatingMachine.q" => {
356 match val {
357 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.q = Some(v); } }
358 crate::base::FieldValue::TextList(svs) => {
359 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.q = Some(v); } }
360 }
361 _ => {}
362 }
363 }
364 "RotatingMachine.ratedPowerFactor" => {
365 match val {
366 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.rated_power_factor = Some(v); } }
367 crate::base::FieldValue::TextList(svs) => {
368 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.rated_power_factor = Some(v); } }
369 }
370 _ => {}
371 }
372 }
373 "RotatingMachine.ratedS" => {
374 match val {
375 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.rated_s = Some(v); } }
376 crate::base::FieldValue::TextList(svs) => {
377 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.rated_s = Some(v); } }
378 }
379 _ => {}
380 }
381 }
382 "RotatingMachine.ratedU" => {
383 match val {
384 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.rated_u = Some(v); } }
385 crate::base::FieldValue::TextList(svs) => {
386 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.rated_u = Some(v); } }
387 }
388 _ => {}
389 }
390 }
391 "RegulatingCondEq.RegulatingControl" => {
392 if let crate::base::FieldValue::Resource(sv) = val {
393 obj.base.base.regulating_control = Some(crate::base::MridRef { mrid: sv.clone() });
394 }
395 }
396 "RegulatingCondEq.controlEnabled" => {
397 match val {
398 crate::base::FieldValue::Text(sv) => { obj.base.base.control_enabled = Some(sv.trim() == "true"); }
399 crate::base::FieldValue::TextList(svs) => {
400 if let Some(sv) = svs.last() { obj.base.base.control_enabled = Some(sv.trim() == "true"); }
401 }
402 _ => {}
403 }
404 }
405 "ConductingEquipment.BaseVoltage" => {
406 if let crate::base::FieldValue::Resource(sv) = val {
407 obj.base.base.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
408 }
409 }
410 "Equipment.EquipmentContainer" => {
411 if let crate::base::FieldValue::Resource(sv) = val {
412 obj.base.base.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
413 }
414 }
415 "Equipment.aggregate" => {
416 match val {
417 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.aggregate = Some(sv.trim() == "true"); }
418 crate::base::FieldValue::TextList(svs) => {
419 if let Some(sv) = svs.last() { obj.base.base.base.base.base.aggregate = Some(sv.trim() == "true"); }
420 }
421 _ => {}
422 }
423 }
424 "Equipment.inService" => {
425 match val {
426 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.in_service = Some(sv.trim() == "true"); }
427 crate::base::FieldValue::TextList(svs) => {
428 if let Some(sv) = svs.last() { obj.base.base.base.base.base.in_service = Some(sv.trim() == "true"); }
429 }
430 _ => {}
431 }
432 }
433 "Equipment.normallyInService" => {
434 match val {
435 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
436 crate::base::FieldValue::TextList(svs) => {
437 if let Some(sv) = svs.last() { obj.base.base.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
438 }
439 _ => {}
440 }
441 }
442 "IdentifiedObject.description" => {
443 match val {
444 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.description = sv.clone(); }
445 crate::base::FieldValue::TextList(svs) => {
446 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.description = sv.clone(); }
447 }
448 _ => {}
449 }
450 }
451 "IdentifiedObject.energyIdentCodeEic" => {
452 match val {
453 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
454 crate::base::FieldValue::TextList(svs) => {
455 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
456 }
457 _ => {}
458 }
459 }
460 "IdentifiedObject.mRID" => {
461 match val {
462 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.m_rid = sv.clone(); }
463 crate::base::FieldValue::TextList(svs) => {
464 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.m_rid = sv.clone(); }
465 }
466 _ => {}
467 }
468 }
469 "IdentifiedObject.name" => {
470 match val {
471 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.name = sv.clone(); }
472 crate::base::FieldValue::TextList(svs) => {
473 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.name = sv.clone(); }
474 }
475 _ => {}
476 }
477 }
478 "IdentifiedObject.shortName" => {
479 match val {
480 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.base.short_name = sv.clone(); }
481 crate::base::FieldValue::TextList(svs) => {
482 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.base.short_name = sv.clone(); }
483 }
484 _ => {}
485 }
486 }
487 _ => {}
488 }
489 }
490 obj
491 }
492}