Skip to main content

cimstructs/
FaultIndicator.rs

1/// A FaultIndicator is typically only an indicator (which may or may not be remotely monitored), and not a piece of equipment that actually initiates a protection event. It is used for FLISR (Fault Location, Isolation and Restoration) purposes, assisting with the dispatch of crews to 'most likely' part of the network (i.e. assists with determining circuit section where the fault most likely happened).
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct FaultIndicator {
4    #[serde(flatten)]
5    pub base: super::AuxiliaryEquipment,
6}
7impl crate::base::CimElement for FaultIndicator {
8    fn mrid(&self) -> &str { &self.base.base.base.base.id }
9    fn type_name(&self) -> &'static str { "FaultIndicator" }
10    fn as_any(&self) -> &dyn std::any::Any { self }
11    fn to_json_value(&self) -> serde_json::Value {
12        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
13    }
14    fn to_block(&self) -> crate::base::RdfBlock {
15        let mut block = self.base.to_block();
16        block.type_name = "FaultIndicator".to_string();
17        block
18    }
19}
20
21impl FaultIndicator {
22    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
23        let mut obj = Self::default();
24        obj.base.base.base.base.id.clone_from(&b.mrid);
25        for (key, val) in &b.fields {
26            match key.as_str() {
27                "AuxiliaryEquipment.Terminal" => {
28                    if let crate::base::FieldValue::Resource(sv) = val {
29                        obj.base.terminal = Some(crate::base::MridRef { mrid: sv.clone() });
30                    }
31                }
32                "Equipment.EquipmentContainer" => {
33                    if let crate::base::FieldValue::Resource(sv) = val {
34                        obj.base.base.equipment_container = Some(crate::base::MridRef { mrid: sv.clone() });
35                    }
36                }
37                "Equipment.aggregate" => {
38                    match val {
39                        crate::base::FieldValue::Text(sv) => { obj.base.base.aggregate = Some(sv.trim() == "true"); }
40                        crate::base::FieldValue::TextList(svs) => {
41                            if let Some(sv) = svs.last() { obj.base.base.aggregate = Some(sv.trim() == "true"); }
42                        }
43                        _ => {}
44                    }
45                }
46                "Equipment.inService" => {
47                    match val {
48                        crate::base::FieldValue::Text(sv) => { obj.base.base.in_service = Some(sv.trim() == "true"); }
49                        crate::base::FieldValue::TextList(svs) => {
50                            if let Some(sv) = svs.last() { obj.base.base.in_service = Some(sv.trim() == "true"); }
51                        }
52                        _ => {}
53                    }
54                }
55                "Equipment.normallyInService" => {
56                    match val {
57                        crate::base::FieldValue::Text(sv) => { obj.base.base.normally_in_service = Some(sv.trim() == "true"); }
58                        crate::base::FieldValue::TextList(svs) => {
59                            if let Some(sv) = svs.last() { obj.base.base.normally_in_service = Some(sv.trim() == "true"); }
60                        }
61                        _ => {}
62                    }
63                }
64                "IdentifiedObject.description" => {
65                    match val {
66                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.description = sv.clone(); }
67                        crate::base::FieldValue::TextList(svs) => {
68                            if let Some(sv) = svs.last() { obj.base.base.base.base.description = sv.clone(); }
69                        }
70                        _ => {}
71                    }
72                }
73                "IdentifiedObject.energyIdentCodeEic" => {
74                    match val {
75                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
76                        crate::base::FieldValue::TextList(svs) => {
77                            if let Some(sv) = svs.last() { obj.base.base.base.base.energy_ident_code_eic = sv.clone(); }
78                        }
79                        _ => {}
80                    }
81                }
82                "IdentifiedObject.mRID" => {
83                    match val {
84                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.m_rid = sv.clone(); }
85                        crate::base::FieldValue::TextList(svs) => {
86                            if let Some(sv) = svs.last() { obj.base.base.base.base.m_rid = sv.clone(); }
87                        }
88                        _ => {}
89                    }
90                }
91                "IdentifiedObject.name" => {
92                    match val {
93                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.name = sv.clone(); }
94                        crate::base::FieldValue::TextList(svs) => {
95                            if let Some(sv) = svs.last() { obj.base.base.base.base.name = sv.clone(); }
96                        }
97                        _ => {}
98                    }
99                }
100                "IdentifiedObject.shortName" => {
101                    match val {
102                        crate::base::FieldValue::Text(sv) => { obj.base.base.base.base.short_name = sv.clone(); }
103                        crate::base::FieldValue::TextList(svs) => {
104                            if let Some(sv) = svs.last() { obj.base.base.base.base.short_name = sv.clone(); }
105                        }
106                        _ => {}
107                    }
108                }
109                _ => {}
110            }
111        }
112        obj
113    }
114}