Skip to main content

cimstructs/
GeneratingUnit.rs

1/// A single or set of synchronous machines for converting mechanical power into alternating-current power. For example, individual machines within a set may be defined for scheduling purposes while a single control signal is derived for the set. In this case there would be a GeneratingUnit for each member of the set and an additional GeneratingUnit corresponding to the set.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct GeneratingUnit {
4    #[serde(flatten)]
5    pub base: super::Equipment,
6    /// The source of controls for a generating unit. Defines the control status of the generating unit.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub gen_control_source: Option<super::base::UriRef>,
9    /// Governor Speed Changer Droop. This is the change in generator power output divided by the change in frequency normalized by the nominal power of the generator and the nominal frequency and expressed in percent and negated. A positive value of speed change droop provides additional generator output upon a drop in frequency.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub governor_scd: Option<f64>,
12    /// Generating unit long term economic participation factor.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub long_pf: Option<f64>,
15    /// This is the maximum operating active power limit the dispatcher can enter for this unit.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub max_operating_p: Option<f64>,
18    /// Maximum allowable spinning reserve. Spinning reserve will never be considered greater than this value regardless of the current operating point.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub maximum_allowable_spinning_reserve: Option<f64>,
21    /// This is the minimum operating active power limit the dispatcher can enter for this unit.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub min_operating_p: Option<f64>,
24    /// The nominal power of the generating unit. Used to give precise meaning to percentage based attributes such as the governor speed change droop (governorSCD attribute). The attribute shall be a positive value equal to or less than RotatingMachine.ratedS.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub nominal_p: Option<f64>,
27    /// Generating unit economic participation factor. The sum of the participation factors across generating units does not have to sum to one. It is used for representing distributed slack participation factor. The attribute shall be a positive value or zero.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub normal_pf: Option<f64>,
30    /// The unit's gross rated maximum capacity (book value). The attribute shall be a positive value.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub rated_gross_max_p: Option<f64>,
33    /// The gross rated minimum generation level which the unit can safely operate at while delivering power to the transmission grid. The attribute shall be a positive value.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub rated_gross_min_p: Option<f64>,
36    /// The net rated maximum capacity determined by subtracting the auxiliary power used to operate the internal plant machinery from the rated gross maximum capacity. The attribute shall be a positive value.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub rated_net_max_p: Option<f64>,
39    /// Generating unit short term economic participation factor.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub short_pf: Option<f64>,
42    /// The initial startup cost incurred for each start of the GeneratingUnit.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub startup_cost: Option<f64>,
45    /// Time it takes to get the unit on-line, from the time that the prime mover mechanical power is applied.
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub startup_time: Option<f64>,
48    /// The efficiency of the unit in converting the fuel into electrical energy.
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub total_efficiency: Option<f64>,
51    /// The variable cost component of production per unit of ActivePower.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub variable_cost: Option<f64>,
54}
55impl crate::base::CimElement for GeneratingUnit {
56    fn mrid(&self) -> &str { &self.base.base.base.id }
57    fn type_name(&self) -> &'static str { "GeneratingUnit" }
58    fn as_any(&self) -> &dyn std::any::Any { self }
59    fn to_json_value(&self) -> serde_json::Value {
60        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
61    }
62    fn to_block(&self) -> crate::base::RdfBlock {
63        let mut block = self.base.to_block();
64        block.type_name = "GeneratingUnit".to_string();
65        if let Some(ref v) = self.gen_control_source {
66            block.fields.insert("GeneratingUnit.genControlSource".into(), crate::base::FieldValue::Resource(v.uri.clone()));
67        }
68        if let Some(v) = self.governor_scd {
69            block.fields.insert("GeneratingUnit.governorSCD".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.long_pf {
72            block.fields.insert("GeneratingUnit.longPF".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.max_operating_p {
75            block.fields.insert("GeneratingUnit.maxOperatingP".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.maximum_allowable_spinning_reserve {
78            block.fields.insert("GeneratingUnit.maximumAllowableSpinningReserve".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.min_operating_p {
81            block.fields.insert("GeneratingUnit.minOperatingP".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        if let Some(v) = self.nominal_p {
84            block.fields.insert("GeneratingUnit.nominalP".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(v) = self.normal_pf {
87            block.fields.insert("GeneratingUnit.normalPF".into(), crate::base::FieldValue::Text(v.to_string()));
88        }
89        if let Some(v) = self.rated_gross_max_p {
90            block.fields.insert("GeneratingUnit.ratedGrossMaxP".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.rated_gross_min_p {
93            block.fields.insert("GeneratingUnit.ratedGrossMinP".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        if let Some(v) = self.rated_net_max_p {
96            block.fields.insert("GeneratingUnit.ratedNetMaxP".into(), crate::base::FieldValue::Text(v.to_string()));
97        }
98        if let Some(v) = self.short_pf {
99            block.fields.insert("GeneratingUnit.shortPF".into(), crate::base::FieldValue::Text(v.to_string()));
100        }
101        if let Some(v) = self.startup_cost {
102            block.fields.insert("GeneratingUnit.startupCost".into(), crate::base::FieldValue::Text(v.to_string()));
103        }
104        if let Some(v) = self.startup_time {
105            block.fields.insert("GeneratingUnit.startupTime".into(), crate::base::FieldValue::Text(v.to_string()));
106        }
107        if let Some(v) = self.total_efficiency {
108            block.fields.insert("GeneratingUnit.totalEfficiency".into(), crate::base::FieldValue::Text(v.to_string()));
109        }
110        if let Some(v) = self.variable_cost {
111            block.fields.insert("GeneratingUnit.variableCost".into(), crate::base::FieldValue::Text(v.to_string()));
112        }
113        block
114    }
115}
116
117impl GeneratingUnit {
118    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
119        let mut obj = Self::default();
120        obj.base.base.base.id.clone_from(&b.mrid);
121        for (key, val) in &b.fields {
122            match key.as_str() {
123                "GeneratingUnit.genControlSource" => {
124                    if let crate::base::FieldValue::Resource(sv) = val {
125                        obj.gen_control_source = Some(crate::base::UriRef { uri: sv.clone() });
126                    }
127                }
128                "GeneratingUnit.governorSCD" => {
129                    match val {
130                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.governor_scd = Some(v); } }
131                        crate::base::FieldValue::TextList(svs) => {
132                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.governor_scd = Some(v); } }
133                        }
134                        _ => {}
135                    }
136                }
137                "GeneratingUnit.longPF" => {
138                    match val {
139                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.long_pf = Some(v); } }
140                        crate::base::FieldValue::TextList(svs) => {
141                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.long_pf = Some(v); } }
142                        }
143                        _ => {}
144                    }
145                }
146                "GeneratingUnit.maxOperatingP" => {
147                    match val {
148                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.max_operating_p = Some(v); } }
149                        crate::base::FieldValue::TextList(svs) => {
150                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.max_operating_p = Some(v); } }
151                        }
152                        _ => {}
153                    }
154                }
155                "GeneratingUnit.maximumAllowableSpinningReserve" => {
156                    match val {
157                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.maximum_allowable_spinning_reserve = Some(v); } }
158                        crate::base::FieldValue::TextList(svs) => {
159                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.maximum_allowable_spinning_reserve = Some(v); } }
160                        }
161                        _ => {}
162                    }
163                }
164                "GeneratingUnit.minOperatingP" => {
165                    match val {
166                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.min_operating_p = Some(v); } }
167                        crate::base::FieldValue::TextList(svs) => {
168                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.min_operating_p = Some(v); } }
169                        }
170                        _ => {}
171                    }
172                }
173                "GeneratingUnit.nominalP" => {
174                    match val {
175                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.nominal_p = Some(v); } }
176                        crate::base::FieldValue::TextList(svs) => {
177                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.nominal_p = Some(v); } }
178                        }
179                        _ => {}
180                    }
181                }
182                "GeneratingUnit.normalPF" => {
183                    match val {
184                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.normal_pf = Some(v); } }
185                        crate::base::FieldValue::TextList(svs) => {
186                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.normal_pf = Some(v); } }
187                        }
188                        _ => {}
189                    }
190                }
191                "GeneratingUnit.ratedGrossMaxP" => {
192                    match val {
193                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rated_gross_max_p = Some(v); } }
194                        crate::base::FieldValue::TextList(svs) => {
195                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rated_gross_max_p = Some(v); } }
196                        }
197                        _ => {}
198                    }
199                }
200                "GeneratingUnit.ratedGrossMinP" => {
201                    match val {
202                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rated_gross_min_p = Some(v); } }
203                        crate::base::FieldValue::TextList(svs) => {
204                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rated_gross_min_p = Some(v); } }
205                        }
206                        _ => {}
207                    }
208                }
209                "GeneratingUnit.ratedNetMaxP" => {
210                    match val {
211                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rated_net_max_p = Some(v); } }
212                        crate::base::FieldValue::TextList(svs) => {
213                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rated_net_max_p = Some(v); } }
214                        }
215                        _ => {}
216                    }
217                }
218                "GeneratingUnit.shortPF" => {
219                    match val {
220                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.short_pf = Some(v); } }
221                        crate::base::FieldValue::TextList(svs) => {
222                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.short_pf = Some(v); } }
223                        }
224                        _ => {}
225                    }
226                }
227                "GeneratingUnit.startupCost" => {
228                    match val {
229                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.startup_cost = Some(v); } }
230                        crate::base::FieldValue::TextList(svs) => {
231                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.startup_cost = Some(v); } }
232                        }
233                        _ => {}
234                    }
235                }
236                "GeneratingUnit.startupTime" => {
237                    match val {
238                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.startup_time = Some(v); } }
239                        crate::base::FieldValue::TextList(svs) => {
240                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.startup_time = Some(v); } }
241                        }
242                        _ => {}
243                    }
244                }
245                "GeneratingUnit.totalEfficiency" => {
246                    match val {
247                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.total_efficiency = Some(v); } }
248                        crate::base::FieldValue::TextList(svs) => {
249                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.total_efficiency = Some(v); } }
250                        }
251                        _ => {}
252                    }
253                }
254                "GeneratingUnit.variableCost" => {
255                    match val {
256                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.variable_cost = Some(v); } }
257                        crate::base::FieldValue::TextList(svs) => {
258                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.variable_cost = Some(v); } }
259                        }
260                        _ => {}
261                    }
262                }
263                "Equipment.EquipmentContainer" => {
264                    if let crate::base::FieldValue::Resource(sv) = val {
265                        obj.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
266                    }
267                }
268                "Equipment.aggregate" => {
269                    match val {
270                        crate::base::FieldValue::Text(sv) => { obj.base.aggregate = Some(sv.trim() == "true"); }
271                        crate::base::FieldValue::TextList(svs) => {
272                            if let Some(sv) = svs.last() { obj.base.aggregate = Some(sv.trim() == "true"); }
273                        }
274                        _ => {}
275                    }
276                }
277                "Equipment.inService" => {
278                    match val {
279                        crate::base::FieldValue::Text(sv) => { obj.base.in_service = Some(sv.trim() == "true"); }
280                        crate::base::FieldValue::TextList(svs) => {
281                            if let Some(sv) = svs.last() { obj.base.in_service = Some(sv.trim() == "true"); }
282                        }
283                        _ => {}
284                    }
285                }
286                "Equipment.normallyInService" => {
287                    match val {
288                        crate::base::FieldValue::Text(sv) => { obj.base.normally_in_service = Some(sv.trim() == "true"); }
289                        crate::base::FieldValue::TextList(svs) => {
290                            if let Some(sv) = svs.last() { obj.base.normally_in_service = Some(sv.trim() == "true"); }
291                        }
292                        _ => {}
293                    }
294                }
295                "IdentifiedObject.description" => {
296                    match val {
297                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
298                        crate::base::FieldValue::TextList(svs) => {
299                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
300                        }
301                        _ => {}
302                    }
303                }
304                "IdentifiedObject.energyIdentCodeEic" => {
305                    match val {
306                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
307                        crate::base::FieldValue::TextList(svs) => {
308                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
309                        }
310                        _ => {}
311                    }
312                }
313                "IdentifiedObject.mRID" => {
314                    match val {
315                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
316                        crate::base::FieldValue::TextList(svs) => {
317                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
318                        }
319                        _ => {}
320                    }
321                }
322                "IdentifiedObject.name" => {
323                    match val {
324                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
325                        crate::base::FieldValue::TextList(svs) => {
326                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
327                        }
328                        _ => {}
329                    }
330                }
331                "IdentifiedObject.shortName" => {
332                    match val {
333                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
334                        crate::base::FieldValue::TextList(svs) => {
335                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
336                        }
337                        _ => {}
338                    }
339                }
340                _ => {}
341            }
342        }
343        obj
344    }
345}