Skip to main content

cimstructs/
WindPitchContPowerIEC.rs

1/// Pitch control power model. Reference: IEC 61400-27-1:2015, 5.6.5.1.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindPitchContPowerIEC {
4    #[serde(flatten)]
5    pub base: super::IdentifiedObject,
6    /// Rate limit for increasing power (dpmax) (> WindPitchContPowerIEC.dpmin). It is a type-dependent parameter.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub dpmax: Option<f64>,
9    /// Rate limit for decreasing power (dpmin) (< WindPitchContPowerIEC.dpmax). It is a type-dependent parameter.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub dpmin: Option<f64>,
12    /// Minimum power setting (pmin). It is a type-dependent parameter.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub pmin: Option<f64>,
15    /// If pinit < pset then power will be ramped down to pmin. It is (pset) in the IEC 61400-27-1:2015. It is a type-dependent parameter.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub pset: Option<f64>,
18    /// Lag time constant (T1) (>= 0). It is a type-dependent parameter.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub t1: Option<f64>,
21    /// Voltage measurement time constant (Tr) (>= 0). It is a type-dependent parameter.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub tr: Option<f64>,
24    /// Dip detection threshold (uUVRT). It is a type-dependent parameter.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub uuvrt: Option<f64>,
27}
28impl crate::base::CimElement for WindPitchContPowerIEC {
29    fn mrid(&self) -> &str { &self.base.id }
30    fn type_name(&self) -> &'static str { "WindPitchContPowerIEC" }
31    fn as_any(&self) -> &dyn std::any::Any { self }
32    fn to_json_value(&self) -> serde_json::Value {
33        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
34    }
35    fn to_block(&self) -> crate::base::RdfBlock {
36        let mut block = self.base.to_block();
37        block.type_name = "WindPitchContPowerIEC".to_string();
38        if let Some(v) = self.dpmax {
39            block.fields.insert("WindPitchContPowerIEC.dpmax".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        if let Some(v) = self.dpmin {
42            block.fields.insert("WindPitchContPowerIEC.dpmin".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.pmin {
45            block.fields.insert("WindPitchContPowerIEC.pmin".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.pset {
48            block.fields.insert("WindPitchContPowerIEC.pset".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.t1 {
51            block.fields.insert("WindPitchContPowerIEC.t1".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.tr {
54            block.fields.insert("WindPitchContPowerIEC.tr".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.uuvrt {
57            block.fields.insert("WindPitchContPowerIEC.uuvrt".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        block
60    }
61}
62
63impl WindPitchContPowerIEC {
64    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
65        let mut obj = Self::default();
66        obj.base.id.clone_from(&b.mrid);
67        for (key, val) in &b.fields {
68            match key.as_str() {
69                "WindPitchContPowerIEC.dpmax" => {
70                    match val {
71                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dpmax = Some(v); } }
72                        crate::base::FieldValue::TextList(svs) => {
73                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dpmax = Some(v); } }
74                        }
75                        _ => {}
76                    }
77                }
78                "WindPitchContPowerIEC.dpmin" => {
79                    match val {
80                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dpmin = Some(v); } }
81                        crate::base::FieldValue::TextList(svs) => {
82                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dpmin = Some(v); } }
83                        }
84                        _ => {}
85                    }
86                }
87                "WindPitchContPowerIEC.pmin" => {
88                    match val {
89                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.pmin = Some(v); } }
90                        crate::base::FieldValue::TextList(svs) => {
91                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.pmin = Some(v); } }
92                        }
93                        _ => {}
94                    }
95                }
96                "WindPitchContPowerIEC.pset" => {
97                    match val {
98                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.pset = Some(v); } }
99                        crate::base::FieldValue::TextList(svs) => {
100                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.pset = Some(v); } }
101                        }
102                        _ => {}
103                    }
104                }
105                "WindPitchContPowerIEC.t1" => {
106                    match val {
107                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
108                        crate::base::FieldValue::TextList(svs) => {
109                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
110                        }
111                        _ => {}
112                    }
113                }
114                "WindPitchContPowerIEC.tr" => {
115                    match val {
116                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tr = Some(v); } }
117                        crate::base::FieldValue::TextList(svs) => {
118                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tr = Some(v); } }
119                        }
120                        _ => {}
121                    }
122                }
123                "WindPitchContPowerIEC.uuvrt" => {
124                    match val {
125                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.uuvrt = Some(v); } }
126                        crate::base::FieldValue::TextList(svs) => {
127                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.uuvrt = Some(v); } }
128                        }
129                        _ => {}
130                    }
131                }
132                "IdentifiedObject.description" => {
133                    match val {
134                        crate::base::FieldValue::Text(sv) => { obj.base.description = sv.clone(); }
135                        crate::base::FieldValue::TextList(svs) => {
136                            if let Some(sv) = svs.last() { obj.base.description = sv.clone(); }
137                        }
138                        _ => {}
139                    }
140                }
141                "IdentifiedObject.energyIdentCodeEic" => {
142                    match val {
143                        crate::base::FieldValue::Text(sv) => { obj.base.energy_ident_code_eic = sv.clone(); }
144                        crate::base::FieldValue::TextList(svs) => {
145                            if let Some(sv) = svs.last() { obj.base.energy_ident_code_eic = sv.clone(); }
146                        }
147                        _ => {}
148                    }
149                }
150                "IdentifiedObject.mRID" => {
151                    match val {
152                        crate::base::FieldValue::Text(sv) => { obj.base.m_rid = sv.clone(); }
153                        crate::base::FieldValue::TextList(svs) => {
154                            if let Some(sv) = svs.last() { obj.base.m_rid = sv.clone(); }
155                        }
156                        _ => {}
157                    }
158                }
159                "IdentifiedObject.name" => {
160                    match val {
161                        crate::base::FieldValue::Text(sv) => { obj.base.name = sv.clone(); }
162                        crate::base::FieldValue::TextList(svs) => {
163                            if let Some(sv) = svs.last() { obj.base.name = sv.clone(); }
164                        }
165                        _ => {}
166                    }
167                }
168                "IdentifiedObject.shortName" => {
169                    match val {
170                        crate::base::FieldValue::Text(sv) => { obj.base.short_name = sv.clone(); }
171                        crate::base::FieldValue::TextList(svs) => {
172                            if let Some(sv) = svs.last() { obj.base.short_name = sv.clone(); }
173                        }
174                        _ => {}
175                    }
176                }
177                _ => {}
178            }
179        }
180        obj
181    }
182}