Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the MPC use case for Monitored Units #108

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions usecases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,8 @@ Actors:
Use Cases:
- `mpc`: Monitoring of Power Consumption
- `mgcp`: Monitoring of Grid Connection Point

- `mu`: Monitored Unit

Use Cases:
- `mpc`: Monitoring of Power Consumption
199 changes: 199 additions & 0 deletions usecases/api/mu_mpc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
package api

import (
"github.com/enbility/eebus-go/api"
"github.com/enbility/spine-go/model"
"time"
)

// Actor: Monitoring Unit
// UseCase: Monitoring of Power Consumption
type MuMPCInterface interface {
// ------------------------- Getters ------------------------- //

// Scenario 1

// get the momentary active power consumption or production
//
// possible errors:
// - ErrMissingData if the id is not available
// - and others
Power() (float64, error)

// get the momentary active power consumption or production per phase
//
// possible errors:
// - ErrMissingData if the id is not available
// - and others
PowerPerPhase() ([]float64, error)
DerAndereAndi marked this conversation as resolved.
Show resolved Hide resolved

// Scenario 2

// get the total feed in energy
//
// - negative values are used for production
//
// possible errors:
// - ErrMissingData if the id is not available
// - and others
EnergyProduced() (float64, error)

// get the total feed in energy
//
// - negative values are used for production
//
// possible errors:
// - ErrMissingData if the id is not available
// - and others
EnergyConsumed() (float64, error)

// Scenario 3

// get the momentary phase specific current consumption or production
//
// - positive values are used for consumption
// - negative values are used for production
//
// possible errors:
// - ErrMissingData if the id is not available
// - and others
CurrentPerPhase() ([]float64, error)

// Scenario 4

// get the phase specific voltage details
//
// possible errors:
// - ErrMissingData if the id is not available
// - and others
VoltagePerPhase() ([]float64, error)

// Scenario 5

// get frequency
//
// possible errors:
// - ErrMissingData if the id is not available
// - and others
Frequency() (float64, error)

// ------------------------- Setters ------------------------- //

// use Update to update the measurement data
// use it like this:
//
// mpc.Update(
// mpc.UpdateDataPowerTotal(1000, nil, nil),
// mpc.UpdateDataPowerPhaseA(500, nil, nil),
// ...
// )
//
// possible errors:
// - ErrMissingData if the id is not available
// - and others
Update(data ...api.MeasurementDataForID) error

// Scenario 1

// use UpdateDataPowerTotal in Update to set the momentary active power consumption or production
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataPowerTotal(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataPowerPhaseA in Update to set the momentary active power consumption or production per phase
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataPowerPhaseA(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataPowerPhaseB in Update to set the momentary active power consumption or production per phase
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataPowerPhaseB(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataPowerPhaseC in Update to set the momentary active power consumption or production per phase
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataPowerPhaseC(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// Scenario 2

// use UpdateDataEnergyConsumed in Update to set the total feed in energy
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
// The evaluationStart and End are optional and can be nil (both must be set to be used)
UpdateDataEnergyConsumed(
value float64,
timestamp *time.Time,
valueState *model.MeasurementValueStateType,
evaluationStart *time.Time,
evaluationEnd *time.Time,
) api.MeasurementDataForID

// use UpdateDataEnergyProduced in Update to set the total feed in energy
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
// The evaluationStart and End are optional and can be nil (both must be set to be used)
UpdateDataEnergyProduced(
value float64,
timestamp *time.Time,
valueState *model.MeasurementValueStateType,
evaluationStart *time.Time,
evaluationEnd *time.Time,
) api.MeasurementDataForID

// Scenario 3

// use UpdateDataCurrentPhaseA in Update to set the momentary phase specific current consumption or production
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataCurrentPhaseA(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataCurrentPhaseB in Update to set the momentary phase specific current consumption or production
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataCurrentPhaseB(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataCurrentPhaseC in Update to set the momentary phase specific current consumption or production
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataCurrentPhaseC(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// Scenario 4

// use UpdateDataVoltagePhaseA in Update to set the phase specific voltage details
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataVoltagePhaseA(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataVoltagePhaseB in Update to set the phase specific voltage details
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataVoltagePhaseB(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataVoltagePhaseC in Update to set the phase specific voltage details
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataVoltagePhaseC(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataVoltagePhaseAToB in Update to set the phase specific voltage details
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataVoltagePhaseAToB(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataVoltagePhaseBToC in Update to set the phase specific voltage details
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataVoltagePhaseBToC(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// use UpdateDataVoltagePhaseCToA in Update to set the phase specific voltage details
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataVoltagePhaseCToA(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID

// Scenario 5

// use AcFrequency in Update to set the frequency
// The timestamp is optional and can be nil
// The valueState shall be set if it differs from the normal valueState otherwise it can be nil
UpdateDataFrequency(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.MeasurementDataForID
}
1 change: 1 addition & 0 deletions usecases/cem/cevc/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func NewCEVC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &CEVC{
Expand Down
1 change: 1 addition & 0 deletions usecases/cem/evcc/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func NewEVCC(
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &EVCC{
Expand Down
4 changes: 3 additions & 1 deletion usecases/cem/evcem/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func NewEVCEM(service api.ServiceInterface, localEntity spineapi.EntityLocalInte
eventCB,
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes)
validEntityTypes,
false,
)

uc := &EVCEM{
UseCaseBase: usecase,
Expand Down
4 changes: 3 additions & 1 deletion usecases/cem/evsecc/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ func NewEVSECC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEven
eventCB,
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes)
validEntityTypes,
false,
)

uc := &EVSECC{
UseCaseBase: usecase,
Expand Down
1 change: 1 addition & 0 deletions usecases/cem/evsoc/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func NewEVSOC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEvent
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &EVSOC{
Expand Down
1 change: 1 addition & 0 deletions usecases/cem/opev/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func NewOPEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &OPEV{
Expand Down
1 change: 1 addition & 0 deletions usecases/cem/oscev/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func NewOSCEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEvent
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &OSCEV{
Expand Down
1 change: 1 addition & 0 deletions usecases/cem/vabd/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func NewVABD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &VABD{
Expand Down
1 change: 1 addition & 0 deletions usecases/cem/vapd/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func NewVAPD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &VAPD{
Expand Down
1 change: 1 addition & 0 deletions usecases/cs/lpc/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &LPC{
Expand Down
1 change: 1 addition & 0 deletions usecases/cs/lpp/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &LPP{
Expand Down
1 change: 1 addition & 0 deletions usecases/eg/lpc/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes,
false,
)

uc := &LPC{
Expand Down
4 changes: 3 additions & 1 deletion usecases/eg/lpp/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa
eventCB,
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes)
validEntityTypes,
false,
)

uc := &LPP{
UseCaseBase: usecase,
Expand Down
4 changes: 3 additions & 1 deletion usecases/ma/mgcp/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ func NewMGCP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC
eventCB,
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes)
validEntityTypes,
false,
)

uc := &MGCP{
UseCaseBase: usecase,
Expand Down
4 changes: 3 additions & 1 deletion usecases/ma/mpc/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ func NewMPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa
eventCB,
UseCaseSupportUpdate,
validActorTypes,
validEntityTypes)
validEntityTypes,
false,
)

uc := &MPC{
UseCaseBase: usecase,
Expand Down
Loading
Loading