cimstructs/
BoundaryPoint.rs1#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct BoundaryPoint {
4 #[serde(flatten)]
5 pub base: super::PowerSystemResource,
6 #[serde(skip_serializing_if = "Option::is_none")]
8 pub connectivity_node: Option<super::base::MridRef>,
9 pub from_end_iso_code: String,
11 pub from_end_name: String,
13 pub from_end_name_tso: String,
15 #[serde(skip_serializing_if = "Option::is_none")]
17 pub is_direct_current: Option<bool>,
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub is_excluded_from_area_interchange: Option<bool>,
21 pub to_end_iso_code: String,
23 pub to_end_name: String,
25 pub to_end_name_tso: String,
27}
28impl crate::base::CimElement for BoundaryPoint {
29 fn mrid(&self) -> &str { &self.base.base.id }
30 fn type_name(&self) -> &'static str { "BoundaryPoint" }
31 fn as_any(&self) -> &dyn std::any::Any { self }
32 fn to_json_value(&self) -> serde_json::Value {
33 serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
34 }
35 fn to_block(&self) -> crate::base::RdfBlock {
36 let mut block = self.base.to_block();
37 block.type_name = "BoundaryPoint".to_string();
38 if let Some(ref v) = self.connectivity_node {
39 block.fields.insert("BoundaryPoint.ConnectivityNode".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
40 }
41 if !self.from_end_iso_code.is_empty() {
42 block.fields.insert("BoundaryPoint.fromEndIsoCode".into(), crate::base::FieldValue::Text(self.from_end_iso_code.clone()));
43 }
44 if !self.from_end_name.is_empty() {
45 block.fields.insert("BoundaryPoint.fromEndName".into(), crate::base::FieldValue::Text(self.from_end_name.clone()));
46 }
47 if !self.from_end_name_tso.is_empty() {
48 block.fields.insert("BoundaryPoint.fromEndNameTso".into(), crate::base::FieldValue::Text(self.from_end_name_tso.clone()));
49 }
50 if let Some(v) = self.is_direct_current {
51 block.fields.insert("BoundaryPoint.isDirectCurrent".into(), crate::base::FieldValue::Text(v.to_string()));
52 }
53 if let Some(v) = self.is_excluded_from_area_interchange {
54 block.fields.insert("BoundaryPoint.isExcludedFromAreaInterchange".into(), crate::base::FieldValue::Text(v.to_string()));
55 }
56 if !self.to_end_iso_code.is_empty() {
57 block.fields.insert("BoundaryPoint.toEndIsoCode".into(), crate::base::FieldValue::Text(self.to_end_iso_code.clone()));
58 }
59 if !self.to_end_name.is_empty() {
60 block.fields.insert("BoundaryPoint.toEndName".into(), crate::base::FieldValue::Text(self.to_end_name.clone()));
61 }
62 if !self.to_end_name_tso.is_empty() {
63 block.fields.insert("BoundaryPoint.toEndNameTso".into(), crate::base::FieldValue::Text(self.to_end_name_tso.clone()));
64 }
65 block
66 }
67}
68
69impl BoundaryPoint {
70 pub fn from_block(b: &crate::base::RdfBlock) -> Self {
71 let mut obj = Self::default();
72 obj.base.base.id.clone_from(&b.mrid);
73 for (key, val) in &b.fields {
74 match key.as_str() {
75 "BoundaryPoint.ConnectivityNode" => {
76 if let crate::base::FieldValue::Resource(sv) = val {
77 obj.connectivity_node = Some(crate::base::MridRef { mrid: sv.clone() });
78 }
79 }
80 "BoundaryPoint.fromEndIsoCode" => {
81 match val {
82 crate::base::FieldValue::Text(sv) => { obj.from_end_iso_code = sv.clone(); }
83 crate::base::FieldValue::TextList(svs) => {
84 if let Some(sv) = svs.last() { obj.from_end_iso_code = sv.clone(); }
85 }
86 _ => {}
87 }
88 }
89 "BoundaryPoint.fromEndName" => {
90 match val {
91 crate::base::FieldValue::Text(sv) => { obj.from_end_name = sv.clone(); }
92 crate::base::FieldValue::TextList(svs) => {
93 if let Some(sv) = svs.last() { obj.from_end_name = sv.clone(); }
94 }
95 _ => {}
96 }
97 }
98 "BoundaryPoint.fromEndNameTso" => {
99 match val {
100 crate::base::FieldValue::Text(sv) => { obj.from_end_name_tso = sv.clone(); }
101 crate::base::FieldValue::TextList(svs) => {
102 if let Some(sv) = svs.last() { obj.from_end_name_tso = sv.clone(); }
103 }
104 _ => {}
105 }
106 }
107 "BoundaryPoint.isDirectCurrent" => {
108 match val {
109 crate::base::FieldValue::Text(sv) => { obj.is_direct_current = Some(sv.trim() == "true"); }
110 crate::base::FieldValue::TextList(svs) => {
111 if let Some(sv) = svs.last() { obj.is_direct_current = Some(sv.trim() == "true"); }
112 }
113 _ => {}
114 }
115 }
116 "BoundaryPoint.isExcludedFromAreaInterchange" => {
117 match val {
118 crate::base::FieldValue::Text(sv) => { obj.is_excluded_from_area_interchange = Some(sv.trim() == "true"); }
119 crate::base::FieldValue::TextList(svs) => {
120 if let Some(sv) = svs.last() { obj.is_excluded_from_area_interchange = Some(sv.trim() == "true"); }
121 }
122 _ => {}
123 }
124 }
125 "BoundaryPoint.toEndIsoCode" => {
126 match val {
127 crate::base::FieldValue::Text(sv) => { obj.to_end_iso_code = sv.clone(); }
128 crate::base::FieldValue::TextList(svs) => {
129 if let Some(sv) = svs.last() { obj.to_end_iso_code = sv.clone(); }
130 }
131 _ => {}
132 }
133 }
134 "BoundaryPoint.toEndName" => {
135 match val {
136 crate::base::FieldValue::Text(sv) => { obj.to_end_name = sv.clone(); }
137 crate::base::FieldValue::TextList(svs) => {
138 if let Some(sv) = svs.last() { obj.to_end_name = sv.clone(); }
139 }
140 _ => {}
141 }
142 }
143 "BoundaryPoint.toEndNameTso" => {
144 match val {
145 crate::base::FieldValue::Text(sv) => { obj.to_end_name_tso = sv.clone(); }
146 crate::base::FieldValue::TextList(svs) => {
147 if let Some(sv) = svs.last() { obj.to_end_name_tso = sv.clone(); }
148 }
149 _ => {}
150 }
151 }
152 "IdentifiedObject.description" => {
153 match val {
154 crate::base::FieldValue::Text(sv) => { obj.base.base.description = sv.clone(); }
155 crate::base::FieldValue::TextList(svs) => {
156 if let Some(sv) = svs.last() { obj.base.base.description = sv.clone(); }
157 }
158 _ => {}
159 }
160 }
161 "IdentifiedObject.energyIdentCodeEic" => {
162 match val {
163 crate::base::FieldValue::Text(sv) => { obj.base.base.energy_ident_code_eic = sv.clone(); }
164 crate::base::FieldValue::TextList(svs) => {
165 if let Some(sv) = svs.last() { obj.base.base.energy_ident_code_eic = sv.clone(); }
166 }
167 _ => {}
168 }
169 }
170 "IdentifiedObject.mRID" => {
171 match val {
172 crate::base::FieldValue::Text(sv) => { obj.base.base.m_rid = sv.clone(); }
173 crate::base::FieldValue::TextList(svs) => {
174 if let Some(sv) = svs.last() { obj.base.base.m_rid = sv.clone(); }
175 }
176 _ => {}
177 }
178 }
179 "IdentifiedObject.name" => {
180 match val {
181 crate::base::FieldValue::Text(sv) => { obj.base.base.name = sv.clone(); }
182 crate::base::FieldValue::TextList(svs) => {
183 if let Some(sv) = svs.last() { obj.base.base.name = sv.clone(); }
184 }
185 _ => {}
186 }
187 }
188 "IdentifiedObject.shortName" => {
189 match val {
190 crate::base::FieldValue::Text(sv) => { obj.base.base.short_name = sv.clone(); }
191 crate::base::FieldValue::TextList(svs) => {
192 if let Some(sv) = svs.last() { obj.base.base.short_name = sv.clone(); }
193 }
194 _ => {}
195 }
196 }
197 _ => {}
198 }
199 }
200 obj
201 }
202}