Skip to main content

cimstructs/
DCConductingEquipment.rs

1/// The parts of the DC power system that are designed to carry current or that are conductively connected through DC terminals.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct DCConductingEquipment {
4    #[serde(flatten)]
5    pub base: super::Equipment,
6    /// Rated DC device voltage. The attribute shall be a positive value. It is configuration data used in power flow.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub rated_udc: Option<f64>,
9}
10impl crate::base::CimElement for DCConductingEquipment {
11    fn mrid(&self) -> &str { &self.base.base.base.id }
12    fn type_name(&self) -> &'static str { "DCConductingEquipment" }
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 = "DCConductingEquipment".to_string();
20        if let Some(v) = self.rated_udc {
21            block.fields.insert("DCConductingEquipment.ratedUdc".into(), crate::base::FieldValue::Text(v.to_string()));
22        }
23        block
24    }
25}
26
27impl DCConductingEquipment {
28    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
29        let mut obj = Self::default();
30        obj.base.base.base.id.clone_from(&b.mrid);
31        for (key, val) in &b.fields {
32            match key.as_str() {
33                "DCConductingEquipment.ratedUdc" => {
34                    match val {
35                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.rated_udc = Some(v); } }
36                        crate::base::FieldValue::TextList(svs) => {
37                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.rated_udc = Some(v); } }
38                        }
39                        _ => {}
40                    }
41                }
42                "Equipment.EquipmentContainer" => {
43                    if let crate::base::FieldValue::Resource(sv) = val {
44                        obj.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
45                    }
46                }
47                "Equipment.aggregate" => {
48                    match val {
49                        crate::base::FieldValue::Text(sv) => { obj.base.aggregate = Some(sv.trim() == "true"); }
50                        crate::base::FieldValue::TextList(svs) => {
51                            if let Some(sv) = svs.last() { obj.base.aggregate = Some(sv.trim() == "true"); }
52                        }
53                        _ => {}
54                    }
55                }
56                "Equipment.inService" => {
57                    match val {
58                        crate::base::FieldValue::Text(sv) => { obj.base.in_service = Some(sv.trim() == "true"); }
59                        crate::base::FieldValue::TextList(svs) => {
60                            if let Some(sv) = svs.last() { obj.base.in_service = Some(sv.trim() == "true"); }
61                        }
62                        _ => {}
63                    }
64                }
65                "Equipment.normallyInService" => {
66                    match val {
67                        crate::base::FieldValue::Text(sv) => { obj.base.normally_in_service = Some(sv.trim() == "true"); }
68                        crate::base::FieldValue::TextList(svs) => {
69                            if let Some(sv) = svs.last() { obj.base.normally_in_service = Some(sv.trim() == "true"); }
70                        }
71                        _ => {}
72                    }
73                }
74                "IdentifiedObject.description" => {
75                    match val {
76                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
77                        crate::base::FieldValue::TextList(svs) => {
78                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
79                        }
80                        _ => {}
81                    }
82                }
83                "IdentifiedObject.energyIdentCodeEic" => {
84                    match val {
85                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
86                        crate::base::FieldValue::TextList(svs) => {
87                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
88                        }
89                        _ => {}
90                    }
91                }
92                "IdentifiedObject.mRID" => {
93                    match val {
94                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
95                        crate::base::FieldValue::TextList(svs) => {
96                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
97                        }
98                        _ => {}
99                    }
100                }
101                "IdentifiedObject.name" => {
102                    match val {
103                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
104                        crate::base::FieldValue::TextList(svs) => {
105                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
106                        }
107                        _ => {}
108                    }
109                }
110                "IdentifiedObject.shortName" => {
111                    match val {
112                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
113                        crate::base::FieldValue::TextList(svs) => {
114                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
115                        }
116                        _ => {}
117                    }
118                }
119                _ => {}
120            }
121        }
122        obj
123    }
124}