cimstructs/
RotatingMachineDynamics.rs1#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct RotatingMachineDynamics {
4 #[serde(flatten)]
5 pub base: super::DynamicsFunctionBlock,
6 #[serde(skip_serializing_if = "Option::is_none")]
8 pub damping: Option<f64>,
9 #[serde(skip_serializing_if = "Option::is_none")]
11 pub inertia: Option<f64>,
12 #[serde(skip_serializing_if = "Option::is_none")]
14 pub saturation_factor: Option<f64>,
15 #[serde(skip_serializing_if = "Option::is_none")]
17 pub saturation_factor120: Option<f64>,
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub stator_leakage_reactance: Option<f64>,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub stator_resistance: Option<f64>,
24}
25impl crate::base::CimElement for RotatingMachineDynamics {
26 fn mrid(&self) -> &str { &self.base.base.id }
27 fn type_name(&self) -> &'static str { "RotatingMachineDynamics" }
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 = "RotatingMachineDynamics".to_string();
35 if let Some(v) = self.damping {
36 block.fields.insert("RotatingMachineDynamics.damping".into(), crate::base::FieldValue::Text(v.to_string()));
37 }
38 if let Some(v) = self.inertia {
39 block.fields.insert("RotatingMachineDynamics.inertia".into(), crate::base::FieldValue::Text(v.to_string()));
40 }
41 if let Some(v) = self.saturation_factor {
42 block.fields.insert("RotatingMachineDynamics.saturationFactor".into(), crate::base::FieldValue::Text(v.to_string()));
43 }
44 if let Some(v) = self.saturation_factor120 {
45 block.fields.insert("RotatingMachineDynamics.saturationFactor120".into(), crate::base::FieldValue::Text(v.to_string()));
46 }
47 if let Some(v) = self.stator_leakage_reactance {
48 block.fields.insert("RotatingMachineDynamics.statorLeakageReactance".into(), crate::base::FieldValue::Text(v.to_string()));
49 }
50 if let Some(v) = self.stator_resistance {
51 block.fields.insert("RotatingMachineDynamics.statorResistance".into(), crate::base::FieldValue::Text(v.to_string()));
52 }
53 block
54 }
55}
56
57impl RotatingMachineDynamics {
58 pub fn from_block(b: &crate::base::RdfBlock) -> Self {
59 let mut obj = Self::default();
60 obj.base.base.id.clone_from(&b.mrid);
61 for (key, val) in &b.fields {
62 match key.as_str() {
63 "RotatingMachineDynamics.damping" => {
64 match val {
65 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.damping = Some(v); } }
66 crate::base::FieldValue::TextList(svs) => {
67 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.damping = Some(v); } }
68 }
69 _ => {}
70 }
71 }
72 "RotatingMachineDynamics.inertia" => {
73 match val {
74 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.inertia = Some(v); } }
75 crate::base::FieldValue::TextList(svs) => {
76 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.inertia = Some(v); } }
77 }
78 _ => {}
79 }
80 }
81 "RotatingMachineDynamics.saturationFactor" => {
82 match val {
83 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.saturation_factor = Some(v); } }
84 crate::base::FieldValue::TextList(svs) => {
85 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.saturation_factor = Some(v); } }
86 }
87 _ => {}
88 }
89 }
90 "RotatingMachineDynamics.saturationFactor120" => {
91 match val {
92 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.saturation_factor120 = Some(v); } }
93 crate::base::FieldValue::TextList(svs) => {
94 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.saturation_factor120 = Some(v); } }
95 }
96 _ => {}
97 }
98 }
99 "RotatingMachineDynamics.statorLeakageReactance" => {
100 match val {
101 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.stator_leakage_reactance = Some(v); } }
102 crate::base::FieldValue::TextList(svs) => {
103 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.stator_leakage_reactance = Some(v); } }
104 }
105 _ => {}
106 }
107 }
108 "RotatingMachineDynamics.statorResistance" => {
109 match val {
110 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.stator_resistance = Some(v); } }
111 crate::base::FieldValue::TextList(svs) => {
112 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.stator_resistance = Some(v); } }
113 }
114 _ => {}
115 }
116 }
117 "DynamicsFunctionBlock.enabled" => {
118 match val {
119 crate::base::FieldValue::Text(sv) => { obj.base.enabled = Some(sv.trim() == "true"); }
120 crate::base::FieldValue::TextList(svs) => {
121 if let Some(sv) = svs.last() { obj.base.enabled = Some(sv.trim() == "true"); }
122 }
123 _ => {}
124 }
125 }
126 "IdentifiedObject.description" => {
127 match val {
128 crate::base::FieldValue::Text(sv) => { obj.base.base.description = sv.clone(); }
129 crate::base::FieldValue::TextList(svs) => {
130 if let Some(sv) = svs.last() { obj.base.base.description = sv.clone(); }
131 }
132 _ => {}
133 }
134 }
135 "IdentifiedObject.energyIdentCodeEic" => {
136 match val {
137 crate::base::FieldValue::Text(sv) => { obj.base.base.energy_ident_code_eic = sv.clone(); }
138 crate::base::FieldValue::TextList(svs) => {
139 if let Some(sv) = svs.last() { obj.base.base.energy_ident_code_eic = sv.clone(); }
140 }
141 _ => {}
142 }
143 }
144 "IdentifiedObject.mRID" => {
145 match val {
146 crate::base::FieldValue::Text(sv) => { obj.base.base.m_rid = sv.clone(); }
147 crate::base::FieldValue::TextList(svs) => {
148 if let Some(sv) = svs.last() { obj.base.base.m_rid = sv.clone(); }
149 }
150 _ => {}
151 }
152 }
153 "IdentifiedObject.name" => {
154 match val {
155 crate::base::FieldValue::Text(sv) => { obj.base.base.name = sv.clone(); }
156 crate::base::FieldValue::TextList(svs) => {
157 if let Some(sv) = svs.last() { obj.base.base.name = sv.clone(); }
158 }
159 _ => {}
160 }
161 }
162 "IdentifiedObject.shortName" => {
163 match val {
164 crate::base::FieldValue::Text(sv) => { obj.base.base.short_name = sv.clone(); }
165 crate::base::FieldValue::TextList(svs) => {
166 if let Some(sv) = svs.last() { obj.base.base.short_name = sv.clone(); }
167 }
168 _ => {}
169 }
170 }
171 _ => {}
172 }
173 }
174 obj
175 }
176}