Skip to main content

cimstructs/
Equipment.rs

1/// The parts of a power system that are physical devices, electronic or mechanical.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct Equipment {
4    #[serde(flatten)]
5    pub base: super::PowerSystemResource,
6    /// Container of this equipment.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub equipment_container: Option<super::base::MridRef>,
9    /// The aggregate flag provides an alternative way of representing an aggregated (equivalent) element. It is applicable in cases when the dedicated classes for equivalent equipment do not have all of the attributes necessary to represent the required level of detail. In case the flag is set to “true” the single instance of equipment represents multiple pieces of equipment that have been modelled together as an aggregate equivalent obtained by a network reduction procedure. Examples would be power transformers or synchronous machines operating in parallel modelled as a single aggregate power transformer or aggregate synchronous machine. The attribute is not used for EquivalentBranch, EquivalentShunt and EquivalentInjection.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub aggregate: Option<bool>,
12    /// Specifies the availability of the equipment. True means the equipment is available for topology processing, which determines if the equipment is energized or not. False means that the equipment is treated by network applications as if it is not in the model.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub in_service: Option<bool>,
15    /// Specifies the availability of the equipment under normal operating conditions. True means the equipment is available for topology processing, which determines if the equipment is energized or not. False means that the equipment is treated by network applications as if it is not in the model.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub normally_in_service: Option<bool>,
18}
19impl crate::base::CimElement for Equipment {
20    fn mrid(&self) -> &str { &self.base.base.id }
21    fn type_name(&self) -> &'static str { "Equipment" }
22    fn as_any(&self) -> &dyn std::any::Any { self }
23    fn to_json_value(&self) -> serde_json::Value {
24        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
25    }
26    fn to_block(&self) -> crate::base::RdfBlock {
27        let mut block = self.base.to_block();
28        block.type_name = "Equipment".to_string();
29        if let Some(ref v) = self.equipment_container {
30            block.fields.insert("Equipment.EquipmentContainer".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
31        }
32        if let Some(v) = self.aggregate {
33            block.fields.insert("Equipment.aggregate".into(), crate::base::FieldValue::Text(v.to_string()));
34        }
35        if let Some(v) = self.in_service {
36            block.fields.insert("Equipment.inService".into(), crate::base::FieldValue::Text(v.to_string()));
37        }
38        if let Some(v) = self.normally_in_service {
39            block.fields.insert("Equipment.normallyInService".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        block
42    }
43}
44
45impl Equipment {
46    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
47        let mut obj = Self::default();
48        obj.base.base.id.clone_from(&b.mrid);
49        for (key, val) in &b.fields {
50            match key.as_str() {
51                "Equipment.EquipmentContainer" => {
52                    if let crate::base::FieldValue::Resource(sv) = val {
53                        obj.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
54                    }
55                }
56                "Equipment.aggregate" => {
57                    match val {
58                        crate::base::FieldValue::Text(sv) => { obj.aggregate = Some(sv.trim() == "true"); }
59                        crate::base::FieldValue::TextList(svs) => {
60                            if let Some(sv) = svs.last() { obj.aggregate = Some(sv.trim() == "true"); }
61                        }
62                        _ => {}
63                    }
64                }
65                "Equipment.inService" => {
66                    match val {
67                        crate::base::FieldValue::Text(sv) => { obj.in_service = Some(sv.trim() == "true"); }
68                        crate::base::FieldValue::TextList(svs) => {
69                            if let Some(sv) = svs.last() { obj.in_service = Some(sv.trim() == "true"); }
70                        }
71                        _ => {}
72                    }
73                }
74                "Equipment.normallyInService" => {
75                    match val {
76                        crate::base::FieldValue::Text(sv) => { obj.normally_in_service = Some(sv.trim() == "true"); }
77                        crate::base::FieldValue::TextList(svs) => {
78                            if let Some(sv) = svs.last() { obj.normally_in_service = Some(sv.trim() == "true"); }
79                        }
80                        _ => {}
81                    }
82                }
83                "IdentifiedObject.description" => {
84                    match val {
85                        crate::base::FieldValue::Text(sv) => { obj.base.base.description = sv.clone(); }
86                        crate::base::FieldValue::TextList(svs) => {
87                            if let Some(sv) = svs.last() { obj.base.base.description = sv.clone(); }
88                        }
89                        _ => {}
90                    }
91                }
92                "IdentifiedObject.energyIdentCodeEic" => {
93                    match val {
94                        crate::base::FieldValue::Text(sv) => { obj.base.base.energy_ident_code_eic = sv.clone(); }
95                        crate::base::FieldValue::TextList(svs) => {
96                            if let Some(sv) = svs.last() { obj.base.base.energy_ident_code_eic = sv.clone(); }
97                        }
98                        _ => {}
99                    }
100                }
101                "IdentifiedObject.mRID" => {
102                    match val {
103                        crate::base::FieldValue::Text(sv) => { obj.base.base.m_rid = sv.clone(); }
104                        crate::base::FieldValue::TextList(svs) => {
105                            if let Some(sv) = svs.last() { obj.base.base.m_rid = sv.clone(); }
106                        }
107                        _ => {}
108                    }
109                }
110                "IdentifiedObject.name" => {
111                    match val {
112                        crate::base::FieldValue::Text(sv) => { obj.base.base.name = sv.clone(); }
113                        crate::base::FieldValue::TextList(svs) => {
114                            if let Some(sv) = svs.last() { obj.base.base.name = sv.clone(); }
115                        }
116                        _ => {}
117                    }
118                }
119                "IdentifiedObject.shortName" => {
120                    match val {
121                        crate::base::FieldValue::Text(sv) => { obj.base.base.short_name = sv.clone(); }
122                        crate::base::FieldValue::TextList(svs) => {
123                            if let Some(sv) = svs.last() { obj.base.base.short_name = sv.clone(); }
124                        }
125                        _ => {}
126                    }
127                }
128                _ => {}
129            }
130        }
131        obj
132    }
133}