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