1919
2020@dataclass (frozen = True )
2121class ComponentData (ABC ):
22- """A private base class for strongly typed component data classes.
23-
24- Attributes:
25- component_id: the ID identifying this component in the microgrid
26- timestamp: the timestamp of when the data was measured.
27- raw: raw component data as decoded from the wire
28- """
22+ """A private base class for strongly typed component data classes."""
2923
3024 component_id : int
25+ """The ID identifying this component in the microgrid."""
26+
3127 timestamp : datetime
28+ """The timestamp of when the data was measured."""
29+
3230 # The `raw` attribute is excluded from the constructor as it can only be provided
3331 # when instantiating `ComponentData` using the `from_proto` method, which reads
3432 # data from a protobuf message. The whole protobuf message is stored as the `raw`
3533 # attribute. When `ComponentData` is not instantiated from a protobuf message,
3634 # i.e. using the constructor, `raw` will be set to `None`.
3735 raw : Optional [microgrid_pb .ComponentData ] = field (default = None , init = False )
36+ """Raw component data as decoded from the wire."""
3837
3938 def _set_raw (self , raw : microgrid_pb .ComponentData ) -> None :
4039 """Store raw protobuf message.
@@ -60,26 +59,27 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> ComponentData:
6059
6160@dataclass (frozen = True )
6261class MeterData (ComponentData ):
63- """A wrapper class for holding meter data.
62+ """A wrapper class for holding meter data."""
6463
65- Attributes:
66- active_power: the 3-phase active power, in Watts, represented in the passive
67- sign convention.
64+ active_power : float
65+ """The 3-phase active power, in Watts, represented in the passive sign convention.
6866 +ve current means consumption, away from the grid.
6967 -ve current means supply into the grid.
70- current_per_phase: AC current in Amperes (A) for phase/line 1,2 and 3
71- respectively.
68+ """
69+
70+ current_per_phase : Tuple [float , float , float ]
71+ """AC current in Amperes (A) for phase/line 1,2 and 3 respectively.
7272 +ve current means consumption, away from the grid.
7373 -ve current means supply into the grid.
74- voltage_per_phase: the AC voltage in Volts (V) between the line and the neutral
75- wire for phase/line 1,2 and 3 respectively.
76- frequency: the AC power frequency in Hertz (Hz).
7774 """
7875
79- active_power : float
80- current_per_phase : Tuple [float , float , float ]
8176 voltage_per_phase : Tuple [float , float , float ]
77+ """The ac voltage in volts (v) between the line and the neutral wire for phase/line
78+ 1,2 and 3 respectively.
79+ """
80+
8281 frequency : float
82+ """The AC power frequency in Hertz (Hz)."""
8383
8484 @classmethod
8585 def from_proto (cls , raw : microgrid_pb .ComponentData ) -> MeterData :
@@ -113,38 +113,46 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> MeterData:
113113
114114@dataclass (frozen = True )
115115class BatteryData (ComponentData ):
116- """A wrapper class for holding battery data.
117-
118- Attributes:
119- soc: battery's overall SoC in percent (%).
120- soc_lower_bound: the SoC below which discharge commands will be blocked by the
121- system, in percent (%).
122- soc_upper_bound: the SoC above which charge commands will be blocked by the
123- system, in percent (%).
124- capacity: the capacity of the battery in Wh (Watt-hour)
125- power_lower_bound: the maximum discharge power, in Watts, represented in the
126- passive sign convention. This will be a negative number, or zero if no
127- discharging is possible.
128- power_upper_bound: the maximum charge power, in Watts, represented in the
129- passive sign convention. This will be a positive number, or zero if no
130- charging is possible.
131- temperature_max: the maximum temperature of all the blocks in a battery, in
132- Celcius (°C).
133- _relay_state: state of the battery relay.
134- _component_state: state of the battery.
135- _errors: list of errors in protobuf struct.
136- """
116+ """A wrapper class for holding battery data."""
137117
138118 soc : float
119+ """Battery's overall SoC in percent (%)."""
120+
139121 soc_lower_bound : float
122+ """The SoC below which discharge commands will be blocked by the system,
123+ in percent (%).
124+ """
125+
140126 soc_upper_bound : float
127+ """The SoC above which charge commands will be blocked by the system,
128+ in percent (%).
129+ """
130+
141131 capacity : float
132+ """The capacity of the battery in Wh (Watt-hour)."""
133+
142134 power_lower_bound : float
135+ """The maximum discharge power, in watts, represented in the passive sign
136+ convention. this will be a negative number, or zero if no discharging is
137+ possible.
138+ """
139+
143140 power_upper_bound : float
141+ """The maximum charge power, in Watts, represented in the passive sign convention.
142+ This will be a positive number, or zero if no charging is possible.
143+ """
144+
144145 temperature_max : float
146+ """The maximum temperature of all the blocks in a battery, in Celcius (°C)."""
147+
145148 _relay_state : battery_pb .RelayState .ValueType
149+ """State of the battery relay."""
150+
146151 _component_state : battery_pb .ComponentState .ValueType
152+ """State of the battery."""
153+
147154 _errors : List [battery_pb .Error ]
155+ """List of errors in protobuf struct."""
148156
149157 @classmethod
150158 def from_proto (cls , raw : microgrid_pb .ComponentData ) -> BatteryData :
@@ -176,28 +184,30 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> BatteryData:
176184
177185@dataclass (frozen = True )
178186class InverterData (ComponentData ):
179- """A wrapper class for holding inverter data.
187+ """A wrapper class for holding inverter data."""
180188
181- Attributes:
182- active_power: the 3-phase active power, in Watts, represented in the passive
183- sign convention.
189+ active_power : float
190+ """The 3-phase active power, in Watts, represented in the passive sign convention.
184191 +ve current means consumption, away from the grid.
185192 -ve current means supply into the grid.
186- active_power_lower_bound: the maximum discharge power, in Watts, represented in
187- the passive sign convention. This will be a negative number, or zero if no
188- discharging is possible.
189- active_power_upper_bound: the maximum charge power, in Watts, represented in
190- the passive sign convention. This will be a positive number, or zero if no
191- charging is possible.
192- _component_state: state of the inverter.
193- _errors: list of errors from the component.
194193 """
195194
196- active_power : float
197195 active_power_lower_bound : float
196+ """The maximum discharge power, in Watts, represented in the passive sign
197+ convention. This will be a negative number, or zero if no discharging is
198+ possible.
199+ """
200+
198201 active_power_upper_bound : float
202+ """The maximum charge power, in Watts, represented in the passive sign convention.
203+ This will be a positive number, or zero if no charging is possible.
204+ """
205+
199206 _component_state : inverter_pb .ComponentState .ValueType
207+ """State of the inverter."""
208+
200209 _errors : List [inverter_pb .Error ]
210+ """List of errors from the component."""
201211
202212 @classmethod
203213 def from_proto (cls , raw : microgrid_pb .ComponentData ) -> InverterData :
@@ -225,26 +235,27 @@ def from_proto(cls, raw: microgrid_pb.ComponentData) -> InverterData:
225235
226236@dataclass (frozen = True )
227237class EVChargerData (ComponentData ):
228- """A wrapper class for holding ev_charger data.
238+ """A wrapper class for holding ev_charger data."""
229239
230- Attributes:
231- active_power_consumption: the 3-phase active power, in Watts, represented in
232- the passive sign convention.
233- +ve current means consumption, away from the grid.
234- -ve current means supply into the grid.
235- current_per_phase: AC current in Amperes (A) for phase/line 1,2 and 3
236- respectively.
237- +ve current means consumption, away from the grid.
238- -ve current means supply into the grid.
239- voltage_per_phase: the AC voltage in Volts (V) between the line and the neutral
240- wire for phase/line 1,2 and 3 respectively.
241- cable_state: the state of the ev charger's cable
240+ active_power : float
241+ """The 3-phase active power, in Watts, represented in the passive sign convention.
242+ +ve current means consumption, away from the grid.
243+ -ve current means supply into the grid.
242244 """
243245
244- active_power : float
245246 current_per_phase : Tuple [float , float , float ]
247+ """AC current in Amperes (A) for phase/line 1,2 and 3 respectively.
248+ +ve current means consumption, away from the grid.
249+ -ve current means supply into the grid.
250+ """
251+
246252 voltage_per_phase : Tuple [float , float , float ]
253+ """The AC voltage in Volts (V) between the line and the neutral
254+ wire for phase/line 1,2 and 3 respectively.
255+ """
256+
247257 cable_state : EVChargerCableState
258+ """The state of the ev charger's cable."""
248259
249260 @classmethod
250261 def from_proto (cls , raw : microgrid_pb .ComponentData ) -> EVChargerData :
0 commit comments