frequenz_microgrid/client/proto/
electrical_component.rs1use crate::{
7 client::{ElectricalComponent, ElectricalComponentCategory},
8 proto::common::microgrid::electrical_components::{
9 InverterType, electrical_component_category_specific_info::Kind,
10 },
11};
12
13impl ElectricalComponent {
14 pub fn is_inverter(&self) -> bool {
16 matches!(
17 ElectricalComponentCategory::try_from(self.category),
18 Ok(ElectricalComponentCategory::Inverter)
19 )
20 }
21
22 pub fn is_pv_inverter(&self) -> bool {
24 if let Some(info) = &self.category_specific_info
25 && let Some(Kind::Inverter(inverter_info)) = &info.kind
26 {
27 return matches!(
28 InverterType::try_from(inverter_info.r#type),
29 Ok(InverterType::Pv)
30 );
31 }
32 false
33 }
34
35 pub fn is_battery_inverter(&self) -> bool {
37 if let Some(info) = &self.category_specific_info
38 && let Some(Kind::Inverter(inverter_info)) = &info.kind
39 {
40 return matches!(
41 InverterType::try_from(inverter_info.r#type),
42 Ok(InverterType::Battery)
43 );
44 }
45 false
46 }
47
48 pub fn is_hybrid_inverter(&self) -> bool {
50 if let Some(info) = &self.category_specific_info
51 && let Some(Kind::Inverter(inverter_info)) = &info.kind
52 {
53 return matches!(
54 InverterType::try_from(inverter_info.r#type),
55 Ok(InverterType::Hybrid)
56 );
57 }
58 false
59 }
60}