Skip to main content

cimstructs/
GrossToNetActivePowerCurve.rs

1/// Relationship between the generating unit's gross active power output on the X-axis (measured at the terminals of the machine(s)) and the generating unit's net active power output on the Y-axis (based on utility-defined measurements at the power station). Station service loads, when modelled, should be treated as non-conforming bus loads. There may be more than one curve, depending on the auxiliary equipment that is in service.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct GrossToNetActivePowerCurve {
4    #[serde(flatten)]
5    pub base: super::Curve,
6    /// A generating unit may have a gross active power to net active power curve, describing the losses and auxiliary power requirements of the unit.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub generating_unit: Option<super::base::MridRef>,
9}
10impl crate::base::CimElement for GrossToNetActivePowerCurve {
11    fn mrid(&self) -> &str { &self.base.base.id }
12    fn type_name(&self) -> &'static str { "GrossToNetActivePowerCurve" }
13    fn as_any(&self) -> &dyn std::any::Any { self }
14    fn to_json_value(&self) -> serde_json::Value {
15        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
16    }
17    fn to_block(&self) -> crate::base::RdfBlock {
18        let mut block = self.base.to_block();
19        block.type_name = "GrossToNetActivePowerCurve".to_string();
20        if let Some(ref v) = self.generating_unit {
21            block.fields.insert("GrossToNetActivePowerCurve.GeneratingUnit".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
22        }
23        block
24    }
25}
26
27impl GrossToNetActivePowerCurve {
28    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
29        let mut obj = Self::default();
30        obj.base.base.id.clone_from(&b.mrid);
31        for (key, val) in &b.fields {
32            match key.as_str() {
33                "GrossToNetActivePowerCurve.GeneratingUnit" => {
34                    if let crate::base::FieldValue::Resource(sv) = val {
35                        obj.generating_unit = Some(crate::base::MridRef { mrid: sv.clone() });
36                    }
37                }
38                "Curve.curveStyle" => {
39                    if let crate::base::FieldValue::Resource(sv) = val {
40                        obj.base.curve_style = Some(crate::base::UriRef { uri: sv.clone() });
41                    }
42                }
43                "Curve.xUnit" => {
44                    if let crate::base::FieldValue::Resource(sv) = val {
45                        obj.base.x_unit = Some(crate::base::UriRef { uri: sv.clone() });
46                    }
47                }
48                "Curve.y1Unit" => {
49                    if let crate::base::FieldValue::Resource(sv) = val {
50                        obj.base.y1unit = Some(crate::base::UriRef { uri: sv.clone() });
51                    }
52                }
53                "Curve.y2Unit" => {
54                    if let crate::base::FieldValue::Resource(sv) = val {
55                        obj.base.y2unit = Some(crate::base::UriRef { uri: sv.clone() });
56                    }
57                }
58                "IdentifiedObject.description" => {
59                    match val {
60                        crate::base::FieldValue::Text(sv) => { obj.base.base.description = sv.clone(); }
61                        crate::base::FieldValue::TextList(svs) => {
62                            if let Some(sv) = svs.last() { obj.base.base.description = sv.clone(); }
63                        }
64                        _ => {}
65                    }
66                }
67                "IdentifiedObject.energyIdentCodeEic" => {
68                    match val {
69                        crate::base::FieldValue::Text(sv) => { obj.base.base.energy_ident_code_eic = sv.clone(); }
70                        crate::base::FieldValue::TextList(svs) => {
71                            if let Some(sv) = svs.last() { obj.base.base.energy_ident_code_eic = sv.clone(); }
72                        }
73                        _ => {}
74                    }
75                }
76                "IdentifiedObject.mRID" => {
77                    match val {
78                        crate::base::FieldValue::Text(sv) => { obj.base.base.m_rid = sv.clone(); }
79                        crate::base::FieldValue::TextList(svs) => {
80                            if let Some(sv) = svs.last() { obj.base.base.m_rid = sv.clone(); }
81                        }
82                        _ => {}
83                    }
84                }
85                "IdentifiedObject.name" => {
86                    match val {
87                        crate::base::FieldValue::Text(sv) => { obj.base.base.name = sv.clone(); }
88                        crate::base::FieldValue::TextList(svs) => {
89                            if let Some(sv) = svs.last() { obj.base.base.name = sv.clone(); }
90                        }
91                        _ => {}
92                    }
93                }
94                "IdentifiedObject.shortName" => {
95                    match val {
96                        crate::base::FieldValue::Text(sv) => { obj.base.base.short_name = sv.clone(); }
97                        crate::base::FieldValue::TextList(svs) => {
98                            if let Some(sv) = svs.last() { obj.base.base.short_name = sv.clone(); }
99                        }
100                        _ => {}
101                    }
102                }
103                _ => {}
104            }
105        }
106        obj
107    }
108}