cimstructs/
DiscExcContIEEEDEC2A.rs1#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct DiscExcContIEEEDEC2A {
4 #[serde(flatten)]
5 pub base: super::DiscontinuousExcitationControlDynamics,
6 #[serde(skip_serializing_if = "Option::is_none")]
8 pub td1: Option<f64>,
9 #[serde(skip_serializing_if = "Option::is_none")]
11 pub td2: Option<f64>,
12 #[serde(skip_serializing_if = "Option::is_none")]
14 pub vdmax: Option<f64>,
15 #[serde(skip_serializing_if = "Option::is_none")]
17 pub vdmin: Option<f64>,
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub vk: Option<f64>,
21}
22impl crate::base::CimElement for DiscExcContIEEEDEC2A {
23 fn mrid(&self) -> &str { &self.base.base.base.id }
24 fn type_name(&self) -> &'static str { "DiscExcContIEEEDEC2A" }
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 = "DiscExcContIEEEDEC2A".to_string();
32 if let Some(v) = self.td1 {
33 block.fields.insert("DiscExcContIEEEDEC2A.td1".into(), crate::base::FieldValue::Text(v.to_string()));
34 }
35 if let Some(v) = self.td2 {
36 block.fields.insert("DiscExcContIEEEDEC2A.td2".into(), crate::base::FieldValue::Text(v.to_string()));
37 }
38 if let Some(v) = self.vdmax {
39 block.fields.insert("DiscExcContIEEEDEC2A.vdmax".into(), crate::base::FieldValue::Text(v.to_string()));
40 }
41 if let Some(v) = self.vdmin {
42 block.fields.insert("DiscExcContIEEEDEC2A.vdmin".into(), crate::base::FieldValue::Text(v.to_string()));
43 }
44 if let Some(v) = self.vk {
45 block.fields.insert("DiscExcContIEEEDEC2A.vk".into(), crate::base::FieldValue::Text(v.to_string()));
46 }
47 block
48 }
49}
50
51impl DiscExcContIEEEDEC2A {
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 "DiscExcContIEEEDEC2A.td1" => {
58 match val {
59 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.td1 = Some(v); } }
60 crate::base::FieldValue::TextList(svs) => {
61 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.td1 = Some(v); } }
62 }
63 _ => {}
64 }
65 }
66 "DiscExcContIEEEDEC2A.td2" => {
67 match val {
68 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.td2 = Some(v); } }
69 crate::base::FieldValue::TextList(svs) => {
70 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.td2 = Some(v); } }
71 }
72 _ => {}
73 }
74 }
75 "DiscExcContIEEEDEC2A.vdmax" => {
76 match val {
77 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vdmax = Some(v); } }
78 crate::base::FieldValue::TextList(svs) => {
79 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vdmax = Some(v); } }
80 }
81 _ => {}
82 }
83 }
84 "DiscExcContIEEEDEC2A.vdmin" => {
85 match val {
86 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vdmin = Some(v); } }
87 crate::base::FieldValue::TextList(svs) => {
88 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vdmin = Some(v); } }
89 }
90 _ => {}
91 }
92 }
93 "DiscExcContIEEEDEC2A.vk" => {
94 match val {
95 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vk = Some(v); } }
96 crate::base::FieldValue::TextList(svs) => {
97 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vk = Some(v); } }
98 }
99 _ => {}
100 }
101 }
102 "DiscontinuousExcitationControlDynamics.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}