Skip to main content

cimstructs/
WindDynamicsLookupTable.rs

1/// Look up table for the purpose of wind standard models.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindDynamicsLookupTable {
4    #[serde(flatten)]
5    pub base: super::IdentifiedObject,
6    /// The current control limitation model with which this wind dynamics lookup table is associated.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub wind_cont_curr_lim_iec: Option<super::base::MridRef>,
9    /// The P control type 3 model with which this wind dynamics lookup table is associated.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub wind_cont_p_type3iec: Option<super::base::MridRef>,
12    /// The QP and QU limitation model with which this wind dynamics lookup table is associated.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub wind_cont_qpqu_lim_iec: Option<super::base::MridRef>,
15    /// The rotor resistance control model with which this wind dynamics lookup table is associated.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub wind_cont_rotor_riec: Option<super::base::MridRef>,
18    /// The generator type 3B model with which this wind dynamics lookup table is associated.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub wind_gen_type3b_iec: Option<super::base::MridRef>,
21    /// The pitch control power model with which this wind dynamics lookup table is associated.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub wind_pitch_cont_power_iec: Option<super::base::MridRef>,
24    /// The frequency and active power wind plant control model with which this wind dynamics lookup table is associated.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub wind_plant_freq_pcontrol_iec: Option<super::base::MridRef>,
27    /// The voltage and reactive power wind plant control model with which this wind dynamics lookup table is associated.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub wind_plant_reactive_control_iec: Option<super::base::MridRef>,
30    /// The grid protection model with which this wind dynamics lookup table is associated.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub wind_protection_iec: Option<super::base::MridRef>,
33    /// Input value (x) for the lookup table function.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub input: Option<f64>,
36    /// Type of the lookup table function.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub lookup_table_function_type: Option<super::base::UriRef>,
39    /// Output value (y) for the lookup table function.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    pub output: Option<f64>,
42    /// Sequence numbers of the pairs of the input (x) and the output (y) of the lookup table function.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub sequence: Option<i64>,
45}
46impl crate::base::CimElement for WindDynamicsLookupTable {
47    fn mrid(&self) -> &str { &self.base.id }
48    fn type_name(&self) -> &'static str { "WindDynamicsLookupTable" }
49    fn as_any(&self) -> &dyn std::any::Any { self }
50    fn to_json_value(&self) -> serde_json::Value {
51        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
52    }
53    fn to_block(&self) -> crate::base::RdfBlock {
54        let mut block = self.base.to_block();
55        block.type_name = "WindDynamicsLookupTable".to_string();
56        if let Some(ref v) = self.wind_cont_curr_lim_iec {
57            block.fields.insert("WindDynamicsLookupTable.WindContCurrLimIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
58        }
59        if let Some(ref v) = self.wind_cont_p_type3iec {
60            block.fields.insert("WindDynamicsLookupTable.WindContPType3IEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
61        }
62        if let Some(ref v) = self.wind_cont_qpqu_lim_iec {
63            block.fields.insert("WindDynamicsLookupTable.WindContQPQULimIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
64        }
65        if let Some(ref v) = self.wind_cont_rotor_riec {
66            block.fields.insert("WindDynamicsLookupTable.WindContRotorRIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
67        }
68        if let Some(ref v) = self.wind_gen_type3b_iec {
69            block.fields.insert("WindDynamicsLookupTable.WindGenType3bIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
70        }
71        if let Some(ref v) = self.wind_pitch_cont_power_iec {
72            block.fields.insert("WindDynamicsLookupTable.WindPitchContPowerIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
73        }
74        if let Some(ref v) = self.wind_plant_freq_pcontrol_iec {
75            block.fields.insert("WindDynamicsLookupTable.WindPlantFreqPcontrolIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
76        }
77        if let Some(ref v) = self.wind_plant_reactive_control_iec {
78            block.fields.insert("WindDynamicsLookupTable.WindPlantReactiveControlIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
79        }
80        if let Some(ref v) = self.wind_protection_iec {
81            block.fields.insert("WindDynamicsLookupTable.WindProtectionIEC".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
82        }
83        if let Some(v) = self.input {
84            block.fields.insert("WindDynamicsLookupTable.input".into(), crate::base::FieldValue::Text(v.to_string()));
85        }
86        if let Some(ref v) = self.lookup_table_function_type {
87            block.fields.insert("WindDynamicsLookupTable.lookupTableFunctionType".into(), crate::base::FieldValue::Resource(v.uri.clone()));
88        }
89        if let Some(v) = self.output {
90            block.fields.insert("WindDynamicsLookupTable.output".into(), crate::base::FieldValue::Text(v.to_string()));
91        }
92        if let Some(v) = self.sequence {
93            block.fields.insert("WindDynamicsLookupTable.sequence".into(), crate::base::FieldValue::Text(v.to_string()));
94        }
95        block
96    }
97}
98
99impl WindDynamicsLookupTable {
100    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
101        let mut obj = Self::default();
102        obj.base.id.clone_from(&b.mrid);
103        for (key, val) in &b.fields {
104            match key.as_str() {
105                "WindDynamicsLookupTable.WindContCurrLimIEC" => {
106                    if let crate::base::FieldValue::Resource(sv) = val {
107                        obj.wind_cont_curr_lim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
108                    }
109                }
110                "WindDynamicsLookupTable.WindContPType3IEC" => {
111                    if let crate::base::FieldValue::Resource(sv) = val {
112                        obj.wind_cont_p_type3iec = Some(crate::base::MridRef { mrid: sv.clone() });
113                    }
114                }
115                "WindDynamicsLookupTable.WindContQPQULimIEC" => {
116                    if let crate::base::FieldValue::Resource(sv) = val {
117                        obj.wind_cont_qpqu_lim_iec = Some(crate::base::MridRef { mrid: sv.clone() });
118                    }
119                }
120                "WindDynamicsLookupTable.WindContRotorRIEC" => {
121                    if let crate::base::FieldValue::Resource(sv) = val {
122                        obj.wind_cont_rotor_riec = Some(crate::base::MridRef { mrid: sv.clone() });
123                    }
124                }
125                "WindDynamicsLookupTable.WindGenType3bIEC" => {
126                    if let crate::base::FieldValue::Resource(sv) = val {
127                        obj.wind_gen_type3b_iec = Some(crate::base::MridRef { mrid: sv.clone() });
128                    }
129                }
130                "WindDynamicsLookupTable.WindPitchContPowerIEC" => {
131                    if let crate::base::FieldValue::Resource(sv) = val {
132                        obj.wind_pitch_cont_power_iec = Some(crate::base::MridRef { mrid: sv.clone() });
133                    }
134                }
135                "WindDynamicsLookupTable.WindPlantFreqPcontrolIEC" => {
136                    if let crate::base::FieldValue::Resource(sv) = val {
137                        obj.wind_plant_freq_pcontrol_iec = Some(crate::base::MridRef { mrid: sv.clone() });
138                    }
139                }
140                "WindDynamicsLookupTable.WindPlantReactiveControlIEC" => {
141                    if let crate::base::FieldValue::Resource(sv) = val {
142                        obj.wind_plant_reactive_control_iec = Some(crate::base::MridRef { mrid: sv.clone() });
143                    }
144                }
145                "WindDynamicsLookupTable.WindProtectionIEC" => {
146                    if let crate::base::FieldValue::Resource(sv) = val {
147                        obj.wind_protection_iec = Some(crate::base::MridRef { mrid: sv.clone() });
148                    }
149                }
150                "WindDynamicsLookupTable.input" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.input = Some(v); } }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.input = Some(v); } }
155                        }
156                        _ => {}
157                    }
158                }
159                "WindDynamicsLookupTable.lookupTableFunctionType" => {
160                    if let crate::base::FieldValue::Resource(sv) = val {
161                        obj.lookup_table_function_type = Some(crate::base::UriRef { uri: sv.clone() });
162                    }
163                }
164                "WindDynamicsLookupTable.output" => {
165                    match val {
166                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.output = Some(v); } }
167                        crate::base::FieldValue::TextList(svs) => {
168                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.output = Some(v); } }
169                        }
170                        _ => {}
171                    }
172                }
173                "WindDynamicsLookupTable.sequence" => {
174                    match val {
175                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.sequence = Some(v); } }
176                        crate::base::FieldValue::TextList(svs) => {
177                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.sequence = Some(v); } }
178                        }
179                        _ => {}
180                    }
181                }
182                "IdentifiedObject.description" => {
183                    match val {
184                        crate::base::FieldValue::Text(sv) => { obj.base.description = sv.clone(); }
185                        crate::base::FieldValue::TextList(svs) => {
186                            if let Some(sv) = svs.last() { obj.base.description = sv.clone(); }
187                        }
188                        _ => {}
189                    }
190                }
191                "IdentifiedObject.energyIdentCodeEic" => {
192                    match val {
193                        crate::base::FieldValue::Text(sv) => { obj.base.energy_ident_code_eic = sv.clone(); }
194                        crate::base::FieldValue::TextList(svs) => {
195                            if let Some(sv) = svs.last() { obj.base.energy_ident_code_eic = sv.clone(); }
196                        }
197                        _ => {}
198                    }
199                }
200                "IdentifiedObject.mRID" => {
201                    match val {
202                        crate::base::FieldValue::Text(sv) => { obj.base.m_rid = sv.clone(); }
203                        crate::base::FieldValue::TextList(svs) => {
204                            if let Some(sv) = svs.last() { obj.base.m_rid = sv.clone(); }
205                        }
206                        _ => {}
207                    }
208                }
209                "IdentifiedObject.name" => {
210                    match val {
211                        crate::base::FieldValue::Text(sv) => { obj.base.name = sv.clone(); }
212                        crate::base::FieldValue::TextList(svs) => {
213                            if let Some(sv) = svs.last() { obj.base.name = sv.clone(); }
214                        }
215                        _ => {}
216                    }
217                }
218                "IdentifiedObject.shortName" => {
219                    match val {
220                        crate::base::FieldValue::Text(sv) => { obj.base.short_name = sv.clone(); }
221                        crate::base::FieldValue::TextList(svs) => {
222                            if let Some(sv) = svs.last() { obj.base.short_name = sv.clone(); }
223                        }
224                        _ => {}
225                    }
226                }
227                _ => {}
228            }
229        }
230        obj
231    }
232}