Skip to main content

cimstructs/
WindTurbineType3or4Dynamics.rs

1/// Parent class supporting relationships to wind turbines type 3 and type 4 and wind plant including their control models.
2#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
3pub struct WindTurbineType3or4Dynamics {
4    #[serde(flatten)]
5    pub base: super::DynamicsFunctionBlock,
6    /// The power electronics connection associated with this wind turbine type 3 or type 4 dynamics model.
7    #[serde(skip_serializing_if = "Option::is_none")]
8    pub power_electronics_connection: Option<super::base::MridRef>,
9    /// Remote input signal used by these wind turbine type 3 or type 4 models.
10    #[serde(skip_serializing_if = "Option::is_none")]
11    pub remote_input_signal: Option<super::base::MridRef>,
12    /// The wind plant with which the wind turbines type 3 or type 4 are associated.
13    #[serde(skip_serializing_if = "Option::is_none")]
14    pub wind_plant_dynamics: Option<super::base::MridRef>,
15}
16impl crate::base::CimElement for WindTurbineType3or4Dynamics {
17    fn mrid(&self) -> &str { &self.base.base.id }
18    fn type_name(&self) -> &'static str { "WindTurbineType3or4Dynamics" }
19    fn as_any(&self) -> &dyn std::any::Any { self }
20    fn to_json_value(&self) -> serde_json::Value {
21        serde_json::to_value(self).unwrap_or(serde_json::Value::Null)
22    }
23    fn to_block(&self) -> crate::base::RdfBlock {
24        let mut block = self.base.to_block();
25        block.type_name = "WindTurbineType3or4Dynamics".to_string();
26        if let Some(ref v) = self.power_electronics_connection {
27            block.fields.insert("WindTurbineType3or4Dynamics.PowerElectronicsConnection".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
28        }
29        if let Some(ref v) = self.remote_input_signal {
30            block.fields.insert("WindTurbineType3or4Dynamics.RemoteInputSignal".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
31        }
32        if let Some(ref v) = self.wind_plant_dynamics {
33            block.fields.insert("WindTurbineType3or4Dynamics.WindPlantDynamics".into(), crate::base::FieldValue::Resource(v.mrid.clone()));
34        }
35        block
36    }
37}
38
39impl WindTurbineType3or4Dynamics {
40    pub fn from_block(b: &crate::base::RdfBlock) -> Self {
41        let mut obj = Self::default();
42        obj.base.base.id.clone_from(&b.mrid);
43        for (key, val) in &b.fields {
44            match key.as_str() {
45                "WindTurbineType3or4Dynamics.PowerElectronicsConnection" => {
46                    if let crate::base::FieldValue::Resource(sv) = val {
47                        obj.power_electronics_connection = Some(crate::base::MridRef { mrid: sv.clone() });
48                    }
49                }
50                "WindTurbineType3or4Dynamics.RemoteInputSignal" => {
51                    if let crate::base::FieldValue::Resource(sv) = val {
52                        obj.remote_input_signal = Some(crate::base::MridRef { mrid: sv.clone() });
53                    }
54                }
55                "WindTurbineType3or4Dynamics.WindPlantDynamics" => {
56                    if let crate::base::FieldValue::Resource(sv) = val {
57                        obj.wind_plant_dynamics = Some(crate::base::MridRef { mrid: sv.clone() });
58                    }
59                }
60                "DynamicsFunctionBlock.enabled" => {
61                    match val {
62                        crate::base::FieldValue::Text(sv) => { obj.base.enabled = Some(sv.trim() == "true"); }
63                        crate::base::FieldValue::TextList(svs) => {
64                            if let Some(sv) = svs.last() { obj.base.enabled = Some(sv.trim() == "true"); }
65                        }
66                        _ => {}
67                    }
68                }
69                "IdentifiedObject.description" => {
70                    match val {
71                        crate::base::FieldValue::Text(sv) => { obj.base.base.description = sv.clone(); }
72                        crate::base::FieldValue::TextList(svs) => {
73                            if let Some(sv) = svs.last() { obj.base.base.description = sv.clone(); }
74                        }
75                        _ => {}
76                    }
77                }
78                "IdentifiedObject.energyIdentCodeEic" => {
79                    match val {
80                        crate::base::FieldValue::Text(sv) => { obj.base.base.energy_ident_code_eic = sv.clone(); }
81                        crate::base::FieldValue::TextList(svs) => {
82                            if let Some(sv) = svs.last() { obj.base.base.energy_ident_code_eic = sv.clone(); }
83                        }
84                        _ => {}
85                    }
86                }
87                "IdentifiedObject.mRID" => {
88                    match val {
89                        crate::base::FieldValue::Text(sv) => { obj.base.base.m_rid = sv.clone(); }
90                        crate::base::FieldValue::TextList(svs) => {
91                            if let Some(sv) = svs.last() { obj.base.base.m_rid = sv.clone(); }
92                        }
93                        _ => {}
94                    }
95                }
96                "IdentifiedObject.name" => {
97                    match val {
98                        crate::base::FieldValue::Text(sv) => { obj.base.base.name = sv.clone(); }
99                        crate::base::FieldValue::TextList(svs) => {
100                            if let Some(sv) = svs.last() { obj.base.base.name = sv.clone(); }
101                        }
102                        _ => {}
103                    }
104                }
105                "IdentifiedObject.shortName" => {
106                    match val {
107                        crate::base::FieldValue::Text(sv) => { obj.base.base.short_name = sv.clone(); }
108                        crate::base::FieldValue::TextList(svs) => {
109                            if let Some(sv) = svs.last() { obj.base.base.short_name = sv.clone(); }
110                        }
111                        _ => {}
112                    }
113                }
114                _ => {}
115            }
116        }
117        obj
118    }
119}