Skip to main content

cimstructs/
CogenerationPlant.rs

1/// A set of thermal generating units for the production of electrical energy and process steam (usually from the output of the steam turbines). The steam sendout is typically used for industrial purposes or for municipal heating and cooling.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct CogenerationPlant {
4    #[serde(flatten)]
5    pub base: super::PowerSystemResource,
6}
7impl crate::base::CimElement for CogenerationPlant {
8    fn mrid(&self) -> &str { &self.base.base.id }
9    fn type_name(&self) -> &'static str { "CogenerationPlant" }
10    fn as_any(&self) -> &dyn std::any::Any { self }
11    fn to_json_value(&self) -> serde_json::Value {
12        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
13    }
14    fn to_block(&self) -> crate::base::RdfBlock {
15        let mut block = self.base.to_block();
16        block.type_name = "CogenerationPlant".to_string();
17        block
18    }
19}
20
21impl CogenerationPlant {
22    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
23        let mut obj = Self::default();
24        obj.base.base.id.clone_from(&b.mrid);
25        for (key, val) in &b.fields {
26            match key.as_str() {
27                "IdentifiedObject.description" => {
28                    match val {
29                        crate::base::FieldValue::Text(sv) => { obj.base.base.description = sv.clone(); }
30                        crate::base::FieldValue::TextList(svs) => {
31                            if let Some(sv) = svs.last() { obj.base.base.description = sv.clone(); }
32                        }
33                        _ => {}
34                    }
35                }
36                "IdentifiedObject.energyIdentCodeEic" => {
37                    match val {
38                        crate::base::FieldValue::Text(sv) => { obj.base.base.energy_ident_code_eic = sv.clone(); }
39                        crate::base::FieldValue::TextList(svs) => {
40                            if let Some(sv) = svs.last() { obj.base.base.energy_ident_code_eic = sv.clone(); }
41                        }
42                        _ => {}
43                    }
44                }
45                "IdentifiedObject.mRID" => {
46                    match val {
47                        crate::base::FieldValue::Text(sv) => { obj.base.base.m_rid = sv.clone(); }
48                        crate::base::FieldValue::TextList(svs) => {
49                            if let Some(sv) = svs.last() { obj.base.base.m_rid = sv.clone(); }
50                        }
51                        _ => {}
52                    }
53                }
54                "IdentifiedObject.name" => {
55                    match val {
56                        crate::base::FieldValue::Text(sv) => { obj.base.base.name = sv.clone(); }
57                        crate::base::FieldValue::TextList(svs) => {
58                            if let Some(sv) = svs.last() { obj.base.base.name = sv.clone(); }
59                        }
60                        _ => {}
61                    }
62                }
63                "IdentifiedObject.shortName" => {
64                    match val {
65                        crate::base::FieldValue::Text(sv) => { obj.base.base.short_name = sv.clone(); }
66                        crate::base::FieldValue::TextList(svs) => {
67                            if let Some(sv) = svs.last() { obj.base.base.short_name = sv.clone(); }
68                        }
69                        _ => {}
70                    }
71                }
72                _ => {}
73            }
74        }
75        obj
76    }
77}