Skip to main content

cimstructs/
PFVArType2Common1.rs

1/// Power factor / reactive power regulator. This model represents the power factor or reactive power controller such as the Basler SCP-250. The controller measures power factor or reactive power (PU on generator rated power) and compares it with the operator's set point. [Footnote: Basler SCP-250 is an example of a suitable product available commercially. This information is given for the convenience of users of this document and does not constitute an endorsement by IEC of this product.]
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct PFVArType2Common1 {
4    #[serde(flatten)]
5    pub base: super::PFVArControllerType2Dynamics,
6    /// Selector (J). true = control mode for reactive power false = control mode for power factor.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub j: Option<bool>,
9    /// Reset gain (Ki).
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub ki: Option<f64>,
12    /// Proportional gain (Kp).
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub kp: Option<f64>,
15    /// Output limit (max).
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub max: Option<f64>,
18    /// Reference value of reactive power or power factor (Ref). The reference value is initialised by this model. This initialisation can override the value exchanged by this attribute to represent a plant operator's change of the reference setting.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub ref_: Option<f64>,
21}
22impl crate::base::CimElement for PFVArType2Common1 {
23    fn mrid(&self) -> &str { &self.base.base.base.id }
24    fn type_name(&self) -> &'static str { "PFVArType2Common1" }
25    fn as_any(&self) -> &dyn std::any::Any { self }
26    fn to_json_value(&self) -> serde_json::Value {
27        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
28    }
29    fn to_block(&self) -> crate::base::RdfBlock {
30        let mut block = self.base.to_block();
31        block.type_name = "PFVArType2Common1".to_string();
32        if let Some(v) = self.j {
33            block.fields.insert("PFVArType2Common1.j".into(), crate::base::FieldValue::Text(v.to_string()));
34        }
35        if let Some(v) = self.ki {
36            block.fields.insert("PFVArType2Common1.ki".into(), crate::base::FieldValue::Text(v.to_string()));
37        }
38        if let Some(v) = self.kp {
39            block.fields.insert("PFVArType2Common1.kp".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        if let Some(v) = self.max {
42            block.fields.insert("PFVArType2Common1.max".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.ref_ {
45            block.fields.insert("PFVArType2Common1.ref".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        block
48    }
49}
50
51impl PFVArType2Common1 {
52    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
53        let mut obj = Self::default();
54        obj.base.base.base.id.clone_from(&b.mrid);
55        for (key, val) in &b.fields {
56            match key.as_str() {
57                "PFVArType2Common1.j" => {
58                    match val {
59                        crate::base::FieldValue::Text(sv) => { obj.j = Some(sv.trim() == "true"); }
60                        crate::base::FieldValue::TextList(svs) => {
61                            if let Some(sv) = svs.last() { obj.j = Some(sv.trim() == "true"); }
62                        }
63                        _ => {}
64                    }
65                }
66                "PFVArType2Common1.ki" => {
67                    match val {
68                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
69                        crate::base::FieldValue::TextList(svs) => {
70                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ki = Some(v); } }
71                        }
72                        _ => {}
73                    }
74                }
75                "PFVArType2Common1.kp" => {
76                    match val {
77                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
78                        crate::base::FieldValue::TextList(svs) => {
79                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kp = Some(v); } }
80                        }
81                        _ => {}
82                    }
83                }
84                "PFVArType2Common1.max" => {
85                    match val {
86                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.max = Some(v); } }
87                        crate::base::FieldValue::TextList(svs) => {
88                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.max = Some(v); } }
89                        }
90                        _ => {}
91                    }
92                }
93                "PFVArType2Common1.ref" => {
94                    match val {
95                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ref_ = Some(v); } }
96                        crate::base::FieldValue::TextList(svs) => {
97                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ref_ = Some(v); } }
98                        }
99                        _ => {}
100                    }
101                }
102                "PFVArControllerType2Dynamics.ExcitationSystemDynamics" => {
103                    if let crate::base::FieldValue::Resource(sv) = val {
104                        obj.base.excitation_system_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
105                    }
106                }
107                "DynamicsFunctionBlock.enabled" => {
108                    match val {
109                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
110                        crate::base::FieldValue::TextList(svs) => {
111                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
112                        }
113                        _ => {}
114                    }
115                }
116                "IdentifiedObject.description" => {
117                    match val {
118                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
119                        crate::base::FieldValue::TextList(svs) => {
120                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
121                        }
122                        _ => {}
123                    }
124                }
125                "IdentifiedObject.energyIdentCodeEic" => {
126                    match val {
127                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
128                        crate::base::FieldValue::TextList(svs) => {
129                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
130                        }
131                        _ => {}
132                    }
133                }
134                "IdentifiedObject.mRID" => {
135                    match val {
136                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
137                        crate::base::FieldValue::TextList(svs) => {
138                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
139                        }
140                        _ => {}
141                    }
142                }
143                "IdentifiedObject.name" => {
144                    match val {
145                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
146                        crate::base::FieldValue::TextList(svs) => {
147                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
148                        }
149                        _ => {}
150                    }
151                }
152                "IdentifiedObject.shortName" => {
153                    match val {
154                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
155                        crate::base::FieldValue::TextList(svs) => {
156                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
157                        }
158                        _ => {}
159                    }
160                }
161                _ => {}
162            }
163        }
164        obj
165    }
166}