Skip to main content

cimstructs/
WindTurbineType4bIEC.rs

1/// Wind turbine IEC type 4B. Reference: IEC 61400-27-1:2015, 5.5.5.3.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindTurbineType4bIEC {
4    #[serde(flatten)]
5    pub base: super::WindTurbineType4IEC,
6    /// Wind control P type 4B model associated with this wind turbine type 4B model.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub wind_cont_p_type4b_iec: Option<super::base::MridRef>,
9    /// Wind generator type 4 model associated with this wind turbine type 4B model.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub wind_gen_type4iec: Option<super::base::MridRef>,
12    /// Wind mechanical model associated with this wind turbine type 4B model.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub wind_mech_iec: Option<super::base::MridRef>,
15}
16impl crate::base::CimElement for WindTurbineType4bIEC {
17    fn mrid(&self) -> &str { &self.base.base.base.base.base.id }
18    fn type_name(&self) -> &'static str { "WindTurbineType4bIEC" }
19    fn as_any(&self) -> &dyn std::any::Any { self }
20    fn to_json_value(&self) -> serde_json::Value {
21        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
22    }
23    fn to_block(&self) -> crate::base::RdfBlock {
24        let mut block = self.base.to_block();
25        block.type_name = "WindTurbineType4bIEC".to_string();
26        if let Some(ref v) = self.wind_cont_p_type4b_iec {
27            block.fields.insert("WindTurbineType4bIEC.WindContPType4bIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
28        }
29        if let Some(ref v) = self.wind_gen_type4iec {
30            block.fields.insert("WindTurbineType4bIEC.WindGenType4IEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
31        }
32        if let Some(ref v) = self.wind_mech_iec {
33            block.fields.insert("WindTurbineType4bIEC.WindMechIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
34        }
35        block
36    }
37}
38
39impl WindTurbineType4bIEC {
40    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
41        let mut obj = Self::default();
42        obj.base.base.base.base.base.id.clone_from(&b.mrid);
43        for (key, val) in &b.fields {
44            match key.as_str() {
45                "WindTurbineType4bIEC.WindContPType4bIEC" => {
46                    if let crate::base::FieldValue::Resource(sv) = val {
47                        obj.wind_cont_p_type4b_iec = Some(crate::base::MridRef { mrid: sv.clone() });
48                    }
49                }
50                "WindTurbineType4bIEC.WindGenType4IEC" => {
51                    if let crate::base::FieldValue::Resource(sv) = val {
52                        obj.wind_gen_type4iec = Some(crate::base::MridRef { mrid: sv.clone() });
53                    }
54                }
55                "WindTurbineType4bIEC.WindMechIEC" => {
56                    if let crate::base::FieldValue::Resource(sv) = val {
57                        obj.wind_mech_iec = Some(crate::base::MridRef { mrid: sv.clone() });
58                    }
59                }
60                "WindTurbineType4IEC.WindGenType3aIEC" => {
61                    if let crate::base::FieldValue::Resource(sv) = val {
62                        obj.base.wind_gen_type3a_iec = Some(crate::base::MridRef { mrid: sv.clone() });
63                    }
64                }
65                "WindTurbineType3or4IEC.WIndContQIEC" => {
66                    if let crate::base::FieldValue::Resource(sv) = val {
67                        obj.base.base.w_ind_cont_qiec = Some(crate::base::MridRef { mrid: sv.clone() });
68                    }
69                }
70                "WindTurbineType3or4IEC.WindContCurrLimIEC" => {
71                    if let crate::base::FieldValue::Resource(sv) = val {
72                        obj.base.base.wind_cont_curr_lim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
73                    }
74                }
75                "WindTurbineType3or4IEC.WindContQLimIEC" => {
76                    if let crate::base::FieldValue::Resource(sv) = val {
77                        obj.base.base.wind_cont_q_lim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
78                    }
79                }
80                "WindTurbineType3or4IEC.WindContQPQULimIEC" => {
81                    if let crate::base::FieldValue::Resource(sv) = val {
82                        obj.base.base.wind_cont_qpqu_lim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
83                    }
84                }
85                "WindTurbineType3or4IEC.WindProtectionIEC" => {
86                    if let crate::base::FieldValue::Resource(sv) = val {
87                        obj.base.base.wind_protection_iec = Some(crate::base::MridRef { mrid: sv.clone() });
88                    }
89                }
90                "WindTurbineType3or4IEC.WindRefFrameRotIEC" => {
91                    if let crate::base::FieldValue::Resource(sv) = val {
92                        obj.base.base.wind_ref_frame_rot_iec = Some(crate::base::MridRef { mrid: sv.clone() });
93                    }
94                }
95                "WindTurbineType3or4Dynamics.PowerElectronicsConnection" => {
96                    if let crate::base::FieldValue::Resource(sv) = val {
97                        obj.base.base.base.power_electronics_connection = Some(crate::base::MridRef { mrid: sv.clone() });
98                    }
99                }
100                "WindTurbineType3or4Dynamics.RemoteInputSignal" => {
101                    if let crate::base::FieldValue::Resource(sv) = val {
102                        obj.base.base.base.remote_input_signal = Some(crate::base::MridRef { mrid: sv.clone() });
103                    }
104                }
105                "WindTurbineType3or4Dynamics.WindPlantDynamics" => {
106                    if let crate::base::FieldValue::Resource(sv) = val {
107                        obj.base.base.base.wind_plant_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
108                    }
109                }
110                "DynamicsFunctionBlock.enabled" => {
111                    match val {
112                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.enabled = Some(sv.trim() == "true"); }
113                        crate::base::FieldValue::TextList(svs) => {
114                            if let Some(sv) = svs.last() { obj.base.base.base.base.enabled = Some(sv.trim() == "true"); }
115                        }
116                        _ => {}
117                    }
118                }
119                "IdentifiedObject.description" => {
120                    match val {
121                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.description = sv.clone(); }
122                        crate::base::FieldValue::TextList(svs) => {
123                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.description = sv.clone(); }
124                        }
125                        _ => {}
126                    }
127                }
128                "IdentifiedObject.energyIdentCodeEic" => {
129                    match val {
130                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
131                        crate::base::FieldValue::TextList(svs) => {
132                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.energy_ident_code_eic = sv.clone(); }
133                        }
134                        _ => {}
135                    }
136                }
137                "IdentifiedObject.mRID" => {
138                    match val {
139                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.m_rid = sv.clone(); }
140                        crate::base::FieldValue::TextList(svs) => {
141                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.m_rid = sv.clone(); }
142                        }
143                        _ => {}
144                    }
145                }
146                "IdentifiedObject.name" => {
147                    match val {
148                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.name = sv.clone(); }
149                        crate::base::FieldValue::TextList(svs) => {
150                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.name = sv.clone(); }
151                        }
152                        _ => {}
153                    }
154                }
155                "IdentifiedObject.shortName" => {
156                    match val {
157                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.base.short_name = sv.clone(); }
158                        crate::base::FieldValue::TextList(svs) => {
159                            if let Some(sv) = svs.last() { obj.base.base.base.base.base.short_name = sv.clone(); }
160                        }
161                        _ => {}
162                    }
163                }
164                _ => {}
165            }
166        }
167        obj
168    }
169}