Skip to main content

cimstructs/
WindRefFrameRotIEC.rs

1/// Reference frame rotation model. Reference: IEC 61400-27-1:2015, 5.6.3.5.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindRefFrameRotIEC {
4    #[serde(flatten)]
5    pub base: super::IdentifiedObject,
6    /// Time constant for PLL first order filter model (TPLL) (>= 0). It is a type-dependent parameter.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub tpll: Option<f64>,
9    /// Voltage below which the angle of the voltage is filtered and possibly also frozen (uPLL1). It is a type-dependent parameter.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub upll1: Option<f64>,
12    /// Voltage (uPLL2) below which the angle of the voltage is frozen if uPLL2 is smaller or equal to uPLL1 . It is a type-dependent parameter.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub upll2: Option<f64>,
15}
16impl crate::base::CimElement for WindRefFrameRotIEC {
17    fn mrid(&self) -> &str { &self.base.id }
18    fn type_name(&self) -> &'static str { "WindRefFrameRotIEC" }
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 = "WindRefFrameRotIEC".to_string();
26        if let Some(v) = self.tpll {
27            block.fields.insert("WindRefFrameRotIEC.tpll".into(), crate::base::FieldValue::Text(v.to_string()));
28        }
29        if let Some(v) = self.upll1 {
30            block.fields.insert("WindRefFrameRotIEC.upll1".into(), crate::base::FieldValue::Text(v.to_string()));
31        }
32        if let Some(v) = self.upll2 {
33            block.fields.insert("WindRefFrameRotIEC.upll2".into(), crate::base::FieldValue::Text(v.to_string()));
34        }
35        block
36    }
37}
38
39impl WindRefFrameRotIEC {
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                "WindRefFrameRotIEC.tpll" => {
46                    match val {
47                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tpll = Some(v); } }
48                        crate::base::FieldValue::TextList(svs) => {
49                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tpll = Some(v); } }
50                        }
51                        _ => {}
52                    }
53                }
54                "WindRefFrameRotIEC.upll1" => {
55                    match val {
56                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.upll1 = Some(v); } }
57                        crate::base::FieldValue::TextList(svs) => {
58                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.upll1 = Some(v); } }
59                        }
60                        _ => {}
61                    }
62                }
63                "WindRefFrameRotIEC.upll2" => {
64                    match val {
65                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.upll2 = Some(v); } }
66                        crate::base::FieldValue::TextList(svs) => {
67                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.upll2 = 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}