Skip to main content

cimstructs/
ACDCConverterDCTerminal.rs

1/// A DC electrical connection point at the AC/DC converter. The AC/DC converter is electrically connected also to the AC side. The AC connection is inherited from the AC conducting equipment in the same way as any other AC equipment. The AC/DC converter DC terminal is separate from generic DC terminal to restrict the connection with the AC side to AC/DC converter and so that no other DC conducting equipment can be connected to the AC side.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct ACDCConverterDCTerminal {
4    #[serde(flatten)]
5    pub base: super::DCBaseTerminal,
6    /// A DC converter terminal belong to an DC converter.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub dc_conducting_equipment: Option<super::base::MridRef>,
9    /// Represents the normal network polarity condition. Depending on the converter configuration the value shall be set as follows: - For a monopole with two converter terminals use DCPolarityKind “positive” and “negative”. - For a bi-pole or symmetric monopole with three converter terminals use DCPolarityKind “positive”, “middle” and “negative”.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub polarity: Option<super::base::UriRef>,
12}
13impl crate::base::CimElement for ACDCConverterDCTerminal {
14    fn mrid(&self) -> &str { &self.base.base.base.id }
15    fn type_name(&self) -> &'static str { "ACDCConverterDCTerminal" }
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 = "ACDCConverterDCTerminal".to_string();
23        if let Some(ref v) = self.dc_conducting_equipment {
24            block.fields.insert("ACDCConverterDCTerminal.DCConductingEquipment".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
25        }
26        if let Some(ref v) = self.polarity {
27            block.fields.insert("ACDCConverterDCTerminal.polarity".into(), crate::base::FieldValue::Resource(v.uri.clone()));
28        }
29        block
30    }
31}
32
33impl ACDCConverterDCTerminal {
34    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
35        let mut obj = Self::default();
36        obj.base.base.base.id.clone_from(&b.mrid);
37        for (key, val) in &b.fields {
38            match key.as_str() {
39                "ACDCConverterDCTerminal.DCConductingEquipment" => {
40                    if let crate::base::FieldValue::Resource(sv) = val {
41                        obj.dc_conducting_equipment = Some(crate::base::MridRef { mrid: sv.clone() });
42                    }
43                }
44                "ACDCConverterDCTerminal.polarity" => {
45                    if let crate::base::FieldValue::Resource(sv) = val {
46                        obj.polarity = Some(crate::base::UriRef { uri: sv.clone() });
47                    }
48                }
49                "DCBaseTerminal.DCNode" => {
50                    if let crate::base::FieldValue::Resource(sv) = val {
51                        obj.base.dc_node = Some(crate::base::MridRef { mrid: sv.clone() });
52                    }
53                }
54                "DCBaseTerminal.DCTopologicalNode" => {
55                    if let crate::base::FieldValue::Resource(sv) = val {
56                        obj.base.dc_topological_node = Some(crate::base::MridRef { mrid: sv.clone() });
57                    }
58                }
59                "ACDCTerminal.BusNameMarker" => {
60                    if let crate::base::FieldValue::Resource(sv) = val {
61                        obj.base.base.bus_name_marker = Some(crate::base::MridRef { mrid: sv.clone() });
62                    }
63                }
64                "ACDCTerminal.connected" => {
65                    match val {
66                        crate::base::FieldValue::Text(sv) => { obj.base.base.connected = Some(sv.trim() == "true"); }
67                        crate::base::FieldValue::TextList(svs) => {
68                            if let Some(sv) = svs.last() { obj.base.base.connected = Some(sv.trim() == "true"); }
69                        }
70                        _ => {}
71                    }
72                }
73                "ACDCTerminal.sequenceNumber" => {
74                    match val {
75                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.base.sequence_number = Some(v); } }
76                        crate::base::FieldValue::TextList(svs) => {
77                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.base.sequence_number = Some(v); } }
78                        }
79                        _ => {}
80                    }
81                }
82                "IdentifiedObject.description" => {
83                    match val {
84                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
85                        crate::base::FieldValue::TextList(svs) => {
86                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
87                        }
88                        _ => {}
89                    }
90                }
91                "IdentifiedObject.energyIdentCodeEic" => {
92                    match val {
93                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
94                        crate::base::FieldValue::TextList(svs) => {
95                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
96                        }
97                        _ => {}
98                    }
99                }
100                "IdentifiedObject.mRID" => {
101                    match val {
102                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
103                        crate::base::FieldValue::TextList(svs) => {
104                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
105                        }
106                        _ => {}
107                    }
108                }
109                "IdentifiedObject.name" => {
110                    match val {
111                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
112                        crate::base::FieldValue::TextList(svs) => {
113                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
114                        }
115                        _ => {}
116                    }
117                }
118                "IdentifiedObject.shortName" => {
119                    match val {
120                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
121                        crate::base::FieldValue::TextList(svs) => {
122                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
123                        }
124                        _ => {}
125                    }
126                }
127                _ => {}
128            }
129        }
130        obj
131    }
132}