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