cimstructs/
StaticVarCompensator.rs1#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct StaticVarCompensator {
4 #[serde(flatten)]
5 pub base: super::RegulatingCondEq,
6 #[serde(skip_serializing_if = "Option::is_none")]
8 pub capacitive_rating: Option<f64>,
9 #[serde(skip_serializing_if = "Option::is_none")]
11 pub inductive_rating: Option<f64>,
12 #[serde(skip_serializing_if = "Option::is_none")]
14 pub q: Option<f64>,
15 #[serde(skip_serializing_if = "Option::is_none")]
17 pub s_vc_control_mode: Option<super::base::MridRef>,
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub slope: Option<f64>,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub voltage_set_point: Option<f64>,
24}
25impl crate::base::CimElement for StaticVarCompensator {
26 fn mrid(&self) -> &str { &self.base.base.base.base.base.base.id }
27 fn type_name(&self) -> &'static str { "StaticVarCompensator" }
28 fn as_any(&self) -> &dyn std::any::Any { self }
29 fn to_json_value(&self) -> serde_json::Value {
30 serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
31 }
32 fn to_block(&self) -> crate::base::RdfBlock {
33 let mut block = self.base.to_block();
34 block.type_name = "StaticVarCompensator".to_string();
35 if let Some(v) = self.capacitive_rating {
36 block.fields.insert("StaticVarCompensator.capacitiveRating".into(), crate::base::FieldValue::Text(v.to_string()));
37 }
38 if let Some(v) = self.inductive_rating {
39 block.fields.insert("StaticVarCompensator.inductiveRating".into(), crate::base::FieldValue::Text(v.to_string()));
40 }
41 if let Some(v) = self.q {
42 block.fields.insert("StaticVarCompensator.q".into(), crate::base::FieldValue::Text(v.to_string()));
43 }
44 if let Some(ref v) = self.s_vc_control_mode {
45 block.fields.insert("StaticVarCompensator.sVCControlMode".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
46 }
47 if let Some(v) = self.slope {
48 block.fields.insert("StaticVarCompensator.slope".into(), crate::base::FieldValue::Text(v.to_string()));
49 }
50 if let Some(v) = self.voltage_set_point {
51 block.fields.insert("StaticVarCompensator.voltageSetPoint".into(), crate::base::FieldValue::Text(v.to_string()));
52 }
53 block
54 }
55}
56
57impl StaticVarCompensator {
58 pub fn from_block(b: &crate::base::RdfBlock) -> Self {
59 let mut obj = Self::default();
60 obj.base.base.base.base.base.base.id.clone_from(&b.mrid);
61 for (key, val) in &b.fields {
62 match key.as_str() {
63 "StaticVarCompensator.capacitiveRating" => {
64 match val {
65 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.capacitive_rating = Some(v); } }
66 crate::base::FieldValue::TextList(svs) => {
67 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.capacitive_rating = Some(v); } }
68 }
69 _ => {}
70 }
71 }
72 "StaticVarCompensator.inductiveRating" => {
73 match val {
74 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.inductive_rating = Some(v); } }
75 crate::base::FieldValue::TextList(svs) => {
76 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.inductive_rating = Some(v); } }
77 }
78 _ => {}
79 }
80 }
81 "StaticVarCompensator.q" => {
82 match val {
83 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.q = Some(v); } }
84 crate::base::FieldValue::TextList(svs) => {
85 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.q = Some(v); } }
86 }
87 _ => {}
88 }
89 }
90 "StaticVarCompensator.sVCControlMode" => {
91 if let crate::base::FieldValue::Resource(sv) = val {
92 obj.s_vc_control_mode = Some(crate::base::MridRef { mrid: sv.clone() });
93 }
94 }
95 "StaticVarCompensator.slope" => {
96 match val {
97 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.slope = Some(v); } }
98 crate::base::FieldValue::TextList(svs) => {
99 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.slope = Some(v); } }
100 }
101 _ => {}
102 }
103 }
104 "StaticVarCompensator.voltageSetPoint" => {
105 match val {
106 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.voltage_set_point = Some(v); } }
107 crate::base::FieldValue::TextList(svs) => {
108 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.voltage_set_point = Some(v); } }
109 }
110 _ => {}
111 }
112 }
113 "RegulatingCondEq.RegulatingControl" => {
114 if let crate::base::FieldValue::Resource(sv) = val {
115 obj.base.regulating_control = Some(crate::base::MridRef { mrid: sv.clone() });
116 }
117 }
118 "RegulatingCondEq.controlEnabled" => {
119 match val {
120 crate::base::FieldValue::Text(sv) => { obj.base.control_enabled = Some(sv.trim() == "true"); }
121 crate::base::FieldValue::TextList(svs) => {
122 if let Some(sv) = svs.last() { obj.base.control_enabled = Some(sv.trim() == "true"); }
123 }
124 _ => {}
125 }
126 }
127 "ConductingEquipment.BaseVoltage" => {
128 if let crate::base::FieldValue::Resource(sv) = val {
129 obj.base.base.base.base_voltage = Some(crate::base::MridRef { mrid: sv.clone() });
130 }
131 }
132 "Equipment.EquipmentContainer" => {
133 if let crate::base::FieldValue::Resource(sv) = val {
134 obj.base.base.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
135 }
136 }
137 "Equipment.aggregate" => {
138 match val {
139 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.aggregate = Some(sv.trim() == "true"); }
140 crate::base::FieldValue::TextList(svs) => {
141 if let Some(sv) = svs.last() { obj.base.base.base.base.aggregate = Some(sv.trim() == "true"); }
142 }
143 _ => {}
144 }
145 }
146 "Equipment.inService" => {
147 match val {
148 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.in_service = Some(sv.trim() == "true"); }
149 crate::base::FieldValue::TextList(svs) => {
150 if let Some(sv) = svs.last() { obj.base.base.base.base.in_service = Some(sv.trim() == "true"); }
151 }
152 _ => {}
153 }
154 }
155 "Equipment.normallyInService" => {
156 match val {
157 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
158 crate::base::FieldValue::TextList(svs) => {
159 if let Some(sv) = svs.last() { obj.base.base.base.base.normally_in_service = Some(sv.trim() == "true"); }
160 }
161 _ => {}
162 }
163 }
164 "IdentifiedObject.description" => {
165 match val {
166 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.description = sv.clone(); }
167 crate::base::FieldValue::TextList(svs) => {
168 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.description = sv.clone(); }
169 }
170 _ => {}
171 }
172 }
173 "IdentifiedObject.energyIdentCodeEic" => {
174 match val {
175 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
176 crate::base::FieldValue::TextList(svs) => {
177 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
178 }
179 _ => {}
180 }
181 }
182 "IdentifiedObject.mRID" => {
183 match val {
184 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.m_rid = sv.clone(); }
185 crate::base::FieldValue::TextList(svs) => {
186 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.m_rid = sv.clone(); }
187 }
188 _ => {}
189 }
190 }
191 "IdentifiedObject.name" => {
192 match val {
193 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.name = sv.clone(); }
194 crate::base::FieldValue::TextList(svs) => {
195 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.name = sv.clone(); }
196 }
197 _ => {}
198 }
199 }
200 "IdentifiedObject.shortName" => {
201 match val {
202 crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.base.short_name = sv.clone(); }
203 crate::base::FieldValue::TextList(svs) => {
204 if let Some(sv) = svs.last() { obj.base.base.base.base.base.base.short_name = sv.clone(); }
205 }
206 _ => {}
207 }
208 }
209 _ => {}
210 }
211 }
212 obj
213 }
214}