Skip to main content

cimstructs/
TapChangerTablePoint.rs

1/// Describes each tap step in the tabular curve.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct TapChangerTablePoint {
4    pub id: String,
5    /// The magnetizing branch susceptance deviation as a percentage of nominal value. The actual susceptance is calculated as follows: calculated magnetizing susceptance = b(nominal) * (1 + b(from this class)/100). The b(nominal) is defined as the static magnetizing susceptance on the associated power transformer end or ends. This model assumes the star impedance (pi model) form.
6    #[serde(skip_serializing_if = "Option::is_none")]
7    pub b: Option<f64>,
8    /// The magnetizing branch conductance deviation as a percentage of nominal value. The actual conductance is calculated as follows: calculated magnetizing conductance = g(nominal) * (1 + g(from this class)/100). The g(nominal) is defined as the static magnetizing conductance on the associated power transformer end or ends. This model assumes the star impedance (pi model) form.
9    #[serde(skip_serializing_if = "Option::is_none")]
10    pub g: Option<f64>,
11    /// The resistance deviation as a percentage of nominal value. The actual reactance is calculated as follows: calculated resistance = r(nominal) * (1 + r(from this class)/100). The r(nominal) is defined as the static resistance on the associated power transformer end or ends. This model assumes the star impedance (pi model) form.
12    #[serde(skip_serializing_if = "Option::is_none")]
13    pub r: Option<f64>,
14    /// The voltage at the tap step divided by rated voltage of the transformer end having the tap changer. Hence this is a value close to one. For example, if the ratio at step 1 is 1.01, and the rated voltage of the transformer end is 110kV, then the voltage obtained by setting the tap changer to step 1 to is 111.1kV.
15    #[serde(skip_serializing_if = "Option::is_none")]
16    pub ratio: Option<f64>,
17    /// The tap step.
18    #[serde(skip_serializing_if = "Option::is_none")]
19    pub step: Option<i64>,
20    /// The series reactance deviation as a percentage of nominal value. The actual reactance is calculated as follows: calculated reactance = x(nominal) * (1 + x(from this class)/100). The x(nominal) is defined as the static series reactance on the associated power transformer end or ends. This model assumes the star impedance (pi model) form.
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub x: Option<f64>,
23}
24impl crate::base::CimElement for TapChangerTablePoint {
25    fn mrid(&self) -> &str { &self.id }
26    fn type_name(&self) -> &'static str { "TapChangerTablePoint" }
27    fn as_any(&self) -> &dyn std::any::Any { self }
28    fn to_json_value(&self) -> serde_json::Value {
29        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
30    }
31    fn to_block(&self) -> crate::base::RdfBlock {
32        let mut block = crate::base::RdfBlock {
33            type_name: "TapChangerTablePoint".to_string(),
34            mrid: self.id.clone(),
35            fields: std::collections::HashMap::new(),
36            duplicate_fields: std::collections::HashSet::new(),
37        };
38        if let Some(v) = self.b {
39            block.fields.insert("TapChangerTablePoint.b".into(), crate::base::FieldValue::Text(v.to_string()));
40        }
41        if let Some(v) = self.g {
42            block.fields.insert("TapChangerTablePoint.g".into(), crate::base::FieldValue::Text(v.to_string()));
43        }
44        if let Some(v) = self.r {
45            block.fields.insert("TapChangerTablePoint.r".into(), crate::base::FieldValue::Text(v.to_string()));
46        }
47        if let Some(v) = self.ratio {
48            block.fields.insert("TapChangerTablePoint.ratio".into(), crate::base::FieldValue::Text(v.to_string()));
49        }
50        if let Some(v) = self.step {
51            block.fields.insert("TapChangerTablePoint.step".into(), crate::base::FieldValue::Text(v.to_string()));
52        }
53        if let Some(v) = self.x {
54            block.fields.insert("TapChangerTablePoint.x".into(), crate::base::FieldValue::Text(v.to_string()));
55        }
56        block
57    }
58}
59
60impl TapChangerTablePoint {
61    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
62        let mut obj = Self::default();
63        obj.id.clone_from(&b.mrid);
64        for (key, val) in &b.fields {
65            match key.as_str() {
66                "TapChangerTablePoint.b" => {
67                    match val {
68                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.b = Some(v); } }
69                        crate::base::FieldValue::TextList(svs) => {
70                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.b = Some(v); } }
71                        }
72                        _ => {}
73                    }
74                }
75                "TapChangerTablePoint.g" => {
76                    match val {
77                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.g = Some(v); } }
78                        crate::base::FieldValue::TextList(svs) => {
79                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.g = Some(v); } }
80                        }
81                        _ => {}
82                    }
83                }
84                "TapChangerTablePoint.r" => {
85                    match val {
86                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
87                        crate::base::FieldValue::TextList(svs) => {
88                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.r = Some(v); } }
89                        }
90                        _ => {}
91                    }
92                }
93                "TapChangerTablePoint.ratio" => {
94                    match val {
95                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.ratio = Some(v); } }
96                        crate::base::FieldValue::TextList(svs) => {
97                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.ratio = Some(v); } }
98                        }
99                        _ => {}
100                    }
101                }
102                "TapChangerTablePoint.step" => {
103                    match val {
104                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.step = Some(v); } }
105                        crate::base::FieldValue::TextList(svs) => {
106                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.step = Some(v); } }
107                        }
108                        _ => {}
109                    }
110                }
111                "TapChangerTablePoint.x" => {
112                    match val {
113                        crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.x = Some(v); } }
114                        crate::base::FieldValue::TextList(svs) => {
115                            if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.x = Some(v); } }
116                        }
117                        _ => {}
118                    }
119                }
120                _ => {}
121            }
122        }
123        obj
124    }
125}