Skip to main content

cimstructs/
OverexcLimX2.rs

1/// Field voltage or current overexcitation limiter designed to protect the generator field of an AC machine with automatic excitation control from overheating due to prolonged overexcitation.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct OverexcLimX2 {
4    #[serde(flatten)]
5    pub base: super::OverexcitationLimiterDynamics,
6    /// Low voltage or current point on the inverse time characteristic (EFD1). Typical value = 1,1.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub efd1: Option<f64>,
9    /// Mid voltage or current point on the inverse time characteristic (EFD2). Typical value = 1,2.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub efd2: Option<f64>,
12    /// High voltage or current point on the inverse time characteristic (EFD3). Typical value = 1,5.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub efd3: Option<f64>,
15    /// Desired field voltage if m = false or desired field current if m = true (EFDDES). Typical value = 1.
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub efddes: Option<f64>,
18    /// Rated field voltage if m = false or rated field current if m = true (EFDRATED). Typical value = 1,05.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub efdrated: Option<f64>,
21    /// Gain (KMX). Typical value = 0,002.
22    #[serde(skip_serializing_if = "Option::is_none")]
23    pub kmx: Option<f64>,
24    /// (m). true = IFD limiting false = EFD limiting.
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub m: Option<bool>,
27    /// Time to trip the exciter at the low voltage or current point on the inverse time characteristic (TIME1) (>= 0). Typical value = 120.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub t1: Option<f64>,
30    /// Time to trip the exciter at the mid voltage or current point on the inverse time characteristic (TIME2) (>= 0). Typical value = 40.
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub t2: Option<f64>,
33    /// Time to trip the exciter at the high voltage or current point on the inverse time characteristic (TIME3) (>= 0). Typical value = 15.
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub t3: Option<f64>,
36    /// Low voltage limit (VLOW) (> 0).
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub vlow: Option<f64>,
39}
40impl crate::base::CimElement for OverexcLimX2 {
41    fn mrid(&self) -> &str { &self.base.base.base.id }
42    fn type_name(&self) -> &'static str { "OverexcLimX2" }
43    fn as_any(&self) -> &dyn std::any::Any { self }
44    fn to_json_value(&self) -> serde_json::Value {
45        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
46    }
47    fn to_block(&self) -> crate::base::RdfBlock {
48        let mut block = self.base.to_block();
49        block.type_name = "OverexcLimX2".to_string();
50        if let Some(v) = self.efd1 {
51            block.fields.insert("OverexcLimX2.efd1".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.efd2 {
54            block.fields.insert("OverexcLimX2.efd2".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        if let Some(v) = self.efd3 {
57            block.fields.insert("OverexcLimX2.efd3".into(), crate::base::FieldValue::Text(v.to_string()));
58        }
59        if let Some(v) = self.efddes {
60            block.fields.insert("OverexcLimX2.efddes".into(), crate::base::FieldValue::Text(v.to_string()));
61        }
62        if let Some(v) = self.efdrated {
63            block.fields.insert("OverexcLimX2.efdrated".into(), crate::base::FieldValue::Text(v.to_string()));
64        }
65        if let Some(v) = self.kmx {
66            block.fields.insert("OverexcLimX2.kmx".into(), crate::base::FieldValue::Text(v.to_string()));
67        }
68        if let Some(v) = self.m {
69            block.fields.insert("OverexcLimX2.m".into(), crate::base::FieldValue::Text(v.to_string()));
70        }
71        if let Some(v) = self.t1 {
72            block.fields.insert("OverexcLimX2.t1".into(), crate::base::FieldValue::Text(v.to_string()));
73        }
74        if let Some(v) = self.t2 {
75            block.fields.insert("OverexcLimX2.t2".into(), crate::base::FieldValue::Text(v.to_string()));
76        }
77        if let Some(v) = self.t3 {
78            block.fields.insert("OverexcLimX2.t3".into(), crate::base::FieldValue::Text(v.to_string()));
79        }
80        if let Some(v) = self.vlow {
81            block.fields.insert("OverexcLimX2.vlow".into(), crate::base::FieldValue::Text(v.to_string()));
82        }
83        block
84    }
85}
86
87impl OverexcLimX2 {
88    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
89        let mut obj = Self::default();
90        obj.base.base.base.id.clone_from(&b.mrid);
91        for (key, val) in &b.fields {
92            match key.as_str() {
93                "OverexcLimX2.efd1" => {
94                    match val {
95                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efd1 = Some(v); } }
96                        crate::base::FieldValue::TextList(svs) => {
97                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efd1 = Some(v); } }
98                        }
99                        _ => {}
100                    }
101                }
102                "OverexcLimX2.efd2" => {
103                    match val {
104                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efd2 = Some(v); } }
105                        crate::base::FieldValue::TextList(svs) => {
106                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efd2 = Some(v); } }
107                        }
108                        _ => {}
109                    }
110                }
111                "OverexcLimX2.efd3" => {
112                    match val {
113                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efd3 = Some(v); } }
114                        crate::base::FieldValue::TextList(svs) => {
115                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efd3 = Some(v); } }
116                        }
117                        _ => {}
118                    }
119                }
120                "OverexcLimX2.efddes" => {
121                    match val {
122                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efddes = Some(v); } }
123                        crate::base::FieldValue::TextList(svs) => {
124                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efddes = Some(v); } }
125                        }
126                        _ => {}
127                    }
128                }
129                "OverexcLimX2.efdrated" => {
130                    match val {
131                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.efdrated = Some(v); } }
132                        crate::base::FieldValue::TextList(svs) => {
133                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.efdrated = Some(v); } }
134                        }
135                        _ => {}
136                    }
137                }
138                "OverexcLimX2.kmx" => {
139                    match val {
140                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.kmx = Some(v); } }
141                        crate::base::FieldValue::TextList(svs) => {
142                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.kmx = Some(v); } }
143                        }
144                        _ => {}
145                    }
146                }
147                "OverexcLimX2.m" => {
148                    match val {
149                        crate::base::FieldValue::Text(sv) => { obj.m = Some(sv.trim() == "true"); }
150                        crate::base::FieldValue::TextList(svs) => {
151                            if let Some(sv) = svs.last() { obj.m = Some(sv.trim() == "true"); }
152                        }
153                        _ => {}
154                    }
155                }
156                "OverexcLimX2.t1" => {
157                    match val {
158                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
159                        crate::base::FieldValue::TextList(svs) => {
160                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t1 = Some(v); } }
161                        }
162                        _ => {}
163                    }
164                }
165                "OverexcLimX2.t2" => {
166                    match val {
167                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t2 = Some(v); } }
168                        crate::base::FieldValue::TextList(svs) => {
169                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t2 = Some(v); } }
170                        }
171                        _ => {}
172                    }
173                }
174                "OverexcLimX2.t3" => {
175                    match val {
176                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.t3 = Some(v); } }
177                        crate::base::FieldValue::TextList(svs) => {
178                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.t3 = Some(v); } }
179                        }
180                        _ => {}
181                    }
182                }
183                "OverexcLimX2.vlow" => {
184                    match val {
185                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vlow = Some(v); } }
186                        crate::base::FieldValue::TextList(svs) => {
187                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vlow = Some(v); } }
188                        }
189                        _ => {}
190                    }
191                }
192                "OverexcitationLimiterDynamics.ExcitationSystemDynamics" => {
193                    if let crate::base::FieldValue::Resource(sv) = val {
194                        obj.base.excitation_system_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
195                    }
196                }
197                "DynamicsFunctionBlock.enabled" => {
198                    match val {
199                        crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
200                        crate::base::FieldValue::TextList(svs) => {
201                            if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
202                        }
203                        _ => {}
204                    }
205                }
206                "IdentifiedObject.description" => {
207                    match val {
208                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
209                        crate::base::FieldValue::TextList(svs) => {
210                            if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
211                        }
212                        _ => {}
213                    }
214                }
215                "IdentifiedObject.energyIdentCodeEic" => {
216                    match val {
217                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
218                        crate::base::FieldValue::TextList(svs) => {
219                            if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
220                        }
221                        _ => {}
222                    }
223                }
224                "IdentifiedObject.mRID" => {
225                    match val {
226                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
227                        crate::base::FieldValue::TextList(svs) => {
228                            if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
229                        }
230                        _ => {}
231                    }
232                }
233                "IdentifiedObject.name" => {
234                    match val {
235                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
236                        crate::base::FieldValue::TextList(svs) => {
237                            if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
238                        }
239                        _ => {}
240                    }
241                }
242                "IdentifiedObject.shortName" => {
243                    match val {
244                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
245                        crate::base::FieldValue::TextList(svs) => {
246                            if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
247                        }
248                        _ => {}
249                    }
250                }
251                _ => {}
252            }
253        }
254        obj
255    }
256}