diff --git a/usecases/cem/cevc/usecase.go b/usecases/cem/cevc/usecase.go index b3efc6eb..261c8fc1 100644 --- a/usecases/cem/cevc/usecase.go +++ b/usecases/cem/cevc/usecase.go @@ -64,6 +64,7 @@ func NewCEVC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &CEVC{ diff --git a/usecases/cem/evcc/usecase.go b/usecases/cem/evcc/usecase.go index 0fcdbad6..fb72aa7b 100644 --- a/usecases/cem/evcc/usecase.go +++ b/usecases/cem/evcc/usecase.go @@ -76,6 +76,7 @@ func NewEVCC( UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &EVCC{ diff --git a/usecases/cem/evcem/usecase.go b/usecases/cem/evcem/usecase.go index c87a9438..7fb10121 100644 --- a/usecases/cem/evcem/usecase.go +++ b/usecases/cem/evcem/usecase.go @@ -58,7 +58,9 @@ func NewEVCEM(service api.ServiceInterface, localEntity spineapi.EntityLocalInte eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &EVCEM{ UseCaseBase: usecase, diff --git a/usecases/cem/evsecc/usecase.go b/usecases/cem/evsecc/usecase.go index 9a5423a8..88da7d54 100644 --- a/usecases/cem/evsecc/usecase.go +++ b/usecases/cem/evsecc/usecase.go @@ -45,7 +45,9 @@ func NewEVSECC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEven eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &EVSECC{ UseCaseBase: usecase, diff --git a/usecases/cem/evsoc/usecase.go b/usecases/cem/evsoc/usecase.go index 996c4409..d26f6f52 100644 --- a/usecases/cem/evsoc/usecase.go +++ b/usecases/cem/evsoc/usecase.go @@ -41,6 +41,7 @@ func NewEVSOC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEvent UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &EVSOC{ diff --git a/usecases/cem/opev/usecase.go b/usecases/cem/opev/usecase.go index 2ad79d95..73f93b73 100644 --- a/usecases/cem/opev/usecase.go +++ b/usecases/cem/opev/usecase.go @@ -52,6 +52,7 @@ func NewOPEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &OPEV{ diff --git a/usecases/cem/oscev/usecase.go b/usecases/cem/oscev/usecase.go index c74a5887..db4627cf 100644 --- a/usecases/cem/oscev/usecase.go +++ b/usecases/cem/oscev/usecase.go @@ -52,6 +52,7 @@ func NewOSCEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEvent UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &OSCEV{ diff --git a/usecases/cem/vabd/usecase.go b/usecases/cem/vabd/usecase.go index f996becc..4a06b0b7 100644 --- a/usecases/cem/vabd/usecase.go +++ b/usecases/cem/vabd/usecase.go @@ -66,6 +66,7 @@ func NewVABD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &VABD{ diff --git a/usecases/cem/vapd/usecase.go b/usecases/cem/vapd/usecase.go index 5e901a76..bce593a8 100644 --- a/usecases/cem/vapd/usecase.go +++ b/usecases/cem/vapd/usecase.go @@ -57,6 +57,7 @@ func NewVAPD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &VAPD{ diff --git a/usecases/cs/lpc/usecase.go b/usecases/cs/lpc/usecase.go index f974a335..864b9827 100644 --- a/usecases/cs/lpc/usecase.go +++ b/usecases/cs/lpc/usecase.go @@ -64,6 +64,7 @@ func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &LPC{ diff --git a/usecases/cs/lpp/usecase.go b/usecases/cs/lpp/usecase.go index 9d8a6d64..5f5bbd44 100644 --- a/usecases/cs/lpp/usecase.go +++ b/usecases/cs/lpp/usecase.go @@ -63,6 +63,7 @@ func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &LPP{ diff --git a/usecases/eg/lpc/usecase.go b/usecases/eg/lpc/usecase.go index b2727628..ffd36c95 100644 --- a/usecases/eg/lpc/usecase.go +++ b/usecases/eg/lpc/usecase.go @@ -60,6 +60,7 @@ func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &LPC{ diff --git a/usecases/eg/lpp/usecase.go b/usecases/eg/lpp/usecase.go index 6d7108f6..381afba5 100644 --- a/usecases/eg/lpp/usecase.go +++ b/usecases/eg/lpp/usecase.go @@ -57,7 +57,9 @@ func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &LPP{ UseCaseBase: usecase, diff --git a/usecases/ma/mgcp/usecase.go b/usecases/ma/mgcp/usecase.go index 8fcfa782..075fed38 100644 --- a/usecases/ma/mgcp/usecase.go +++ b/usecases/ma/mgcp/usecase.go @@ -87,7 +87,9 @@ func NewMGCP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &MGCP{ UseCaseBase: usecase, diff --git a/usecases/ma/mpc/usecase.go b/usecases/ma/mpc/usecase.go index 393b8a7b..332f6218 100644 --- a/usecases/ma/mpc/usecase.go +++ b/usecases/ma/mpc/usecase.go @@ -79,7 +79,9 @@ func NewMPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &MPC{ UseCaseBase: usecase, diff --git a/usecases/mu/mpc/usecase.go b/usecases/mu/mpc/usecase.go index e027ada9..4f4606fe 100644 --- a/usecases/mu/mpc/usecase.go +++ b/usecases/mu/mpc/usecase.go @@ -1,6 +1,8 @@ package mpc import ( + "time" + "github.com/enbility/eebus-go/api" "github.com/enbility/eebus-go/features/server" ucapi "github.com/enbility/eebus-go/usecases/api" @@ -9,7 +11,6 @@ import ( "github.com/enbility/spine-go/model" "github.com/enbility/spine-go/spine" "github.com/enbility/spine-go/util" - "time" ) type MPC struct { @@ -29,7 +30,7 @@ var _ ucapi.MuMPCInterface = (*MPC)(nil) // At the moment the MPC use case configures itself as a 3-phase meter by default (ABC). func NewMPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *MPC { validActorTypes := []model.UseCaseActorType{model.UseCaseActorTypeMonitoringAppliance} - var validEntityTypes []model.EntityTypeType = nil // all entity types are valid + allEntityTypesValid := true useCaseScenarios := []api.UseCaseScenario{ { Scenario: model.UseCaseScenarioSupportType(1), @@ -83,7 +84,9 @@ func NewMPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + nil, + allEntityTypesValid, + ) uc := &MPC{ UseCaseBase: u, diff --git a/usecases/usecase/events.go b/usecases/usecase/events.go index b5351350..a879f8ed 100644 --- a/usecases/usecase/events.go +++ b/usecases/usecase/events.go @@ -81,7 +81,7 @@ func (u *UseCaseBase) useCaseDataUpdate( } for _, entity := range entitiesToCheck { - if u.validEntityTypes != nil && !slices.Contains(u.validEntityTypes, entity.EntityType()) { + if !u.allEntityTypesValid && !slices.Contains(u.validEntityTypes, entity.EntityType()) { continue } diff --git a/usecases/usecase/testhelper_test.go b/usecases/usecase/testhelper_test.go index 4e8fe2d0..2d8fc5ba 100644 --- a/usecases/usecase/testhelper_test.go +++ b/usecases/usecase/testhelper_test.go @@ -107,6 +107,7 @@ func (s *UseCaseSuite) BeforeTest(suiteName, testName string) { useCaseUpdateEvent, validActorTypes, validEntityTypes, + false, ) } diff --git a/usecases/usecase/usecase.go b/usecases/usecase/usecase.go index 2b92a554..7968c94d 100644 --- a/usecases/usecase/usecase.go +++ b/usecases/usecase/usecase.go @@ -25,8 +25,9 @@ type UseCaseBase struct { availableEntityScenarios []api.RemoteEntityScenarios // map of scenarios and their availability for each compatible remote entity - validActorTypes []model.UseCaseActorType // valid remote actor types for this use case - validEntityTypes []model.EntityTypeType // valid remote entity types for this use case (if nil all are valid) + validActorTypes []model.UseCaseActorType // valid remote actor types for this use case + validEntityTypes []model.EntityTypeType // valid remote entity types for this use case + allEntityTypesValid bool mux sync.Mutex } @@ -44,6 +45,7 @@ func NewUseCaseBase( useCaseUpdateEvent api.EventType, validActorTypes []model.UseCaseActorType, validEntityTypes []model.EntityTypeType, + allEntityTypesValid bool, ) *UseCaseBase { ucb := &UseCaseBase{ LocalEntity: localEntity, @@ -56,6 +58,7 @@ func NewUseCaseBase( useCaseUpdateEvent: useCaseUpdateEvent, validActorTypes: validActorTypes, validEntityTypes: validEntityTypes, + allEntityTypesValid: allEntityTypesValid, } _ = spine.Events.Subscribe(ucb) @@ -91,7 +94,7 @@ func (u *UseCaseBase) IsCompatibleEntityType(entity spineapi.EntityRemoteInterfa return false } - if u.validEntityTypes == nil { + if u.allEntityTypesValid { return true }