Skip to main content

cimstructs/
RegulatingCondEq.rs

1/// A type of conducting equipment that can regulate a quantity (i.e. voltage or flow) at a specific point in the network.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct RegulatingCondEq {
4    #[serde(flatten)]
5    pub base: super::EnergyConnection,
6    /// The regulating control scheme in which this equipment participates.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub regulating_control: Option<super::base::MridRef>,
9    /// Specifies the regulation status of the equipment. True is regulating, false is not regulating.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub control_enabled: Option<bool>,
12}
13impl crate::base::CimElement for RegulatingCondEq {
14    fn mrid(&self) -> &str { &self.base.base.base.base.base.id }
15    fn type_name(&self) -> &'static str { "RegulatingCondEq" }
16    fn as_any(&self) -> &dyn std::any::Any { self }
17    fn to_json_value(&self) -> serde_json::Value {
18        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
19    }
20    fn to_block(&self) -> crate::base::RdfBlock {
21        let mut block = self.base.to_block();
22        block.type_name = "RegulatingCondEq".to_string();
23        if let Some(ref v) = self.regulating_control {
24            block.fields.insert("RegulatingCondEq.RegulatingControl".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
25        }
26        if let Some(v) = self.control_enabled {
27            block.fields.insert("RegulatingCondEq.controlEnabled".into(), crate::base::FieldValue::Text(v.to_string()));
28        }
29        block
30    }
31}
32
33impl RegulatingCondEq {
34    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
35        let mut obj = Self::default();
36        obj.base.base.base.base.base.id.clone_from(&b.mrid);
37        for (key, val) in &b.fields {
38            match key.as_str() {
39                "RegulatingCondEq.RegulatingControl" => {
40                    if let crate::base::FieldValue::Resource(sv) = val {
41                        obj.regulating_control = Some(crate::base::MridRef { mrid: sv.clone() });
42                    }
43                }
44                "RegulatingCondEq.controlEnabled" => {
45                    match val {
46                        crate::base::FieldValue::Text(sv) => { obj.control_enabled = Some(sv.trim() == "true"); }
47                        crate::base::FieldValue::TextList(svs) => {
48                            if let Some(sv) = svs.last() { obj.control_enabled = Some(sv.trim() == "true"); }
49                        }
50                        _ => {}
51                    }
52                }
53                "ConductingEquipment.BaseVoltage" => {
54                    if let crate::base::FieldValue::Resource(sv) = val {
55                        obj.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
56                    }
57                }
58                "Equipment.EquipmentContainer" => {
59                    if let crate::base::FieldValue::Resource(sv) = val {
60                        obj.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
61                    }
62                }
63                "Equipment.aggregate" => {
64                    match val {
65                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
66                        crate::base::FieldValue::TextList(svs) => {
67                            if let Some(sv) = svs.last() { obj.base.base.base.aggregate = Some(sv.trim() == "true"); }
68                        }
69                        _ => {}
70                    }
71                }
72                "Equipment.inService" => {
73                    match val {
74                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
75                        crate::base::FieldValue::TextList(svs) => {
76                            if let Some(sv) = svs.last() { obj.base.base.base.in_service = Some(sv.trim() == "true"); }
77                        }
78                        _ => {}
79                    }
80                }
81                "Equipment.normallyInService" => {
82                    match val {
83                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
84                        crate::base::FieldValue::TextList(svs) => {
85                            if let Some(sv) = svs.last() { obj.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
86                        }
87                        _ => {}
88                    }
89                }
90                "IdentifiedObject.description" => {
91                    match val {
92                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.description = sv.clone(); }
93                        crate::base::FieldValue::TextList(svs) => {
94                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.description = sv.clone(); }
95                        }
96                        _ => {}
97                    }
98                }
99                "IdentifiedObject.energyIdentCodeEic" => {
100                    match val {
101                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
102                        crate::base::FieldValue::TextList(svs) => {
103                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
104                        }
105                        _ => {}
106                    }
107                }
108                "IdentifiedObject.mRID" => {
109                    match val {
110                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.m_rid = sv.clone(); }
111                        crate::base::FieldValue::TextList(svs) => {
112                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.m_rid = sv.clone(); }
113                        }
114                        _ => {}
115                    }
116                }
117                "IdentifiedObject.name" => {
118                    match val {
119                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.name = sv.clone(); }
120                        crate::base::FieldValue::TextList(svs) => {
121                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.name = sv.clone(); }
122                        }
123                        _ => {}
124                    }
125                }
126                "IdentifiedObject.shortName" => {
127                    match val {
128                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.short_name = sv.clone(); }
129                        crate::base::FieldValue::TextList(svs) => {
130                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.short_name = sv.clone(); }
131                        }
132                        _ => {}
133                    }
134                }
135                _ => {}
136            }
137        }
138        obj
139    }
140}