Skip to main content

cimstructs/
AsynchronousMachineDynamics.rs

1/// Asynchronous machine whose behaviour is described by reference to a standard model expressed in either time constant reactance form or equivalent circuit form or by definition of a user-defined model. Parameter details: Asynchronous machine parameters such as Xl, Xs, etc. are actually used as inductances in the model, but are commonly referred to as reactances since, at nominal frequency, the PU values are the same. However, some references use the symbol L instead of X.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct AsynchronousMachineDynamics {
4    #[serde(flatten)]
5    pub base: super::RotatingMachineDynamics,
6    /// Asynchronous machine to which this asynchronous machine dynamics model applies.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub asynchronous_machine: Option<super::base::MridRef>,
9}
10impl crate::base::CimElement for AsynchronousMachineDynamics {
11    fn mrid(&self) -> &str { &self.base.base.base.id }
12    fn type_name(&self) -> &'static str { "AsynchronousMachineDynamics" }
13    fn as_any(&self) -> &dyn std::any::Any { self }
14    fn to_json_value(&self) -> serde_json::Value {
15        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
16    }
17    fn to_block(&self) -> crate::base::RdfBlock {
18        let mut block = self.base.to_block();
19        block.type_name = "AsynchronousMachineDynamics".to_string();
20        if let Some(ref v) = self.asynchronous_machine {
21            block.fields.insert("AsynchronousMachineDynamics.AsynchronousMachine".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
22        }
23        block
24    }
25}
26
27impl AsynchronousMachineDynamics {
28    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
29        let mut obj = Self::default();
30        obj.base.base.base.id.clone_from(&b.mrid);
31        for (key, val) in &b.fields {
32            match key.as_str() {
33                "AsynchronousMachineDynamics.AsynchronousMachine" => {
34                    if let crate::base::FieldValue::Resource(sv) = val {
35                        obj.asynchronous_machine = Some(crate::base::MridRef { mrid: sv.clone() });
36                    }
37                }
38                "RotatingMachineDynamics.damping" => {
39                    match val {
40                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.damping = Some(v); } }
41                        crate::base::FieldValue::TextList(svs) => {
42                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.damping = Some(v); } }
43                        }
44                        _ => {}
45                    }
46                }
47                "RotatingMachineDynamics.inertia" => {
48                    match val {
49                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.inertia = Some(v); } }
50                        crate::base::FieldValue::TextList(svs) => {
51                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.inertia = Some(v); } }
52                        }
53                        _ => {}
54                    }
55                }
56                "RotatingMachineDynamics.saturationFactor" => {
57                    match val {
58                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.saturation_factor = Some(v); } }
59                        crate::base::FieldValue::TextList(svs) => {
60                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.saturation_factor = Some(v); } }
61                        }
62                        _ => {}
63                    }
64                }
65                "RotatingMachineDynamics.saturationFactor120" => {
66                    match val {
67                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.saturation_factor120 = Some(v); } }
68                        crate::base::FieldValue::TextList(svs) => {
69                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.saturation_factor120 = Some(v); } }
70                        }
71                        _ => {}
72                    }
73                }
74                "RotatingMachineDynamics.statorLeakageReactance" => {
75                    match val {
76                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.stator_leakage_reactance = Some(v); } }
77                        crate::base::FieldValue::TextList(svs) => {
78                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.stator_leakage_reactance = Some(v); } }
79                        }
80                        _ => {}
81                    }
82                }
83                "RotatingMachineDynamics.statorResistance" => {
84                    match val {
85                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.base.stator_resistance = Some(v); } }
86                        crate::base::FieldValue::TextList(svs) => {
87                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.base.stator_resistance = Some(v); } }
88                        }
89                        _ => {}
90                    }
91                }
92                "DynamicsFunctionBlock.enabled" => {
93                    match val {
94                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
95                        crate::base::FieldValue::TextList(svs) => {
96                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
97                        }
98                        _ => {}
99                    }
100                }
101                "IdentifiedObject.description" => {
102                    match val {
103                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
104                        crate::base::FieldValue::TextList(svs) => {
105                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
106                        }
107                        _ => {}
108                    }
109                }
110                "IdentifiedObject.energyIdentCodeEic" => {
111                    match val {
112                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
113                        crate::base::FieldValue::TextList(svs) => {
114                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
115                        }
116                        _ => {}
117                    }
118                }
119                "IdentifiedObject.mRID" => {
120                    match val {
121                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
122                        crate::base::FieldValue::TextList(svs) => {
123                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
124                        }
125                        _ => {}
126                    }
127                }
128                "IdentifiedObject.name" => {
129                    match val {
130                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
131                        crate::base::FieldValue::TextList(svs) => {
132                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
133                        }
134                        _ => {}
135                    }
136                }
137                "IdentifiedObject.shortName" => {
138                    match val {
139                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
140                        crate::base::FieldValue::TextList(svs) => {
141                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
142                        }
143                        _ => {}
144                    }
145                }
146                _ => {}
147            }
148        }
149        obj
150    }
151}