Skip to main content

cimstructs/
GovHydroPID2.rs

1/// Hydro turbine and governor. Represents plants with straightforward penstock configurations and 'three term' electro-hydraulic governors (i.e. WoodwardTM electronic). [Footnote: Woodward electronic governors are an example of suitable products available commercially. This information is given for the convenience of users of this document and does not constitute an endorsement by IEC of these products.]
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct GovHydroPID2 {
4    #[serde(flatten)]
5    pub base: super::TurbineGovernorDynamics,
6    /// Factor multiplying Tw (Atw). Typical value = 0.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub atw: Option<f64>,
9    /// Turbine damping factor (D). Unit = delta P / delta speed. Typical value = 0.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub d: Option<f64>,
12    /// Feedback signal type flag (Flag). true = use gate position feedback signal false = use Pe.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub feedback_signal: Option<bool>,
15    /// Gate opening at speed no load (G0). Typical value = 0.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub g0: Option<f64>,
18    /// Intermediate gate opening (G1). Typical value = 0.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub g1: Option<f64>,
21    /// Intermediate gate opening (G2). Typical value = 0.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub g2: Option<f64>,
24    /// Maximum gate opening (Gmax) (> GovHydroPID2.gmin). Typical value = 0.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub gmax: Option<f64>,
27    /// Minimum gate opening (Gmin) (> GovHydroPID2.gmax). Typical value = 0.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub gmin: Option<f64>,
30    /// Derivative gain (Kd). Typical value = 0.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub kd: Option<f64>,
33    /// Reset gain (Ki). Unit = PU/s. Typical value = 0.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub ki: Option<f64>,
36    /// Proportional gain (Kp). Typical value = 0.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub kp: Option<f64>,
39    /// Base for power values (MWbase) (>0). Unit = MW.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub mwbase: Option<f64>,
42    /// Power at gate opening G1 (P1). Typical value = 0.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub p1: Option<f64>,
45    /// Power at gate opening G2 (P2). Typical value = 0.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub p2: Option<f64>,
48    /// Power at full opened gate (P3). Typical value = 0.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub p3: Option<f64>,
51    /// Permanent drop (Rperm). Typical value = 0.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub rperm: Option<f64>,
54    /// Controller time constant (Ta) (>= 0). Typical value = 0.
55    #[serde(skip_serializing_if = "Option::is_none")]
56    pub ta: Option<f64>,
57    /// Gate servo time constant (Tb) (> 0).
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub tb: Option<f64>,
60    /// Speed detector time constant (Treg) (>= 0). Typical value = 0.
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub treg: Option<f64>,
63    /// Water inertia time constant (Tw) (>= 0). Typical value = 0.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub tw: Option<f64>,
66    /// Maximum gate opening velocity (Velmax) (< GovHydroPID2.velmin). Unit = PU / s. Typical value = 0.
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub velmax: Option<f64>,
69    /// Maximum gate closing velocity (Velmin) (> GovHydroPID2.velmax). Unit = PU / s. Typical value = 0.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub velmin: Option<f64>,
72}
73impl crate::base::CimElement for GovHydroPID2 {
74    fn mrid(&self) -> &str { &self.base.base.base.id }
75    fn type_name(&self) -> &'static str { "GovHydroPID2" }
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 = "GovHydroPID2".to_string();
83        if let Some(v) = self.atw {
84            block.fields.insert("GovHydroPID2.atw".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.d {
87            block.fields.insert("GovHydroPID2.d".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.feedback_signal {
90            block.fields.insert("GovHydroPID2.feedbackSignal".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.g0 {
93            block.fields.insert("GovHydroPID2.g0".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.g1 {
96            block.fields.insert("GovHydroPID2.g1".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.g2 {
99            block.fields.insert("GovHydroPID2.g2".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.gmax {
102            block.fields.insert("GovHydroPID2.gmax".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.gmin {
105            block.fields.insert("GovHydroPID2.gmin".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.kd {
108            block.fields.insert("GovHydroPID2.kd".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.ki {
111            block.fields.insert("GovHydroPID2.ki".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        if let Some(v) = self.kp {
114            block.fields.insert("GovHydroPID2.kp".into(), crate::base::FieldValue::Text(v.to_string()));
115        }
116        if let Some(v) = self.mwbase {
117            block.fields.insert("GovHydroPID2.mwbase".into(), crate::base::FieldValue::Text(v.to_string()));
118        }
119        if let Some(v) = self.p1 {
120            block.fields.insert("GovHydroPID2.p1".into(), crate::base::FieldValue::Text(v.to_string()));
121        }
122        if let Some(v) = self.p2 {
123            block.fields.insert("GovHydroPID2.p2".into(), crate::base::FieldValue::Text(v.to_string()));
124        }
125        if let Some(v) = self.p3 {
126            block.fields.insert("GovHydroPID2.p3".into(), crate::base::FieldValue::Text(v.to_string()));
127        }
128        if let Some(v) = self.rperm {
129            block.fields.insert("GovHydroPID2.rperm".into(), crate::base::FieldValue::Text(v.to_string()));
130        }
131        if let Some(v) = self.ta {
132            block.fields.insert("GovHydroPID2.ta".into(), crate::base::FieldValue::Text(v.to_string()));
133        }
134        if let Some(v) = self.tb {
135            block.fields.insert("GovHydroPID2.tb".into(), crate::base::FieldValue::Text(v.to_string()));
136        }
137        if let Some(v) = self.treg {
138            block.fields.insert("GovHydroPID2.treg".into(), crate::base::FieldValue::Text(v.to_string()));
139        }
140        if let Some(v) = self.tw {
141            block.fields.insert("GovHydroPID2.tw".into(), crate::base::FieldValue::Text(v.to_string()));
142        }
143        if let Some(v) = self.velmax {
144            block.fields.insert("GovHydroPID2.velmax".into(), crate::base::FieldValue::Text(v.to_string()));
145        }
146        if let Some(v) = self.velmin {
147            block.fields.insert("GovHydroPID2.velmin".into(), crate::base::FieldValue::Text(v.to_string()));
148        }
149        block
150    }
151}
152
153impl GovHydroPID2 {
154    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
155        let mut obj = Self::default();
156        obj.base.base.base.id.clone_from(&b.mrid);
157        for (key, val) in &b.fields {
158            match key.as_str() {
159                "GovHydroPID2.atw" => {
160                    match val {
161                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.atw = Some(v); } }
162                        crate::base::FieldValue::TextList(svs) => {
163                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.atw = Some(v); } }
164                        }
165                        _ => {}
166                    }
167                }
168                "GovHydroPID2.d" => {
169                    match val {
170                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.d = Some(v); } }
171                        crate::base::FieldValue::TextList(svs) => {
172                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.d = Some(v); } }
173                        }
174                        _ => {}
175                    }
176                }
177                "GovHydroPID2.feedbackSignal" => {
178                    match val {
179                        crate::base::FieldValue::Text(sv) => { obj.feedback_signal = Some(sv.trim() == "true"); }
180                        crate::base::FieldValue::TextList(svs) => {
181                            if let Some(sv) = svs.last() { obj.feedback_signal = Some(sv.trim() == "true"); }
182                        }
183                        _ => {}
184                    }
185                }
186                "GovHydroPID2.g0" => {
187                    match val {
188                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.g0 = Some(v); } }
189                        crate::base::FieldValue::TextList(svs) => {
190                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.g0 = Some(v); } }
191                        }
192                        _ => {}
193                    }
194                }
195                "GovHydroPID2.g1" => {
196                    match val {
197                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.g1 = Some(v); } }
198                        crate::base::FieldValue::TextList(svs) => {
199                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.g1 = Some(v); } }
200                        }
201                        _ => {}
202                    }
203                }
204                "GovHydroPID2.g2" => {
205                    match val {
206                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.g2 = Some(v); } }
207                        crate::base::FieldValue::TextList(svs) => {
208                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.g2 = Some(v); } }
209                        }
210                        _ => {}
211                    }
212                }
213                "GovHydroPID2.gmax" => {
214                    match val {
215                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.gmax = Some(v); } }
216                        crate::base::FieldValue::TextList(svs) => {
217                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.gmax = Some(v); } }
218                        }
219                        _ => {}
220                    }
221                }
222                "GovHydroPID2.gmin" => {
223                    match val {
224                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.gmin = Some(v); } }
225                        crate::base::FieldValue::TextList(svs) => {
226                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.gmin = Some(v); } }
227                        }
228                        _ => {}
229                    }
230                }
231                "GovHydroPID2.kd" => {
232                    match val {
233                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kd = Some(v); } }
234                        crate::base::FieldValue::TextList(svs) => {
235                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kd = Some(v); } }
236                        }
237                        _ => {}
238                    }
239                }
240                "GovHydroPID2.ki" => {
241                    match val {
242                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
243                        crate::base::FieldValue::TextList(svs) => {
244                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
245                        }
246                        _ => {}
247                    }
248                }
249                "GovHydroPID2.kp" => {
250                    match val {
251                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
252                        crate::base::FieldValue::TextList(svs) => {
253                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
254                        }
255                        _ => {}
256                    }
257                }
258                "GovHydroPID2.mwbase" => {
259                    match val {
260                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.mwbase = Some(v); } }
261                        crate::base::FieldValue::TextList(svs) => {
262                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.mwbase = Some(v); } }
263                        }
264                        _ => {}
265                    }
266                }
267                "GovHydroPID2.p1" => {
268                    match val {
269                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.p1 = Some(v); } }
270                        crate::base::FieldValue::TextList(svs) => {
271                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.p1 = Some(v); } }
272                        }
273                        _ => {}
274                    }
275                }
276                "GovHydroPID2.p2" => {
277                    match val {
278                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.p2 = Some(v); } }
279                        crate::base::FieldValue::TextList(svs) => {
280                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.p2 = Some(v); } }
281                        }
282                        _ => {}
283                    }
284                }
285                "GovHydroPID2.p3" => {
286                    match val {
287                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.p3 = Some(v); } }
288                        crate::base::FieldValue::TextList(svs) => {
289                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.p3 = Some(v); } }
290                        }
291                        _ => {}
292                    }
293                }
294                "GovHydroPID2.rperm" => {
295                    match val {
296                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rperm = Some(v); } }
297                        crate::base::FieldValue::TextList(svs) => {
298                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rperm = Some(v); } }
299                        }
300                        _ => {}
301                    }
302                }
303                "GovHydroPID2.ta" => {
304                    match val {
305                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
306                        crate::base::FieldValue::TextList(svs) => {
307                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ta = Some(v); } }
308                        }
309                        _ => {}
310                    }
311                }
312                "GovHydroPID2.tb" => {
313                    match val {
314                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
315                        crate::base::FieldValue::TextList(svs) => {
316                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tb = Some(v); } }
317                        }
318                        _ => {}
319                    }
320                }
321                "GovHydroPID2.treg" => {
322                    match val {
323                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.treg = Some(v); } }
324                        crate::base::FieldValue::TextList(svs) => {
325                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.treg = Some(v); } }
326                        }
327                        _ => {}
328                    }
329                }
330                "GovHydroPID2.tw" => {
331                    match val {
332                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tw = Some(v); } }
333                        crate::base::FieldValue::TextList(svs) => {
334                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tw = Some(v); } }
335                        }
336                        _ => {}
337                    }
338                }
339                "GovHydroPID2.velmax" => {
340                    match val {
341                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.velmax = Some(v); } }
342                        crate::base::FieldValue::TextList(svs) => {
343                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.velmax = Some(v); } }
344                        }
345                        _ => {}
346                    }
347                }
348                "GovHydroPID2.velmin" => {
349                    match val {
350                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.velmin = Some(v); } }
351                        crate::base::FieldValue::TextList(svs) => {
352                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.velmin = Some(v); } }
353                        }
354                        _ => {}
355                    }
356                }
357                "TurbineGovernorDynamics.AsynchronousMachineDynamics" => {
358                    if let crate::base::FieldValue::Resource(sv) = val {
359                        obj.base.asynchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
360                    }
361                }
362                "TurbineGovernorDynamics.SynchronousMachineDynamics" => {
363                    if let crate::base::FieldValue::Resource(sv) = val {
364                        obj.base.synchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
365                    }
366                }
367                "DynamicsFunctionBlock.enabled" => {
368                    match val {
369                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
370                        crate::base::FieldValue::TextList(svs) => {
371                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
372                        }
373                        _ => {}
374                    }
375                }
376                "IdentifiedObject.description" => {
377                    match val {
378                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
379                        crate::base::FieldValue::TextList(svs) => {
380                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
381                        }
382                        _ => {}
383                    }
384                }
385                "IdentifiedObject.energyIdentCodeEic" => {
386                    match val {
387                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
388                        crate::base::FieldValue::TextList(svs) => {
389                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
390                        }
391                        _ => {}
392                    }
393                }
394                "IdentifiedObject.mRID" => {
395                    match val {
396                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
397                        crate::base::FieldValue::TextList(svs) => {
398                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
399                        }
400                        _ => {}
401                    }
402                }
403                "IdentifiedObject.name" => {
404                    match val {
405                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
406                        crate::base::FieldValue::TextList(svs) => {
407                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
408                        }
409                        _ => {}
410                    }
411                }
412                "IdentifiedObject.shortName" => {
413                    match val {
414                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
415                        crate::base::FieldValue::TextList(svs) => {
416                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
417                        }
418                        _ => {}
419                    }
420                }
421                _ => {}
422            }
423        }
424        obj
425    }
426}