cimstructs/
DiscExcContIEEEDEC3A.rs1#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct DiscExcContIEEEDEC3A {
4 #[serde(flatten)]
5 pub base: super::DiscontinuousExcitationControlDynamics,
6 #[serde(skip_serializing_if = "Option::is_none")]
8 pub tdr: Option<f64>,
9 #[serde(skip_serializing_if = "Option::is_none")]
11 pub vtmin: Option<f64>,
12}
13impl crate::base::CimElement for DiscExcContIEEEDEC3A {
14 fn mrid(&self) -> &str { &self.base.base.base.id }
15 fn type_name(&self) -> &'static str { "DiscExcContIEEEDEC3A" }
16 fn as_any(&self) -> &dyn std::any::Any { self }
17 fn to_json_value(&self) -> serde_json::Value {
18 serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
19 }
20 fn to_block(&self) -> crate::base::RdfBlock {
21 let mut block = self.base.to_block();
22 block.type_name = "DiscExcContIEEEDEC3A".to_string();
23 if let Some(v) = self.tdr {
24 block.fields.insert("DiscExcContIEEEDEC3A.tdr".into(), crate::base::FieldValue::Text(v.to_string()));
25 }
26 if let Some(v) = self.vtmin {
27 block.fields.insert("DiscExcContIEEEDEC3A.vtmin".into(), crate::base::FieldValue::Text(v.to_string()));
28 }
29 block
30 }
31}
32
33impl DiscExcContIEEEDEC3A {
34 pub fn from_block(b: &crate::base::RdfBlock) -> Self {
35 let mut obj = Self::default();
36 obj.base.base.base.id.clone_from(&b.mrid);
37 for (key, val) in &b.fields {
38 match key.as_str() {
39 "DiscExcContIEEEDEC3A.tdr" => {
40 match val {
41 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.tdr = Some(v); } }
42 crate::base::FieldValue::TextList(svs) => {
43 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.tdr = Some(v); } }
44 }
45 _ => {}
46 }
47 }
48 "DiscExcContIEEEDEC3A.vtmin" => {
49 match val {
50 crate::base::FieldValue::Text(sv) => { if let Ok(v) = sv.trim().parse() { obj.vtmin = Some(v); } }
51 crate::base::FieldValue::TextList(svs) => {
52 if let Some(sv) = svs.last() { if let Ok(v) = sv.trim().parse() { obj.vtmin = Some(v); } }
53 }
54 _ => {}
55 }
56 }
57 "DiscontinuousExcitationControlDynamics.ExcitationSystemDynamics" => {
58 if let crate::base::FieldValue::Resource(sv) = val {
59 obj.base.excitation_system_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
60 }
61 }
62 "DynamicsFunctionBlock.enabled" => {
63 match val {
64 crate::base::FieldValue::Text(sv) => { obj.base.base.enabled = Some(sv.trim() == "true"); }
65 crate::base::FieldValue::TextList(svs) => {
66 if let Some(sv) = svs.last() { obj.base.base.enabled = Some(sv.trim() == "true"); }
67 }
68 _ => {}
69 }
70 }
71 "IdentifiedObject.description" => {
72 match val {
73 crate::base::FieldValue::Text(sv) => { obj.base.base.base.description = sv.clone(); }
74 crate::base::FieldValue::TextList(svs) => {
75 if let Some(sv) = svs.last() { obj.base.base.base.description = sv.clone(); }
76 }
77 _ => {}
78 }
79 }
80 "IdentifiedObject.energyIdentCodeEic" => {
81 match val {
82 crate::base::FieldValue::Text(sv) => { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
83 crate::base::FieldValue::TextList(svs) => {
84 if let Some(sv) = svs.last() { obj.base.base.base.energy_ident_code_eic = sv.clone(); }
85 }
86 _ => {}
87 }
88 }
89 "IdentifiedObject.mRID" => {
90 match val {
91 crate::base::FieldValue::Text(sv) => { obj.base.base.base.m_rid = sv.clone(); }
92 crate::base::FieldValue::TextList(svs) => {
93 if let Some(sv) = svs.last() { obj.base.base.base.m_rid = sv.clone(); }
94 }
95 _ => {}
96 }
97 }
98 "IdentifiedObject.name" => {
99 match val {
100 crate::base::FieldValue::Text(sv) => { obj.base.base.base.name = sv.clone(); }
101 crate::base::FieldValue::TextList(svs) => {
102 if let Some(sv) = svs.last() { obj.base.base.base.name = sv.clone(); }
103 }
104 _ => {}
105 }
106 }
107 "IdentifiedObject.shortName" => {
108 match val {
109 crate::base::FieldValue::Text(sv) => { obj.base.base.base.short_name = sv.clone(); }
110 crate::base::FieldValue::TextList(svs) => {
111 if let Some(sv) = svs.last() { obj.base.base.base.short_name = sv.clone(); }
112 }
113 _ => {}
114 }
115 }
116 _ => {}
117 }
118 }
119 obj
120 }
121}