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