@@ -24,6 +24,19 @@ func (e *MPC) SetPower(power float64) error {
2424 return nil
2525}
2626
27+ // get the momentary active power consumption or production
28+ //
29+ // possible errors:
30+ // - ErrMissingData if the id is not available
31+ // - and others
32+ func (e * MPC ) Power () (float64 , error ) {
33+ if e .acPowerTotal == nil {
34+ return 0 , api .ErrMissingData
35+ }
36+
37+ return e .getMeasurementDataForId (e .acPowerTotal )
38+ }
39+
2740// set the momentary active power consumption or production per phase
2841//
2942// possible errors:
@@ -52,6 +65,34 @@ func (e *MPC) SetPowerPerPhase(phaseA, phaseB, phaseC float64) error {
5265 return nil
5366}
5467
68+ // get the momentary active power consumption or production per phase
69+ //
70+ // possible errors:
71+ // - ErrMissingData if the id is not available
72+ // - and others
73+ func (e * MPC ) PowerPerPhase () ([]float64 , error ) {
74+ if e .acPower [0 ] == nil || e .acPower [1 ] == nil || e .acPower [2 ] == nil {
75+ return nil , api .ErrMissingData
76+ }
77+
78+ phaseA , err := e .getMeasurementDataForId (e .acPower [0 ])
79+ if err != nil {
80+ return nil , err
81+ }
82+
83+ phaseB , err := e .getMeasurementDataForId (e .acPower [1 ])
84+ if err != nil {
85+ return nil , err
86+ }
87+
88+ phaseC , err := e .getMeasurementDataForId (e .acPower [2 ])
89+ if err != nil {
90+ return nil , err
91+ }
92+
93+ return []float64 {phaseA , phaseB , phaseC }, nil
94+ }
95+
5596// Scenario 2
5697
5798// set the total consumption energy
@@ -70,6 +111,21 @@ func (e *MPC) SetEnergyConsumed(energy float64) error {
70111 return nil
71112}
72113
114+ // get the total feed in energy
115+ //
116+ // - negative values are used for production
117+ //
118+ // possible errors:
119+ // - ErrMissingData if the id is not available
120+ // - and others
121+ func (e * MPC ) EnergyConsumed () (float64 , error ) {
122+ if e .acEnergyConsumed == nil {
123+ return 0 , api .ErrMissingData
124+ }
125+
126+ return e .getMeasurementDataForId (e .acEnergyConsumed )
127+ }
128+
73129// set the total feed in energy
74130//
75131// - negative values are used for production
@@ -86,6 +142,21 @@ func (e *MPC) SetEnergyProduced(energy float64) error {
86142 return nil
87143}
88144
145+ // get the total feed in energy
146+ //
147+ // - negative values are used for production
148+ //
149+ // possible errors:
150+ // - ErrMissingData if the id is not available
151+ // - and others
152+ func (e * MPC ) EnergyProduced () (float64 , error ) {
153+ if e .acEnergyProduced == nil {
154+ return 0 , api .ErrMissingData
155+ }
156+
157+ return e .getMeasurementDataForId (e .acEnergyProduced )
158+ }
159+
89160// Scenario 3
90161
91162// set the momentary phase specific current consumption or production
@@ -115,6 +186,37 @@ func (e *MPC) SetCurrentPerPhase(phaseA, phaseB, phaseC float64) error {
115186 return nil
116187}
117188
189+ // get the momentary phase specific current consumption or production
190+ //
191+ // - positive values are used for consumption
192+ // - negative values are used for production
193+ //
194+ // possible errors:
195+ // - ErrMissingData if the id is not available
196+ // - and others
197+ func (e * MPC ) CurrentPerPhase () ([]float64 , error ) {
198+ if e .acCurrent [0 ] == nil || e .acCurrent [1 ] == nil || e .acCurrent [2 ] == nil {
199+ return nil , api .ErrMissingData
200+ }
201+
202+ phaseA , err := e .getMeasurementDataForId (e .acCurrent [0 ])
203+ if err != nil {
204+ return nil , err
205+ }
206+
207+ phaseB , err := e .getMeasurementDataForId (e .acCurrent [1 ])
208+ if err != nil {
209+ return nil , err
210+ }
211+
212+ phaseC , err := e .getMeasurementDataForId (e .acCurrent [2 ])
213+ if err != nil {
214+ return nil , err
215+ }
216+
217+ return []float64 {phaseA , phaseB , phaseC }, nil
218+ }
219+
118220// Scenario 4
119221
120222// set the phase specific voltage details
@@ -143,6 +245,36 @@ func (e *MPC) SetVoltagePerPhase(phaseA, phaseB, phaseC float64) error {
143245 return nil
144246}
145247
248+ // get the phase specific voltage details
249+ //
250+ // possible errors:
251+ // - ErrMissingData if the id is not available
252+ // - and others
253+ func (e * MPC ) VoltagePerPhase () ([]float64 , error ) {
254+ for _ , id := range e .acVoltage {
255+ if id == nil {
256+ return nil , api .ErrMissingData
257+ }
258+ }
259+
260+ phaseA , err := e .getMeasurementDataForId (e .acVoltage [0 ])
261+ if err != nil {
262+ return nil , err
263+ }
264+
265+ phaseB , err := e .getMeasurementDataForId (e .acVoltage [1 ])
266+ if err != nil {
267+ return nil , err
268+ }
269+
270+ phaseC , err := e .getMeasurementDataForId (e .acVoltage [2 ])
271+ if err != nil {
272+ return nil , err
273+ }
274+
275+ return []float64 {phaseA , phaseB , phaseC }, nil
276+ }
277+
146278// Scenario 5
147279
148280// SetFrequency set frequency
@@ -158,3 +290,16 @@ func (e *MPC) SetFrequency(frequency float64) error {
158290
159291 return nil
160292}
293+
294+ // get frequency
295+ //
296+ // possible errors:
297+ // - ErrMissingData if the id is not available
298+ // - and others
299+ func (e * MPC ) Frequency () (float64 , error ) {
300+ if e .acFrequency == nil {
301+ return 0 , api .ErrMissingData
302+ }
303+
304+ return e .getMeasurementDataForId (e .acFrequency )
305+ }
0 commit comments