cimstructs/
NonlinearShuntCompensatorPoint.rs1#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct NonlinearShuntCompensatorPoint {
4 pub id: String,
5 #[serde(skip_serializing_if = "Option::is_none")]
7 pub nonlinear_shunt_compensator: Option<super::base::MridRef>,
8 #[serde(skip_serializing_if = "Option::is_none")]
10 pub b: Option<f64>,
11 #[serde(skip_serializing_if = "Option::is_none")]
13 pub b0: Option<f64>,
14 #[serde(skip_serializing_if = "Option::is_none")]
16 pub g: Option<f64>,
17 #[serde(skip_serializing_if = "Option::is_none")]
19 pub g0: Option<f64>,
20 #[serde(skip_serializing_if = "Option::is_none")]
22 pub section_number: Option<i64>,
23}
24impl crate::base::CimElement for NonlinearShuntCompensatorPoint {
25 fn mrid(&self) -> &str { &self.id }
26 fn type_name(&self) -> &'static str { "NonlinearShuntCompensatorPoint" }
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: "NonlinearShuntCompensatorPoint".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(ref v) = self.nonlinear_shunt_compensator {
39 block.fields.insert("NonlinearShuntCompensatorPoint.NonlinearShuntCompensator".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
40 }
41 if let Some(v) = self.b {
42 block.fields.insert("NonlinearShuntCompensatorPoint.b".into(), crate::base::FieldValue::Text(v.to_string()));
43 }
44 if let Some(v) = self.b0 {
45 block.fields.insert("NonlinearShuntCompensatorPoint.b0".into(), crate::base::FieldValue::Text(v.to_string()));
46 }
47 if let Some(v) = self.g {
48 block.fields.insert("NonlinearShuntCompensatorPoint.g".into(), crate::base::FieldValue::Text(v.to_string()));
49 }
50 if let Some(v) = self.g0 {
51 block.fields.insert("NonlinearShuntCompensatorPoint.g0".into(), crate::base::FieldValue::Text(v.to_string()));
52 }
53 if let Some(v) = self.section_number {
54 block.fields.insert("NonlinearShuntCompensatorPoint.sectionNumber".into(), crate::base::FieldValue::Text(v.to_string()));
55 }
56 block
57 }
58}
59
60impl NonlinearShuntCompensatorPoint {
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 "NonlinearShuntCompensatorPoint.NonlinearShuntCompensator" => {
67 if let crate::base::FieldValue::Resource(sv) = val {
68 obj.nonlinear_shunt_compensator = Some(crate::base::MridRef { mrid: sv.clone() });
69 }
70 }
71 "NonlinearShuntCompensatorPoint.b" => {
72 match val {
73 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.b = Some(v); } }
74 crate::base::FieldValue::TextList(svs) => {
75 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.b = Some(v); } }
76 }
77 _ => {}
78 }
79 }
80 "NonlinearShuntCompensatorPoint.b0" => {
81 match val {
82 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.b0 = Some(v); } }
83 crate::base::FieldValue::TextList(svs) => {
84 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.b0 = Some(v); } }
85 }
86 _ => {}
87 }
88 }
89 "NonlinearShuntCompensatorPoint.g" => {
90 match val {
91 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.g = Some(v); } }
92 crate::base::FieldValue::TextList(svs) => {
93 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.g = Some(v); } }
94 }
95 _ => {}
96 }
97 }
98 "NonlinearShuntCompensatorPoint.g0" => {
99 match val {
100 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.g0 = Some(v); } }
101 crate::base::FieldValue::TextList(svs) => {
102 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.g0 = Some(v); } }
103 }
104 _ => {}
105 }
106 }
107 "NonlinearShuntCompensatorPoint.sectionNumber" => {
108 match val {
109 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.section_number = Some(v); } }
110 crate::base::FieldValue::TextList(svs) => {
111 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.section_number = Some(v); } }
112 }
113 _ => {}
114 }
115 }
116 _ => {}
117 }
118 }
119 obj
120 }
121}