Skip to main content

cimstructs/
WindTurbineType3IEC.rs

1/// Parent class supporting relationships to IEC wind turbines type 3 including their control models.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindTurbineType3IEC {
4    #[serde(flatten)]
5    pub base: super::WindTurbineType3or4IEC,
6    /// Wind aerodynamic model associated with this wind generator type 3 model.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub wind_aero_one_dim_iec: Option<super::base::MridRef>,
9    /// Wind aerodynamic model associated with this wind turbine type 3 model.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub wind_aero_two_dim_iec: Option<super::base::MridRef>,
12    /// Wind control P type 3 model associated with this wind turbine type 3 model.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub wind_cont_p_type3iec: Option<super::base::MridRef>,
15    /// Wind control pitch angle model associated with this wind turbine type 3.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub wind_cont_pitch_angle_iec: Option<super::base::MridRef>,
18    /// Wind generator type 3 model associated with this wind turbine type 3 model.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub wind_gen_type3iec: Option<super::base::MridRef>,
21    /// Wind mechanical model associated with this wind turbine type 3 model.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub wind_mech_iec: Option<super::base::MridRef>,
24}
25impl crate::base::CimElement for WindTurbineType3IEC {
26    fn mrid(&self) -> &str { &self.base.base.base.base.id }
27    fn type_name(&self) -> &'static str { "WindTurbineType3IEC" }
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 = "WindTurbineType3IEC".to_string();
35        if let Some(ref v) = self.wind_aero_one_dim_iec {
36            block.fields.insert("WindTurbineType3IEC.WindAeroOneDimIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
37        }
38        if let Some(ref v) = self.wind_aero_two_dim_iec {
39            block.fields.insert("WindTurbineType3IEC.WindAeroTwoDimIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
40        }
41        if let Some(ref v) = self.wind_cont_p_type3iec {
42            block.fields.insert("WindTurbineType3IEC.WindContPType3IEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
43        }
44        if let Some(ref v) = self.wind_cont_pitch_angle_iec {
45            block.fields.insert("WindTurbineType3IEC.WindContPitchAngleIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
46        }
47        if let Some(ref v) = self.wind_gen_type3iec {
48            block.fields.insert("WindTurbineType3IEC.WindGenType3IEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
49        }
50        if let Some(ref v) = self.wind_mech_iec {
51            block.fields.insert("WindTurbineType3IEC.WindMechIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
52        }
53        block
54    }
55}
56
57impl WindTurbineType3IEC {
58    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
59        let mut obj = Self::default();
60        obj.base.base.base.base.id.clone_from(&b.mrid);
61        for (key, val) in &b.fields {
62            match key.as_str() {
63                "WindTurbineType3IEC.WindAeroOneDimIEC" => {
64                    if let crate::base::FieldValue::Resource(sv) = val {
65                        obj.wind_aero_one_dim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
66                    }
67                }
68                "WindTurbineType3IEC.WindAeroTwoDimIEC" => {
69                    if let crate::base::FieldValue::Resource(sv) = val {
70                        obj.wind_aero_two_dim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
71                    }
72                }
73                "WindTurbineType3IEC.WindContPType3IEC" => {
74                    if let crate::base::FieldValue::Resource(sv) = val {
75                        obj.wind_cont_p_type3iec = Some(crate::base::MridRef { mrid: sv.clone() });
76                    }
77                }
78                "WindTurbineType3IEC.WindContPitchAngleIEC" => {
79                    if let crate::base::FieldValue::Resource(sv) = val {
80                        obj.wind_cont_pitch_angle_iec = Some(crate::base::MridRef { mrid: sv.clone() });
81                    }
82                }
83                "WindTurbineType3IEC.WindGenType3IEC" => {
84                    if let crate::base::FieldValue::Resource(sv) = val {
85                        obj.wind_gen_type3iec = Some(crate::base::MridRef { mrid: sv.clone() });
86                    }
87                }
88                "WindTurbineType3IEC.WindMechIEC" => {
89                    if let crate::base::FieldValue::Resource(sv) = val {
90                        obj.wind_mech_iec = Some(crate::base::MridRef { mrid: sv.clone() });
91                    }
92                }
93                "WindTurbineType3or4IEC.WIndContQIEC" => {
94                    if let crate::base::FieldValue::Resource(sv) = val {
95                        obj.base.w_ind_cont_qiec = Some(crate::base::MridRef { mrid: sv.clone() });
96                    }
97                }
98                "WindTurbineType3or4IEC.WindContCurrLimIEC" => {
99                    if let crate::base::FieldValue::Resource(sv) = val {
100                        obj.base.wind_cont_curr_lim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
101                    }
102                }
103                "WindTurbineType3or4IEC.WindContQLimIEC" => {
104                    if let crate::base::FieldValue::Resource(sv) = val {
105                        obj.base.wind_cont_q_lim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
106                    }
107                }
108                "WindTurbineType3or4IEC.WindContQPQULimIEC" => {
109                    if let crate::base::FieldValue::Resource(sv) = val {
110                        obj.base.wind_cont_qpqu_lim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
111                    }
112                }
113                "WindTurbineType3or4IEC.WindProtectionIEC" => {
114                    if let crate::base::FieldValue::Resource(sv) = val {
115                        obj.base.wind_protection_iec = Some(crate::base::MridRef { mrid: sv.clone() });
116                    }
117                }
118                "WindTurbineType3or4IEC.WindRefFrameRotIEC" => {
119                    if let crate::base::FieldValue::Resource(sv) = val {
120                        obj.base.wind_ref_frame_rot_iec = Some(crate::base::MridRef { mrid: sv.clone() });
121                    }
122                }
123                "WindTurbineType3or4Dynamics.PowerElectronicsConnection" => {
124                    if let crate::base::FieldValue::Resource(sv) = val {
125                        obj.base.base.power_electronics_connection = Some(crate::base::MridRef { mrid: sv.clone() });
126                    }
127                }
128                "WindTurbineType3or4Dynamics.RemoteInputSignal" => {
129                    if let crate::base::FieldValue::Resource(sv) = val {
130                        obj.base.base.remote_input_signal = Some(crate::base::MridRef { mrid: sv.clone() });
131                    }
132                }
133                "WindTurbineType3or4Dynamics.WindPlantDynamics" => {
134                    if let crate::base::FieldValue::Resource(sv) = val {
135                        obj.base.base.wind_plant_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
136                    }
137                }
138                "DynamicsFunctionBlock.enabled" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.enabled = Some(sv.trim() == "true"); }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { obj.base.base.base.enabled = Some(sv.trim() == "true"); }
143                        }
144                        _ => {}
145                    }
146                }
147                "IdentifiedObject.description" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.description = sv.clone(); }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { obj.base.base.base.base.description = sv.clone(); }
152                        }
153                        _ => {}
154                    }
155                }
156                "IdentifiedObject.energyIdentCodeEic" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
161                        }
162                        _ => {}
163                    }
164                }
165                "IdentifiedObject.mRID" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.m_rid = sv.clone(); }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { obj.base.base.base.base.m_rid = sv.clone(); }
170                        }
171                        _ => {}
172                    }
173                }
174                "IdentifiedObject.name" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.name = sv.clone(); }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { obj.base.base.base.base.name = sv.clone(); }
179                        }
180                        _ => {}
181                    }
182                }
183                "IdentifiedObject.shortName" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.short_name = sv.clone(); }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { obj.base.base.base.base.short_name = sv.clone(); }
188                        }
189                        _ => {}
190                    }
191                }
192                _ => {}
193            }
194        }
195        obj
196    }
197}