diff --git a/api/api.go b/api/api.go index c9647f7b..d89e7b3e 100644 --- a/api/api.go +++ b/api/api.go @@ -28,7 +28,7 @@ type ServiceInterface interface { IsRunning() bool // add a use case to the service - AddUseCase(useCase UseCaseInterface) + AddUseCase(useCase UseCaseInterface) error // set logging interface SetLogging(logger logging.LoggingInterface) diff --git a/api/usecases.go b/api/usecases.go index bb120ee7..37203270 100644 --- a/api/usecases.go +++ b/api/usecases.go @@ -56,6 +56,15 @@ type UseCaseBaseInterface interface { type UseCaseInterface interface { UseCaseBaseInterface - // add the features - AddFeatures() + // add the features described by the Use Case + // + // returns an error if any Feature could not be added + // - errors should not occur during normal usage of eebus-go, and should + // generally be considered fatal implementation errors + // - if an error occurs while adding features to a new Entity, that Entity + // will be in an incomplete state and should not be added to the service + // + // No cleanup occurs on error, some features may end up partially + // configured and unused + AddFeatures() error } diff --git a/examples/ced/main.go b/examples/ced/main.go index 978b3271..bd9d9436 100644 --- a/examples/ced/main.go +++ b/examples/ced/main.go @@ -99,12 +99,18 @@ func (h *controlbox) run() { localEntity := h.myService.LocalDevice().EntityForType(model.EntityTypeTypeGridGuard) h.uclpc = lpc.NewLPC(localEntity, h.OnLPCEvent) - h.myService.AddUseCase(h.uclpc) + err = h.myService.AddUseCase(h.uclpc) + if err != nil { + log.Fatal(err) + } // h.uclpp = lpp.NewLPP(localEntity, h.OnLPPEvent) // h.myService.AddUseCase(h.uclpp) h.ucmpc = mpc.NewMPC(localEntity, h.OnMPCEvent) - h.myService.AddUseCase(h.ucmpc) + err = h.myService.AddUseCase(h.ucmpc) + if err != nil { + log.Fatal(err) + } if len(remoteSki) == 0 { os.Exit(0) diff --git a/examples/controlbox/main.go b/examples/controlbox/main.go index 9965915d..2c8050bf 100644 --- a/examples/controlbox/main.go +++ b/examples/controlbox/main.go @@ -95,10 +95,16 @@ func (h *controlbox) run() { localEntity := h.myService.LocalDevice().EntityForType(model.EntityTypeTypeGridGuard) h.uclpc = lpc.NewLPC(localEntity, h.OnLPCEvent) - h.myService.AddUseCase(h.uclpc) + err = h.myService.AddUseCase(h.uclpc) + if err != nil { + log.Fatal(err) + } h.uclpp = lpp.NewLPP(localEntity, h.OnLPPEvent) - h.myService.AddUseCase(h.uclpp) + err = h.myService.AddUseCase(h.uclpp) + if err != nil { + log.Fatal(err) + } if len(remoteSki) == 0 { os.Exit(0) diff --git a/examples/evse/main.go b/examples/evse/main.go index 8dc17592..60bf8a9a 100644 --- a/examples/evse/main.go +++ b/examples/evse/main.go @@ -92,7 +92,10 @@ func (h *evse) run() { localEntity := h.myService.LocalDevice().EntityForType(model.EntityTypeTypeEVSE) h.uclpc = lpc.NewLPC(localEntity, h.OnLPCEvent) - h.myService.AddUseCase(h.uclpc) + err = h.myService.AddUseCase(h.uclpc) + if err != nil { + log.Fatal(err) + } // Initialize local server data _ = h.uclpc.SetConsumptionNominalMax(32000) diff --git a/examples/hems/main.go b/examples/hems/main.go index 4c6e2a4f..b7b47e3b 100644 --- a/examples/hems/main.go +++ b/examples/hems/main.go @@ -102,19 +102,46 @@ func (h *hems) run() { localEntity := h.myService.LocalDevice().EntityForType(model.EntityTypeTypeCEM) h.uccslpc = cslpc.NewLPC(localEntity, h.OnLPCEvent) - h.myService.AddUseCase(h.uccslpc) + err = h.myService.AddUseCase(h.uccslpc) + if err != nil { + log.Fatal(err) + } + h.uccslpp = cslpp.NewLPP(localEntity, h.OnLPPEvent) - h.myService.AddUseCase(h.uccslpp) + err = h.myService.AddUseCase(h.uccslpp) + if err != nil { + log.Fatal(err) + } + h.uceglpc = eglpc.NewLPC(localEntity, nil) - h.myService.AddUseCase(h.uceglpc) + err = h.myService.AddUseCase(h.uceglpc) + if err != nil { + log.Fatal(err) + } + h.uceglpp = eglpp.NewLPP(localEntity, nil) - h.myService.AddUseCase(h.uceglpp) + err = h.myService.AddUseCase(h.uceglpp) + if err != nil { + log.Fatal(err) + } + h.ucmamgcp = mgcp.NewMGCP(localEntity, h.OnMGCPEvent) - h.myService.AddUseCase(h.ucmamgcp) + err = h.myService.AddUseCase(h.ucmamgcp) + if err != nil { + log.Fatal(err) + } + h.uccemvabd = vabd.NewVABD(localEntity, h.OnVABDEvent) - h.myService.AddUseCase(h.uccemvabd) + err = h.myService.AddUseCase(h.uccemvabd) + if err != nil { + log.Fatal(err) + } + h.uccemvapd = vapd.NewVAPD(localEntity, h.OnVAPDEvent) - h.myService.AddUseCase(h.uccemvapd) + err = h.myService.AddUseCase(h.uccemvapd) + if err != nil { + log.Fatal(err) + } // Initialize local server data _ = h.uccslpc.SetConsumptionNominalMax(32000) diff --git a/examples/remote/ucs.go b/examples/remote/ucs.go index d1eead23..92e7069e 100644 --- a/examples/remote/ucs.go +++ b/examples/remote/ucs.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "log" "github.com/enbility/eebus-go/api" spineapi "github.com/enbility/spine-go/api" @@ -31,7 +32,10 @@ func (r *Remote) RegisterUseCase(entityType model.EntityTypeType, usecaseId stri ) { r.PropagateEvent(identifier, ski, device, entity, event) }) - r.service.AddUseCase(uc) + err := r.service.AddUseCase(uc) + if err != nil { + log.Fatal(err) + } return r.registerStaticReceiverProxy(usecaseId, uc) } diff --git a/features/server/electricalconnection.go b/features/server/electricalconnection.go index 44d3885c..80035f5a 100644 --- a/features/server/electricalconnection.go +++ b/features/server/electricalconnection.go @@ -31,6 +31,48 @@ func NewElectricalConnection(localEntity spineapi.EntityLocalInterface) (*Electr return ec, nil } +func (e *ElectricalConnection) GetOrAddIdForDescription( + electricalConnectionDescription model.ElectricalConnectionDescriptionDataType, +) (*model.ElectricalConnectionIdType, error) { + electricalConnectionId := (*model.ElectricalConnectionIdType)(nil) + highestExistingElectricalConnectionId := model.ElectricalConnectionIdType(0) + + descriptionData := e.featureLocal.DataCopy(model.FunctionTypeElectricalConnectionDescriptionListData).(*model.ElectricalConnectionDescriptionListDataType) + + if descriptionData != nil && descriptionData.ElectricalConnectionDescriptionData != nil { + for _, description := range descriptionData.ElectricalConnectionDescriptionData { + if description.ElectricalConnectionId != nil && + description.PowerSupplyType == electricalConnectionDescription.PowerSupplyType && + description.AcConnectedPhases == electricalConnectionDescription.AcConnectedPhases && + description.AcRmsPeriodDuration == electricalConnectionDescription.AcRmsPeriodDuration && + description.PositiveEnergyDirection == electricalConnectionDescription.PositiveEnergyDirection && + description.ScopeType == electricalConnectionDescription.ScopeType && + description.Label == electricalConnectionDescription.Label && + description.Description == electricalConnectionDescription.Description { + electricalConnectionId = description.ElectricalConnectionId + break + } else if description.ElectricalConnectionId != nil { + if *description.ElectricalConnectionId > highestExistingElectricalConnectionId { + highestExistingElectricalConnectionId = *description.ElectricalConnectionId + } + } + } + } + + if electricalConnectionId == nil { + electricalConnectionId = util.Ptr(highestExistingElectricalConnectionId + 1) + description := electricalConnectionDescription + description.ElectricalConnectionId = electricalConnectionId + if errType := e.featureLocal.UpdateData(model.FunctionTypeElectricalConnectionDescriptionListData, &model.ElectricalConnectionDescriptionListDataType{ + ElectricalConnectionDescriptionData: []model.ElectricalConnectionDescriptionDataType{description}, + }, model.NewFilterTypePartial(), nil); errType != nil { + return nil, errors.New("could not add description data") + } + } + + return electricalConnectionId, nil +} + // Add a new description data set // // NOTE: the electricalConnectionId has to be provided diff --git a/features/server/electricalconnection_test.go b/features/server/electricalconnection_test.go index b89e4172..c84ca1fd 100644 --- a/features/server/electricalconnection_test.go +++ b/features/server/electricalconnection_test.go @@ -119,6 +119,40 @@ func (s *ElectricalConnectionSuite) Test_Description() { assert.NotNil(s.T(), data) } +func (s *ElectricalConnectionSuite) Test_GetOrAddIdForDescription() { + filter := model.ElectricalConnectionDescriptionDataType{} + + data, err := s.sut.GetDescriptionsForFilter(filter) + assert.NotNil(s.T(), err) + assert.Nil(s.T(), data) + + desc1 := model.ElectricalConnectionDescriptionDataType{ + PowerSupplyType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeDc), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + + eConnectionId, err := s.sut.GetOrAddIdForDescription(desc1) + assert.Nil(s.T(), err) + assert.Equal(s.T(), model.ElectricalConnectionIdType(1), *eConnectionId) + + eConnectionId, err = s.sut.GetOrAddIdForDescription(desc1) + assert.Nil(s.T(), err) + assert.Equal(s.T(), model.ElectricalConnectionIdType(1), *eConnectionId) + + desc2 := model.ElectricalConnectionDescriptionDataType{ + PowerSupplyType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + + eConnectionId2, err := s.sut.GetOrAddIdForDescription(desc2) + assert.Nil(s.T(), err) + assert.Equal(s.T(), model.ElectricalConnectionIdType(2), *eConnectionId2) + + eConnectionId, err = s.sut.GetOrAddIdForDescription(desc1) + assert.Nil(s.T(), err) + assert.Equal(s.T(), model.ElectricalConnectionIdType(1), *eConnectionId) +} + func (s *ElectricalConnectionSuite) Test_ParameterDescription() { filter := model.ElectricalConnectionParameterDescriptionDataType{} diff --git a/mocks/DeviceClassificationClientInterface.go b/mocks/DeviceClassificationClientInterface.go index 567c8b6e..254176b4 100644 --- a/mocks/DeviceClassificationClientInterface.go +++ b/mocks/DeviceClassificationClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/DeviceClassificationCommonInterface.go b/mocks/DeviceClassificationCommonInterface.go index 19b8b339..e98a3f96 100644 --- a/mocks/DeviceClassificationCommonInterface.go +++ b/mocks/DeviceClassificationCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/DeviceClassificationServerInterface.go b/mocks/DeviceClassificationServerInterface.go index a072e4b4..c79d8620 100644 --- a/mocks/DeviceClassificationServerInterface.go +++ b/mocks/DeviceClassificationServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/DeviceConfigurationClientInterface.go b/mocks/DeviceConfigurationClientInterface.go index a55ed0f3..6374f9a3 100644 --- a/mocks/DeviceConfigurationClientInterface.go +++ b/mocks/DeviceConfigurationClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -21,7 +21,7 @@ func (_m *DeviceConfigurationClientInterface) EXPECT() *DeviceConfigurationClien } // CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter -func (_m *DeviceConfigurationClientInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { +func (_m *DeviceConfigurationClientInterface) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { ret := _m.Called(payloadData, filter) if len(ret) == 0 { @@ -29,7 +29,7 @@ func (_m *DeviceConfigurationClientInterface) CheckEventPayloadDataForFilter(pay } var r0 bool - if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + if rf, ok := ret.Get(0).(func(any, any) bool); ok { r0 = rf(payloadData, filter) } else { r0 = ret.Get(0).(bool) @@ -44,15 +44,15 @@ type DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call stru } // CheckEventPayloadDataForFilter is a helper method to define mock.On call -// - payloadData interface{} -// - filter interface{} +// - payloadData any +// - filter any func (_e *DeviceConfigurationClientInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { return &DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} } -func (_c *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { +func (_c *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData any, filter any)) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{}), args[1].(interface{})) + run(args[0].(any), args[1].(any)) }) return _c } @@ -62,7 +62,7 @@ func (_c *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call return _c } -func (_c *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { +func (_c *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(any, any) bool) *DeviceConfigurationClientInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Return(run) return _c } diff --git a/mocks/DeviceConfigurationCommonInterface.go b/mocks/DeviceConfigurationCommonInterface.go index e10b3e7a..181919f0 100644 --- a/mocks/DeviceConfigurationCommonInterface.go +++ b/mocks/DeviceConfigurationCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -21,7 +21,7 @@ func (_m *DeviceConfigurationCommonInterface) EXPECT() *DeviceConfigurationCommo } // CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter -func (_m *DeviceConfigurationCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { +func (_m *DeviceConfigurationCommonInterface) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { ret := _m.Called(payloadData, filter) if len(ret) == 0 { @@ -29,7 +29,7 @@ func (_m *DeviceConfigurationCommonInterface) CheckEventPayloadDataForFilter(pay } var r0 bool - if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + if rf, ok := ret.Get(0).(func(any, any) bool); ok { r0 = rf(payloadData, filter) } else { r0 = ret.Get(0).(bool) @@ -44,15 +44,15 @@ type DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call stru } // CheckEventPayloadDataForFilter is a helper method to define mock.On call -// - payloadData interface{} -// - filter interface{} +// - payloadData any +// - filter any func (_e *DeviceConfigurationCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { return &DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} } -func (_c *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData any, filter any)) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{}), args[1].(interface{})) + run(args[0].(any), args[1].(any)) }) return _c } @@ -62,7 +62,7 @@ func (_c *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call return _c } -func (_c *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(any, any) bool) *DeviceConfigurationCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Return(run) return _c } diff --git a/mocks/DeviceConfigurationServerInterface.go b/mocks/DeviceConfigurationServerInterface.go index ad7a0972..06b26c16 100644 --- a/mocks/DeviceConfigurationServerInterface.go +++ b/mocks/DeviceConfigurationServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -69,7 +69,7 @@ func (_c *DeviceConfigurationServerInterface_AddKeyValueDescription_Call) RunAnd } // CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter -func (_m *DeviceConfigurationServerInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { +func (_m *DeviceConfigurationServerInterface) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { ret := _m.Called(payloadData, filter) if len(ret) == 0 { @@ -77,7 +77,7 @@ func (_m *DeviceConfigurationServerInterface) CheckEventPayloadDataForFilter(pay } var r0 bool - if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + if rf, ok := ret.Get(0).(func(any, any) bool); ok { r0 = rf(payloadData, filter) } else { r0 = ret.Get(0).(bool) @@ -92,15 +92,15 @@ type DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call stru } // CheckEventPayloadDataForFilter is a helper method to define mock.On call -// - payloadData interface{} -// - filter interface{} +// - payloadData any +// - filter any func (_e *DeviceConfigurationServerInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { return &DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} } -func (_c *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { +func (_c *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData any, filter any)) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{}), args[1].(interface{})) + run(args[0].(any), args[1].(any)) }) return _c } @@ -110,7 +110,7 @@ func (_c *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call return _c } -func (_c *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { +func (_c *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(any, any) bool) *DeviceConfigurationServerInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Return(run) return _c } diff --git a/mocks/DeviceDiagnosisClientInterface.go b/mocks/DeviceDiagnosisClientInterface.go index f2096d22..58f5b614 100644 --- a/mocks/DeviceDiagnosisClientInterface.go +++ b/mocks/DeviceDiagnosisClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/DeviceDiagnosisCommonInterface.go b/mocks/DeviceDiagnosisCommonInterface.go index c5c71233..ba52ef8f 100644 --- a/mocks/DeviceDiagnosisCommonInterface.go +++ b/mocks/DeviceDiagnosisCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/DeviceDiagnosisServerInterface.go b/mocks/DeviceDiagnosisServerInterface.go index 382080b5..e3356cb9 100644 --- a/mocks/DeviceDiagnosisServerInterface.go +++ b/mocks/DeviceDiagnosisServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/ElectricalConnectionClientInterface.go b/mocks/ElectricalConnectionClientInterface.go index b6605ccd..6df3bf35 100644 --- a/mocks/ElectricalConnectionClientInterface.go +++ b/mocks/ElectricalConnectionClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/ElectricalConnectionCommonInterface.go b/mocks/ElectricalConnectionCommonInterface.go index 6fb44028..c1acb9cb 100644 --- a/mocks/ElectricalConnectionCommonInterface.go +++ b/mocks/ElectricalConnectionCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -68,7 +68,7 @@ func (_c *ElectricalConnectionCommonInterface_AdjustValueToBeWithinPermittedValu } // CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter -func (_m *ElectricalConnectionCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { +func (_m *ElectricalConnectionCommonInterface) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { ret := _m.Called(payloadData, filter) if len(ret) == 0 { @@ -76,7 +76,7 @@ func (_m *ElectricalConnectionCommonInterface) CheckEventPayloadDataForFilter(pa } var r0 bool - if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + if rf, ok := ret.Get(0).(func(any, any) bool); ok { r0 = rf(payloadData, filter) } else { r0 = ret.Get(0).(bool) @@ -91,15 +91,15 @@ type ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call str } // CheckEventPayloadDataForFilter is a helper method to define mock.On call -// - payloadData interface{} -// - filter interface{} +// - payloadData any +// - filter any func (_e *ElectricalConnectionCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { return &ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} } -func (_c *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData any, filter any)) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{}), args[1].(interface{})) + run(args[0].(any), args[1].(any)) }) return _c } @@ -109,7 +109,7 @@ func (_c *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Cal return _c } -func (_c *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(any, any) bool) *ElectricalConnectionCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Return(run) return _c } diff --git a/mocks/ElectricalConnectionServerInterface.go b/mocks/ElectricalConnectionServerInterface.go index 54f21735..5ec2bed3 100644 --- a/mocks/ElectricalConnectionServerInterface.go +++ b/mocks/ElectricalConnectionServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -222,7 +222,7 @@ func (_c *ElectricalConnectionServerInterface_AdjustValueToBeWithinPermittedValu } // CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter -func (_m *ElectricalConnectionServerInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { +func (_m *ElectricalConnectionServerInterface) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { ret := _m.Called(payloadData, filter) if len(ret) == 0 { @@ -230,7 +230,7 @@ func (_m *ElectricalConnectionServerInterface) CheckEventPayloadDataForFilter(pa } var r0 bool - if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + if rf, ok := ret.Get(0).(func(any, any) bool); ok { r0 = rf(payloadData, filter) } else { r0 = ret.Get(0).(bool) @@ -245,15 +245,15 @@ type ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call str } // CheckEventPayloadDataForFilter is a helper method to define mock.On call -// - payloadData interface{} -// - filter interface{} +// - payloadData any +// - filter any func (_e *ElectricalConnectionServerInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { return &ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} } -func (_c *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { +func (_c *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData any, filter any)) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{}), args[1].(interface{})) + run(args[0].(any), args[1].(any)) }) return _c } @@ -263,7 +263,7 @@ func (_c *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Cal return _c } -func (_c *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { +func (_c *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(any, any) bool) *ElectricalConnectionServerInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Return(run) return _c } diff --git a/mocks/EntityEventCallback.go b/mocks/EntityEventCallback.go index 042ca199..c1b5b914 100644 --- a/mocks/EntityEventCallback.go +++ b/mocks/EntityEventCallback.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/FeatureClientInterface.go b/mocks/FeatureClientInterface.go index d6ac99b1..77edda79 100644 --- a/mocks/FeatureClientInterface.go +++ b/mocks/FeatureClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/FeatureServerInterface.go b/mocks/FeatureServerInterface.go index 32cf51d9..6598e318 100644 --- a/mocks/FeatureServerInterface.go +++ b/mocks/FeatureServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/IdentificationClientInterface.go b/mocks/IdentificationClientInterface.go index a58d983d..d7b15179 100644 --- a/mocks/IdentificationClientInterface.go +++ b/mocks/IdentificationClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/IdentificationCommonInterface.go b/mocks/IdentificationCommonInterface.go index fa18d8ae..3a3494dc 100644 --- a/mocks/IdentificationCommonInterface.go +++ b/mocks/IdentificationCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -21,7 +21,7 @@ func (_m *IdentificationCommonInterface) EXPECT() *IdentificationCommonInterface } // CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData -func (_m *IdentificationCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}) bool { +func (_m *IdentificationCommonInterface) CheckEventPayloadDataForFilter(payloadData any) bool { ret := _m.Called(payloadData) if len(ret) == 0 { @@ -29,7 +29,7 @@ func (_m *IdentificationCommonInterface) CheckEventPayloadDataForFilter(payloadD } var r0 bool - if rf, ok := ret.Get(0).(func(interface{}) bool); ok { + if rf, ok := ret.Get(0).(func(any) bool); ok { r0 = rf(payloadData) } else { r0 = ret.Get(0).(bool) @@ -44,14 +44,14 @@ type IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call struct { } // CheckEventPayloadDataForFilter is a helper method to define mock.On call -// - payloadData interface{} +// - payloadData any func (_e *IdentificationCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { return &IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData)} } -func (_c *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{})) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData any)) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{})) + run(args[0].(any)) }) return _c } @@ -61,7 +61,7 @@ func (_c *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call) Ret return _c } -func (_c *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}) bool) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(any) bool) *IdentificationCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Return(run) return _c } diff --git a/mocks/IdentificationServerInterface.go b/mocks/IdentificationServerInterface.go index 19acc2b2..199be57a 100644 --- a/mocks/IdentificationServerInterface.go +++ b/mocks/IdentificationServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/IncentiveTableClientInterface.go b/mocks/IncentiveTableClientInterface.go index a392e228..2e3d8447 100644 --- a/mocks/IncentiveTableClientInterface.go +++ b/mocks/IncentiveTableClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/IncentiveTableCommonInterface.go b/mocks/IncentiveTableCommonInterface.go index f792f67e..676dd655 100644 --- a/mocks/IncentiveTableCommonInterface.go +++ b/mocks/IncentiveTableCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/IncentiveTableServerInterface.go b/mocks/IncentiveTableServerInterface.go index c5dc48fc..ec5d6019 100644 --- a/mocks/IncentiveTableServerInterface.go +++ b/mocks/IncentiveTableServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/LoadControlClientInterface.go b/mocks/LoadControlClientInterface.go index 74a5bfc3..39ad5f31 100644 --- a/mocks/LoadControlClientInterface.go +++ b/mocks/LoadControlClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/LoadControlCommonInterface.go b/mocks/LoadControlCommonInterface.go index 6796a96a..920dd722 100644 --- a/mocks/LoadControlCommonInterface.go +++ b/mocks/LoadControlCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -21,7 +21,7 @@ func (_m *LoadControlCommonInterface) EXPECT() *LoadControlCommonInterface_Expec } // CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter -func (_m *LoadControlCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { +func (_m *LoadControlCommonInterface) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { ret := _m.Called(payloadData, filter) if len(ret) == 0 { @@ -29,7 +29,7 @@ func (_m *LoadControlCommonInterface) CheckEventPayloadDataForFilter(payloadData } var r0 bool - if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + if rf, ok := ret.Get(0).(func(any, any) bool); ok { r0 = rf(payloadData, filter) } else { r0 = ret.Get(0).(bool) @@ -44,15 +44,15 @@ type LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call struct { } // CheckEventPayloadDataForFilter is a helper method to define mock.On call -// - payloadData interface{} -// - filter interface{} +// - payloadData any +// - filter any func (_e *LoadControlCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { return &LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} } -func (_c *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData any, filter any)) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{}), args[1].(interface{})) + run(args[0].(any), args[1].(any)) }) return _c } @@ -62,7 +62,7 @@ func (_c *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call) Return return _c } -func (_c *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(any, any) bool) *LoadControlCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Return(run) return _c } diff --git a/mocks/LoadControlServerInterface.go b/mocks/LoadControlServerInterface.go index 7094c30a..25baa8cb 100644 --- a/mocks/LoadControlServerInterface.go +++ b/mocks/LoadControlServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/MeasurementClientInterface.go b/mocks/MeasurementClientInterface.go index 82c85af8..33d63220 100644 --- a/mocks/MeasurementClientInterface.go +++ b/mocks/MeasurementClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/MeasurementCommonInterface.go b/mocks/MeasurementCommonInterface.go index ab2ee75e..18113462 100644 --- a/mocks/MeasurementCommonInterface.go +++ b/mocks/MeasurementCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -21,7 +21,7 @@ func (_m *MeasurementCommonInterface) EXPECT() *MeasurementCommonInterface_Expec } // CheckEventPayloadDataForFilter provides a mock function with given fields: payloadData, filter -func (_m *MeasurementCommonInterface) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) bool { +func (_m *MeasurementCommonInterface) CheckEventPayloadDataForFilter(payloadData any, filter any) bool { ret := _m.Called(payloadData, filter) if len(ret) == 0 { @@ -29,7 +29,7 @@ func (_m *MeasurementCommonInterface) CheckEventPayloadDataForFilter(payloadData } var r0 bool - if rf, ok := ret.Get(0).(func(interface{}, interface{}) bool); ok { + if rf, ok := ret.Get(0).(func(any, any) bool); ok { r0 = rf(payloadData, filter) } else { r0 = ret.Get(0).(bool) @@ -44,15 +44,15 @@ type MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call struct { } // CheckEventPayloadDataForFilter is a helper method to define mock.On call -// - payloadData interface{} -// - filter interface{} +// - payloadData any +// - filter any func (_e *MeasurementCommonInterface_Expecter) CheckEventPayloadDataForFilter(payloadData interface{}, filter interface{}) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { return &MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call{Call: _e.mock.On("CheckEventPayloadDataForFilter", payloadData, filter)} } -func (_c *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData interface{}, filter interface{})) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call) Run(run func(payloadData any, filter any)) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(interface{}), args[1].(interface{})) + run(args[0].(any), args[1].(any)) }) return _c } @@ -62,7 +62,7 @@ func (_c *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call) Return return _c } -func (_c *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(interface{}, interface{}) bool) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { +func (_c *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call) RunAndReturn(run func(any, any) bool) *MeasurementCommonInterface_CheckEventPayloadDataForFilter_Call { _c.Call.Return(run) return _c } diff --git a/mocks/MeasurementServerInterface.go b/mocks/MeasurementServerInterface.go index 37c64d3e..1812a765 100644 --- a/mocks/MeasurementServerInterface.go +++ b/mocks/MeasurementServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/ServiceInterface.go b/mocks/ServiceInterface.go index 868ead26..df78013f 100644 --- a/mocks/ServiceInterface.go +++ b/mocks/ServiceInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -27,8 +27,21 @@ func (_m *ServiceInterface) EXPECT() *ServiceInterface_Expecter { } // AddUseCase provides a mock function with given fields: useCase -func (_m *ServiceInterface) AddUseCase(useCase api.UseCaseInterface) { - _m.Called(useCase) +func (_m *ServiceInterface) AddUseCase(useCase api.UseCaseInterface) error { + ret := _m.Called(useCase) + + if len(ret) == 0 { + panic("no return value specified for AddUseCase") + } + + var r0 error + if rf, ok := ret.Get(0).(func(api.UseCaseInterface) error); ok { + r0 = rf(useCase) + } else { + r0 = ret.Error(0) + } + + return r0 } // ServiceInterface_AddUseCase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddUseCase' @@ -49,12 +62,12 @@ func (_c *ServiceInterface_AddUseCase_Call) Run(run func(useCase api.UseCaseInte return _c } -func (_c *ServiceInterface_AddUseCase_Call) Return() *ServiceInterface_AddUseCase_Call { - _c.Call.Return() +func (_c *ServiceInterface_AddUseCase_Call) Return(_a0 error) *ServiceInterface_AddUseCase_Call { + _c.Call.Return(_a0) return _c } -func (_c *ServiceInterface_AddUseCase_Call) RunAndReturn(run func(api.UseCaseInterface)) *ServiceInterface_AddUseCase_Call { +func (_c *ServiceInterface_AddUseCase_Call) RunAndReturn(run func(api.UseCaseInterface) error) *ServiceInterface_AddUseCase_Call { _c.Call.Return(run) return _c } diff --git a/mocks/ServiceReaderInterface.go b/mocks/ServiceReaderInterface.go index 7aaa7d2d..a5e75953 100644 --- a/mocks/ServiceReaderInterface.go +++ b/mocks/ServiceReaderInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/SmartEnergyManagementPsClientInterface.go b/mocks/SmartEnergyManagementPsClientInterface.go index ab3f15b5..47f64e51 100644 --- a/mocks/SmartEnergyManagementPsClientInterface.go +++ b/mocks/SmartEnergyManagementPsClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/SmartEnergyManagementPsCommonInterface.go b/mocks/SmartEnergyManagementPsCommonInterface.go index e77ecd67..a0b6a2ae 100644 --- a/mocks/SmartEnergyManagementPsCommonInterface.go +++ b/mocks/SmartEnergyManagementPsCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/SmartEnergyManagementPsServerInterface.go b/mocks/SmartEnergyManagementPsServerInterface.go index d311565a..bec16a96 100644 --- a/mocks/SmartEnergyManagementPsServerInterface.go +++ b/mocks/SmartEnergyManagementPsServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/TimeSeriesClientInterface.go b/mocks/TimeSeriesClientInterface.go index c5498cb8..65fd8c00 100644 --- a/mocks/TimeSeriesClientInterface.go +++ b/mocks/TimeSeriesClientInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/TimeSeriesCommonInterface.go b/mocks/TimeSeriesCommonInterface.go index 667242a5..e845f24e 100644 --- a/mocks/TimeSeriesCommonInterface.go +++ b/mocks/TimeSeriesCommonInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/TimeSeriesServerInterface.go b/mocks/TimeSeriesServerInterface.go index e9de6a82..247d75dc 100644 --- a/mocks/TimeSeriesServerInterface.go +++ b/mocks/TimeSeriesServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/UseCaseBaseInterface.go b/mocks/UseCaseBaseInterface.go index db3fe67b..7ebe1cab 100644 --- a/mocks/UseCaseBaseInterface.go +++ b/mocks/UseCaseBaseInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks diff --git a/mocks/UseCaseInterface.go b/mocks/UseCaseInterface.go index c7136f66..2f3a6128 100644 --- a/mocks/UseCaseInterface.go +++ b/mocks/UseCaseInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -23,8 +23,21 @@ func (_m *UseCaseInterface) EXPECT() *UseCaseInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *UseCaseInterface) AddFeatures() { - _m.Called() +func (_m *UseCaseInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // UseCaseInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -44,12 +57,12 @@ func (_c *UseCaseInterface_AddFeatures_Call) Run(run func()) *UseCaseInterface_A return _c } -func (_c *UseCaseInterface_AddFeatures_Call) Return() *UseCaseInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *UseCaseInterface_AddFeatures_Call) Return(_a0 error) *UseCaseInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *UseCaseInterface_AddFeatures_Call) RunAndReturn(run func()) *UseCaseInterface_AddFeatures_Call { +func (_c *UseCaseInterface_AddFeatures_Call) RunAndReturn(run func() error) *UseCaseInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/service/service.go b/service/service.go index 7542250a..69c1a809 100644 --- a/service/service.go +++ b/service/service.go @@ -193,11 +193,23 @@ func (s *Service) IsRunning() bool { } // add a use case to the service -func (s *Service) AddUseCase(useCase api.UseCaseInterface) { +// +// returns an error when adding features to the entity fails +// +// errors should not occur during normal usage of eebus-go, and should +// generally be considered fatal implementation errors +// +// see usecase.AddFeatures() for more information +func (s *Service) AddUseCase(useCase api.UseCaseInterface) error { s.usecases = append(s.usecases, useCase) - useCase.AddFeatures() + err := useCase.AddFeatures() + if err != nil { + return err + } useCase.AddUseCase() + + return nil } func (s *Service) Configuration() *api.Configuration { diff --git a/service/service_test.go b/service/service_test.go index fa64e8da..cd225c0f 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -63,7 +63,7 @@ func (s *ServiceSuite) BeforeTest(suiteName, testName string) { func (s *ServiceSuite) Test_AddUseCase() { ucMock := mocks.NewUseCaseInterface(s.T()) - ucMock.EXPECT().AddFeatures().Return().Once() + ucMock.EXPECT().AddFeatures().Return(nil).Once() ucMock.EXPECT().AddUseCase().Return().Once() s.sut.AddUseCase(ucMock) diff --git a/usecases/README.md b/usecases/README.md index 47a977b1..88166c85 100644 --- a/usecases/README.md +++ b/usecases/README.md @@ -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 diff --git a/usecases/api/api.go b/usecases/api/api.go index 898b38b1..4bbeb772 100644 --- a/usecases/api/api.go +++ b/usecases/api/api.go @@ -1,7 +1,34 @@ package api -import "github.com/enbility/spine-go/model" +import ( + "github.com/enbility/eebus-go/api" + "github.com/enbility/spine-go/model" +) //go:generate mockery var PhaseNameMapping = []model.ElectricalConnectionPhaseNameType{model.ElectricalConnectionPhaseNameTypeA, model.ElectricalConnectionPhaseNameTypeB, model.ElectricalConnectionPhaseNameTypeC} + +// used to enable batch data updates for certain usecases +// +// a usecase that wants to provide batch update capabilities using this interface should +// +// 1. provide methods that return a type implementing this interface +// 2. provide an Update method that accepts a list of this interface +// +// The Update method can then iterate over the provided UpdateData, ensure all +// data points are supported, and then create a batched spine update request +type UpdateData interface { + Supported() bool + NotSupportedError() error +} + +// used to enable batch data updates for MeaserumentData +// +// usecases can use this interface to provide batch update capabilities by +// implementing a method that takes a list of this interface and passes a list +// of MeasurementData to Measurement.UpdateDataForIds +type UpdateMeasurementData interface { + UpdateData + MeasurementData() api.MeasurementDataForID +} diff --git a/usecases/api/mu_mpc.go b/usecases/api/mu_mpc.go new file mode 100644 index 00000000..b3e6a63a --- /dev/null +++ b/usecases/api/mu_mpc.go @@ -0,0 +1,199 @@ +package api + +import ( + "time" + + "github.com/enbility/spine-go/model" +) + +// 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) + + // 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 ...UpdateMeasurementData) 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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, + ) UpdateMeasurementData + + // 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, + ) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData + + // 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) UpdateMeasurementData +} diff --git a/usecases/cem/cevc/testhelper_test.go b/usecases/cem/cevc/testhelper_test.go index 1c05a410..26c8931c 100644 --- a/usecases/cem/cevc/testhelper_test.go +++ b/usecases/cem/cevc/testhelper_test.go @@ -75,7 +75,7 @@ func (s *CemCEVCSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewCEVC(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() var entities []spineapi.EntityRemoteInterface diff --git a/usecases/cem/cevc/usecase.go b/usecases/cem/cevc/usecase.go index 56c61c81..a06446cf 100644 --- a/usecases/cem/cevc/usecase.go +++ b/usecases/cem/cevc/usecase.go @@ -70,6 +70,7 @@ func NewCEVC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &CEVC{ @@ -81,7 +82,7 @@ func NewCEVC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC return uc } -func (e *CEVC) AddFeatures() { +func (e *CEVC) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeDeviceConfiguration, @@ -97,4 +98,6 @@ func (e *CEVC) AddFeatures() { f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) f.AddFunctionType(model.FunctionTypeDeviceDiagnosisStateData, true, false) f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) + + return nil } diff --git a/usecases/cem/evcc/usecase.go b/usecases/cem/evcc/usecase.go index 1612522f..3d9cb7f4 100644 --- a/usecases/cem/evcc/usecase.go +++ b/usecases/cem/evcc/usecase.go @@ -83,6 +83,7 @@ func NewEVCC( UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &EVCC{ @@ -95,7 +96,7 @@ func NewEVCC( return uc } -func (e *EVCC) AddFeatures() { +func (e *EVCC) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeDeviceConfiguration, @@ -108,4 +109,6 @@ func (e *EVCC) AddFeatures() { f := e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) f.AddResultCallback(e.HandleResponse) } + + return nil } diff --git a/usecases/cem/evcem/testhelper_test.go b/usecases/cem/evcem/testhelper_test.go index 7e469bc7..ea5fc254 100644 --- a/usecases/cem/evcem/testhelper_test.go +++ b/usecases/cem/evcem/testhelper_test.go @@ -70,7 +70,7 @@ func (s *CemEVCEMSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewEVCEM(s.service, localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() var entities []spineapi.EntityRemoteInterface diff --git a/usecases/cem/evcem/usecase.go b/usecases/cem/evcem/usecase.go index 42491c4a..0df08616 100644 --- a/usecases/cem/evcem/usecase.go +++ b/usecases/cem/evcem/usecase.go @@ -69,7 +69,9 @@ func NewEVCEM( eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &EVCEM{ UseCaseBase: usecase, @@ -81,7 +83,7 @@ func NewEVCEM( return uc } -func (e *EVCEM) AddFeatures() { +func (e *EVCEM) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeElectricalConnection, @@ -90,4 +92,6 @@ func (e *EVCEM) AddFeatures() { for _, feature := range clientFeatures { _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) } + + return nil } diff --git a/usecases/cem/evsecc/testhelper_test.go b/usecases/cem/evsecc/testhelper_test.go index 0093606c..ed5aa168 100644 --- a/usecases/cem/evsecc/testhelper_test.go +++ b/usecases/cem/evsecc/testhelper_test.go @@ -73,7 +73,7 @@ func (s *CemEVSECCSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewEVSECC(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() var entities []spineapi.EntityRemoteInterface diff --git a/usecases/cem/evsecc/usecase.go b/usecases/cem/evsecc/usecase.go index d96ee92b..255bf374 100644 --- a/usecases/cem/evsecc/usecase.go +++ b/usecases/cem/evsecc/usecase.go @@ -51,7 +51,9 @@ func NewEVSECC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEven eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &EVSECC{ UseCaseBase: usecase, @@ -62,7 +64,7 @@ func NewEVSECC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEven return uc } -func (e *EVSECC) AddFeatures() { +func (e *EVSECC) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeDeviceClassification, @@ -72,4 +74,6 @@ func (e *EVSECC) AddFeatures() { for _, feature := range clientFeatures { _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) } + + return nil } diff --git a/usecases/cem/evsoc/testhelper_test.go b/usecases/cem/evsoc/testhelper_test.go index bd36782a..e5ed4b42 100644 --- a/usecases/cem/evsoc/testhelper_test.go +++ b/usecases/cem/evsoc/testhelper_test.go @@ -73,7 +73,7 @@ func (s *CemEVSOCSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewEVSOC(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() var entities []spineapi.EntityRemoteInterface diff --git a/usecases/cem/evsoc/usecase.go b/usecases/cem/evsoc/usecase.go index 32df9b0c..63bb978d 100644 --- a/usecases/cem/evsoc/usecase.go +++ b/usecases/cem/evsoc/usecase.go @@ -47,6 +47,7 @@ func NewEVSOC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEvent UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &EVSOC{ @@ -58,7 +59,7 @@ func NewEVSOC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEvent return uc } -func (e *EVSOC) AddFeatures() { +func (e *EVSOC) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeElectricalConnection, @@ -67,6 +68,8 @@ func (e *EVSOC) AddFeatures() { for _, feature := range clientFeatures { _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) } + + return nil } func (e *EVSOC) UpdateUseCaseAvailability(available bool) { diff --git a/usecases/cem/opev/testhelper_test.go b/usecases/cem/opev/testhelper_test.go index d69dbb64..4cc4cbe8 100644 --- a/usecases/cem/opev/testhelper_test.go +++ b/usecases/cem/opev/testhelper_test.go @@ -73,7 +73,7 @@ func (s *CemOPEVSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewOPEV(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() var clientFeatures = []model.FeatureTypeType{ diff --git a/usecases/cem/opev/usecase.go b/usecases/cem/opev/usecase.go index 40937b25..bbe3ca28 100644 --- a/usecases/cem/opev/usecase.go +++ b/usecases/cem/opev/usecase.go @@ -58,6 +58,7 @@ func NewOPEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &OPEV{ @@ -69,7 +70,7 @@ func NewOPEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC return uc } -func (e *OPEV) AddFeatures() { +func (e *OPEV) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeLoadControl, @@ -83,4 +84,6 @@ func (e *OPEV) AddFeatures() { f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) f.AddFunctionType(model.FunctionTypeDeviceDiagnosisStateData, true, false) f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) + + return nil } diff --git a/usecases/cem/oscev/testhelper_test.go b/usecases/cem/oscev/testhelper_test.go index 163e4640..f441e18c 100644 --- a/usecases/cem/oscev/testhelper_test.go +++ b/usecases/cem/oscev/testhelper_test.go @@ -72,7 +72,7 @@ func (s *CemOSCEVSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewOSCEV(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() var clientFeatures = []model.FeatureTypeType{ diff --git a/usecases/cem/oscev/usecase.go b/usecases/cem/oscev/usecase.go index 75fc3e2a..cc18fb1c 100644 --- a/usecases/cem/oscev/usecase.go +++ b/usecases/cem/oscev/usecase.go @@ -58,6 +58,7 @@ func NewOSCEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEvent UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &OSCEV{ @@ -69,7 +70,7 @@ func NewOSCEV(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEvent return uc } -func (e *OSCEV) AddFeatures() { +func (e *OSCEV) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeLoadControl, @@ -83,4 +84,6 @@ func (e *OSCEV) AddFeatures() { f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) f.AddFunctionType(model.FunctionTypeDeviceDiagnosisStateData, true, false) f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) + + return nil } diff --git a/usecases/cem/vabd/testhelper_test.go b/usecases/cem/vabd/testhelper_test.go index e067e486..69b566e5 100644 --- a/usecases/cem/vabd/testhelper_test.go +++ b/usecases/cem/vabd/testhelper_test.go @@ -73,7 +73,7 @@ func (s *CemVABDSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewVABD(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() s.remoteDevice, s.batteryEntity = setupDevices(s.service, s.T()) diff --git a/usecases/cem/vabd/usecase.go b/usecases/cem/vabd/usecase.go index c28ed5d3..faf7ef6b 100644 --- a/usecases/cem/vabd/usecase.go +++ b/usecases/cem/vabd/usecase.go @@ -72,6 +72,7 @@ func NewVABD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &VABD{ @@ -83,7 +84,7 @@ func NewVABD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC return uc } -func (e *VABD) AddFeatures() { +func (e *VABD) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeDeviceConfiguration, @@ -93,4 +94,6 @@ func (e *VABD) AddFeatures() { for _, feature := range clientFeatures { _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) } + + return nil } diff --git a/usecases/cem/vapd/testhelper_test.go b/usecases/cem/vapd/testhelper_test.go index 6fc95e79..07e02ad3 100644 --- a/usecases/cem/vapd/testhelper_test.go +++ b/usecases/cem/vapd/testhelper_test.go @@ -73,7 +73,7 @@ func (s *CemVAPDSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewVAPD(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() s.remoteDevice, s.pvEntity = setupDevices(s.service, s.T()) diff --git a/usecases/cem/vapd/usecase.go b/usecases/cem/vapd/usecase.go index 50578d1b..302b68c4 100644 --- a/usecases/cem/vapd/usecase.go +++ b/usecases/cem/vapd/usecase.go @@ -63,6 +63,7 @@ func NewVAPD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &VAPD{ @@ -74,7 +75,7 @@ func NewVAPD(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC return uc } -func (e *VAPD) AddFeatures() { +func (e *VAPD) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeDeviceConfiguration, @@ -84,4 +85,6 @@ func (e *VAPD) AddFeatures() { for _, feature := range clientFeatures { _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) } + + return nil } diff --git a/usecases/cs/lpc/testhelper_test.go b/usecases/cs/lpc/testhelper_test.go index 9a06e053..f48a8878 100644 --- a/usecases/cs/lpc/testhelper_test.go +++ b/usecases/cs/lpc/testhelper_test.go @@ -16,6 +16,7 @@ import ( "github.com/enbility/spine-go/model" "github.com/enbility/spine-go/spine" "github.com/enbility/spine-go/util" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" ) @@ -76,7 +77,7 @@ func (s *CsLPCSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewLPC(localEntity, s.Event) - s.sut.AddFeatures() + assert.Nil(s.T(), s.sut.AddFeatures()) s.sut.AddUseCase() s.loadControlFeature = localEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) diff --git a/usecases/cs/lpc/usecase.go b/usecases/cs/lpc/usecase.go index 5b6d3608..b23f0d29 100644 --- a/usecases/cs/lpc/usecase.go +++ b/usecases/cs/lpc/usecase.go @@ -71,6 +71,7 @@ func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &LPC{ @@ -172,7 +173,7 @@ func (e *LPC) loadControlWriteCB(msg *spineapi.Message) { go e.approveOrDenyConsumptionLimit(msg, true, "") } -func (e *LPC) AddFeatures() { +func (e *LPC) AddFeatures() error { // client features _ = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeClient) @@ -180,7 +181,10 @@ func (e *LPC) AddFeatures() { f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) f.AddFunctionType(model.FunctionTypeLoadControlLimitDescriptionListData, true, false) f.AddFunctionType(model.FunctionTypeLoadControlLimitListData, true, true) - _ = f.AddWriteApprovalCallback(e.loadControlWriteCB) + err := f.AddWriteApprovalCallback(e.loadControlWriteCB) + if err != nil { + return err + } newLimitDesc := model.LoadControlLimitDescriptionDataType{ LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), @@ -204,6 +208,8 @@ func (e *LPC) AddFeatures() { }, } _ = lc.UpdateLimitDataForIds(newLimiData) + } else { + return err } f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceConfiguration, model.RoleTypeServer) @@ -235,7 +241,7 @@ func (e *LPC) AddFeatures() { value := &model.DeviceConfigurationKeyValueValueType{ ScaledNumber: model.NewScaledNumberType(0), } - _ = dcs.UpdateKeyValueDataForFilter( + err1 := dcs.UpdateKeyValueDataForFilter( model.DeviceConfigurationKeyValueDataType{ Value: value, IsValueChangeable: util.Ptr(true), @@ -245,11 +251,14 @@ func (e *LPC) AddFeatures() { KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeConsumptionActivePowerLimit), }, ) + if err1 != nil { + return err1 + } value = &model.DeviceConfigurationKeyValueValueType{ Duration: model.NewDurationType(0), } - _ = dcs.UpdateKeyValueDataForFilter( + err1 = dcs.UpdateKeyValueDataForFilter( model.DeviceConfigurationKeyValueDataType{ Value: value, IsValueChangeable: util.Ptr(true), @@ -259,6 +268,11 @@ func (e *LPC) AddFeatures() { KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), }, ) + if err1 != nil { + return err1 + } + } else { + return err } f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) @@ -278,5 +292,9 @@ func (e *LPC) AddFeatures() { Unit: util.Ptr(model.UnitOfMeasurementTypeW), } _, _ = ec.AddCharacteristic(newCharData) + } else { + return err } + + return nil } diff --git a/usecases/cs/lpp/testhelper_test.go b/usecases/cs/lpp/testhelper_test.go index 6a0920ba..0bad0a4e 100644 --- a/usecases/cs/lpp/testhelper_test.go +++ b/usecases/cs/lpp/testhelper_test.go @@ -16,6 +16,7 @@ import ( "github.com/enbility/spine-go/model" "github.com/enbility/spine-go/spine" "github.com/enbility/spine-go/util" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/suite" ) @@ -76,7 +77,7 @@ func (s *CsLPPSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewLPP(localEntity, s.Event) - s.sut.AddFeatures() + assert.Nil(s.T(), s.sut.AddFeatures()) s.sut.AddUseCase() s.loadControlFeature = localEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) diff --git a/usecases/cs/lpp/usecase.go b/usecases/cs/lpp/usecase.go index 8b859f98..642932d1 100644 --- a/usecases/cs/lpp/usecase.go +++ b/usecases/cs/lpp/usecase.go @@ -70,6 +70,7 @@ func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &LPP{ @@ -172,7 +173,7 @@ func (e *LPP) loadControlWriteCB(msg *spineapi.Message) { go e.approveOrDenyProductionLimit(msg, true, "") } -func (e *LPP) AddFeatures() { +func (e *LPP) AddFeatures() error { // client features _ = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeClient) @@ -180,7 +181,10 @@ func (e *LPP) AddFeatures() { f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeLoadControl, model.RoleTypeServer) f.AddFunctionType(model.FunctionTypeLoadControlLimitDescriptionListData, true, false) f.AddFunctionType(model.FunctionTypeLoadControlLimitListData, true, true) - _ = f.AddWriteApprovalCallback(e.loadControlWriteCB) + err := f.AddWriteApprovalCallback(e.loadControlWriteCB) + if err != nil { + return err + } newLimitDesc := model.LoadControlLimitDescriptionDataType{ LimitType: util.Ptr(model.LoadControlLimitTypeTypeSignDependentAbsValueLimit), @@ -204,6 +208,8 @@ func (e *LPP) AddFeatures() { }, } _ = lc.UpdateLimitDataForIds(newLimiData) + } else { + return err } f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceConfiguration, model.RoleTypeServer) @@ -235,7 +241,7 @@ func (e *LPP) AddFeatures() { value := &model.DeviceConfigurationKeyValueValueType{ ScaledNumber: model.NewScaledNumberType(0), } - _ = dcs.UpdateKeyValueDataForFilter( + err1 := dcs.UpdateKeyValueDataForFilter( model.DeviceConfigurationKeyValueDataType{ Value: value, IsValueChangeable: util.Ptr(true), @@ -245,11 +251,14 @@ func (e *LPP) AddFeatures() { KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeProductionActivePowerLimit), }, ) + if err1 != nil { + return err1 + } value = &model.DeviceConfigurationKeyValueValueType{ Duration: model.NewDurationType(0), } - _ = dcs.UpdateKeyValueDataForFilter( + err1 = dcs.UpdateKeyValueDataForFilter( model.DeviceConfigurationKeyValueDataType{ Value: value, IsValueChangeable: util.Ptr(true), @@ -259,6 +268,11 @@ func (e *LPP) AddFeatures() { KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum), }, ) + if err1 != nil { + return err1 + } + } else { + return err } f = e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) @@ -277,6 +291,13 @@ func (e *LPP) AddFeatures() { CharacteristicType: util.Ptr(e.characteristicType()), Unit: util.Ptr(model.UnitOfMeasurementTypeW), } - _, _ = ec.AddCharacteristic(newCharData) + _, err1 := ec.AddCharacteristic(newCharData) + if err1 != nil { + return err1 + } + } else { + return err } + + return nil } diff --git a/usecases/eg/lpc/usecase.go b/usecases/eg/lpc/usecase.go index 84c3c5d3..ed4f3f7b 100644 --- a/usecases/eg/lpc/usecase.go +++ b/usecases/eg/lpc/usecase.go @@ -66,6 +66,7 @@ func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa UseCaseSupportUpdate, validActorTypes, validEntityTypes, + false, ) uc := &LPC{ @@ -77,7 +78,7 @@ func NewLPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa return uc } -func (e *LPC) AddFeatures() { +func (e *LPC) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeDeviceDiagnosis, @@ -92,4 +93,6 @@ func (e *LPC) AddFeatures() { // server features f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) + + return nil } diff --git a/usecases/eg/lpp/testhelper_test.go b/usecases/eg/lpp/testhelper_test.go index 3e3efff0..8ea3ed5d 100644 --- a/usecases/eg/lpp/testhelper_test.go +++ b/usecases/eg/lpp/testhelper_test.go @@ -73,7 +73,7 @@ func (s *EgLPPSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewLPP(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() s.remoteDevice, s.monitoredEntity = setupDevices(s.service, s.T()) diff --git a/usecases/eg/lpp/usecase.go b/usecases/eg/lpp/usecase.go index c68a5b74..3dbd51ad 100644 --- a/usecases/eg/lpp/usecase.go +++ b/usecases/eg/lpp/usecase.go @@ -63,7 +63,9 @@ func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &LPP{ UseCaseBase: usecase, @@ -74,7 +76,7 @@ func NewLPP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa return uc } -func (e *LPP) AddFeatures() { +func (e *LPP) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeDeviceDiagnosis, @@ -89,6 +91,8 @@ func (e *LPP) AddFeatures() { // server features f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) + + return nil } func (e *LPP) UpdateUseCaseAvailability(available bool) { diff --git a/usecases/ma/mgcp/testhelper_test.go b/usecases/ma/mgcp/testhelper_test.go index 2af4484f..784441dd 100644 --- a/usecases/ma/mgcp/testhelper_test.go +++ b/usecases/ma/mgcp/testhelper_test.go @@ -73,7 +73,7 @@ func (s *GcpMGCPSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewMGCP(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() s.remoteDevice, s.smgwEntity = setupDevices(s.service, s.T()) diff --git a/usecases/ma/mgcp/usecase.go b/usecases/ma/mgcp/usecase.go index 6f6988d2..30a3e77d 100644 --- a/usecases/ma/mgcp/usecase.go +++ b/usecases/ma/mgcp/usecase.go @@ -93,7 +93,9 @@ func NewMGCP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &MGCP{ UseCaseBase: usecase, @@ -104,7 +106,7 @@ func NewMGCP(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventC return uc } -func (e *MGCP) AddFeatures() { +func (e *MGCP) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeDeviceConfiguration, @@ -114,4 +116,6 @@ func (e *MGCP) AddFeatures() { for _, feature := range clientFeatures { _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) } + + return nil } diff --git a/usecases/ma/mpc/testhelper_test.go b/usecases/ma/mpc/testhelper_test.go index c24338b7..6b850cc9 100644 --- a/usecases/ma/mpc/testhelper_test.go +++ b/usecases/ma/mpc/testhelper_test.go @@ -73,7 +73,7 @@ func (s *MaMPCSuite) BeforeTest(suiteName, testName string) { localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeCEM) s.sut = NewMPC(localEntity, s.Event) - s.sut.AddFeatures() + _ = s.sut.AddFeatures() s.sut.AddUseCase() s.remoteDevice, s.monitoredEntity = setupDevices(s.service, s.T()) diff --git a/usecases/ma/mpc/usecase.go b/usecases/ma/mpc/usecase.go index 8e23395b..d2a1ddf9 100644 --- a/usecases/ma/mpc/usecase.go +++ b/usecases/ma/mpc/usecase.go @@ -85,7 +85,9 @@ func NewMPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa eventCB, UseCaseSupportUpdate, validActorTypes, - validEntityTypes) + validEntityTypes, + false, + ) uc := &MPC{ UseCaseBase: usecase, @@ -96,7 +98,7 @@ func NewMPC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCa return uc } -func (e *MPC) AddFeatures() { +func (e *MPC) AddFeatures() error { // client features var clientFeatures = []model.FeatureTypeType{ model.FeatureTypeTypeElectricalConnection, @@ -105,4 +107,6 @@ func (e *MPC) AddFeatures() { for _, feature := range clientFeatures { _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) } + + return nil } diff --git a/usecases/mocks/CemCEVCInterface.go b/usecases/mocks/CemCEVCInterface.go index 3954e533..8877b864 100644 --- a/usecases/mocks/CemCEVCInterface.go +++ b/usecases/mocks/CemCEVCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -25,8 +25,21 @@ func (_m *CemCEVCInterface) EXPECT() *CemCEVCInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemCEVCInterface) AddFeatures() { - _m.Called() +func (_m *CemCEVCInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemCEVCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -46,12 +59,12 @@ func (_c *CemCEVCInterface_AddFeatures_Call) Run(run func()) *CemCEVCInterface_A return _c } -func (_c *CemCEVCInterface_AddFeatures_Call) Return() *CemCEVCInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemCEVCInterface_AddFeatures_Call) Return(_a0 error) *CemCEVCInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemCEVCInterface_AddFeatures_Call) RunAndReturn(run func()) *CemCEVCInterface_AddFeatures_Call { +func (_c *CemCEVCInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemCEVCInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CemEVCCInterface.go b/usecases/mocks/CemEVCCInterface.go index 4ba5ea83..75fad2bd 100644 --- a/usecases/mocks/CemEVCCInterface.go +++ b/usecases/mocks/CemEVCCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -27,8 +27,21 @@ func (_m *CemEVCCInterface) EXPECT() *CemEVCCInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemEVCCInterface) AddFeatures() { - _m.Called() +func (_m *CemEVCCInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemEVCCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -48,12 +61,12 @@ func (_c *CemEVCCInterface_AddFeatures_Call) Run(run func()) *CemEVCCInterface_A return _c } -func (_c *CemEVCCInterface_AddFeatures_Call) Return() *CemEVCCInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemEVCCInterface_AddFeatures_Call) Return(_a0 error) *CemEVCCInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemEVCCInterface_AddFeatures_Call) RunAndReturn(run func()) *CemEVCCInterface_AddFeatures_Call { +func (_c *CemEVCCInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemEVCCInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CemEVCEMInterface.go b/usecases/mocks/CemEVCEMInterface.go index ae4fa5b0..f1f81fe0 100644 --- a/usecases/mocks/CemEVCEMInterface.go +++ b/usecases/mocks/CemEVCEMInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -23,8 +23,21 @@ func (_m *CemEVCEMInterface) EXPECT() *CemEVCEMInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemEVCEMInterface) AddFeatures() { - _m.Called() +func (_m *CemEVCEMInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemEVCEMInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -44,12 +57,12 @@ func (_c *CemEVCEMInterface_AddFeatures_Call) Run(run func()) *CemEVCEMInterface return _c } -func (_c *CemEVCEMInterface_AddFeatures_Call) Return() *CemEVCEMInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemEVCEMInterface_AddFeatures_Call) Return(_a0 error) *CemEVCEMInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemEVCEMInterface_AddFeatures_Call) RunAndReturn(run func()) *CemEVCEMInterface_AddFeatures_Call { +func (_c *CemEVCEMInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemEVCEMInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CemEVSECCInterface.go b/usecases/mocks/CemEVSECCInterface.go index 6650e628..2b000512 100644 --- a/usecases/mocks/CemEVSECCInterface.go +++ b/usecases/mocks/CemEVSECCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -27,8 +27,21 @@ func (_m *CemEVSECCInterface) EXPECT() *CemEVSECCInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemEVSECCInterface) AddFeatures() { - _m.Called() +func (_m *CemEVSECCInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemEVSECCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -48,12 +61,12 @@ func (_c *CemEVSECCInterface_AddFeatures_Call) Run(run func()) *CemEVSECCInterfa return _c } -func (_c *CemEVSECCInterface_AddFeatures_Call) Return() *CemEVSECCInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemEVSECCInterface_AddFeatures_Call) Return(_a0 error) *CemEVSECCInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemEVSECCInterface_AddFeatures_Call) RunAndReturn(run func()) *CemEVSECCInterface_AddFeatures_Call { +func (_c *CemEVSECCInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemEVSECCInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CemEVSOCInterface.go b/usecases/mocks/CemEVSOCInterface.go index cdbfcd6c..4643a892 100644 --- a/usecases/mocks/CemEVSOCInterface.go +++ b/usecases/mocks/CemEVSOCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -23,8 +23,21 @@ func (_m *CemEVSOCInterface) EXPECT() *CemEVSOCInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemEVSOCInterface) AddFeatures() { - _m.Called() +func (_m *CemEVSOCInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemEVSOCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -44,12 +57,12 @@ func (_c *CemEVSOCInterface_AddFeatures_Call) Run(run func()) *CemEVSOCInterface return _c } -func (_c *CemEVSOCInterface_AddFeatures_Call) Return() *CemEVSOCInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemEVSOCInterface_AddFeatures_Call) Return(_a0 error) *CemEVSOCInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemEVSOCInterface_AddFeatures_Call) RunAndReturn(run func()) *CemEVSOCInterface_AddFeatures_Call { +func (_c *CemEVSOCInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemEVSOCInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CemOPEVInterface.go b/usecases/mocks/CemOPEVInterface.go index 50b42384..b2371c81 100644 --- a/usecases/mocks/CemOPEVInterface.go +++ b/usecases/mocks/CemOPEVInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -27,8 +27,21 @@ func (_m *CemOPEVInterface) EXPECT() *CemOPEVInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemOPEVInterface) AddFeatures() { - _m.Called() +func (_m *CemOPEVInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemOPEVInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -48,12 +61,12 @@ func (_c *CemOPEVInterface_AddFeatures_Call) Run(run func()) *CemOPEVInterface_A return _c } -func (_c *CemOPEVInterface_AddFeatures_Call) Return() *CemOPEVInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemOPEVInterface_AddFeatures_Call) Return(_a0 error) *CemOPEVInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemOPEVInterface_AddFeatures_Call) RunAndReturn(run func()) *CemOPEVInterface_AddFeatures_Call { +func (_c *CemOPEVInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemOPEVInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CemOSCEVInterface.go b/usecases/mocks/CemOSCEVInterface.go index 60636687..4e8f0457 100644 --- a/usecases/mocks/CemOSCEVInterface.go +++ b/usecases/mocks/CemOSCEVInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -27,8 +27,21 @@ func (_m *CemOSCEVInterface) EXPECT() *CemOSCEVInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemOSCEVInterface) AddFeatures() { - _m.Called() +func (_m *CemOSCEVInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemOSCEVInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -48,12 +61,12 @@ func (_c *CemOSCEVInterface_AddFeatures_Call) Run(run func()) *CemOSCEVInterface return _c } -func (_c *CemOSCEVInterface_AddFeatures_Call) Return() *CemOSCEVInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemOSCEVInterface_AddFeatures_Call) Return(_a0 error) *CemOSCEVInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemOSCEVInterface_AddFeatures_Call) RunAndReturn(run func()) *CemOSCEVInterface_AddFeatures_Call { +func (_c *CemOSCEVInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemOSCEVInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CemVABDInterface.go b/usecases/mocks/CemVABDInterface.go index f84ed25c..62deda9f 100644 --- a/usecases/mocks/CemVABDInterface.go +++ b/usecases/mocks/CemVABDInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -23,8 +23,21 @@ func (_m *CemVABDInterface) EXPECT() *CemVABDInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemVABDInterface) AddFeatures() { - _m.Called() +func (_m *CemVABDInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemVABDInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -44,12 +57,12 @@ func (_c *CemVABDInterface_AddFeatures_Call) Run(run func()) *CemVABDInterface_A return _c } -func (_c *CemVABDInterface_AddFeatures_Call) Return() *CemVABDInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemVABDInterface_AddFeatures_Call) Return(_a0 error) *CemVABDInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemVABDInterface_AddFeatures_Call) RunAndReturn(run func()) *CemVABDInterface_AddFeatures_Call { +func (_c *CemVABDInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemVABDInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CemVAPDInterface.go b/usecases/mocks/CemVAPDInterface.go index 65c3af91..5c9a1f22 100644 --- a/usecases/mocks/CemVAPDInterface.go +++ b/usecases/mocks/CemVAPDInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -23,8 +23,21 @@ func (_m *CemVAPDInterface) EXPECT() *CemVAPDInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CemVAPDInterface) AddFeatures() { - _m.Called() +func (_m *CemVAPDInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CemVAPDInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -44,12 +57,12 @@ func (_c *CemVAPDInterface_AddFeatures_Call) Run(run func()) *CemVAPDInterface_A return _c } -func (_c *CemVAPDInterface_AddFeatures_Call) Return() *CemVAPDInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CemVAPDInterface_AddFeatures_Call) Return(_a0 error) *CemVAPDInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CemVAPDInterface_AddFeatures_Call) RunAndReturn(run func()) *CemVAPDInterface_AddFeatures_Call { +func (_c *CemVAPDInterface_AddFeatures_Call) RunAndReturn(run func() error) *CemVAPDInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CsLPCInterface.go b/usecases/mocks/CsLPCInterface.go index c8e1ac4a..5e17dbdf 100644 --- a/usecases/mocks/CsLPCInterface.go +++ b/usecases/mocks/CsLPCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -29,8 +29,21 @@ func (_m *CsLPCInterface) EXPECT() *CsLPCInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CsLPCInterface) AddFeatures() { - _m.Called() +func (_m *CsLPCInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CsLPCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -50,12 +63,12 @@ func (_c *CsLPCInterface_AddFeatures_Call) Run(run func()) *CsLPCInterface_AddFe return _c } -func (_c *CsLPCInterface_AddFeatures_Call) Return() *CsLPCInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CsLPCInterface_AddFeatures_Call) Return(_a0 error) *CsLPCInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CsLPCInterface_AddFeatures_Call) RunAndReturn(run func()) *CsLPCInterface_AddFeatures_Call { +func (_c *CsLPCInterface_AddFeatures_Call) RunAndReturn(run func() error) *CsLPCInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/CsLPPInterface.go b/usecases/mocks/CsLPPInterface.go index c2b07f16..95d2356b 100644 --- a/usecases/mocks/CsLPPInterface.go +++ b/usecases/mocks/CsLPPInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -29,8 +29,21 @@ func (_m *CsLPPInterface) EXPECT() *CsLPPInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *CsLPPInterface) AddFeatures() { - _m.Called() +func (_m *CsLPPInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // CsLPPInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -50,12 +63,12 @@ func (_c *CsLPPInterface_AddFeatures_Call) Run(run func()) *CsLPPInterface_AddFe return _c } -func (_c *CsLPPInterface_AddFeatures_Call) Return() *CsLPPInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *CsLPPInterface_AddFeatures_Call) Return(_a0 error) *CsLPPInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *CsLPPInterface_AddFeatures_Call) RunAndReturn(run func()) *CsLPPInterface_AddFeatures_Call { +func (_c *CsLPPInterface_AddFeatures_Call) RunAndReturn(run func() error) *CsLPPInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/EgLPCInterface.go b/usecases/mocks/EgLPCInterface.go index d4f6f349..6574df1d 100644 --- a/usecases/mocks/EgLPCInterface.go +++ b/usecases/mocks/EgLPCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -29,8 +29,21 @@ func (_m *EgLPCInterface) EXPECT() *EgLPCInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *EgLPCInterface) AddFeatures() { - _m.Called() +func (_m *EgLPCInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // EgLPCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -50,12 +63,12 @@ func (_c *EgLPCInterface_AddFeatures_Call) Run(run func()) *EgLPCInterface_AddFe return _c } -func (_c *EgLPCInterface_AddFeatures_Call) Return() *EgLPCInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *EgLPCInterface_AddFeatures_Call) Return(_a0 error) *EgLPCInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *EgLPCInterface_AddFeatures_Call) RunAndReturn(run func()) *EgLPCInterface_AddFeatures_Call { +func (_c *EgLPCInterface_AddFeatures_Call) RunAndReturn(run func() error) *EgLPCInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/EgLPPInterface.go b/usecases/mocks/EgLPPInterface.go index b18ea631..5449a4b6 100644 --- a/usecases/mocks/EgLPPInterface.go +++ b/usecases/mocks/EgLPPInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -29,8 +29,21 @@ func (_m *EgLPPInterface) EXPECT() *EgLPPInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *EgLPPInterface) AddFeatures() { - _m.Called() +func (_m *EgLPPInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // EgLPPInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -50,12 +63,12 @@ func (_c *EgLPPInterface_AddFeatures_Call) Run(run func()) *EgLPPInterface_AddFe return _c } -func (_c *EgLPPInterface_AddFeatures_Call) Return() *EgLPPInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *EgLPPInterface_AddFeatures_Call) Return(_a0 error) *EgLPPInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *EgLPPInterface_AddFeatures_Call) RunAndReturn(run func()) *EgLPPInterface_AddFeatures_Call { +func (_c *EgLPPInterface_AddFeatures_Call) RunAndReturn(run func() error) *EgLPPInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/MaMGCPInterface.go b/usecases/mocks/MaMGCPInterface.go index bc4ea319..a53b0962 100644 --- a/usecases/mocks/MaMGCPInterface.go +++ b/usecases/mocks/MaMGCPInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -23,8 +23,21 @@ func (_m *MaMGCPInterface) EXPECT() *MaMGCPInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *MaMGCPInterface) AddFeatures() { - _m.Called() +func (_m *MaMGCPInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // MaMGCPInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -44,12 +57,12 @@ func (_c *MaMGCPInterface_AddFeatures_Call) Run(run func()) *MaMGCPInterface_Add return _c } -func (_c *MaMGCPInterface_AddFeatures_Call) Return() *MaMGCPInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *MaMGCPInterface_AddFeatures_Call) Return(_a0 error) *MaMGCPInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *MaMGCPInterface_AddFeatures_Call) RunAndReturn(run func()) *MaMGCPInterface_AddFeatures_Call { +func (_c *MaMGCPInterface_AddFeatures_Call) RunAndReturn(run func() error) *MaMGCPInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/MaMPCInterface.go b/usecases/mocks/MaMPCInterface.go index a3e5b8f4..3a1baa21 100644 --- a/usecases/mocks/MaMPCInterface.go +++ b/usecases/mocks/MaMPCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.46.3. DO NOT EDIT. package mocks @@ -23,8 +23,21 @@ func (_m *MaMPCInterface) EXPECT() *MaMPCInterface_Expecter { } // AddFeatures provides a mock function with given fields: -func (_m *MaMPCInterface) AddFeatures() { - _m.Called() +func (_m *MaMPCInterface) AddFeatures() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for AddFeatures") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 } // MaMPCInterface_AddFeatures_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddFeatures' @@ -44,12 +57,12 @@ func (_c *MaMPCInterface_AddFeatures_Call) Run(run func()) *MaMPCInterface_AddFe return _c } -func (_c *MaMPCInterface_AddFeatures_Call) Return() *MaMPCInterface_AddFeatures_Call { - _c.Call.Return() +func (_c *MaMPCInterface_AddFeatures_Call) Return(_a0 error) *MaMPCInterface_AddFeatures_Call { + _c.Call.Return(_a0) return _c } -func (_c *MaMPCInterface_AddFeatures_Call) RunAndReturn(run func()) *MaMPCInterface_AddFeatures_Call { +func (_c *MaMPCInterface_AddFeatures_Call) RunAndReturn(run func() error) *MaMPCInterface_AddFeatures_Call { _c.Call.Return(run) return _c } diff --git a/usecases/mocks/MuMPCInterface.go b/usecases/mocks/MuMPCInterface.go new file mode 100644 index 00000000..87d1eeea --- /dev/null +++ b/usecases/mocks/MuMPCInterface.go @@ -0,0 +1,1293 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/eebus-go/usecases/api" + mock "github.com/stretchr/testify/mock" + + model "github.com/enbility/spine-go/model" + + time "time" +) + +// MuMPCInterface is an autogenerated mock type for the MuMPCInterface type +type MuMPCInterface struct { + mock.Mock +} + +type MuMPCInterface_Expecter struct { + mock *mock.Mock +} + +func (_m *MuMPCInterface) EXPECT() *MuMPCInterface_Expecter { + return &MuMPCInterface_Expecter{mock: &_m.Mock} +} + +// CurrentPerPhase provides a mock function with given fields: +func (_m *MuMPCInterface) CurrentPerPhase() ([]float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for CurrentPerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func() ([]float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []float64); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MuMPCInterface_CurrentPerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentPerPhase' +type MuMPCInterface_CurrentPerPhase_Call struct { + *mock.Call +} + +// CurrentPerPhase is a helper method to define mock.On call +func (_e *MuMPCInterface_Expecter) CurrentPerPhase() *MuMPCInterface_CurrentPerPhase_Call { + return &MuMPCInterface_CurrentPerPhase_Call{Call: _e.mock.On("CurrentPerPhase")} +} + +func (_c *MuMPCInterface_CurrentPerPhase_Call) Run(run func()) *MuMPCInterface_CurrentPerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MuMPCInterface_CurrentPerPhase_Call) Return(_a0 []float64, _a1 error) *MuMPCInterface_CurrentPerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MuMPCInterface_CurrentPerPhase_Call) RunAndReturn(run func() ([]float64, error)) *MuMPCInterface_CurrentPerPhase_Call { + _c.Call.Return(run) + return _c +} + +// EnergyConsumed provides a mock function with given fields: +func (_m *MuMPCInterface) EnergyConsumed() (float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for EnergyConsumed") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func() (float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MuMPCInterface_EnergyConsumed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyConsumed' +type MuMPCInterface_EnergyConsumed_Call struct { + *mock.Call +} + +// EnergyConsumed is a helper method to define mock.On call +func (_e *MuMPCInterface_Expecter) EnergyConsumed() *MuMPCInterface_EnergyConsumed_Call { + return &MuMPCInterface_EnergyConsumed_Call{Call: _e.mock.On("EnergyConsumed")} +} + +func (_c *MuMPCInterface_EnergyConsumed_Call) Run(run func()) *MuMPCInterface_EnergyConsumed_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MuMPCInterface_EnergyConsumed_Call) Return(_a0 float64, _a1 error) *MuMPCInterface_EnergyConsumed_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MuMPCInterface_EnergyConsumed_Call) RunAndReturn(run func() (float64, error)) *MuMPCInterface_EnergyConsumed_Call { + _c.Call.Return(run) + return _c +} + +// EnergyProduced provides a mock function with given fields: +func (_m *MuMPCInterface) EnergyProduced() (float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for EnergyProduced") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func() (float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MuMPCInterface_EnergyProduced_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EnergyProduced' +type MuMPCInterface_EnergyProduced_Call struct { + *mock.Call +} + +// EnergyProduced is a helper method to define mock.On call +func (_e *MuMPCInterface_Expecter) EnergyProduced() *MuMPCInterface_EnergyProduced_Call { + return &MuMPCInterface_EnergyProduced_Call{Call: _e.mock.On("EnergyProduced")} +} + +func (_c *MuMPCInterface_EnergyProduced_Call) Run(run func()) *MuMPCInterface_EnergyProduced_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MuMPCInterface_EnergyProduced_Call) Return(_a0 float64, _a1 error) *MuMPCInterface_EnergyProduced_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MuMPCInterface_EnergyProduced_Call) RunAndReturn(run func() (float64, error)) *MuMPCInterface_EnergyProduced_Call { + _c.Call.Return(run) + return _c +} + +// Frequency provides a mock function with given fields: +func (_m *MuMPCInterface) Frequency() (float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Frequency") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func() (float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MuMPCInterface_Frequency_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Frequency' +type MuMPCInterface_Frequency_Call struct { + *mock.Call +} + +// Frequency is a helper method to define mock.On call +func (_e *MuMPCInterface_Expecter) Frequency() *MuMPCInterface_Frequency_Call { + return &MuMPCInterface_Frequency_Call{Call: _e.mock.On("Frequency")} +} + +func (_c *MuMPCInterface_Frequency_Call) Run(run func()) *MuMPCInterface_Frequency_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MuMPCInterface_Frequency_Call) Return(_a0 float64, _a1 error) *MuMPCInterface_Frequency_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MuMPCInterface_Frequency_Call) RunAndReturn(run func() (float64, error)) *MuMPCInterface_Frequency_Call { + _c.Call.Return(run) + return _c +} + +// Power provides a mock function with given fields: +func (_m *MuMPCInterface) Power() (float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Power") + } + + var r0 float64 + var r1 error + if rf, ok := ret.Get(0).(func() (float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() float64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(float64) + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MuMPCInterface_Power_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Power' +type MuMPCInterface_Power_Call struct { + *mock.Call +} + +// Power is a helper method to define mock.On call +func (_e *MuMPCInterface_Expecter) Power() *MuMPCInterface_Power_Call { + return &MuMPCInterface_Power_Call{Call: _e.mock.On("Power")} +} + +func (_c *MuMPCInterface_Power_Call) Run(run func()) *MuMPCInterface_Power_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MuMPCInterface_Power_Call) Return(_a0 float64, _a1 error) *MuMPCInterface_Power_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MuMPCInterface_Power_Call) RunAndReturn(run func() (float64, error)) *MuMPCInterface_Power_Call { + _c.Call.Return(run) + return _c +} + +// PowerPerPhase provides a mock function with given fields: +func (_m *MuMPCInterface) PowerPerPhase() ([]float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for PowerPerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func() ([]float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []float64); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MuMPCInterface_PowerPerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PowerPerPhase' +type MuMPCInterface_PowerPerPhase_Call struct { + *mock.Call +} + +// PowerPerPhase is a helper method to define mock.On call +func (_e *MuMPCInterface_Expecter) PowerPerPhase() *MuMPCInterface_PowerPerPhase_Call { + return &MuMPCInterface_PowerPerPhase_Call{Call: _e.mock.On("PowerPerPhase")} +} + +func (_c *MuMPCInterface_PowerPerPhase_Call) Run(run func()) *MuMPCInterface_PowerPerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MuMPCInterface_PowerPerPhase_Call) Return(_a0 []float64, _a1 error) *MuMPCInterface_PowerPerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MuMPCInterface_PowerPerPhase_Call) RunAndReturn(run func() ([]float64, error)) *MuMPCInterface_PowerPerPhase_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: data +func (_m *MuMPCInterface) Update(data ...api.UpdateMeasurementData) error { + _va := make([]interface{}, len(data)) + for _i := range data { + _va[_i] = data[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 error + if rf, ok := ret.Get(0).(func(...api.UpdateMeasurementData) error); ok { + r0 = rf(data...) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MuMPCInterface_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MuMPCInterface_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - data ...api.UpdateMeasurementData +func (_e *MuMPCInterface_Expecter) Update(data ...interface{}) *MuMPCInterface_Update_Call { + return &MuMPCInterface_Update_Call{Call: _e.mock.On("Update", + append([]interface{}{}, data...)...)} +} + +func (_c *MuMPCInterface_Update_Call) Run(run func(data ...api.UpdateMeasurementData)) *MuMPCInterface_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]api.UpdateMeasurementData, len(args)-0) + for i, a := range args[0:] { + if a != nil { + variadicArgs[i] = a.(api.UpdateMeasurementData) + } + } + run(variadicArgs...) + }) + return _c +} + +func (_c *MuMPCInterface_Update_Call) Return(_a0 error) *MuMPCInterface_Update_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_Update_Call) RunAndReturn(run func(...api.UpdateMeasurementData) error) *MuMPCInterface_Update_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataCurrentPhaseA provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataCurrentPhaseA(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataCurrentPhaseA") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataCurrentPhaseA_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataCurrentPhaseA' +type MuMPCInterface_UpdateDataCurrentPhaseA_Call struct { + *mock.Call +} + +// UpdateDataCurrentPhaseA is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataCurrentPhaseA(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataCurrentPhaseA_Call { + return &MuMPCInterface_UpdateDataCurrentPhaseA_Call{Call: _e.mock.On("UpdateDataCurrentPhaseA", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseA_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataCurrentPhaseA_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseA_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataCurrentPhaseA_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseA_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataCurrentPhaseA_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataCurrentPhaseB provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataCurrentPhaseB(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataCurrentPhaseB") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataCurrentPhaseB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataCurrentPhaseB' +type MuMPCInterface_UpdateDataCurrentPhaseB_Call struct { + *mock.Call +} + +// UpdateDataCurrentPhaseB is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataCurrentPhaseB(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataCurrentPhaseB_Call { + return &MuMPCInterface_UpdateDataCurrentPhaseB_Call{Call: _e.mock.On("UpdateDataCurrentPhaseB", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseB_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataCurrentPhaseB_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseB_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataCurrentPhaseB_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseB_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataCurrentPhaseB_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataCurrentPhaseC provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataCurrentPhaseC(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataCurrentPhaseC") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataCurrentPhaseC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataCurrentPhaseC' +type MuMPCInterface_UpdateDataCurrentPhaseC_Call struct { + *mock.Call +} + +// UpdateDataCurrentPhaseC is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataCurrentPhaseC(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataCurrentPhaseC_Call { + return &MuMPCInterface_UpdateDataCurrentPhaseC_Call{Call: _e.mock.On("UpdateDataCurrentPhaseC", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseC_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataCurrentPhaseC_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseC_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataCurrentPhaseC_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataCurrentPhaseC_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataCurrentPhaseC_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataEnergyConsumed provides a mock function with given fields: value, timestamp, valueState, evaluationStart, evaluationEnd +func (_m *MuMPCInterface) UpdateDataEnergyConsumed(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType, evaluationStart *time.Time, evaluationEnd *time.Time) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState, evaluationStart, evaluationEnd) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataEnergyConsumed") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType, *time.Time, *time.Time) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState, evaluationStart, evaluationEnd) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataEnergyConsumed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataEnergyConsumed' +type MuMPCInterface_UpdateDataEnergyConsumed_Call struct { + *mock.Call +} + +// UpdateDataEnergyConsumed is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +// - evaluationStart *time.Time +// - evaluationEnd *time.Time +func (_e *MuMPCInterface_Expecter) UpdateDataEnergyConsumed(value interface{}, timestamp interface{}, valueState interface{}, evaluationStart interface{}, evaluationEnd interface{}) *MuMPCInterface_UpdateDataEnergyConsumed_Call { + return &MuMPCInterface_UpdateDataEnergyConsumed_Call{Call: _e.mock.On("UpdateDataEnergyConsumed", value, timestamp, valueState, evaluationStart, evaluationEnd)} +} + +func (_c *MuMPCInterface_UpdateDataEnergyConsumed_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType, evaluationStart *time.Time, evaluationEnd *time.Time)) *MuMPCInterface_UpdateDataEnergyConsumed_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType), args[3].(*time.Time), args[4].(*time.Time)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataEnergyConsumed_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataEnergyConsumed_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataEnergyConsumed_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType, *time.Time, *time.Time) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataEnergyConsumed_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataEnergyProduced provides a mock function with given fields: value, timestamp, valueState, evaluationStart, evaluationEnd +func (_m *MuMPCInterface) UpdateDataEnergyProduced(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType, evaluationStart *time.Time, evaluationEnd *time.Time) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState, evaluationStart, evaluationEnd) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataEnergyProduced") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType, *time.Time, *time.Time) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState, evaluationStart, evaluationEnd) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataEnergyProduced_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataEnergyProduced' +type MuMPCInterface_UpdateDataEnergyProduced_Call struct { + *mock.Call +} + +// UpdateDataEnergyProduced is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +// - evaluationStart *time.Time +// - evaluationEnd *time.Time +func (_e *MuMPCInterface_Expecter) UpdateDataEnergyProduced(value interface{}, timestamp interface{}, valueState interface{}, evaluationStart interface{}, evaluationEnd interface{}) *MuMPCInterface_UpdateDataEnergyProduced_Call { + return &MuMPCInterface_UpdateDataEnergyProduced_Call{Call: _e.mock.On("UpdateDataEnergyProduced", value, timestamp, valueState, evaluationStart, evaluationEnd)} +} + +func (_c *MuMPCInterface_UpdateDataEnergyProduced_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType, evaluationStart *time.Time, evaluationEnd *time.Time)) *MuMPCInterface_UpdateDataEnergyProduced_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType), args[3].(*time.Time), args[4].(*time.Time)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataEnergyProduced_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataEnergyProduced_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataEnergyProduced_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType, *time.Time, *time.Time) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataEnergyProduced_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataFrequency provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataFrequency(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataFrequency") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataFrequency_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataFrequency' +type MuMPCInterface_UpdateDataFrequency_Call struct { + *mock.Call +} + +// UpdateDataFrequency is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataFrequency(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataFrequency_Call { + return &MuMPCInterface_UpdateDataFrequency_Call{Call: _e.mock.On("UpdateDataFrequency", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataFrequency_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataFrequency_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataFrequency_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataFrequency_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataFrequency_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataFrequency_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataPowerPhaseA provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataPowerPhaseA(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataPowerPhaseA") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataPowerPhaseA_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataPowerPhaseA' +type MuMPCInterface_UpdateDataPowerPhaseA_Call struct { + *mock.Call +} + +// UpdateDataPowerPhaseA is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataPowerPhaseA(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataPowerPhaseA_Call { + return &MuMPCInterface_UpdateDataPowerPhaseA_Call{Call: _e.mock.On("UpdateDataPowerPhaseA", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseA_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataPowerPhaseA_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseA_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataPowerPhaseA_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseA_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataPowerPhaseA_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataPowerPhaseB provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataPowerPhaseB(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataPowerPhaseB") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataPowerPhaseB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataPowerPhaseB' +type MuMPCInterface_UpdateDataPowerPhaseB_Call struct { + *mock.Call +} + +// UpdateDataPowerPhaseB is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataPowerPhaseB(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataPowerPhaseB_Call { + return &MuMPCInterface_UpdateDataPowerPhaseB_Call{Call: _e.mock.On("UpdateDataPowerPhaseB", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseB_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataPowerPhaseB_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseB_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataPowerPhaseB_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseB_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataPowerPhaseB_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataPowerPhaseC provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataPowerPhaseC(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataPowerPhaseC") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataPowerPhaseC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataPowerPhaseC' +type MuMPCInterface_UpdateDataPowerPhaseC_Call struct { + *mock.Call +} + +// UpdateDataPowerPhaseC is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataPowerPhaseC(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataPowerPhaseC_Call { + return &MuMPCInterface_UpdateDataPowerPhaseC_Call{Call: _e.mock.On("UpdateDataPowerPhaseC", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseC_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataPowerPhaseC_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseC_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataPowerPhaseC_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataPowerPhaseC_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataPowerPhaseC_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataPowerTotal provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataPowerTotal(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataPowerTotal") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataPowerTotal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataPowerTotal' +type MuMPCInterface_UpdateDataPowerTotal_Call struct { + *mock.Call +} + +// UpdateDataPowerTotal is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataPowerTotal(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataPowerTotal_Call { + return &MuMPCInterface_UpdateDataPowerTotal_Call{Call: _e.mock.On("UpdateDataPowerTotal", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataPowerTotal_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataPowerTotal_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataPowerTotal_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataPowerTotal_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataPowerTotal_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataPowerTotal_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataVoltagePhaseA provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataVoltagePhaseA(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataVoltagePhaseA") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataVoltagePhaseA_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataVoltagePhaseA' +type MuMPCInterface_UpdateDataVoltagePhaseA_Call struct { + *mock.Call +} + +// UpdateDataVoltagePhaseA is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataVoltagePhaseA(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataVoltagePhaseA_Call { + return &MuMPCInterface_UpdateDataVoltagePhaseA_Call{Call: _e.mock.On("UpdateDataVoltagePhaseA", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseA_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataVoltagePhaseA_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseA_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseA_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseA_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseA_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataVoltagePhaseAToB provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataVoltagePhaseAToB(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataVoltagePhaseAToB") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataVoltagePhaseAToB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataVoltagePhaseAToB' +type MuMPCInterface_UpdateDataVoltagePhaseAToB_Call struct { + *mock.Call +} + +// UpdateDataVoltagePhaseAToB is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataVoltagePhaseAToB(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataVoltagePhaseAToB_Call { + return &MuMPCInterface_UpdateDataVoltagePhaseAToB_Call{Call: _e.mock.On("UpdateDataVoltagePhaseAToB", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseAToB_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataVoltagePhaseAToB_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseAToB_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseAToB_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseAToB_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseAToB_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataVoltagePhaseB provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataVoltagePhaseB(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataVoltagePhaseB") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataVoltagePhaseB_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataVoltagePhaseB' +type MuMPCInterface_UpdateDataVoltagePhaseB_Call struct { + *mock.Call +} + +// UpdateDataVoltagePhaseB is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataVoltagePhaseB(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataVoltagePhaseB_Call { + return &MuMPCInterface_UpdateDataVoltagePhaseB_Call{Call: _e.mock.On("UpdateDataVoltagePhaseB", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseB_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataVoltagePhaseB_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseB_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseB_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseB_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseB_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataVoltagePhaseBToC provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataVoltagePhaseBToC(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataVoltagePhaseBToC") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataVoltagePhaseBToC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataVoltagePhaseBToC' +type MuMPCInterface_UpdateDataVoltagePhaseBToC_Call struct { + *mock.Call +} + +// UpdateDataVoltagePhaseBToC is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataVoltagePhaseBToC(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataVoltagePhaseBToC_Call { + return &MuMPCInterface_UpdateDataVoltagePhaseBToC_Call{Call: _e.mock.On("UpdateDataVoltagePhaseBToC", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseBToC_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataVoltagePhaseBToC_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseBToC_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseBToC_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseBToC_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseBToC_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataVoltagePhaseC provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataVoltagePhaseC(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataVoltagePhaseC") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataVoltagePhaseC_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataVoltagePhaseC' +type MuMPCInterface_UpdateDataVoltagePhaseC_Call struct { + *mock.Call +} + +// UpdateDataVoltagePhaseC is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataVoltagePhaseC(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataVoltagePhaseC_Call { + return &MuMPCInterface_UpdateDataVoltagePhaseC_Call{Call: _e.mock.On("UpdateDataVoltagePhaseC", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseC_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataVoltagePhaseC_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseC_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseC_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseC_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseC_Call { + _c.Call.Return(run) + return _c +} + +// UpdateDataVoltagePhaseCToA provides a mock function with given fields: value, timestamp, valueState +func (_m *MuMPCInterface) UpdateDataVoltagePhaseCToA(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType) api.UpdateMeasurementData { + ret := _m.Called(value, timestamp, valueState) + + if len(ret) == 0 { + panic("no return value specified for UpdateDataVoltagePhaseCToA") + } + + var r0 api.UpdateMeasurementData + if rf, ok := ret.Get(0).(func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData); ok { + r0 = rf(value, timestamp, valueState) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(api.UpdateMeasurementData) + } + } + + return r0 +} + +// MuMPCInterface_UpdateDataVoltagePhaseCToA_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateDataVoltagePhaseCToA' +type MuMPCInterface_UpdateDataVoltagePhaseCToA_Call struct { + *mock.Call +} + +// UpdateDataVoltagePhaseCToA is a helper method to define mock.On call +// - value float64 +// - timestamp *time.Time +// - valueState *model.MeasurementValueStateType +func (_e *MuMPCInterface_Expecter) UpdateDataVoltagePhaseCToA(value interface{}, timestamp interface{}, valueState interface{}) *MuMPCInterface_UpdateDataVoltagePhaseCToA_Call { + return &MuMPCInterface_UpdateDataVoltagePhaseCToA_Call{Call: _e.mock.On("UpdateDataVoltagePhaseCToA", value, timestamp, valueState)} +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseCToA_Call) Run(run func(value float64, timestamp *time.Time, valueState *model.MeasurementValueStateType)) *MuMPCInterface_UpdateDataVoltagePhaseCToA_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(float64), args[1].(*time.Time), args[2].(*model.MeasurementValueStateType)) + }) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseCToA_Call) Return(_a0 api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseCToA_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MuMPCInterface_UpdateDataVoltagePhaseCToA_Call) RunAndReturn(run func(float64, *time.Time, *model.MeasurementValueStateType) api.UpdateMeasurementData) *MuMPCInterface_UpdateDataVoltagePhaseCToA_Call { + _c.Call.Return(run) + return _c +} + +// VoltagePerPhase provides a mock function with given fields: +func (_m *MuMPCInterface) VoltagePerPhase() ([]float64, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for VoltagePerPhase") + } + + var r0 []float64 + var r1 error + if rf, ok := ret.Get(0).(func() ([]float64, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() []float64); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]float64) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MuMPCInterface_VoltagePerPhase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'VoltagePerPhase' +type MuMPCInterface_VoltagePerPhase_Call struct { + *mock.Call +} + +// VoltagePerPhase is a helper method to define mock.On call +func (_e *MuMPCInterface_Expecter) VoltagePerPhase() *MuMPCInterface_VoltagePerPhase_Call { + return &MuMPCInterface_VoltagePerPhase_Call{Call: _e.mock.On("VoltagePerPhase")} +} + +func (_c *MuMPCInterface_VoltagePerPhase_Call) Run(run func()) *MuMPCInterface_VoltagePerPhase_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MuMPCInterface_VoltagePerPhase_Call) Return(_a0 []float64, _a1 error) *MuMPCInterface_VoltagePerPhase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MuMPCInterface_VoltagePerPhase_Call) RunAndReturn(run func() ([]float64, error)) *MuMPCInterface_VoltagePerPhase_Call { + _c.Call.Return(run) + return _c +} + +// NewMuMPCInterface creates a new instance of MuMPCInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMuMPCInterface(t interface { + mock.TestingT + Cleanup(func()) +}) *MuMPCInterface { + mock := &MuMPCInterface{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/usecases/mocks/UpdateData.go b/usecases/mocks/UpdateData.go new file mode 100644 index 00000000..57d17880 --- /dev/null +++ b/usecases/mocks/UpdateData.go @@ -0,0 +1,122 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// UpdateData is an autogenerated mock type for the UpdateData type +type UpdateData struct { + mock.Mock +} + +type UpdateData_Expecter struct { + mock *mock.Mock +} + +func (_m *UpdateData) EXPECT() *UpdateData_Expecter { + return &UpdateData_Expecter{mock: &_m.Mock} +} + +// NotSupportedError provides a mock function with given fields: +func (_m *UpdateData) NotSupportedError() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for NotSupportedError") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// UpdateData_NotSupportedError_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NotSupportedError' +type UpdateData_NotSupportedError_Call struct { + *mock.Call +} + +// NotSupportedError is a helper method to define mock.On call +func (_e *UpdateData_Expecter) NotSupportedError() *UpdateData_NotSupportedError_Call { + return &UpdateData_NotSupportedError_Call{Call: _e.mock.On("NotSupportedError")} +} + +func (_c *UpdateData_NotSupportedError_Call) Run(run func()) *UpdateData_NotSupportedError_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UpdateData_NotSupportedError_Call) Return(_a0 error) *UpdateData_NotSupportedError_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UpdateData_NotSupportedError_Call) RunAndReturn(run func() error) *UpdateData_NotSupportedError_Call { + _c.Call.Return(run) + return _c +} + +// Supported provides a mock function with given fields: +func (_m *UpdateData) Supported() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Supported") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// UpdateData_Supported_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Supported' +type UpdateData_Supported_Call struct { + *mock.Call +} + +// Supported is a helper method to define mock.On call +func (_e *UpdateData_Expecter) Supported() *UpdateData_Supported_Call { + return &UpdateData_Supported_Call{Call: _e.mock.On("Supported")} +} + +func (_c *UpdateData_Supported_Call) Run(run func()) *UpdateData_Supported_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UpdateData_Supported_Call) Return(_a0 bool) *UpdateData_Supported_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UpdateData_Supported_Call) RunAndReturn(run func() bool) *UpdateData_Supported_Call { + _c.Call.Return(run) + return _c +} + +// NewUpdateData creates a new instance of UpdateData. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUpdateData(t interface { + mock.TestingT + Cleanup(func()) +}) *UpdateData { + mock := &UpdateData{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/usecases/mocks/UpdateMeasurementData.go b/usecases/mocks/UpdateMeasurementData.go new file mode 100644 index 00000000..5b1545cf --- /dev/null +++ b/usecases/mocks/UpdateMeasurementData.go @@ -0,0 +1,170 @@ +// Code generated by mockery v2.46.3. DO NOT EDIT. + +package mocks + +import ( + api "github.com/enbility/eebus-go/api" + mock "github.com/stretchr/testify/mock" +) + +// UpdateMeasurementData is an autogenerated mock type for the UpdateMeasurementData type +type UpdateMeasurementData struct { + mock.Mock +} + +type UpdateMeasurementData_Expecter struct { + mock *mock.Mock +} + +func (_m *UpdateMeasurementData) EXPECT() *UpdateMeasurementData_Expecter { + return &UpdateMeasurementData_Expecter{mock: &_m.Mock} +} + +// MeasurementData provides a mock function with given fields: +func (_m *UpdateMeasurementData) MeasurementData() api.MeasurementDataForID { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for MeasurementData") + } + + var r0 api.MeasurementDataForID + if rf, ok := ret.Get(0).(func() api.MeasurementDataForID); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(api.MeasurementDataForID) + } + + return r0 +} + +// UpdateMeasurementData_MeasurementData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MeasurementData' +type UpdateMeasurementData_MeasurementData_Call struct { + *mock.Call +} + +// MeasurementData is a helper method to define mock.On call +func (_e *UpdateMeasurementData_Expecter) MeasurementData() *UpdateMeasurementData_MeasurementData_Call { + return &UpdateMeasurementData_MeasurementData_Call{Call: _e.mock.On("MeasurementData")} +} + +func (_c *UpdateMeasurementData_MeasurementData_Call) Run(run func()) *UpdateMeasurementData_MeasurementData_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UpdateMeasurementData_MeasurementData_Call) Return(_a0 api.MeasurementDataForID) *UpdateMeasurementData_MeasurementData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UpdateMeasurementData_MeasurementData_Call) RunAndReturn(run func() api.MeasurementDataForID) *UpdateMeasurementData_MeasurementData_Call { + _c.Call.Return(run) + return _c +} + +// NotSupportedError provides a mock function with given fields: +func (_m *UpdateMeasurementData) NotSupportedError() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for NotSupportedError") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// UpdateMeasurementData_NotSupportedError_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NotSupportedError' +type UpdateMeasurementData_NotSupportedError_Call struct { + *mock.Call +} + +// NotSupportedError is a helper method to define mock.On call +func (_e *UpdateMeasurementData_Expecter) NotSupportedError() *UpdateMeasurementData_NotSupportedError_Call { + return &UpdateMeasurementData_NotSupportedError_Call{Call: _e.mock.On("NotSupportedError")} +} + +func (_c *UpdateMeasurementData_NotSupportedError_Call) Run(run func()) *UpdateMeasurementData_NotSupportedError_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UpdateMeasurementData_NotSupportedError_Call) Return(_a0 error) *UpdateMeasurementData_NotSupportedError_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UpdateMeasurementData_NotSupportedError_Call) RunAndReturn(run func() error) *UpdateMeasurementData_NotSupportedError_Call { + _c.Call.Return(run) + return _c +} + +// Supported provides a mock function with given fields: +func (_m *UpdateMeasurementData) Supported() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Supported") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// UpdateMeasurementData_Supported_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Supported' +type UpdateMeasurementData_Supported_Call struct { + *mock.Call +} + +// Supported is a helper method to define mock.On call +func (_e *UpdateMeasurementData_Expecter) Supported() *UpdateMeasurementData_Supported_Call { + return &UpdateMeasurementData_Supported_Call{Call: _e.mock.On("Supported")} +} + +func (_c *UpdateMeasurementData_Supported_Call) Run(run func()) *UpdateMeasurementData_Supported_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *UpdateMeasurementData_Supported_Call) Return(_a0 bool) *UpdateMeasurementData_Supported_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *UpdateMeasurementData_Supported_Call) RunAndReturn(run func() bool) *UpdateMeasurementData_Supported_Call { + _c.Call.Return(run) + return _c +} + +// NewUpdateMeasurementData creates a new instance of UpdateMeasurementData. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUpdateMeasurementData(t interface { + mock.TestingT + Cleanup(func()) +}) *UpdateMeasurementData { + mock := &UpdateMeasurementData{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/usecases/mu/mpc/config.go b/usecases/mu/mpc/config.go new file mode 100644 index 00000000..9b5314c1 --- /dev/null +++ b/usecases/mu/mpc/config.go @@ -0,0 +1,100 @@ +package mpc + +import ( + "strings" + + "github.com/enbility/spine-go/model" +) + +type ConnectedPhases string + +const ( + ConnectedPhasesA ConnectedPhases = "a" + ConnectedPhasesB ConnectedPhases = "b" + ConnectedPhasesC ConnectedPhases = "c" + ConnectedPhasesAB ConnectedPhases = "ab" + ConnectedPhasesBC ConnectedPhases = "bc" + ConnectedPhasesCA ConnectedPhases = "ac" + ConnectedPhasesABC ConnectedPhases = "abc" +) + +// MonitorPowerConfig is the configuration for the monitor use case +// This config is required by the mpc use case and must be used in mpc.NewMPC +type MonitorPowerConfig struct { + ConnectedPhases ConnectedPhases // The phases that are measured + + ValueSourceTotal *model.MeasurementValueSourceType // The source of the values from the acPowerTotal (required) + ValueSourcePhaseA *model.MeasurementValueSourceType // The source of the values from the acPower for phase A (required if the phase is supported) + ValueSourcePhaseB *model.MeasurementValueSourceType // The source of the values from the acPower for phase B (required if the phase is supported) + ValueSourcePhaseC *model.MeasurementValueSourceType // The source of the values from the acPower for phase C (required if the phase is supported) + + ValueConstraintsTotal *model.MeasurementConstraintsDataType // The constraints for the acPowerTotal (optional can be nil) + ValueConstraintsPhaseA *model.MeasurementConstraintsDataType // The constraints for the acPower for phase A (optional can be nil) + ValueConstraintsPhaseB *model.MeasurementConstraintsDataType // The constraints for the acPower for phase B (optional can be nil) + ValueConstraintsPhaseC *model.MeasurementConstraintsDataType // The constraints for the acPower for phase C (optional can be nil) +} + +// MonitorEnergyConfig is the configuration for the monitor use case +// If this config is passed via NewMPC, the use case will support energy monitoring as specified +type MonitorEnergyConfig struct { + ValueSourceProduction *model.MeasurementValueSourceType // The source of the production values (if this is set, the use case will support production) (optional can be nil) + ValueConstraintsProduction *model.MeasurementConstraintsDataType // The constraints for the production values (optional can be nil) (requires ProductionValueSource to be set) + + ValueSourceConsumption *model.MeasurementValueSourceType // The source of the consumption values (if this is set, the use case will support consumption) (optional can be nil) + ValueConstraintsConsumption *model.MeasurementConstraintsDataType // The constraints for the consumption values (optional can be nil) (requires ConsumptionValueSource to be set) +} + +// MonitorCurrentConfig is the configuration for the monitor use case +// If this config is passed via NewMPC, the use case will support current monitoring +// The current phases will be the same as specified in MonitorPowerConfig +type MonitorCurrentConfig struct { + ValueSourcePhaseA *model.MeasurementValueSourceType // The source of the values for phase A (required if the phase is supported) + ValueSourcePhaseB *model.MeasurementValueSourceType // The source of the values for phase B (required if the phase is supported) + ValueSourcePhaseC *model.MeasurementValueSourceType // The source of the values for phase C (required if the phase is supported) + + ValueConstraintsPhaseA *model.MeasurementConstraintsDataType // The constraints for the current for phase A (optional can be nil) (requires ValueSourcePhaseA to be set) + ValueConstraintsPhaseB *model.MeasurementConstraintsDataType // The constraints for the current for phase B (optional can be nil) (requires ValueSourcePhaseB to be set) + ValueConstraintsPhaseC *model.MeasurementConstraintsDataType // The constraints for the current for phase C (optional can be nil) (requires ValueSourcePhaseC to be set) +} + +// MonitorVoltageConfig is the configuration for the monitor use case +// If this config is passed via NewMPC, the use case will support voltage monitoring +// The voltage phases will be the same as specified in MonitorPowerConfig +type MonitorVoltageConfig struct { + ValueSourcePhaseA *model.MeasurementValueSourceType // The source of the values for phase A (required if the phase is supported) + ValueSourcePhaseB *model.MeasurementValueSourceType // The source of the values for phase B (required if the phase is supported) + ValueSourcePhaseC *model.MeasurementValueSourceType // The source of the values for phase C (required if the phase is supported) + + ValueConstraintsPhaseA *model.MeasurementConstraintsDataType // The constraints for the voltage for phase A (optional can be nil) (requires ValueSourcePhaseA to be set) + ValueConstraintsPhaseB *model.MeasurementConstraintsDataType // The constraints for the voltage for phase B (optional can be nil) (requires ValueSourcePhaseB to be set) + ValueConstraintsPhaseC *model.MeasurementConstraintsDataType // The constraints for the voltage for phase C (optional can be nil) (requires ValueSourcePhaseC to be set) + + SupportPhaseToPhase bool // Set to true if the use case supports phase to phase voltage monitoring + ValueSourcePhaseAToB *model.MeasurementValueSourceType // The source of the values for phase A to B (required if the phases are supported and SupportPhaseToPhase is true) + ValueSourcePhaseBToC *model.MeasurementValueSourceType // The source of the values for phase B to C (required if the phases are supported and SupportPhaseToPhase is true) + ValueSourcePhaseCToA *model.MeasurementValueSourceType // The source of the values for phase C to A (required if the phases are supported and SupportPhaseToPhase is true) + + ValueConstraintsPhaseAToB *model.MeasurementConstraintsDataType // The constraints for the voltage for phase A to B (optional can be nil) (requires ValueSourcePhaseAToB to be set) + ValueConstraintsPhaseBToC *model.MeasurementConstraintsDataType // The constraints for the voltage for phase B to C (optional can be nil) (requires ValueSourcePhaseBToC to be set) + ValueConstraintsPhaseCToA *model.MeasurementConstraintsDataType // The constraints for the voltage for phase C to A (optional can be nil) (requires ValueSourcePhaseCToA to be set) +} + +// MonitorFrequencyConfig is the configuration for the monitor use case +type MonitorFrequencyConfig struct { + ValueSource *model.MeasurementValueSourceType // The source of the values (required) + ValueConstraints *model.MeasurementConstraintsDataType // The constraints for the frequency values (optional can be nil) +} + +// SupportsPhases checks if the config supports the given phases +// e.g. SupportsPhases([]string{"a", "B"}) will return true if the config has ConnectedPhases set to "ab" or "abc" +func (c *MonitorPowerConfig) SupportsPhases(phase []string) bool { + phasesString := string(c.ConnectedPhases) + supports := true + for _, p := range phase { + if !strings.Contains(strings.ToLower(phasesString), strings.ToLower(p)) { + supports = false + break + } + } + return supports +} diff --git a/usecases/mu/mpc/config_test.go b/usecases/mu/mpc/config_test.go new file mode 100644 index 00000000..10d04777 --- /dev/null +++ b/usecases/mu/mpc/config_test.go @@ -0,0 +1,46 @@ +package mpc + +import ( + "github.com/stretchr/testify/assert" +) + +func (s *MuMPCSuite) Test_SupportsPhases() { + allowedConstellations := map[ConnectedPhases][][]string{ + ConnectedPhasesA: {{"a"}}, + ConnectedPhasesB: {{"b"}}, + ConnectedPhasesC: {{"C"}}, + ConnectedPhasesAB: {{"a"}, {"b"}, {"a", "b"}}, + ConnectedPhasesBC: {{"b"}, {"c"}, {"B", "c"}}, + ConnectedPhasesCA: {{"a"}, {"c"}, {"A", "C"}}, + ConnectedPhasesABC: {{"a"}, {"b"}, {"c"}, {"a", "b"}, {"b", "c"}, {"a", "c"}, {"A", "b", "c"}}, + } + + for constellation, phases := range allowedConstellations { + config := MonitorPowerConfig{ + ConnectedPhases: constellation, + } + + for _, phase := range phases { + assert.True(s.T(), config.SupportsPhases(phase)) + } + } + + notAllowedConstellations := map[ConnectedPhases][]string{ + ConnectedPhasesA: {"b", "c", "ab", "bc", "ac", "abc"}, + ConnectedPhasesB: {"a", "c", "ab", "bc", "ac", "abc"}, + ConnectedPhasesC: {"a", "b", "ab", "bc", "ac", "abc"}, + ConnectedPhasesAB: {"c", "ac", "abc"}, + ConnectedPhasesBC: {"a", "ab", "abc"}, + ConnectedPhasesCA: {"b", "bc", "abc"}, + } + + for constellation, notSupportedPhases := range notAllowedConstellations { + config := MonitorPowerConfig{ + ConnectedPhases: constellation, + } + + for _, phase := range notSupportedPhases { + assert.False(s.T(), config.SupportsPhases([]string{phase})) + } + } +} diff --git a/usecases/mu/mpc/events.go b/usecases/mu/mpc/events.go new file mode 100644 index 00000000..c05e05aa --- /dev/null +++ b/usecases/mu/mpc/events.go @@ -0,0 +1,10 @@ +package mpc + +import ( + spineapi "github.com/enbility/spine-go/api" +) + +// handle SPINE events +func (e *MPC) HandleEvent(payload spineapi.EventPayload) { + // No events supported +} diff --git a/usecases/mu/mpc/public.go b/usecases/mu/mpc/public.go new file mode 100644 index 00000000..7e1e05f5 --- /dev/null +++ b/usecases/mu/mpc/public.go @@ -0,0 +1,545 @@ +package mpc + +import ( + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/server" + usecaseapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/spine-go/model" +) + +// ------------------------- Getters ------------------------- // + +// Scenario 1 + +// get the momentary active power consumption or production +// +// possible errors: +// - ErrMissingData if the id is not available +// - and others +func (e *MPC) Power() (float64, error) { + if e.acPowerTotal == nil { + return 0, api.ErrMissingData + } + + return e.getMeasurementDataForId(e.acPowerTotal) +} + +// get the momentary active power consumption or production per phase +// +// possible errors: +// - ErrMissingData if the id is not available +// - and others +func (e *MPC) PowerPerPhase() ([]float64, error) { + powerPerPhase := make([]float64, 0) + + for _, id := range e.acPower { + if id != nil { + power, err := e.getMeasurementDataForId(id) + if err != nil { + return nil, err + } + powerPerPhase = append(powerPerPhase, power) + } + } + + return powerPerPhase, nil +} + +// 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 +func (e *MPC) EnergyConsumed() (float64, error) { + if e.acEnergyConsumed == nil { + return 0, api.ErrMissingData + } + + return e.getMeasurementDataForId(e.acEnergyConsumed) +} + +// get the total feed in energy +// +// - negative values are used for production +// +// possible errors: +// - ErrMissingData if the id is not available +// - and others +func (e *MPC) EnergyProduced() (float64, error) { + if e.acEnergyProduced == nil { + return 0, api.ErrMissingData + } + + return e.getMeasurementDataForId(e.acEnergyProduced) +} + +// 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 +func (e *MPC) CurrentPerPhase() ([]float64, error) { + currentPerPhase := make([]float64, 0) + + for _, id := range e.acCurrent { + if id != nil { + current, err := e.getMeasurementDataForId(id) + if err != nil { + return nil, err + } + currentPerPhase = append(currentPerPhase, current) + } + } + + return currentPerPhase, nil +} + +// Scenario 4 + +// get the phase specific voltage details +// +// possible errors: +// - ErrMissingData if the id is not available +// - and others +func (e *MPC) VoltagePerPhase() ([]float64, error) { + voltagePerPhase := make([]float64, 0) + + for _, id := range e.acVoltage { + if id != nil { + voltage, err := e.getMeasurementDataForId(id) + if err != nil { + return nil, err + } + voltagePerPhase = append(voltagePerPhase, voltage) + } + } + + return voltagePerPhase, nil +} + +// Scenario 5 + +// get frequency +// +// possible errors: +// - ErrMissingData if the id is not available +// - and others +func (e *MPC) Frequency() (float64, error) { + if e.acFrequency == nil { + return 0, api.ErrMissingData + } + + return e.getMeasurementDataForId(e.acFrequency) +} + +// ------------------------- Setters ------------------------- // + +// use MPC.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 +func (e *MPC) Update(updateData ...usecaseapi.UpdateMeasurementData) error { + measurements, err := server.NewMeasurement(e.LocalEntity) + if err != nil { + return err + } + + measurementDataForIds := make([]api.MeasurementDataForID, 0) + + for _, measurementDataForId := range updateData { + if !measurementDataForId.Supported() { + return measurementDataForId.NotSupportedError() + } else { + measurementDataForIds = append(measurementDataForIds, measurementDataForId.MeasurementData()) + } + } + + return measurements.UpdateDataForIds(measurementDataForIds) +} + +// Scenario 1 + +// use MPC.UpdateDataPowerTotal in MPC.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 +func (e *MPC) UpdateDataPowerTotal( + acPowerTotal float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acPowerTotal is not supported, please check the configuration", + e.acPowerTotal, + measurementData( + acPowerTotal, + timestamp, + e.powerConfig.ValueSourceTotal, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataPowerPhaseA in MPC.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 +func (e *MPC) UpdateDataPowerPhaseA( + acPowerPhaseA float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acPowerPhaseA is not supported, please check the configuration", + e.acPower[0], + measurementData( + acPowerPhaseA, + timestamp, + e.powerConfig.ValueSourcePhaseA, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataPowerPhaseB in MPC.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 +func (e *MPC) UpdateDataPowerPhaseB( + acPowerPhaseB float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acPowerPhaseB is not supported, please check the configuration", + e.acPower[1], + measurementData( + acPowerPhaseB, + timestamp, + e.powerConfig.ValueSourcePhaseB, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataPowerPhaseC in MPC.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 +func (e *MPC) UpdateDataPowerPhaseC( + acPowerPhaseC float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acPowerPhaseC is not supported, please check the configuration", + e.acPower[2], + measurementData( + acPowerPhaseC, + timestamp, + e.powerConfig.ValueSourcePhaseC, + valueState, + nil, + nil, + ), + ) +} + +// Scenario 2 + +// use MPC.UpdateDataEnergyConsumed in MPC.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) +func (e *MPC) UpdateDataEnergyConsumed( + energyConsumed float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, + evaluationStart *time.Time, + evaluationEnd *time.Time, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acEnergyConsumed is not supported, please check the configuration", + e.acEnergyConsumed, + measurementData( + energyConsumed, + timestamp, + e.energyConfig.ValueSourceConsumption, + valueState, + evaluationStart, + evaluationEnd, + ), + ) +} + +// use MPC.MeasuredUpdateDataEnergyProduced in MPC.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) +func (e *MPC) UpdateDataEnergyProduced( + energyProduced float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, + evaluationStart *time.Time, + evaluationEnd *time.Time, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acEnergyProduced is not supported, please check the configuration", + e.acEnergyProduced, + measurementData( + energyProduced, + timestamp, + e.energyConfig.ValueSourceProduction, + valueState, + evaluationStart, + evaluationEnd, + ), + ) +} + +// Scenario 3 + +// use MPC.UpdateDataCurrentPhaseA in MPC.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 +func (e *MPC) UpdateDataCurrentPhaseA( + acCurrentPhaseA float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acCurrentPhaseA is not supported, please check the configuration", + e.acCurrent[0], + measurementData( + acCurrentPhaseA, + timestamp, + e.currentConfig.ValueSourcePhaseA, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataCurrentPhaseB in MPC.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 +func (e *MPC) UpdateDataCurrentPhaseB( + acCurrentPhaseB float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acCurrentPhaseB is not supported, please check the configuration", + e.acCurrent[1], + measurementData( + acCurrentPhaseB, + timestamp, + e.currentConfig.ValueSourcePhaseB, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataCurrentPhaseC in MPC.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 +func (e *MPC) UpdateDataCurrentPhaseC( + acCurrentPhaseC float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acCurrentPhaseC is not supported, please check the configuration", + e.acCurrent[2], + measurementData( + acCurrentPhaseC, + timestamp, + e.currentConfig.ValueSourcePhaseC, + valueState, + nil, + nil, + ), + ) +} + +// Scenario 4 + +// use MPC.UpdateDataVoltagePhaseA in MPC.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 +func (e *MPC) UpdateDataVoltagePhaseA( + voltagePhaseA float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acVoltagePhaseA is not supported, please check the configuration", + e.acVoltage[0], + measurementData( + voltagePhaseA, + timestamp, + e.voltageConfig.ValueSourcePhaseA, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataVoltagePhaseB in MPC.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 +func (e *MPC) UpdateDataVoltagePhaseB( + voltagePhaseB float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acVoltagePhaseB is not supported, please check the configuration", + e.acVoltage[1], + measurementData( + voltagePhaseB, + timestamp, + e.voltageConfig.ValueSourcePhaseB, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataVoltagePhaseC in MPC.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 +func (e *MPC) UpdateDataVoltagePhaseC( + voltagePhaseC float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acVoltagePhaseC is not supported, please check the configuration", + e.acVoltage[2], + measurementData( + voltagePhaseC, + timestamp, + e.voltageConfig.ValueSourcePhaseC, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataVoltagePhaseAToB in MPC.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 +func (e *MPC) UpdateDataVoltagePhaseAToB( + voltagePhaseAToB float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acVoltagePhaseAToB is not supported, please check the configuration", + e.acVoltage[3], + measurementData( + voltagePhaseAToB, + timestamp, + e.voltageConfig.ValueSourcePhaseAToB, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataVoltagePhaseBToC in MPC.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 +func (e *MPC) UpdateDataVoltagePhaseBToC( + voltagePhaseBToC float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acVoltagePhaseBToC is not supported, please check the configuration", + e.acVoltage[4], + measurementData( + voltagePhaseBToC, + timestamp, + e.voltageConfig.ValueSourcePhaseBToC, + valueState, + nil, + nil, + ), + ) +} + +// use MPC.UpdateDataVoltagePhaseCToA in MPC.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 +func (e *MPC) UpdateDataVoltagePhaseCToA( + voltagePhaseCToA float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acVoltagePhaseCToA is not supported, please check the configuration", + e.acVoltage[5], + measurementData( + voltagePhaseCToA, + timestamp, + e.voltageConfig.ValueSourcePhaseCToA, + valueState, + nil, + nil, + ), + ) +} + +// Scenario 5 + +// use MPC.UpdateDataFrequency in MPC.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 +func (e *MPC) UpdateDataFrequency( + frequency float64, + timestamp *time.Time, + valueState *model.MeasurementValueStateType, +) usecaseapi.UpdateMeasurementData { + return newUpdateData( + "acFrequency is not supported, please check the configuration", + e.acFrequency, + measurementData( + frequency, + timestamp, + e.frequencyConfig.ValueSource, + valueState, + nil, + nil, + ), + ) +} diff --git a/usecases/mu/mpc/public_abc_test.go b/usecases/mu/mpc/public_abc_test.go new file mode 100644 index 00000000..25f7209d --- /dev/null +++ b/usecases/mu/mpc/public_abc_test.go @@ -0,0 +1,232 @@ +package mpc + +import ( + "testing" + "time" + + "github.com/enbility/eebus-go/features/server" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +type MuMpcAbcSuite struct { + suite.Suite + *MuMPCSuite +} + +// Test suite testing an MPC MonitoredUnit that supports 3-phase metering (phases ABC) +func TestMuMpcAbcSuite(t *testing.T) { + suite.Run(t, new(MuMpcAbcSuite)) +} + +func (s *MuMpcAbcSuite) BeforeTest(suiteName, testName string) { + s.MuMPCSuite = NewMuMPCSuite( + &s.Suite, + &MonitorPowerConfig{ + ConnectedPhases: ConnectedPhasesABC, + ValueSourceTotal: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + }, + &MonitorEnergyConfig{ + ValueSourceProduction: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraintsProduction: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(0), + ValueStepSize: model.NewScaledNumberType(0.001), + }), + ValueSourceConsumption: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + }, + &MonitorCurrentConfig{ + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + }, + &MonitorVoltageConfig{ + SupportPhaseToPhase: true, + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseAToB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseBToC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseCToA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + }, + &MonitorFrequencyConfig{ + ValueSource: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraints: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(0), + ValueRangeMax: model.NewScaledNumberType(100), + ValueStepSize: model.NewScaledNumberType(1), + }), + }, + ) + s.MuMPCSuite.BeforeTest(suiteName, testName) +} + +func (s *MuMpcAbcSuite) Test_Power() { + err := s.sut.Update( + s.sut.UpdateDataPowerTotal(5.0, util.Ptr(time.Now()), nil), + ) + assert.Nil(s.T(), err) + + power, err := s.sut.Power() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.0, power) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, model.EnergyDirectionTypeConsume, nil) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.0}, values) +} + +func (s *MuMpcAbcSuite) Test_PowerPerPhase() { + err := s.sut.Update( + s.sut.UpdateDataPowerPhaseA(5.0, util.Ptr(time.Now()), nil), + s.sut.UpdateDataPowerPhaseB(6.0, util.Ptr(time.Now()), nil), + s.sut.UpdateDataPowerPhaseC(7.0, util.Ptr(time.Now()), util.Ptr(model.MeasurementValueStateTypeError)), + ) + assert.Nil(s.T(), err) + + powerPerPhases, err := s.sut.PowerPerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.0, 6.0, 7.0}, powerPerPhases) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, model.EnergyDirectionTypeConsume, ucapi.PhaseNameMapping) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.0, 6.0, 7.0}, values) +} + +func (s *MuMpcAbcSuite) Test_EnergyConsumed() { + err := s.sut.Update( + s.sut.UpdateDataEnergyConsumed(5.0, util.Ptr(time.Now()), nil, util.Ptr(time.Now()), util.Ptr(time.Now())), + ) + assert.Nil(s.T(), err) + + energyConsumed, err := s.sut.EnergyConsumed() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.0, energyConsumed) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACEnergyConsumed), + } + measurement, err := server.NewMeasurement(s.sut.LocalEntity) + assert.Nil(s.T(), err) + values, err := measurement.GetDataForFilter(filter) + assert.Nil(s.T(), err) + assert.Equal(s.T(), 1, len(values)) + assert.Equal(s.T(), 5.0, (*values[0].Value).GetValue()) +} + +func (s *MuMpcAbcSuite) Test_EnergyProduced() { + err := s.sut.Update( + s.sut.UpdateDataEnergyProduced(5.0, nil, nil, nil, nil), + ) + assert.Nil(s.T(), err) + + energyProduced, err := s.sut.EnergyProduced() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.0, energyProduced) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACEnergyProduced), + } + measurement, err := server.NewMeasurement(s.sut.LocalEntity) + assert.Nil(s.T(), err) + values, err := measurement.GetDataForFilter(filter) + assert.Nil(s.T(), err) + assert.Equal(s.T(), 1, len(values)) + assert.Equal(s.T(), 5.0, (*values[0].Value).GetValue()) +} + +func (s *MuMpcAbcSuite) Test_CurrentPerPhase() { + err := s.sut.Update( + s.sut.UpdateDataCurrentPhaseA(5.0, nil, nil), + s.sut.UpdateDataCurrentPhaseB(3.0, nil, nil), + s.sut.UpdateDataCurrentPhaseC(1.0, nil, nil), + ) + assert.Nil(s.T(), err) + + currentPerPhases, err := s.sut.CurrentPerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.0, 3.0, 1.0}, currentPerPhases) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, model.EnergyDirectionTypeConsume, ucapi.PhaseNameMapping) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.0, 3.0, 1.0}, values) +} + +func (s *MuMpcAbcSuite) Test_VoltagePerPhase() { + err := s.sut.Update( + s.sut.UpdateDataVoltagePhaseA(5.0, nil, nil), + s.sut.UpdateDataVoltagePhaseB(6.0, nil, nil), + s.sut.UpdateDataVoltagePhaseC(7.0, nil, nil), + s.sut.UpdateDataVoltagePhaseAToB(8.0, nil, nil), + s.sut.UpdateDataVoltagePhaseBToC(9.0, nil, nil), + s.sut.UpdateDataVoltagePhaseCToA(10.0, nil, nil), + ) + assert.Nil(s.T(), err) + + voltagePerPhases, err := s.sut.VoltagePerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, voltagePerPhases) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeVoltage), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACVoltage), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, "", ucapi.PhaseNameMapping) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.0, 6.0, 7.0, 8.0, 9.0, 10.0}, values) +} + +func (s *MuMpcAbcSuite) Test_Frequency() { + err := s.sut.Update( + s.sut.UpdateDataFrequency(5.0, nil, nil), + ) + assert.Nil(s.T(), err) + + frequency, err := s.sut.Frequency() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.0, frequency) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeFrequency), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACFrequency), + } + measurements, err := server.NewMeasurement(s.sut.LocalEntity) + assert.Nil(s.T(), err) + values, err := measurements.GetDataForFilter(filter) + assert.Nil(s.T(), err) + assert.Equal(s.T(), 1, len(values)) + assert.Equal(s.T(), 5.0, (*values[0].Value).GetValue()) +} diff --git a/usecases/mu/mpc/public_bc_test.go b/usecases/mu/mpc/public_bc_test.go new file mode 100644 index 00000000..f12646cd --- /dev/null +++ b/usecases/mu/mpc/public_bc_test.go @@ -0,0 +1,183 @@ +package mpc + +import ( + "testing" + "time" + + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +type MuMpcBcSuite struct { + suite.Suite + *MuMPCSuite +} + +// Test suite testing an MPC MonitoredUnit that supports metering for 2 phases (phases AB) +func TestMuMpcAbSuite(t *testing.T) { + suite.Run(t, new(MuMpcBcSuite)) +} + +func (s *MuMpcBcSuite) BeforeTest(suiteName, testName string) { + s.MuMPCSuite = NewMuMPCSuite( + &s.Suite, + &MonitorPowerConfig{ + ConnectedPhases: ConnectedPhasesBC, + ValueSourceTotal: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + }, + &MonitorEnergyConfig{ + ValueSourceProduction: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourceConsumption: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + }, + &MonitorCurrentConfig{ + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + }, + &MonitorVoltageConfig{ + SupportPhaseToPhase: true, + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseBToC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + }, + &MonitorFrequencyConfig{ + ValueSource: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraints: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(0), + ValueRangeMax: model.NewScaledNumberType(100), + ValueStepSize: model.NewScaledNumberType(1), + }), + }, + ) + s.MuMPCSuite.BeforeTest(suiteName, testName) +} + +func (s *MuMpcBcSuite) Test_Power() { + err := s.sut.Update( + s.sut.UpdateDataPowerTotal(5.0, util.Ptr(time.Now()), nil), + ) + assert.Nil(s.T(), err) + + power, err := s.sut.Power() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.0, power) +} + +func (s *MuMpcBcSuite) Test_PowerPerPhase() { + err := s.sut.Update( + s.sut.UpdateDataPowerPhaseB(6.0, util.Ptr(time.Now()), nil), + s.sut.UpdateDataPowerPhaseC(7.0, util.Ptr(time.Now()), util.Ptr(model.MeasurementValueStateTypeError)), + ) + assert.Nil(s.T(), err) + + powerPerPhases, err := s.sut.PowerPerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{6.0, 7.0}, powerPerPhases) + + err = s.sut.Update( + s.sut.UpdateDataPowerPhaseA(5.0, util.Ptr(time.Now()), nil), + ) + assert.NotNil(s.T(), err) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, model.EnergyDirectionTypeConsume, ucapi.PhaseNameMapping) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{6.0, 7.0}, values) +} + +func (s *MuMpcBcSuite) Test_EnergyConsumed() { + err := s.sut.Update( + s.sut.UpdateDataEnergyConsumed(5.0, util.Ptr(time.Now()), nil, util.Ptr(time.Now()), util.Ptr(time.Now())), + ) + assert.Nil(s.T(), err) + + energyConsumed, err := s.sut.EnergyConsumed() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.0, energyConsumed) +} + +func (s *MuMpcBcSuite) Test_EnergyProduced() { + err := s.sut.Update( + s.sut.UpdateDataEnergyProduced(5.0, nil, nil, nil, nil), + ) + assert.Nil(s.T(), err) + + energyProduced, err := s.sut.EnergyProduced() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.0, energyProduced) +} + +func (s *MuMpcBcSuite) Test_CurrentPerPhase() { + err := s.sut.Update( + s.sut.UpdateDataCurrentPhaseB(3.0, nil, nil), + s.sut.UpdateDataCurrentPhaseC(1.0, nil, nil), + ) + assert.Nil(s.T(), err) + + currentPerPhases, err := s.sut.CurrentPerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{3.0, 1.0}, currentPerPhases) + + err = s.sut.Update( + s.sut.UpdateDataCurrentPhaseA(5.0, nil, nil), + ) + assert.NotNil(s.T(), err) +} + +func (s *MuMpcBcSuite) Test_VoltagePerPhase() { + err := s.sut.Update( + s.sut.UpdateDataVoltagePhaseB(6.0, nil, nil), + s.sut.UpdateDataVoltagePhaseC(7.0, nil, nil), + s.sut.UpdateDataVoltagePhaseBToC(9.0, nil, nil), + ) + assert.Nil(s.T(), err) + + voltagePerPhases, err := s.sut.VoltagePerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{6.0, 7.0, 9.0}, voltagePerPhases) + + err = s.sut.Update( + s.sut.UpdateDataVoltagePhaseA(5.0, nil, nil), + ) + assert.NotNil(s.T(), err) + + err = s.sut.Update( + s.sut.UpdateDataVoltagePhaseAToB(5.0, nil, nil), + ) + assert.NotNil(s.T(), err) + + err = s.sut.Update( + s.sut.UpdateDataVoltagePhaseCToA(5.0, nil, nil), + ) + assert.NotNil(s.T(), err) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeVoltage), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACVoltage), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, "", ucapi.PhaseNameMapping) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{6.0, 7.0, 9.0}, values) +} + +func (s *MuMpcBcSuite) Test_Frequency() { + err := s.sut.Update( + s.sut.UpdateDataFrequency(5.0, nil, nil), + ) + assert.Nil(s.T(), err) + + frequency, err := s.sut.Frequency() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.0, frequency) +} diff --git a/usecases/mu/mpc/public_constraint_test.go b/usecases/mu/mpc/public_constraint_test.go new file mode 100644 index 00000000..e70db4a5 --- /dev/null +++ b/usecases/mu/mpc/public_constraint_test.go @@ -0,0 +1,226 @@ +package mpc + +import ( + "testing" + "time" + + "github.com/enbility/eebus-go/features/server" + ucapi "github.com/enbility/eebus-go/usecases/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +type MuMpcConstraintSuite struct { + suite.Suite + *MuMPCSuite +} + +// Test suite testing an MPC MonitoredUnit that uses ValueConstraints on its measurements +func TestMuMpcConstraintSuite(t *testing.T) { + suite.Run(t, new(MuMpcConstraintSuite)) +} + +func (s *MuMpcConstraintSuite) BeforeTest(suiteName, testName string) { + s.MuMPCSuite = NewMuMPCSuite( + &s.Suite, + &MonitorPowerConfig{ + ConnectedPhases: ConnectedPhasesA, + ValueSourceTotal: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraintsTotal: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(0), + ValueStepSize: model.NewScaledNumberType(0.1), + }), + ValueConstraintsPhaseA: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(0), + ValueStepSize: model.NewScaledNumberType(0.1), + }), + }, + &MonitorEnergyConfig{ + ValueSourceConsumption: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraintsConsumption: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(0), + ValueStepSize: model.NewScaledNumberType(100), + }), + }, + &MonitorCurrentConfig{ + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraintsPhaseA: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(0), + ValueRangeMax: model.NewScaledNumberType(32), + ValueStepSize: model.NewScaledNumberType(0.1), + }), + }, + &MonitorVoltageConfig{ + SupportPhaseToPhase: false, + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraintsPhaseA: util.Ptr(model.MeasurementConstraintsDataType{ + ValueStepSize: model.NewScaledNumberType(0.1), + }), + }, + &MonitorFrequencyConfig{ + ValueSource: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraints: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(40), + ValueRangeMax: model.NewScaledNumberType(60), + ValueStepSize: model.NewScaledNumberType(0.01), + }), + }, + ) + s.MuMPCSuite.BeforeTest(suiteName, testName) +} + +func (s *MuMpcConstraintSuite) Test_Power() { + err := s.sut.Update( + s.sut.UpdateDataPowerTotal(5.7, util.Ptr(time.Now()), nil), + ) + assert.Nil(s.T(), err) + + power, err := s.sut.Power() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 5.7, power) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, model.EnergyDirectionTypeConsume, nil) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.7}, values) +} + +func (s *MuMpcConstraintSuite) Test_PowerPerPhase() { + err := s.sut.Update( + s.sut.UpdateDataPowerPhaseA(5.7, util.Ptr(time.Now()), nil), + ) + assert.Nil(s.T(), err) + + powerPerPhases, err := s.sut.PowerPerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.7}, powerPerPhases) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, model.EnergyDirectionTypeConsume, ucapi.PhaseNameMapping) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{5.7}, values) +} + +func (s *MuMpcConstraintSuite) Test_EnergyConsumed() { + err := s.sut.Update( + s.sut.UpdateDataEnergyConsumed(570, util.Ptr(time.Now()), nil, util.Ptr(time.Now()), util.Ptr(time.Now())), + ) + assert.Nil(s.T(), err) + + energyConsumed, err := s.sut.EnergyConsumed() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 570.0, energyConsumed) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACEnergyConsumed), + } + measurement, err := server.NewMeasurement(s.sut.LocalEntity) + assert.Nil(s.T(), err) + values, err := measurement.GetDataForFilter(filter) + assert.Nil(s.T(), err) + assert.Equal(s.T(), 1, len(values)) + assert.Equal(s.T(), 570.0, (*values[0].Value).GetValue()) +} + +func (s *MuMpcConstraintSuite) Test_EnergyProduced() { + err := s.sut.Update( + s.sut.UpdateDataEnergyProduced(5.0, nil, nil, nil, nil), + ) + assert.NotNil(s.T(), err) + + _, err = s.sut.EnergyProduced() + assert.NotNil(s.T(), err) + + // Check if the client filter works (it shouldn't) + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACEnergyProduced), + } + measurement, err := server.NewMeasurement(s.sut.LocalEntity) + assert.Nil(s.T(), err) + _, err = measurement.GetDataForFilter(filter) + assert.NotNil(s.T(), err) +} + +func (s *MuMpcConstraintSuite) Test_CurrentPerPhase() { + err := s.sut.Update( + s.sut.UpdateDataCurrentPhaseA(0.1, nil, nil), + ) + assert.Nil(s.T(), err) + + currentPerPhases, err := s.sut.CurrentPerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{0.1}, currentPerPhases) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, model.EnergyDirectionTypeConsume, ucapi.PhaseNameMapping) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{0.1}, values) +} + +func (s *MuMpcConstraintSuite) Test_VoltagePerPhase() { + err := s.sut.Update( + s.sut.UpdateDataVoltagePhaseA(230, nil, nil), + ) + assert.Nil(s.T(), err) + + voltagePerPhases, err := s.sut.VoltagePerPhase() + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{230}, voltagePerPhases) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeVoltage), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACVoltage), + } + values, err := s.measurementPhaseSpecificDataForFilter(filter, "", ucapi.PhaseNameMapping) + assert.Nil(s.T(), err) + assert.Equal(s.T(), []float64{230}, values) +} + +func (s *MuMpcConstraintSuite) Test_Frequency() { + err := s.sut.Update( + s.sut.UpdateDataFrequency(50, nil, nil), + ) + assert.Nil(s.T(), err) + + frequency, err := s.sut.Frequency() + assert.Nil(s.T(), err) + assert.Equal(s.T(), 50.0, frequency) + + // Check if the client filter works + filter := model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeFrequency), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACFrequency), + } + measurements, err := server.NewMeasurement(s.sut.LocalEntity) + assert.Nil(s.T(), err) + values, err := measurements.GetDataForFilter(filter) + assert.Nil(s.T(), err) + assert.Equal(s.T(), 1, len(values)) + assert.Equal(s.T(), 50.0, (*values[0].Value).GetValue()) +} diff --git a/usecases/mu/mpc/testhelper_test.go b/usecases/mu/mpc/testhelper_test.go new file mode 100644 index 00000000..2e503215 --- /dev/null +++ b/usecases/mu/mpc/testhelper_test.go @@ -0,0 +1,147 @@ +package mpc + +import ( + "slices" + "time" + + "github.com/enbility/eebus-go/features/server" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/mocks" + "github.com/enbility/eebus-go/service" + shipapi "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/cert" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" +) + +const remoteSki string = "testremoteski" + +type MuMPCSuite struct { + *suite.Suite + + powerConfig *MonitorPowerConfig + energyConfig *MonitorEnergyConfig + currentConfig *MonitorCurrentConfig + voltageConfig *MonitorVoltageConfig + frequencyConfig *MonitorFrequencyConfig + sut *MPC + + service api.ServiceInterface +} + +func NewMuMPCSuite( + suite *suite.Suite, + powerConfig *MonitorPowerConfig, + energyConfig *MonitorEnergyConfig, + currentConfig *MonitorCurrentConfig, + voltageConfig *MonitorVoltageConfig, + frequencyConfig *MonitorFrequencyConfig, +) *MuMPCSuite { + return &MuMPCSuite{ + Suite: suite, + powerConfig: powerConfig, + energyConfig: energyConfig, + currentConfig: currentConfig, + voltageConfig: voltageConfig, + frequencyConfig: frequencyConfig, + } +} + +func (s *MuMPCSuite) Event(_ string, _ spineapi.DeviceRemoteInterface, _ spineapi.EntityRemoteInterface, _ api.EventType) { +} + +func (s *MuMPCSuite) BeforeTest(_, _ string) { + cert, _ := cert.CreateCertificate("test", "test", "DE", "test") + configuration, _ := api.NewConfiguration( + "test", "test", "test", "test", + []shipapi.DeviceCategoryType{shipapi.DeviceCategoryTypeEnergyManagementSystem}, + model.DeviceTypeTypeEnergyManagementSystem, + []model.EntityTypeType{model.EntityTypeTypeInverter}, + 9999, cert, time.Second*4) + + serviceHandler := mocks.NewServiceReaderInterface(s.T()) + serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() + + s.service = service.NewService(configuration, serviceHandler) + _ = s.service.Setup() + + localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeInverter) + s.sut, _ = NewMPC( + localEntity, + s.Event, + s.powerConfig, + s.energyConfig, + s.currentConfig, + s.voltageConfig, + s.frequencyConfig, + ) + + assert.Nil(s.T(), s.sut.AddFeatures()) + s.sut.AddUseCase() +} + +func (s *MuMPCSuite) measurementPhaseSpecificDataForFilter( + measurementFilter model.MeasurementDescriptionDataType, + energyDirection model.EnergyDirectionType, + validPhaseNameTypes []model.ElectricalConnectionPhaseNameType, +) ([]float64, error) { + measurements, err := server.NewMeasurement(s.sut.LocalEntity) + if err != nil { + return nil, err + } + + electricalConnection, err := server.NewElectricalConnection(s.sut.LocalEntity) + if err != nil { + return nil, err + } + + data, err := measurements.GetDataForFilter(measurementFilter) + if err != nil || len(data) == 0 { + return nil, api.ErrDataNotAvailable + } + + var result []float64 + + for _, item := range data { + if item.Value == nil || item.MeasurementId == nil { + continue + } + + if validPhaseNameTypes != nil { + filter := model.ElectricalConnectionParameterDescriptionDataType{ + MeasurementId: item.MeasurementId, + } + param, err := electricalConnection.GetParameterDescriptionsForFilter(filter) + if err != nil || len(param) == 0 || + param[0].AcMeasuredPhases == nil || + !slices.Contains(validPhaseNameTypes, *param[0].AcMeasuredPhases) { + continue + } + } + + if energyDirection != "" { + filter := model.ElectricalConnectionParameterDescriptionDataType{ + MeasurementId: item.MeasurementId, + } + desc, err := electricalConnection.GetDescriptionForParameterDescriptionFilter(filter) + if err != nil || desc == nil { + continue + } + + // if energy direction is not consume + if desc.PositiveEnergyDirection == nil || *desc.PositiveEnergyDirection != energyDirection { + return nil, err + } + } + + value := item.Value.GetValue() + + result = append(result, value) + } + + return result, nil +} diff --git a/usecases/mu/mpc/types.go b/usecases/mu/mpc/types.go new file mode 100644 index 00000000..67f2d3f0 --- /dev/null +++ b/usecases/mu/mpc/types.go @@ -0,0 +1,10 @@ +package mpc + +import "github.com/enbility/eebus-go/api" + +const ( + // Update of the list of remote entities supporting the Use Case + // + // Use `RemoteEntities` to get the current data + UseCaseSupportUpdate api.EventType = "mu-mpc-UseCaseSupportUpdate" +) diff --git a/usecases/mu/mpc/update_helper.go b/usecases/mu/mpc/update_helper.go new file mode 100644 index 00000000..279f03bc --- /dev/null +++ b/usecases/mu/mpc/update_helper.go @@ -0,0 +1,77 @@ +package mpc + +import ( + "errors" + "github.com/enbility/eebus-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" + "time" +) + +type UpdateData struct { + supported bool + notSupportedError error + measurementData api.MeasurementDataForID +} + +func (u *UpdateData) Supported() bool { + return u.supported +} + +func (u *UpdateData) NotSupportedError() error { + return u.notSupportedError +} + +func (u *UpdateData) MeasurementData() api.MeasurementDataForID { + return u.measurementData +} + +func newUpdateData( + errorString string, + id *model.MeasurementIdType, + data *model.MeasurementDataType, +) *UpdateData { + if id == nil || data == nil { + return &UpdateData{ + supported: false, + notSupportedError: errors.New(errorString), + } + } else { + return &UpdateData{ + supported: true, + measurementData: api.MeasurementDataForID{ + Id: *id, + Data: *data, + }, + } + } +} + +func measurementData( + value float64, + timestamp *time.Time, + valueSource *model.MeasurementValueSourceType, + valueState *model.MeasurementValueStateType, + evaluationStart *time.Time, + evaluationEnd *time.Time, +) *model.MeasurementDataType { + measurement := model.MeasurementDataType{ + ValueType: util.Ptr(model.MeasurementValueTypeTypeValue), + Value: model.NewScaledNumberType(value), + ValueSource: valueSource, + ValueState: valueState, + } + + if timestamp != nil { + measurement.Timestamp = model.NewAbsoluteOrRelativeTimeTypeFromTime(*timestamp) + } + + if evaluationStart != nil && evaluationEnd != nil { + measurement.EvaluationPeriod = &model.TimePeriodType{ + StartTime: model.NewAbsoluteOrRelativeTimeTypeFromTime(*evaluationStart), + EndTime: model.NewAbsoluteOrRelativeTimeTypeFromTime(*evaluationEnd), + } + } + + return &measurement +} diff --git a/usecases/mu/mpc/usecase.go b/usecases/mu/mpc/usecase.go new file mode 100644 index 00000000..e2b1a3d9 --- /dev/null +++ b/usecases/mu/mpc/usecase.go @@ -0,0 +1,560 @@ +package mpc + +import ( + "errors" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/features/server" + "github.com/enbility/eebus-go/usecases/usecase" + spineapi "github.com/enbility/spine-go/api" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/spine" + "github.com/enbility/spine-go/util" +) + +type MPC struct { + *usecase.UseCaseBase + + powerConfig *MonitorPowerConfig + energyConfig *MonitorEnergyConfig + currentConfig *MonitorCurrentConfig + voltageConfig *MonitorVoltageConfig + frequencyConfig *MonitorFrequencyConfig + + acPowerTotal *model.MeasurementIdType + acPower [3]*model.MeasurementIdType + acEnergyConsumed *model.MeasurementIdType + acEnergyProduced *model.MeasurementIdType + acCurrent [3]*model.MeasurementIdType + acVoltage [6]*model.MeasurementIdType // Phase to phase voltages are not supported (yet) + acFrequency *model.MeasurementIdType +} + +// creates a new MPC usecase instance for a MonitoredUnit entity +// +// parameters: +// - localEntity: the local entity for which to construct an MPC instance +// - eventCB: the callback to notify about events for this usecase +// - monitorPowerConfig: (required) configuration parameters for MPC scenario 1 +// - monitorEnergyConfig: (optional) configuration parameters for MPC scenario 2, nil if not supported +// - monitorCurrentConfig: (optional) configuration parameters for MPC scenario 3, nil if not supported +// - monitorVoltageConfig: (optional) configuration parameters for MPC scenario 4, nil if not supported +// - monitorFrequencyConfig: (optional) configuration parameters for MPC scenario, nil if not supported +// +// possible errors: +// - if required fields in parameters are unset +func NewMPC( + localEntity spineapi.EntityLocalInterface, + eventCB api.EntityEventCallback, + monitorPowerConfig *MonitorPowerConfig, + monitorEnergyConfig *MonitorEnergyConfig, + monitorCurrentConfig *MonitorCurrentConfig, + monitorVoltageConfig *MonitorVoltageConfig, + monitorFrequencyConfig *MonitorFrequencyConfig, +) (*MPC, error) { + if monitorPowerConfig == nil { + return nil, errors.New("the monitor power config for the MPC-Use-Case must not be nil") + } + + validActorTypes := []model.UseCaseActorType{model.UseCaseActorTypeMonitoringAppliance} + useCaseScenarios := []api.UseCaseScenario{ + { + Scenario: model.UseCaseScenarioSupportType(1), + Mandatory: true, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }, + } + + if monitorEnergyConfig != nil { + useCaseScenarios = append(useCaseScenarios, api.UseCaseScenario{ + Scenario: model.UseCaseScenarioSupportType(2), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }) + } + + if monitorCurrentConfig != nil { + useCaseScenarios = append(useCaseScenarios, api.UseCaseScenario{ + Scenario: model.UseCaseScenarioSupportType(3), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }) + } + + if monitorVoltageConfig != nil { + useCaseScenarios = append(useCaseScenarios, api.UseCaseScenario{ + Scenario: model.UseCaseScenarioSupportType(4), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }) + } + + if monitorFrequencyConfig != nil { + useCaseScenarios = append(useCaseScenarios, api.UseCaseScenario{ + Scenario: model.UseCaseScenarioSupportType(5), + Mandatory: false, + ServerFeatures: []model.FeatureTypeType{ + model.FeatureTypeTypeElectricalConnection, + model.FeatureTypeTypeMeasurement, + }, + }) + } + + u := usecase.NewUseCaseBase( + localEntity, + model.UseCaseActorTypeMonitoredUnit, + model.UseCaseNameTypeMonitoringOfPowerConsumption, + "1.0.0", + "release", + useCaseScenarios, + eventCB, + UseCaseSupportUpdate, + validActorTypes, + nil, + true, + ) + + uc := &MPC{ + UseCaseBase: u, + powerConfig: monitorPowerConfig, + energyConfig: monitorEnergyConfig, + currentConfig: monitorCurrentConfig, + voltageConfig: monitorVoltageConfig, + frequencyConfig: monitorFrequencyConfig, + } + + _ = spine.Events.Subscribe(uc) + + return uc, nil +} + +func (e *MPC) AddFeatures() error { + // server features + electricalConnectionFeature := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeElectricalConnection, model.RoleTypeServer) + electricalConnectionFeature.AddFunctionType(model.FunctionTypeElectricalConnectionDescriptionListData, true, false) + electricalConnectionFeature.AddFunctionType(model.FunctionTypeElectricalConnectionParameterDescriptionListData, true, false) + + measurementFeature := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeMeasurement, model.RoleTypeServer) + measurementFeature.AddFunctionType(model.FunctionTypeMeasurementDescriptionListData, true, false) + measurementFeature.AddFunctionType(model.FunctionTypeMeasurementConstraintsListData, true, false) + measurementFeature.AddFunctionType(model.FunctionTypeMeasurementListData, true, false) + + measurements, err := server.NewMeasurement(e.LocalEntity) + if err != nil { + return err + } + + electricalConnection, err := server.NewElectricalConnection(e.LocalEntity) + if err != nil { + return err + } + + electricalConnectionId, err := electricalConnection.GetOrAddIdForDescription(model.ElectricalConnectionDescriptionDataType{ + PowerSupplyType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + PositiveEnergyDirection: util.Ptr(model.EnergyDirectionTypeConsume), + }) + if err != nil { + return err + } + + constraints := make([]model.MeasurementConstraintsDataType, 0) + + configMethods := []func( + measurements *server.Measurement, + electricalConnection *server.ElectricalConnection, + electricalConnectionId *model.ElectricalConnectionIdType, + measurementsConstraintData *[]model.MeasurementConstraintsDataType, + ) error{ + e.configureMonitorPower, + e.configureMonitorEnergy, + e.configureMonitorCurrent, + e.configureMonitorVoltage, + e.configureMonitorFrequency, + } + + for _, configMethod := range configMethods { + if err := configMethod(measurements, electricalConnection, electricalConnectionId, &constraints); err != nil { + return err + } + } + + // if any of the configured measurements set constraints, update the + // measurementFeature with those accumulated constraints + if len(constraints) > 0 { + measurementFeature.UpdateData( + model.FunctionTypeMeasurementConstraintsListData, + &model.MeasurementConstraintsListDataType{ + MeasurementConstraintsData: constraints, + }, nil, nil, + ) + } + + return nil +} + +func (e *MPC) configureMonitorPower( + measurements *server.Measurement, + electricalConnection *server.ElectricalConnection, + electricalConnectionId *model.ElectricalConnectionIdType, + measurementsConstraintData *[]model.MeasurementConstraintsDataType, +) error { + if e.powerConfig == nil { + return errors.New("mpc monitoring power must be configured") + } + + e.acPowerTotal = measurements.AddDescription(model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + }) + + // if constraints are configured for acPowerTotal, set the + // constraint id and update measurementsConstraintData + if e.powerConfig.ValueConstraintsTotal != nil { + e.powerConfig.ValueConstraintsTotal.MeasurementId = e.acPowerTotal + *measurementsConstraintData = append(*measurementsConstraintData, *e.powerConfig.ValueConstraintsTotal) + } + + parameterDescription := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: electricalConnectionId, + MeasurementId: e.acPowerTotal, + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameType(e.powerConfig.ConnectedPhases)), + AcMeasuredInReferenceTo: util.Ptr(model.ElectricalConnectionPhaseNameTypeNeutral), + AcMeasurementType: util.Ptr(model.ElectricalConnectionAcMeasurementTypeTypeReal), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + } + + parameterDescriptionId := electricalConnection.AddParameterDescription(parameterDescription) + if parameterDescriptionId == nil { + return errors.New("could not add parameter description") + } + + acPowerConstraints := []*model.MeasurementConstraintsDataType{ + e.powerConfig.ValueConstraintsPhaseA, + e.powerConfig.ValueConstraintsPhaseB, + e.powerConfig.ValueConstraintsPhaseC, + } + + acMeasuredPhases := []*model.ElectricalConnectionPhaseNameType{ + util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + } + + for id := 0; id < len(e.acPower); id++ { + if e.powerConfig.SupportsPhases(phases[id]) { + e.acPower[id] = measurements.AddDescription(model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + }) + + // if constraints are configured for acPower[id], set the + // constraint id and update measurementsConstraintData + if acPowerConstraints[id] != nil { + acPowerConstraints[id].MeasurementId = e.acPower[id] + *measurementsConstraintData = append(*measurementsConstraintData, *acPowerConstraints[id]) + } + + parameterDescription := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: electricalConnectionId, + MeasurementId: e.acPower[id], + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + AcMeasuredPhases: acMeasuredPhases[id], + AcMeasuredInReferenceTo: util.Ptr(model.ElectricalConnectionPhaseNameTypeNeutral), + AcMeasurementType: util.Ptr(model.ElectricalConnectionAcMeasurementTypeTypeReal), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + } + + parameterDescriptionId := electricalConnection.AddParameterDescription(parameterDescription) + if parameterDescriptionId == nil { + return errors.New("could not add parameter description") + } + } + } + + return nil +} + +func (e *MPC) configureMonitorEnergy( + measurements *server.Measurement, + electricalConnection *server.ElectricalConnection, + electricalConnectionId *model.ElectricalConnectionIdType, + measurementsConstraintData *[]model.MeasurementConstraintsDataType, +) error { + if e.energyConfig == nil { + return nil + } + + if e.energyConfig.ValueSourceConsumption != nil { + e.acEnergyConsumed = measurements.AddDescription(model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeWh), + ScopeType: util.Ptr(model.ScopeTypeTypeACEnergyConsumed), + }) + + // if constraints are configured for acEnergyConsumed, set the + // constraint id and update measurementsConstraintData + if e.energyConfig.ValueConstraintsConsumption != nil { + e.energyConfig.ValueConstraintsConsumption.MeasurementId = e.acEnergyConsumed + *measurementsConstraintData = append(*measurementsConstraintData, *e.energyConfig.ValueConstraintsConsumption) + } + + parameterDescription := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: electricalConnectionId, + MeasurementId: e.acEnergyConsumed, + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + AcMeasurementType: util.Ptr(model.ElectricalConnectionAcMeasurementTypeTypeReal), + } + + parameterDescriptionId := electricalConnection.AddParameterDescription(parameterDescription) + if parameterDescriptionId == nil { + return errors.New("could not add parameter description") + } + } + + if e.energyConfig.ValueSourceProduction != nil { + e.acEnergyProduced = measurements.AddDescription(model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeWh), + ScopeType: util.Ptr(model.ScopeTypeTypeACEnergyProduced), + }) + + // if constraints are configured for acEnergyProduced, set the + // constraint id and update measurementsConstraintData + if e.energyConfig.ValueConstraintsProduction != nil { + e.energyConfig.ValueConstraintsProduction.MeasurementId = e.acEnergyProduced + *measurementsConstraintData = append(*measurementsConstraintData, *e.energyConfig.ValueConstraintsProduction) + } + + p4 := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: electricalConnectionId, + MeasurementId: e.acEnergyProduced, + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + AcMeasurementType: util.Ptr(model.ElectricalConnectionAcMeasurementTypeTypeReal), + } + idP4 := electricalConnection.AddParameterDescription(p4) + if idP4 == nil { + return errors.New("could not add parameter description") + } + } + + return nil +} + +func (e *MPC) configureMonitorCurrent( + measurements *server.Measurement, + electricalConnection *server.ElectricalConnection, + electricalConnectionId *model.ElectricalConnectionIdType, + measurementsConstraintData *[]model.MeasurementConstraintsDataType, +) error { + if e.currentConfig == nil { + return nil + } + + acCurrentConstraints := []*model.MeasurementConstraintsDataType{ + e.currentConfig.ValueConstraintsPhaseA, + e.currentConfig.ValueConstraintsPhaseB, + e.currentConfig.ValueConstraintsPhaseC, + } + + acMeasuredPhases := []*model.ElectricalConnectionPhaseNameType{ + util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + } + + for id := 0; id < len(e.acCurrent); id++ { + if e.powerConfig.SupportsPhases(phases[id]) { + e.acCurrent[id] = measurements.AddDescription(model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + }) + + // if constraints are configured for acCurrent[id], set the + // constraint id and update measurementsConstraintData + if acCurrentConstraints[id] != nil { + acCurrentConstraints[id].MeasurementId = e.acCurrent[id] + *measurementsConstraintData = append(*measurementsConstraintData, *acCurrentConstraints[id]) + } + + parameterDescription := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: electricalConnectionId, + MeasurementId: e.acCurrent[id], + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + AcMeasuredPhases: acMeasuredPhases[id], + AcMeasurementType: util.Ptr(model.ElectricalConnectionAcMeasurementTypeTypeReal), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + } + + parameterDescriptionId := electricalConnection.AddParameterDescription(parameterDescription) + if parameterDescriptionId == nil { + return errors.New("could not add parameter description") + } + } + } + + return nil +} + +func (e *MPC) configureMonitorVoltage( + measurements *server.Measurement, + electricalConnection *server.ElectricalConnection, + electricalConnectionId *model.ElectricalConnectionIdType, + measurementsConstraintData *[]model.MeasurementConstraintsDataType, +) error { + if e.voltageConfig == nil { + return nil + } + + acVoltagePhasesFrom := []*model.ElectricalConnectionPhaseNameType{ + util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + } + + acVoltagePhasesTo := []*model.ElectricalConnectionPhaseNameType{ + util.Ptr(model.ElectricalConnectionPhaseNameTypeNeutral), + util.Ptr(model.ElectricalConnectionPhaseNameTypeNeutral), + util.Ptr(model.ElectricalConnectionPhaseNameTypeNeutral), + util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + } + + acVoltageConstraints := []*model.MeasurementConstraintsDataType{ + e.voltageConfig.ValueConstraintsPhaseA, + e.voltageConfig.ValueConstraintsPhaseB, + e.voltageConfig.ValueConstraintsPhaseC, + e.voltageConfig.ValueConstraintsPhaseAToB, + e.voltageConfig.ValueConstraintsPhaseBToC, + e.voltageConfig.ValueConstraintsPhaseCToA, + } + + for id := 0; id < len(e.acVoltage); id++ { + if e.powerConfig.SupportsPhases(phases[id]) { + // skip PhaseToPhase voltages if they're not supported + if len(phases[id]) == 2 && !e.voltageConfig.SupportPhaseToPhase { + continue + } + + e.acVoltage[id] = measurements.AddDescription(model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeVoltage), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeV), + ScopeType: util.Ptr(model.ScopeTypeTypeACVoltage), + }) + + // if constraints are configured for acVoltage[id], set the + // constraint id and update measurementsConstraintData + if acVoltageConstraints[id] != nil { + acVoltageConstraints[id].MeasurementId = e.acVoltage[id] + *measurementsConstraintData = append(*measurementsConstraintData, *acVoltageConstraints[id]) + } + + parameterDescription := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: electricalConnectionId, + MeasurementId: e.acVoltage[id], + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + AcMeasuredPhases: acVoltagePhasesFrom[id], + AcMeasuredInReferenceTo: acVoltagePhasesTo[id], + AcMeasurementType: util.Ptr(model.ElectricalConnectionAcMeasurementTypeTypeApparent), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + } + + parameterDescriptionId := electricalConnection.AddParameterDescription(parameterDescription) + if parameterDescriptionId == nil { + return errors.New("could not add parameter description") + } + } + } + + return nil +} + +func (e *MPC) configureMonitorFrequency( + measurements *server.Measurement, + electricalConnection *server.ElectricalConnection, + electricalConnectionId *model.ElectricalConnectionIdType, + measurementsConstraintData *[]model.MeasurementConstraintsDataType, +) error { + if e.frequencyConfig == nil { + return nil + } + + e.acFrequency = measurements.AddDescription(model.MeasurementDescriptionDataType{ + MeasurementType: util.Ptr(model.MeasurementTypeTypeFrequency), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + Unit: util.Ptr(model.UnitOfMeasurementTypeHz), + ScopeType: util.Ptr(model.ScopeTypeTypeACFrequency), + }) + + // if constraints are configured for acFrequency, set the + // constraint id and update measurementsConstraintData + if e.frequencyConfig.ValueConstraints != nil { + e.frequencyConfig.ValueConstraints.MeasurementId = e.acFrequency + *measurementsConstraintData = append(*measurementsConstraintData, *e.frequencyConfig.ValueConstraints) + } + + parameterDescription := model.ElectricalConnectionParameterDescriptionDataType{ + ElectricalConnectionId: electricalConnectionId, + MeasurementId: e.acFrequency, + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + } + + parameterDescriptionId := electricalConnection.AddParameterDescription(parameterDescription) + if parameterDescriptionId == nil { + return errors.New("could not add parameter description") + } + + return nil +} + +func (e *MPC) getMeasurementDataForId(id *model.MeasurementIdType) (float64, error) { + measurements, err := server.NewMeasurement(e.LocalEntity) + if err != nil { + return 0, err + } + + data, err := measurements.GetDataForId(*id) + if err != nil { + return 0, err + } + + if data == nil { + return 0, api.ErrDataNotAvailable + } + + return data.Value.GetValue(), nil +} + +var phases = [][]string{ + {"a"}, + {"b"}, + {"c"}, + {"a", "b"}, + {"b", "c"}, + {"c", "a"}, +} diff --git a/usecases/mu/mpc/usecase_test.go b/usecases/mu/mpc/usecase_test.go new file mode 100644 index 00000000..fb7404f3 --- /dev/null +++ b/usecases/mu/mpc/usecase_test.go @@ -0,0 +1,152 @@ +package mpc + +import ( + "testing" + "time" + + "github.com/enbility/eebus-go/api" + "github.com/enbility/eebus-go/mocks" + "github.com/enbility/eebus-go/service" + shipapi "github.com/enbility/ship-go/api" + "github.com/enbility/ship-go/cert" + spineapi "github.com/enbility/spine-go/api" + spinemocks "github.com/enbility/spine-go/mocks" + "github.com/enbility/spine-go/model" + "github.com/enbility/spine-go/util" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/suite" +) + +func TestBasicSuite(t *testing.T) { + suite.Run(t, new(BasicSuite)) +} + +type BasicSuite struct { + suite.Suite + + service api.ServiceInterface + + remoteDevice spineapi.DeviceRemoteInterface + mockRemoteEntity *spinemocks.EntityRemoteInterface + monitoredEntity spineapi.EntityRemoteInterface + loadControlFeature, + deviceDiagnosisFeature, + deviceConfigurationFeature spineapi.FeatureLocalInterface + + eventCalled bool +} + +func (s *BasicSuite) Event(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event api.EventType) { + s.eventCalled = true +} + +func (s *BasicSuite) BeforeTest(suiteName, testName string) { + s.eventCalled = false + cert, _ := cert.CreateCertificate("test", "test", "DE", "test") + configuration, _ := api.NewConfiguration( + "test", "test", "test", "test", + []shipapi.DeviceCategoryType{shipapi.DeviceCategoryTypeEnergyManagementSystem}, + model.DeviceTypeTypeEnergyManagementSystem, + []model.EntityTypeType{model.EntityTypeTypeInverter}, + 9999, cert, time.Second*4) + + serviceHandler := mocks.NewServiceReaderInterface(s.T()) + serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() + + s.service = service.NewService(configuration, serviceHandler) + _ = s.service.Setup() + + mockRemoteDevice := spinemocks.NewDeviceRemoteInterface(s.T()) + s.mockRemoteEntity = spinemocks.NewEntityRemoteInterface(s.T()) + mockRemoteFeature := spinemocks.NewFeatureRemoteInterface(s.T()) + mockRemoteDevice.EXPECT().FeatureByEntityTypeAndRole(mock.Anything, mock.Anything, mock.Anything).Return(mockRemoteFeature).Maybe() + mockRemoteDevice.EXPECT().Ski().Return(remoteSki).Maybe() + s.mockRemoteEntity.EXPECT().Device().Return(mockRemoteDevice).Maybe() + s.mockRemoteEntity.EXPECT().EntityType().Return(mock.Anything).Maybe() + entityAddress := &model.EntityAddressType{} + s.mockRemoteEntity.EXPECT().Address().Return(entityAddress).Maybe() + mockRemoteFeature.EXPECT().DataCopy(mock.Anything).Return(mock.Anything).Maybe() + mockRemoteFeature.EXPECT().Address().Return(&model.FeatureAddressType{}).Maybe() + mockRemoteFeature.EXPECT().Operations().Return(nil).Maybe() +} + +func (s *BasicSuite) Test_MpcOptionalParameters() { + localEntity := s.service.LocalDevice().EntityForType(model.EntityTypeTypeInverter) + + // required + var monitorPowerConfig = MonitorPowerConfig{ + ConnectedPhases: ConnectedPhasesABC, + ValueSourceTotal: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + } + + // the following 4 parameters are optional and can be nil + var monitorEnergyConfig = MonitorEnergyConfig{ + ValueSourceProduction: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourceConsumption: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + } + var monitorCurrentConfig = MonitorCurrentConfig{ + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + } + var monitorVoltageConfig = MonitorVoltageConfig{ + SupportPhaseToPhase: true, + ValueSourcePhaseA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseAToB: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseBToC: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueSourcePhaseCToA: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + } + var monitorFrequencyConfig = MonitorFrequencyConfig{ + ValueSource: util.Ptr(model.MeasurementValueSourceTypeMeasuredValue), + ValueConstraints: util.Ptr(model.MeasurementConstraintsDataType{ + ValueRangeMin: model.NewScaledNumberType(0), + ValueRangeMax: model.NewScaledNumberType(100), + ValueStepSize: model.NewScaledNumberType(1), + }), + } + + numOptionalParams := 4 + + // iterate over all permutations of nil/set + for i := 0; i < (1 << numOptionalParams); i++ { + // Determine which parameters to set + var optEnergyConfig *MonitorEnergyConfig + var optCurrentConfig *MonitorCurrentConfig + var optVoltageConfig *MonitorVoltageConfig + var optFrequencyConfig *MonitorFrequencyConfig + if i&1 != 0 { + optEnergyConfig = &monitorEnergyConfig + } + if i&2 != 0 { + optCurrentConfig = &monitorCurrentConfig + } + if i&4 != 0 { + optVoltageConfig = &monitorVoltageConfig + } + if i&8 != 0 { + optFrequencyConfig = &monitorFrequencyConfig + } + + mpc, err := NewMPC( + localEntity, + s.Event, + &monitorPowerConfig, + optEnergyConfig, + optCurrentConfig, + optVoltageConfig, + optFrequencyConfig, + ) + + assert.Nil(s.T(), err) + + err = mpc.AddFeatures() + assert.Nil(s.T(), err) + mpc.AddUseCase() + } +} diff --git a/usecases/usecase/events.go b/usecases/usecase/events.go index 0bab5b49..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 !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 77df868c..6ecaf71f 100644 --- a/usecases/usecase/testhelper_test.go +++ b/usecases/usecase/testhelper_test.go @@ -110,6 +110,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 17d58e36..0ebdb5b7 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 + 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 } @@ -57,6 +58,7 @@ func NewUseCaseBase( useCaseUpdateEvent api.EventType, validActorTypes []model.UseCaseActorType, validEntityTypes []model.EntityTypeType, + allEntityTypesValid bool, ) *UseCaseBase { ucb := &UseCaseBase{ LocalEntity: localEntity, @@ -69,6 +71,7 @@ func NewUseCaseBase( useCaseUpdateEvent: useCaseUpdateEvent, validActorTypes: validActorTypes, validEntityTypes: validEntityTypes, + allEntityTypesValid: allEntityTypesValid, } _ = spine.Events.Subscribe(ucb) @@ -114,6 +117,10 @@ func (u *UseCaseBase) IsCompatibleEntityType(entity spineapi.EntityRemoteInterfa return false } + if u.allEntityTypesValid { + return true + } + return slices.Contains(u.validEntityTypes, entity.EntityType()) }