@@ -25,14 +25,14 @@ async fn main() -> Result<(), Error> {
2525 )
2626 . await ?;
2727
28- let formula_grid = logical_meter. grid ( metric:: AcPowerActive ) ?;
29- let formula_pv = logical_meter. pv ( None , metric:: AcPowerActive ) ?;
30- let formula_consumer = logical_meter. consumer ( metric:: AcPowerActive ) ?;
28+ let formula_grid = logical_meter. grid :: < metric:: AcPowerActive > ( ) ?;
29+ let formula_pv = logical_meter. pv :: < metric:: AcPowerActive > ( None ) ?;
30+ let formula_consumer = logical_meter. consumer :: < metric:: AcPowerActive > ( ) ?;
3131
3232 // Create a formula that calculates `grid_power - pv_power + consumer_power + 100kW`.
33- let formula = logical_meter. grid ( metric:: AcPowerActive ) ?
34- - logical_meter. pv ( None , metric:: AcPowerActive ) ?
35- + logical_meter. consumer ( metric:: AcPowerActive ) ?
33+ let formula = logical_meter. grid :: < metric:: AcPowerActive > ( ) ?
34+ - logical_meter. pv :: < metric:: AcPowerActive > ( None ) ?
35+ + logical_meter. consumer :: < metric:: AcPowerActive > ( ) ?
3636 + Power :: from_kilowatts ( 100.0 ) ;
3737
3838 let mut rx = formula. subscribe ( ) . await ?;
@@ -68,10 +68,10 @@ async fn main() -> Result<(), Error> {
6868
6969 // Create a formula that calculates the grid voltage as:
7070 // COALESCE(grid_voltage, AVG(grid_voltage_p1, grid_voltage_p2, grid_voltage_p3) * SQRT(3))
71- let formula_grid_voltage = logical_meter. grid ( metric:: AcVoltage ) ?. coalesce (
72- logical_meter. grid ( metric:: AcVoltagePhase1N ) ?. avg ( vec ! [
73- logical_meter. grid( metric:: AcVoltagePhase2N ) ?,
74- logical_meter. grid( metric:: AcVoltagePhase3N ) ?,
71+ let formula_grid_voltage = logical_meter. grid :: < metric:: AcVoltage > ( ) ?. coalesce (
72+ logical_meter. grid :: < metric:: AcVoltagePhase1N > ( ) ?. avg ( vec ! [
73+ logical_meter. grid:: < metric:: AcVoltagePhase2N > ( ) ?,
74+ logical_meter. grid:: < metric:: AcVoltagePhase3N > ( ) ?,
7575 ] ) ? * 3.0_f32 . sqrt ( ) ,
7676 ) ?;
7777
@@ -95,18 +95,21 @@ async fn main() -> Result<(), Error> {
9595 drop ( consumer_rx) ;
9696
9797 let mut p1 = logical_meter
98- . grid ( metric:: AcVoltagePhase1N ) ?
98+ . grid :: < metric:: AcVoltagePhase1N > ( ) ?
9999 . subscribe ( )
100100 . await ?;
101101 let mut p2 = logical_meter
102- . grid ( metric:: AcVoltagePhase2N ) ?
102+ . grid :: < metric:: AcVoltagePhase2N > ( ) ?
103103 . subscribe ( )
104104 . await ?;
105105 let mut p3 = logical_meter
106- . grid ( metric:: AcVoltagePhase3N ) ?
106+ . grid :: < metric:: AcVoltagePhase3N > ( ) ?
107+ . subscribe ( )
108+ . await ?;
109+ let mut three_phase = logical_meter
110+ . grid :: < metric:: AcVoltage > ( ) ?
107111 . subscribe ( )
108112 . await ?;
109- let mut three_phase = logical_meter. grid ( metric:: AcVoltage ) ?. subscribe ( ) . await ?;
110113
111114 loop {
112115 let sample = grid_voltage_rx. recv ( ) . await . unwrap ( ) ;
0 commit comments