Skip to main content

cimstructs/
WindContPType4aIEC.rs

1/// P control model type 4A. Reference: IEC 61400-27-1:2015, 5.6.5.5.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindContPType4aIEC {
4    #[serde(flatten)]
5    pub base: super::IdentifiedObject,
6    /// Maximum wind turbine power ramp rate (dpmaxp4A). It is a project-dependent parameter.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub dpmaxp4a: Option<f64>,
9    /// Time constant in power order lag (Tpordp4A) (>= 0). It is a type-dependent parameter.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub tpordp4a: Option<f64>,
12    /// Voltage measurement filter time constant (Tufiltp4A) (>= 0). It is a type-dependent parameter.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub tufiltp4a: Option<f64>,
15}
16impl crate::base::CimElement for WindContPType4aIEC {
17    fn mrid(&self) -> &str { &self.base.id }
18    fn type_name(&self) -> &'static str { "WindContPType4aIEC" }
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 = "WindContPType4aIEC".to_string();
26        if let Some(v) = self.dpmaxp4a {
27            block.fields.insert("WindContPType4aIEC.dpmaxp4a".into(), crate::base::FieldValue::Text(v.to_string()));
28        }
29        if let Some(v) = self.tpordp4a {
30            block.fields.insert("WindContPType4aIEC.tpordp4a".into(), crate::base::FieldValue::Text(v.to_string()));
31        }
32        if let Some(v) = self.tufiltp4a {
33            block.fields.insert("WindContPType4aIEC.tufiltp4a".into(), crate::base::FieldValue::Text(v.to_string()));
34        }
35        block
36    }
37}
38
39impl WindContPType4aIEC {
40    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
41        let mut obj = Self::default();
42        obj.base.id.clone_from(&b.mrid);
43        for (key, val) in &b.fields {
44            match key.as_str() {
45                "WindContPType4aIEC.dpmaxp4a" => {
46                    match val {
47                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.dpmaxp4a = Some(v); } }
48                        crate::base::FieldValue::TextList(svs) => {
49                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.dpmaxp4a = Some(v); } }
50                        }
51                        _ => {}
52                    }
53                }
54                "WindContPType4aIEC.tpordp4a" => {
55                    match val {
56                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tpordp4a = Some(v); } }
57                        crate::base::FieldValue::TextList(svs) => {
58                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tpordp4a = Some(v); } }
59                        }
60                        _ => {}
61                    }
62                }
63                "WindContPType4aIEC.tufiltp4a" => {
64                    match val {
65                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tufiltp4a = Some(v); } }
66                        crate::base::FieldValue::TextList(svs) => {
67                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tufiltp4a = Some(v); } }
68                        }
69                        _ => {}
70                    }
71                }
72                "IdentifiedObject.description" => {
73                    match val {
74                        crate::base::FieldValue::Text(sv) => { obj.base.description = sv.clone(); }
75                        crate::base::FieldValue::TextList(svs) => {
76                            if let Some(sv) = svs.last() { obj.base.description = sv.clone(); }
77                        }
78                        _ => {}
79                    }
80                }
81                "IdentifiedObject.energyIdentCodeEic" => {
82                    match val {
83                        crate::base::FieldValue::Text(sv) => { obj.base.energy_ident_code_eic = sv.clone(); }
84                        crate::base::FieldValue::TextList(svs) => {
85                            if let Some(sv) = svs.last() { obj.base.energy_ident_code_eic = sv.clone(); }
86                        }
87                        _ => {}
88                    }
89                }
90                "IdentifiedObject.mRID" => {
91                    match val {
92                        crate::base::FieldValue::Text(sv) => { obj.base.m_rid = sv.clone(); }
93                        crate::base::FieldValue::TextList(svs) => {
94                            if let Some(sv) = svs.last() { obj.base.m_rid = sv.clone(); }
95                        }
96                        _ => {}
97                    }
98                }
99                "IdentifiedObject.name" => {
100                    match val {
101                        crate::base::FieldValue::Text(sv) => { obj.base.name = sv.clone(); }
102                        crate::base::FieldValue::TextList(svs) => {
103                            if let Some(sv) = svs.last() { obj.base.name = sv.clone(); }
104                        }
105                        _ => {}
106                    }
107                }
108                "IdentifiedObject.shortName" => {
109                    match val {
110                        crate::base::FieldValue::Text(sv) => { obj.base.short_name = sv.clone(); }
111                        crate::base::FieldValue::TextList(svs) => {
112                            if let Some(sv) = svs.last() { obj.base.short_name = sv.clone(); }
113                        }
114                        _ => {}
115                    }
116                }
117                _ => {}
118            }
119        }
120        obj
121    }
122}