Skip to main content

cimstructs/
WindGenTurbineType2IEC.rs

1/// Wind turbine IEC type 2. Reference: IEC 61400-27-1:2015, 5.5.3.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindGenTurbineType2IEC {
4    #[serde(flatten)]
5    pub base: super::WindTurbineType1or2IEC,
6    /// Wind control rotor resistance model associated with wind turbine type 2 model.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub wind_cont_rotor_riec: Option<super::base::MridRef>,
9    /// Pitch control power model associated with this wind turbine type 2 model.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub wind_pitch_cont_power_iec: Option<super::base::MridRef>,
12}
13impl crate::base::CimElement for WindGenTurbineType2IEC {
14    fn mrid(&self) -> &str { &self.base.base.base.base.id }
15    fn type_name(&self) -> &'static str { "WindGenTurbineType2IEC" }
16    fn as_any(&self) -> &dyn std::any::Any { self }
17    fn to_json_value(&self) -> serde_json::Value {
18        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
19    }
20    fn to_block(&self) -> crate::base::RdfBlock {
21        let mut block = self.base.to_block();
22        block.type_name = "WindGenTurbineType2IEC".to_string();
23        if let Some(ref v) = self.wind_cont_rotor_riec {
24            block.fields.insert("WindGenTurbineType2IEC.WindContRotorRIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
25        }
26        if let Some(ref v) = self.wind_pitch_cont_power_iec {
27            block.fields.insert("WindGenTurbineType2IEC.WindPitchContPowerIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
28        }
29        block
30    }
31}
32
33impl WindGenTurbineType2IEC {
34    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
35        let mut obj = Self::default();
36        obj.base.base.base.base.id.clone_from(&b.mrid);
37        for (key, val) in &b.fields {
38            match key.as_str() {
39                "WindGenTurbineType2IEC.WindContRotorRIEC" => {
40                    if let crate::base::FieldValue::Resource(sv) = val {
41                        obj.wind_cont_rotor_riec = Some(crate::base::MridRef { mrid: sv.clone() });
42                    }
43                }
44                "WindGenTurbineType2IEC.WindPitchContPowerIEC" => {
45                    if let crate::base::FieldValue::Resource(sv) = val {
46                        obj.wind_pitch_cont_power_iec = Some(crate::base::MridRef { mrid: sv.clone() });
47                    }
48                }
49                "WindTurbineType1or2IEC.WindMechIEC" => {
50                    if let crate::base::FieldValue::Resource(sv) = val {
51                        obj.base.wind_mech_iec = Some(crate::base::MridRef { mrid: sv.clone() });
52                    }
53                }
54                "WindTurbineType1or2IEC.WindProtectionIEC" => {
55                    if let crate::base::FieldValue::Resource(sv) = val {
56                        obj.base.wind_protection_iec = Some(crate::base::MridRef { mrid: sv.clone() });
57                    }
58                }
59                "WindTurbineType1or2Dynamics.AsynchronousMachineDynamics" => {
60                    if let crate::base::FieldValue::Resource(sv) = val {
61                        obj.base.base.asynchronous_machine_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
62                    }
63                }
64                "WindTurbineType1or2Dynamics.RemoteInputSignal" => {
65                    if let crate::base::FieldValue::Resource(sv) = val {
66                        obj.base.base.remote_input_signal = Some(crate::base::MridRef { mrid: sv.clone() });
67                    }
68                }
69                "DynamicsFunctionBlock.enabled" => {
70                    match val {
71                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.enabled = Some(sv.trim() == "true"); }
72                        crate::base::FieldValue::TextList(svs) => {
73                            if let Some(sv) = svs.last() { obj.base.base.base.enabled = Some(sv.trim() == "true"); }
74                        }
75                        _ => {}
76                    }
77                }
78                "IdentifiedObject.description" => {
79                    match val {
80                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.description = sv.clone(); }
81                        crate::base::FieldValue::TextList(svs) => {
82                            if let Some(sv) = svs.last() { obj.base.base.base.base.description = sv.clone(); }
83                        }
84                        _ => {}
85                    }
86                }
87                "IdentifiedObject.energyIdentCodeEic" => {
88                    match val {
89                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
90                        crate::base::FieldValue::TextList(svs) => {
91                            if let Some(sv) = svs.last() { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
92                        }
93                        _ => {}
94                    }
95                }
96                "IdentifiedObject.mRID" => {
97                    match val {
98                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.m_rid = sv.clone(); }
99                        crate::base::FieldValue::TextList(svs) => {
100                            if let Some(sv) = svs.last() { obj.base.base.base.base.m_rid = sv.clone(); }
101                        }
102                        _ => {}
103                    }
104                }
105                "IdentifiedObject.name" => {
106                    match val {
107                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.name = sv.clone(); }
108                        crate::base::FieldValue::TextList(svs) => {
109                            if let Some(sv) = svs.last() { obj.base.base.base.base.name = sv.clone(); }
110                        }
111                        _ => {}
112                    }
113                }
114                "IdentifiedObject.shortName" => {
115                    match val {
116                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.short_name = sv.clone(); }
117                        crate::base::FieldValue::TextList(svs) => {
118                            if let Some(sv) = svs.last() { obj.base.base.base.base.short_name = sv.clone(); }
119                        }
120                        _ => {}
121                    }
122                }
123                _ => {}
124            }
125        }
126        obj
127    }
128}