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