diff --git a/api/featuresserver.go b/api/featuresserver.go index be02d89e..fcc5cad9 100644 --- a/api/featuresserver.go +++ b/api/featuresserver.go @@ -35,8 +35,11 @@ type DeviceConfigurationServerInterface interface { } type DeviceDiagnosisServerInterface interface { - // set the local diagnosis state of the device - SetLocalState(operatingState *model.DeviceDiagnosisStateDataType) + // set the local device diagnosis state of the device + SetLocalState(statetate *model.DeviceDiagnosisStateDataType) + + // set the local device diagnosis operating state + SetLocalOperatingState(operatingState model.DeviceDiagnosisOperatingStateType) } type ElectricalConnectionServerInterface interface { diff --git a/features/server/devicediagnosis.go b/features/server/devicediagnosis.go index 70768c24..ab63ff77 100644 --- a/features/server/devicediagnosis.go +++ b/features/server/devicediagnosis.go @@ -14,7 +14,7 @@ type DeviceDiagnosis struct { } func NewDeviceDiagnosis(localEntity spineapi.EntityLocalInterface) (*DeviceDiagnosis, error) { - feature, err := NewFeature(model.FeatureTypeTypeDeviceConfiguration, localEntity) + feature, err := NewFeature(model.FeatureTypeTypeDeviceDiagnosis, localEntity) if err != nil { return nil, err } @@ -29,7 +29,15 @@ func NewDeviceDiagnosis(localEntity spineapi.EntityLocalInterface) (*DeviceDiagn var _ api.DeviceDiagnosisServerInterface = (*DeviceDiagnosis)(nil) -// set the local diagnosis state of the device -func (d *DeviceDiagnosis) SetLocalState(operatingState *model.DeviceDiagnosisStateDataType) { - d.featureLocal.SetData(model.FunctionTypeDeviceDiagnosisStateData, operatingState) +// set the local device diagnosis state of the device +func (d *DeviceDiagnosis) SetLocalState(state *model.DeviceDiagnosisStateDataType) { + d.featureLocal.SetData(model.FunctionTypeDeviceDiagnosisStateData, state) +} + +// set the local device diagnosis operating state +func (d *DeviceDiagnosis) SetLocalOperatingState(operatingState model.DeviceDiagnosisOperatingStateType) { + stateData := &model.DeviceDiagnosisStateDataType{ + OperatingState: &operatingState, + } + d.SetLocalState(stateData) } diff --git a/features/server/devicediagnosis_test.go b/features/server/devicediagnosis_test.go index 4684a6f2..1a097d9f 100644 --- a/features/server/devicediagnosis_test.go +++ b/features/server/devicediagnosis_test.go @@ -84,3 +84,7 @@ func (s *DeviceDiagnosisSuite) Test_SetState() { } s.sut.SetLocalState(data) } + +func (s *DeviceDiagnosisSuite) Test_SetLocalOperatingState() { + s.sut.SetLocalOperatingState(model.DeviceDiagnosisOperatingStateTypeNormalOperation) +} diff --git a/features/server/helper_test.go b/features/server/helper_test.go index 142e2a82..e4bdaf13 100644 --- a/features/server/helper_test.go +++ b/features/server/helper_test.go @@ -49,6 +49,10 @@ func setupFeatures( f.AddFunctionType(model.FunctionTypeDeviceClassificationManufacturerData, true, false) f.AddFunctionType(model.FunctionTypeDeviceClassificationUserData, true, true) localEntity.AddFeature(f) + f = spine.NewFeatureLocal(9, localEntity, model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisStateData, true, false) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, true) + localEntity.AddFeature(f) f = spine.NewFeatureLocal(10, localEntity, model.FeatureTypeTypeMeasurement, model.RoleTypeServer) f.AddFunctionType(model.FunctionTypeMeasurementDescriptionListData, true, false) f.AddFunctionType(model.FunctionTypeMeasurementListData, true, false) diff --git a/mocks/DeviceDiagnosisServerInterface.go b/mocks/DeviceDiagnosisServerInterface.go index e6cdc56e..382080b5 100644 --- a/mocks/DeviceDiagnosisServerInterface.go +++ b/mocks/DeviceDiagnosisServerInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks @@ -20,23 +20,56 @@ func (_m *DeviceDiagnosisServerInterface) EXPECT() *DeviceDiagnosisServerInterfa return &DeviceDiagnosisServerInterface_Expecter{mock: &_m.Mock} } -// SetLocalState provides a mock function with given fields: operatingState -func (_m *DeviceDiagnosisServerInterface) SetLocalState(operatingState *model.DeviceDiagnosisStateDataType) { +// SetLocalOperatingState provides a mock function with given fields: operatingState +func (_m *DeviceDiagnosisServerInterface) SetLocalOperatingState(operatingState model.DeviceDiagnosisOperatingStateType) { _m.Called(operatingState) } +// DeviceDiagnosisServerInterface_SetLocalOperatingState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetLocalOperatingState' +type DeviceDiagnosisServerInterface_SetLocalOperatingState_Call struct { + *mock.Call +} + +// SetLocalOperatingState is a helper method to define mock.On call +// - operatingState model.DeviceDiagnosisOperatingStateType +func (_e *DeviceDiagnosisServerInterface_Expecter) SetLocalOperatingState(operatingState interface{}) *DeviceDiagnosisServerInterface_SetLocalOperatingState_Call { + return &DeviceDiagnosisServerInterface_SetLocalOperatingState_Call{Call: _e.mock.On("SetLocalOperatingState", operatingState)} +} + +func (_c *DeviceDiagnosisServerInterface_SetLocalOperatingState_Call) Run(run func(operatingState model.DeviceDiagnosisOperatingStateType)) *DeviceDiagnosisServerInterface_SetLocalOperatingState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(model.DeviceDiagnosisOperatingStateType)) + }) + return _c +} + +func (_c *DeviceDiagnosisServerInterface_SetLocalOperatingState_Call) Return() *DeviceDiagnosisServerInterface_SetLocalOperatingState_Call { + _c.Call.Return() + return _c +} + +func (_c *DeviceDiagnosisServerInterface_SetLocalOperatingState_Call) RunAndReturn(run func(model.DeviceDiagnosisOperatingStateType)) *DeviceDiagnosisServerInterface_SetLocalOperatingState_Call { + _c.Call.Return(run) + return _c +} + +// SetLocalState provides a mock function with given fields: statetate +func (_m *DeviceDiagnosisServerInterface) SetLocalState(statetate *model.DeviceDiagnosisStateDataType) { + _m.Called(statetate) +} + // DeviceDiagnosisServerInterface_SetLocalState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetLocalState' type DeviceDiagnosisServerInterface_SetLocalState_Call struct { *mock.Call } // SetLocalState is a helper method to define mock.On call -// - operatingState *model.DeviceDiagnosisStateDataType -func (_e *DeviceDiagnosisServerInterface_Expecter) SetLocalState(operatingState interface{}) *DeviceDiagnosisServerInterface_SetLocalState_Call { - return &DeviceDiagnosisServerInterface_SetLocalState_Call{Call: _e.mock.On("SetLocalState", operatingState)} +// - statetate *model.DeviceDiagnosisStateDataType +func (_e *DeviceDiagnosisServerInterface_Expecter) SetLocalState(statetate interface{}) *DeviceDiagnosisServerInterface_SetLocalState_Call { + return &DeviceDiagnosisServerInterface_SetLocalState_Call{Call: _e.mock.On("SetLocalState", statetate)} } -func (_c *DeviceDiagnosisServerInterface_SetLocalState_Call) Run(run func(operatingState *model.DeviceDiagnosisStateDataType)) *DeviceDiagnosisServerInterface_SetLocalState_Call { +func (_c *DeviceDiagnosisServerInterface_SetLocalState_Call) Run(run func(statetate *model.DeviceDiagnosisStateDataType)) *DeviceDiagnosisServerInterface_SetLocalState_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(*model.DeviceDiagnosisStateDataType)) }) diff --git a/usecases/api/cem_cevc.go b/usecases/api/cem_cevc.go index 13c18624..0b39b960 100644 --- a/usecases/api/cem_cevc.go +++ b/usecases/api/cem_cevc.go @@ -87,5 +87,19 @@ type CemCEVCInterface interface { // Scenario 5 & 6 - // this is automatically covered by the SPINE implementation + // start sending heartbeat from the local CEM entity + // + // the heartbeat is started by default when a non 0 timeout is set in the service configuration + StartHeartbeat() + + // stop sending heartbeat from the local CEM entity + StopHeartbeat() + + // Scenario 7 & 8 + + // set the local operating state of the local cem entity + // + // parameters: + // - failureState: if true, the operating state is set to failure, otherwise to normal + SetOperatingState(failureState bool) error } diff --git a/usecases/api/cem_opev.go b/usecases/api/cem_opev.go index 1746a558..c4ae2252 100644 --- a/usecases/api/cem_opev.go +++ b/usecases/api/cem_opev.go @@ -60,10 +60,19 @@ type CemOPEVInterface interface { // Scenario 2 - // this is automatically covered by the SPINE implementation + // start sending heartbeat from the local CEM entity + // + // the heartbeat is started by default when a non 0 timeout is set in the service configuration + StartHeartbeat() + + // stop sending heartbeat from the local CEM entity + StopHeartbeat() // Scenario 3 - // this is covered by the central CEM interface implementation - // use that one to set the CEM's operation state which will inform all remote devices + // set the local operating state of the local cem entity + // + // parameters: + // - failureState: if true, the operating state is set to failure, otherwise to normal + SetOperatingState(failureState bool) error } diff --git a/usecases/api/cem_oscev.go b/usecases/api/cem_oscev.go index c9cabd61..7b1f8c81 100644 --- a/usecases/api/cem_oscev.go +++ b/usecases/api/cem_oscev.go @@ -53,10 +53,19 @@ type CemOSCEVInterface interface { // Scenario 2 - // this is automatically covered by the SPINE implementation + // start sending heartbeat from the local CEM entity + // + // the heartbeat is started by default when a non 0 timeout is set in the service configuration + StartHeartbeat() + + // stop sending heartbeat from the local CEM entity + StopHeartbeat() // Scenario 3 - // this is covered by the central CEM interface implementation - // use that one to set the CEM's operation state which will inform all remote devices + // set the local operating state of the local cem entity + // + // parameters: + // - failureState: if true, the operating state is set to failure, otherwise to normal + SetOperatingState(failureState bool) error } diff --git a/usecases/api/cs_lpc.go b/usecases/api/cs_lpc.go index 9374133e..4b1d4eaa 100644 --- a/usecases/api/cs_lpc.go +++ b/usecases/api/cs_lpc.go @@ -74,7 +74,14 @@ type CsLPCInterface interface { // Scenario 3 - // this is automatically covered by the SPINE implementation + // start sending heartbeat from the local entity supporting this usecase + // + // the heartbeat is started by default when a non 0 timeout is set in the service configuration + StartHeartbeat() + + // stop sending heartbeat from the local entity supporting this usecase + StopHeartbeat() + // // returns true, if the last heartbeat is within 2 minutes, otherwise false IsHeartbeatWithinDuration() bool diff --git a/usecases/api/cs_lpp.go b/usecases/api/cs_lpp.go index 3759ff3e..752c5c1e 100644 --- a/usecases/api/cs_lpp.go +++ b/usecases/api/cs_lpp.go @@ -74,7 +74,15 @@ type CsLPPInterface interface { // Scenario 3 - // this is automatically covered by the SPINE implementation + // start sending heartbeat from the local entity supporting this usecase + // + // the heartbeat is started by default when a non 0 timeout is set in the service configuration + StartHeartbeat() + + // stop sending heartbeat from the local entity supporting this usecase + StopHeartbeat() + + // check wether there was a heartbeat received within the last 2 minutes // // returns true, if the last heartbeat is within 2 minutes, otherwise false IsHeartbeatWithinDuration() bool diff --git a/usecases/api/eg_lpc.go b/usecases/api/eg_lpc.go index cf4b8345..9b1d567e 100644 --- a/usecases/api/eg_lpc.go +++ b/usecases/api/eg_lpc.go @@ -78,7 +78,18 @@ type EgLPCInterface interface { // Scenario 3 - // this is automatically covered by the SPINE implementation + // start sending heartbeat from the local entity supporting this usecase + // + // the heartbeat is started by default when a non 0 timeout is set in the service configuration + StartHeartbeat() + + // stop sending heartbeat from the local entity supporting this usecase + StopHeartbeat() + + // check wether there was a heartbeat received within the last 2 minutes + // + // returns true, if the last heartbeat is within 2 minutes, otherwise false + IsHeartbeatWithinDuration(entity spineapi.EntityRemoteInterface) bool // Scenario 4 diff --git a/usecases/api/eg_lpp.go b/usecases/api/eg_lpp.go index 89dd89b0..9d94020d 100644 --- a/usecases/api/eg_lpp.go +++ b/usecases/api/eg_lpp.go @@ -78,7 +78,18 @@ type EgLPPInterface interface { // Scenario 3 - // this is automatically covered by the SPINE implementation + // start sending heartbeat from the local entity supporting this usecase + // + // the heartbeat is started by default when a non 0 timeout is set in the service configuration + StartHeartbeat() + + // stop sending heartbeat from the local entity supporting this usecase + StopHeartbeat() + + // check wether there was a heartbeat received within the last 2 minutes + // + // returns true, if the last heartbeat is within 2 minutes, otherwise false + IsHeartbeatWithinDuration(entity spineapi.EntityRemoteInterface) bool // Scenario 4 diff --git a/usecases/cem/cevc/public_scen58.go b/usecases/cem/cevc/public_scen58.go new file mode 100644 index 00000000..bc2940ee --- /dev/null +++ b/usecases/cem/cevc/public_scen58.go @@ -0,0 +1,45 @@ +package cevc + +import ( + "github.com/enbility/eebus-go/features/server" + "github.com/enbility/spine-go/model" +) + +// Scenario 5 & 6 + +// start sending heartbeat from the local CEM entity +// +// the heartbeat is started by default when a non 0 timeout is set in the service configuration +func (e *CEVC) StartHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + _ = hm.StartHeartbeat() + } +} + +// stop sending heartbeat from the local CEM entity +func (e *CEVC) StopHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + hm.StopHeartbeat() + } +} + +// Scenario 7 & 8 + +// set the local operating state of the local cem entity +// +// parameters: +// - failureState: if true, the operating state is set to failure, otherwise to normal +func (e *CEVC) SetOperatingState(failureState bool) error { + lf, err := server.NewDeviceDiagnosis(e.LocalEntity) + if err != nil { + return err + } + + state := model.DeviceDiagnosisOperatingStateTypeNormalOperation + if failureState { + state = model.DeviceDiagnosisOperatingStateTypeFailure + } + lf.SetLocalOperatingState(state) + + return nil +} diff --git a/usecases/cem/cevc/public_scen58_test.go b/usecases/cem/cevc/public_scen58_test.go new file mode 100644 index 00000000..e7769bed --- /dev/null +++ b/usecases/cem/cevc/public_scen58_test.go @@ -0,0 +1,11 @@ +package cevc + +func (s *CemCEVCSuite) Test_Heartbeat() { + s.sut.StartHeartbeat() + + s.sut.StopHeartbeat() +} + +func (s *CemCEVCSuite) Test_OperatingState() { + s.sut.SetOperatingState(true) +} diff --git a/usecases/cem/cevc/usecase.go b/usecases/cem/cevc/usecase.go index b3efc6eb..4996c0f8 100644 --- a/usecases/cem/cevc/usecase.go +++ b/usecases/cem/cevc/usecase.go @@ -86,4 +86,9 @@ func (e *CEVC) AddFeatures() { for _, feature := range clientFeatures { _ = e.LocalEntity.GetOrAddFeature(feature, model.RoleTypeClient) } + + // server features + f := e.LocalEntity.GetOrAddFeature(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisStateData, true, false) + f.AddFunctionType(model.FunctionTypeDeviceDiagnosisHeartbeatData, true, false) } diff --git a/usecases/cem/opev/public.go b/usecases/cem/opev/public.go index 53732d67..48baf2b4 100644 --- a/usecases/cem/opev/public.go +++ b/usecases/cem/opev/public.go @@ -3,6 +3,7 @@ package opev import ( "github.com/enbility/eebus-go/api" "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/features/server" ucapi "github.com/enbility/eebus-go/usecases/api" "github.com/enbility/eebus-go/usecases/internal" spineapi "github.com/enbility/spine-go/api" @@ -106,3 +107,42 @@ func (e *OPEV) WriteLoadControlLimits( } return internal.WriteLoadControlPhaseLimits(e.LocalEntity, entity, filter, limits, resultCB) } + +// Scenario 2 + +// start sending heartbeat from the local CEM entity +// +// the heartbeat is started by default when a non 0 timeout is set in the service configuration +func (e *OPEV) StartHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + _ = hm.StartHeartbeat() + } +} + +// stop sending heartbeat from the local CEM entity +func (e *OPEV) StopHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + hm.StopHeartbeat() + } +} + +// Scenario 3 + +// set the local operating state of the local cem entity +// +// parameters: +// - failureState: if true, the operating state is set to failure, otherwise to normal +func (e *OPEV) SetOperatingState(failureState bool) error { + lf, err := server.NewDeviceDiagnosis(e.LocalEntity) + if err != nil { + return err + } + + state := model.DeviceDiagnosisOperatingStateTypeNormalOperation + if failureState { + state = model.DeviceDiagnosisOperatingStateTypeFailure + } + lf.SetLocalOperatingState(state) + + return nil +} diff --git a/usecases/cem/opev/public_test.go b/usecases/cem/opev/public_test.go index e3b864f7..bbccf6ff 100644 --- a/usecases/cem/opev/public_test.go +++ b/usecases/cem/opev/public_test.go @@ -47,4 +47,10 @@ func (s *CemOPEVSuite) Test_Public() { _, err = s.sut.WriteLoadControlLimits(s.evEntity, []ucapi.LoadLimitsPhase{}, nil) assert.NotNil(s.T(), err) + + s.sut.StopHeartbeat() + s.sut.StartHeartbeat() + + err = s.sut.SetOperatingState(true) + assert.Nil(s.T(), err) } diff --git a/usecases/cem/oscev/public.go b/usecases/cem/oscev/public.go index 02a49760..de4cba0b 100644 --- a/usecases/cem/oscev/public.go +++ b/usecases/cem/oscev/public.go @@ -3,6 +3,7 @@ package oscev import ( "github.com/enbility/eebus-go/api" "github.com/enbility/eebus-go/features/client" + "github.com/enbility/eebus-go/features/server" ucapi "github.com/enbility/eebus-go/usecases/api" "github.com/enbility/eebus-go/usecases/internal" spineapi "github.com/enbility/spine-go/api" @@ -99,3 +100,42 @@ func (e *OSCEV) WriteLoadControlLimits( } return internal.WriteLoadControlPhaseLimits(e.LocalEntity, entity, filter, limits, resultCB) } + +// Scenario 2 + +// start sending heartbeat from the local CEM entity +// +// the heartbeat is started by default when a non 0 timeout is set in the service configuration +func (e *OSCEV) StartHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + _ = hm.StartHeartbeat() + } +} + +// stop sending heartbeat from the local CEM entity +func (e *OSCEV) StopHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + hm.StopHeartbeat() + } +} + +// Scenario 3 + +// set the local operating state of the local cem entity +// +// parameters: +// - failureState: if true, the operating state is set to failure, otherwise to normal +func (e *OSCEV) SetOperatingState(failureState bool) error { + lf, err := server.NewDeviceDiagnosis(e.LocalEntity) + if err != nil { + return err + } + + state := model.DeviceDiagnosisOperatingStateTypeNormalOperation + if failureState { + state = model.DeviceDiagnosisOperatingStateTypeFailure + } + lf.SetLocalOperatingState(state) + + return nil +} diff --git a/usecases/cem/oscev/public_test.go b/usecases/cem/oscev/public_test.go index bc996ede..50de4cb8 100644 --- a/usecases/cem/oscev/public_test.go +++ b/usecases/cem/oscev/public_test.go @@ -47,4 +47,10 @@ func (s *CemOSCEVSuite) Test_Public() { _, err = s.sut.WriteLoadControlLimits(s.evEntity, []ucapi.LoadLimitsPhase{}, nil) assert.NotNil(s.T(), err) + + s.sut.StopHeartbeat() + s.sut.StartHeartbeat() + + err = s.sut.SetOperatingState(true) + assert.Nil(s.T(), err) } diff --git a/usecases/cs/lpc/public.go b/usecases/cs/lpc/public.go index 4c6148ae..f4dafc83 100644 --- a/usecases/cs/lpc/public.go +++ b/usecases/cs/lpc/public.go @@ -258,6 +258,22 @@ func (e *LPC) SetFailsafeDurationMinimum(duration time.Duration, changeable bool // Scenario 3 +// start sending heartbeat from the local entity supporting this usecase +// +// the heartbeat is started by default when a non 0 timeout is set in the service configuration +func (e *LPC) StartHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + _ = hm.StartHeartbeat() + } +} + +// stop sending heartbeat from the local CEM entity +func (e *LPC) StopHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + hm.StopHeartbeat() + } +} + func (e *LPC) IsHeartbeatWithinDuration() bool { if e.heartbeatDiag == nil { return false diff --git a/usecases/cs/lpc/public_test.go b/usecases/cs/lpc/public_test.go index 77a5d8e1..152f4890 100644 --- a/usecases/cs/lpc/public_test.go +++ b/usecases/cs/lpc/public_test.go @@ -118,7 +118,7 @@ func (s *CsLPCSuite) Test_Failsafe() { assert.Nil(s.T(), err) } -func (s *CsLPCSuite) Test_IsHeartbeatWithinDuration() { +func (s *CsLPCSuite) Test_Heartbeat() { assert.Nil(s.T(), s.sut.heartbeatDiag) value := s.sut.IsHeartbeatWithinDuration() @@ -129,7 +129,7 @@ func (s *CsLPCSuite) Test_IsHeartbeatWithinDuration() { var err error s.sut.heartbeatDiag, err = client.NewDeviceDiagnosis(s.sut.LocalEntity, s.monitoredEntity) - assert.NotNil(s.T(), remoteDiagServer) + assert.NotNil(s.T(), s.sut.heartbeatDiag) assert.Nil(s.T(), err) // add heartbeat data to the remoteDiagServer @@ -153,6 +153,9 @@ func (s *CsLPCSuite) Test_IsHeartbeatWithinDuration() { value = s.sut.IsHeartbeatWithinDuration() assert.True(s.T(), value) + + s.sut.StopHeartbeat() + s.sut.StartHeartbeat() } func (s *CsLPCSuite) Test_ConsumptionNominalMax() { diff --git a/usecases/cs/lpp/public.go b/usecases/cs/lpp/public.go index 15d47df2..6e9af19a 100644 --- a/usecases/cs/lpp/public.go +++ b/usecases/cs/lpp/public.go @@ -258,6 +258,22 @@ func (e *LPP) SetFailsafeDurationMinimum(duration time.Duration, changeable bool // Scenario 3 +// start sending heartbeat from the local entity supporting this usecase +// +// the heartbeat is started by default when a non 0 timeout is set in the service configuration +func (e *LPP) StartHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + _ = hm.StartHeartbeat() + } +} + +// stop sending heartbeat from the local CEM entity +func (e *LPP) StopHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + hm.StopHeartbeat() + } +} + func (e *LPP) IsHeartbeatWithinDuration() bool { if e.heartbeatDiag == nil { return false diff --git a/usecases/cs/lpp/public_test.go b/usecases/cs/lpp/public_test.go index 6d911172..e768228e 100644 --- a/usecases/cs/lpp/public_test.go +++ b/usecases/cs/lpp/public_test.go @@ -117,7 +117,7 @@ func (s *CsLPPSuite) Test_Failsafe() { assert.Nil(s.T(), err) } -func (s *CsLPPSuite) Test_IsHeartbeatWithinDuration() { +func (s *CsLPPSuite) Test_Heartbeat() { assert.Nil(s.T(), s.sut.heartbeatDiag) value := s.sut.IsHeartbeatWithinDuration() @@ -128,7 +128,7 @@ func (s *CsLPPSuite) Test_IsHeartbeatWithinDuration() { var err error s.sut.heartbeatDiag, err = client.NewDeviceDiagnosis(s.sut.LocalEntity, s.monitoredEntity) - assert.NotNil(s.T(), remoteDiagServer) + assert.NotNil(s.T(), s.sut.heartbeatDiag) assert.Nil(s.T(), err) // add heartbeat data to the remoteDiagServer @@ -152,6 +152,9 @@ func (s *CsLPPSuite) Test_IsHeartbeatWithinDuration() { value = s.sut.IsHeartbeatWithinDuration() assert.True(s.T(), value) + + s.sut.StopHeartbeat() + s.sut.StartHeartbeat() } func (s *CsLPPSuite) Test_ContractualProductionNominalMax() { diff --git a/usecases/eg/lpc/public.go b/usecases/eg/lpc/public.go index 0a33f716..29b395f6 100644 --- a/usecases/eg/lpc/public.go +++ b/usecases/eg/lpc/public.go @@ -234,6 +234,36 @@ func (e *LPC) WriteFailsafeDurationMinimum(entity spineapi.EntityRemoteInterface return msgCounter, err } +// Scenario 3 + +// start sending heartbeat from the local entity supporting this usecase +// +// the heartbeat is started by default when a non 0 timeout is set in the service configuration +func (e *LPC) StartHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + _ = hm.StartHeartbeat() + } +} + +// stop sending heartbeat from the local CEM entity +func (e *LPC) StopHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + hm.StopHeartbeat() + } +} + +// check wether there was a heartbeat received within the last 2 minutes +// +// returns true, if the last heartbeat is within 2 minutes, otherwise false +func (e *LPC) IsHeartbeatWithinDuration(entity spineapi.EntityRemoteInterface) bool { + lf, err := client.NewDeviceDiagnosis(e.LocalEntity, entity) + if err != nil { + return false + } + + return lf.IsHeartbeatWithinDuration(2 * time.Minute) +} + // Scenario 4 // return nominal maximum active (real) power the Controllable System is diff --git a/usecases/eg/lpc/public_test.go b/usecases/eg/lpc/public_test.go index eec728c7..59eb3185 100644 --- a/usecases/eg/lpc/public_test.go +++ b/usecases/eg/lpc/public_test.go @@ -3,6 +3,7 @@ package lpc import ( "time" + "github.com/enbility/eebus-go/features/client" ucapi "github.com/enbility/eebus-go/usecases/api" "github.com/enbility/spine-go/model" "github.com/enbility/spine-go/util" @@ -332,6 +333,41 @@ func (s *EgLPCSuite) Test_WriteFailsafeDurationMinimum() { assert.NotNil(s.T(), err) } +func (s *EgLPCSuite) Test_Heartbeat() { + remoteDiagServer := s.monitoredEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + assert.NotNil(s.T(), remoteDiagServer) + + var err error + heartbeatDiag, err := client.NewDeviceDiagnosis(s.sut.LocalEntity, s.monitoredEntity) + assert.NotNil(s.T(), heartbeatDiag) + assert.Nil(s.T(), err) + + // add heartbeat data to the remoteDiagServer + timestamp := time.Now().Add(-time.Second * 121) + data := &model.DeviceDiagnosisHeartbeatDataType{ + Timestamp: model.NewAbsoluteOrRelativeTimeTypeFromTime(timestamp), + HeartbeatCounter: util.Ptr(uint64(1)), + HeartbeatTimeout: model.NewDurationType(time.Second * 120), + } + _, err1 := remoteDiagServer.UpdateData(true, model.FunctionTypeDeviceDiagnosisHeartbeatData, data, nil, nil) + assert.Nil(s.T(), err1) + + value := s.sut.IsHeartbeatWithinDuration(s.monitoredEntity) + assert.False(s.T(), value) + + timestamp = time.Now() + data.Timestamp = model.NewAbsoluteOrRelativeTimeTypeFromTime(timestamp) + + _, err1 = remoteDiagServer.UpdateData(true, model.FunctionTypeDeviceDiagnosisHeartbeatData, data, nil, nil) + assert.Nil(s.T(), err1) + + value = s.sut.IsHeartbeatWithinDuration(s.monitoredEntity) + assert.True(s.T(), value) + + s.sut.StopHeartbeat() + s.sut.StartHeartbeat() +} + func (s *EgLPCSuite) Test_PowerConsumptionNominalMax() { data, err := s.sut.ConsumptionNominalMax(s.mockRemoteEntity) assert.NotNil(s.T(), err) diff --git a/usecases/eg/lpp/public.go b/usecases/eg/lpp/public.go index 437ee009..1d9af3bf 100644 --- a/usecases/eg/lpp/public.go +++ b/usecases/eg/lpp/public.go @@ -233,6 +233,36 @@ func (e *LPP) WriteFailsafeDurationMinimum(entity spineapi.EntityRemoteInterface return msgCounter, err } +// Scenario 3 + +// start sending heartbeat from the local entity supporting this usecase +// +// the heartbeat is started by default when a non 0 timeout is set in the service configuration +func (e *LPP) StartHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + _ = hm.StartHeartbeat() + } +} + +// stop sending heartbeat from the local CEM entity +func (e *LPP) StopHeartbeat() { + if hm := e.LocalEntity.HeartbeatManager(); hm != nil { + hm.StopHeartbeat() + } +} + +// check wether there was a heartbeat received within the last 2 minutes +// +// returns true, if the last heartbeat is within 2 minutes, otherwise false +func (e *LPP) IsHeartbeatWithinDuration(entity spineapi.EntityRemoteInterface) bool { + lf, err := client.NewDeviceDiagnosis(e.LocalEntity, entity) + if err != nil { + return false + } + + return lf.IsHeartbeatWithinDuration(2 * time.Minute) +} + // Scenario 4 // return nominal maximum active (real) power the Controllable System is diff --git a/usecases/eg/lpp/public_test.go b/usecases/eg/lpp/public_test.go index 1b15ae92..cf6b7b97 100644 --- a/usecases/eg/lpp/public_test.go +++ b/usecases/eg/lpp/public_test.go @@ -3,6 +3,7 @@ package lpp import ( "time" + "github.com/enbility/eebus-go/features/client" ucapi "github.com/enbility/eebus-go/usecases/api" "github.com/enbility/spine-go/model" "github.com/enbility/spine-go/util" @@ -326,6 +327,41 @@ func (s *EgLPPSuite) Test_WriteFailsafeDurationMinimum() { assert.NotNil(s.T(), err) } +func (s *EgLPPSuite) Test_Heartbeat() { + remoteDiagServer := s.monitoredEntity.FeatureOfTypeAndRole(model.FeatureTypeTypeDeviceDiagnosis, model.RoleTypeServer) + assert.NotNil(s.T(), remoteDiagServer) + + var err error + heartbeatDiag, err := client.NewDeviceDiagnosis(s.sut.LocalEntity, s.monitoredEntity) + assert.NotNil(s.T(), heartbeatDiag) + assert.Nil(s.T(), err) + + // add heartbeat data to the remoteDiagServer + timestamp := time.Now().Add(-time.Second * 121) + data := &model.DeviceDiagnosisHeartbeatDataType{ + Timestamp: model.NewAbsoluteOrRelativeTimeTypeFromTime(timestamp), + HeartbeatCounter: util.Ptr(uint64(1)), + HeartbeatTimeout: model.NewDurationType(time.Second * 120), + } + _, err1 := remoteDiagServer.UpdateData(true, model.FunctionTypeDeviceDiagnosisHeartbeatData, data, nil, nil) + assert.Nil(s.T(), err1) + + value := s.sut.IsHeartbeatWithinDuration(s.monitoredEntity) + assert.False(s.T(), value) + + timestamp = time.Now() + data.Timestamp = model.NewAbsoluteOrRelativeTimeTypeFromTime(timestamp) + + _, err1 = remoteDiagServer.UpdateData(true, model.FunctionTypeDeviceDiagnosisHeartbeatData, data, nil, nil) + assert.Nil(s.T(), err1) + + value = s.sut.IsHeartbeatWithinDuration(s.monitoredEntity) + assert.True(s.T(), value) + + s.sut.StopHeartbeat() + s.sut.StartHeartbeat() +} + func (s *EgLPPSuite) Test_PowerProductionNominalMax() { data, err := s.sut.ProductionNominalMax(s.mockRemoteEntity) assert.NotNil(s.T(), err) diff --git a/usecases/mocks/CemCEVCInterface.go b/usecases/mocks/CemCEVCInterface.go index d0936bee..3954e533 100644 --- a/usecases/mocks/CemCEVCInterface.go +++ b/usecases/mocks/CemCEVCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks @@ -580,6 +580,116 @@ func (_c *CemCEVCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemCEVC return _c } +// SetOperatingState provides a mock function with given fields: failureState +func (_m *CemCEVCInterface) SetOperatingState(failureState bool) error { + ret := _m.Called(failureState) + + if len(ret) == 0 { + panic("no return value specified for SetOperatingState") + } + + var r0 error + if rf, ok := ret.Get(0).(func(bool) error); ok { + r0 = rf(failureState) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CemCEVCInterface_SetOperatingState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetOperatingState' +type CemCEVCInterface_SetOperatingState_Call struct { + *mock.Call +} + +// SetOperatingState is a helper method to define mock.On call +// - failureState bool +func (_e *CemCEVCInterface_Expecter) SetOperatingState(failureState interface{}) *CemCEVCInterface_SetOperatingState_Call { + return &CemCEVCInterface_SetOperatingState_Call{Call: _e.mock.On("SetOperatingState", failureState)} +} + +func (_c *CemCEVCInterface_SetOperatingState_Call) Run(run func(failureState bool)) *CemCEVCInterface_SetOperatingState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemCEVCInterface_SetOperatingState_Call) Return(_a0 error) *CemCEVCInterface_SetOperatingState_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemCEVCInterface_SetOperatingState_Call) RunAndReturn(run func(bool) error) *CemCEVCInterface_SetOperatingState_Call { + _c.Call.Return(run) + return _c +} + +// StartHeartbeat provides a mock function with given fields: +func (_m *CemCEVCInterface) StartHeartbeat() { + _m.Called() +} + +// CemCEVCInterface_StartHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartHeartbeat' +type CemCEVCInterface_StartHeartbeat_Call struct { + *mock.Call +} + +// StartHeartbeat is a helper method to define mock.On call +func (_e *CemCEVCInterface_Expecter) StartHeartbeat() *CemCEVCInterface_StartHeartbeat_Call { + return &CemCEVCInterface_StartHeartbeat_Call{Call: _e.mock.On("StartHeartbeat")} +} + +func (_c *CemCEVCInterface_StartHeartbeat_Call) Run(run func()) *CemCEVCInterface_StartHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemCEVCInterface_StartHeartbeat_Call) Return() *CemCEVCInterface_StartHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CemCEVCInterface_StartHeartbeat_Call) RunAndReturn(run func()) *CemCEVCInterface_StartHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// StopHeartbeat provides a mock function with given fields: +func (_m *CemCEVCInterface) StopHeartbeat() { + _m.Called() +} + +// CemCEVCInterface_StopHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopHeartbeat' +type CemCEVCInterface_StopHeartbeat_Call struct { + *mock.Call +} + +// StopHeartbeat is a helper method to define mock.On call +func (_e *CemCEVCInterface_Expecter) StopHeartbeat() *CemCEVCInterface_StopHeartbeat_Call { + return &CemCEVCInterface_StopHeartbeat_Call{Call: _e.mock.On("StopHeartbeat")} +} + +func (_c *CemCEVCInterface_StopHeartbeat_Call) Run(run func()) *CemCEVCInterface_StopHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemCEVCInterface_StopHeartbeat_Call) Return() *CemCEVCInterface_StopHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CemCEVCInterface_StopHeartbeat_Call) RunAndReturn(run func()) *CemCEVCInterface_StopHeartbeat_Call { + _c.Call.Return(run) + return _c +} + // TimeSlotConstraints provides a mock function with given fields: entity func (_m *CemCEVCInterface) TimeSlotConstraints(entity spine_goapi.EntityRemoteInterface) (api.TimeSlotConstraints, error) { ret := _m.Called(entity) diff --git a/usecases/mocks/CemOPEVInterface.go b/usecases/mocks/CemOPEVInterface.go index 6966e141..50b42384 100644 --- a/usecases/mocks/CemOPEVInterface.go +++ b/usecases/mocks/CemOPEVInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks @@ -444,6 +444,116 @@ func (_c *CemOPEVInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemOPEV return _c } +// SetOperatingState provides a mock function with given fields: failureState +func (_m *CemOPEVInterface) SetOperatingState(failureState bool) error { + ret := _m.Called(failureState) + + if len(ret) == 0 { + panic("no return value specified for SetOperatingState") + } + + var r0 error + if rf, ok := ret.Get(0).(func(bool) error); ok { + r0 = rf(failureState) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CemOPEVInterface_SetOperatingState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetOperatingState' +type CemOPEVInterface_SetOperatingState_Call struct { + *mock.Call +} + +// SetOperatingState is a helper method to define mock.On call +// - failureState bool +func (_e *CemOPEVInterface_Expecter) SetOperatingState(failureState interface{}) *CemOPEVInterface_SetOperatingState_Call { + return &CemOPEVInterface_SetOperatingState_Call{Call: _e.mock.On("SetOperatingState", failureState)} +} + +func (_c *CemOPEVInterface_SetOperatingState_Call) Run(run func(failureState bool)) *CemOPEVInterface_SetOperatingState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemOPEVInterface_SetOperatingState_Call) Return(_a0 error) *CemOPEVInterface_SetOperatingState_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOPEVInterface_SetOperatingState_Call) RunAndReturn(run func(bool) error) *CemOPEVInterface_SetOperatingState_Call { + _c.Call.Return(run) + return _c +} + +// StartHeartbeat provides a mock function with given fields: +func (_m *CemOPEVInterface) StartHeartbeat() { + _m.Called() +} + +// CemOPEVInterface_StartHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartHeartbeat' +type CemOPEVInterface_StartHeartbeat_Call struct { + *mock.Call +} + +// StartHeartbeat is a helper method to define mock.On call +func (_e *CemOPEVInterface_Expecter) StartHeartbeat() *CemOPEVInterface_StartHeartbeat_Call { + return &CemOPEVInterface_StartHeartbeat_Call{Call: _e.mock.On("StartHeartbeat")} +} + +func (_c *CemOPEVInterface_StartHeartbeat_Call) Run(run func()) *CemOPEVInterface_StartHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOPEVInterface_StartHeartbeat_Call) Return() *CemOPEVInterface_StartHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOPEVInterface_StartHeartbeat_Call) RunAndReturn(run func()) *CemOPEVInterface_StartHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// StopHeartbeat provides a mock function with given fields: +func (_m *CemOPEVInterface) StopHeartbeat() { + _m.Called() +} + +// CemOPEVInterface_StopHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopHeartbeat' +type CemOPEVInterface_StopHeartbeat_Call struct { + *mock.Call +} + +// StopHeartbeat is a helper method to define mock.On call +func (_e *CemOPEVInterface_Expecter) StopHeartbeat() *CemOPEVInterface_StopHeartbeat_Call { + return &CemOPEVInterface_StopHeartbeat_Call{Call: _e.mock.On("StopHeartbeat")} +} + +func (_c *CemOPEVInterface_StopHeartbeat_Call) Run(run func()) *CemOPEVInterface_StopHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOPEVInterface_StopHeartbeat_Call) Return() *CemOPEVInterface_StopHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOPEVInterface_StopHeartbeat_Call) RunAndReturn(run func()) *CemOPEVInterface_StopHeartbeat_Call { + _c.Call.Return(run) + return _c +} + // UpdateUseCaseAvailability provides a mock function with given fields: available func (_m *CemOPEVInterface) UpdateUseCaseAvailability(available bool) { _m.Called(available) diff --git a/usecases/mocks/CemOSCEVInterface.go b/usecases/mocks/CemOSCEVInterface.go index 28fdf4db..60636687 100644 --- a/usecases/mocks/CemOSCEVInterface.go +++ b/usecases/mocks/CemOSCEVInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks @@ -444,6 +444,116 @@ func (_c *CemOSCEVInterface_RemoveUseCase_Call) RunAndReturn(run func()) *CemOSC return _c } +// SetOperatingState provides a mock function with given fields: failureState +func (_m *CemOSCEVInterface) SetOperatingState(failureState bool) error { + ret := _m.Called(failureState) + + if len(ret) == 0 { + panic("no return value specified for SetOperatingState") + } + + var r0 error + if rf, ok := ret.Get(0).(func(bool) error); ok { + r0 = rf(failureState) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// CemOSCEVInterface_SetOperatingState_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetOperatingState' +type CemOSCEVInterface_SetOperatingState_Call struct { + *mock.Call +} + +// SetOperatingState is a helper method to define mock.On call +// - failureState bool +func (_e *CemOSCEVInterface_Expecter) SetOperatingState(failureState interface{}) *CemOSCEVInterface_SetOperatingState_Call { + return &CemOSCEVInterface_SetOperatingState_Call{Call: _e.mock.On("SetOperatingState", failureState)} +} + +func (_c *CemOSCEVInterface_SetOperatingState_Call) Run(run func(failureState bool)) *CemOSCEVInterface_SetOperatingState_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *CemOSCEVInterface_SetOperatingState_Call) Return(_a0 error) *CemOSCEVInterface_SetOperatingState_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *CemOSCEVInterface_SetOperatingState_Call) RunAndReturn(run func(bool) error) *CemOSCEVInterface_SetOperatingState_Call { + _c.Call.Return(run) + return _c +} + +// StartHeartbeat provides a mock function with given fields: +func (_m *CemOSCEVInterface) StartHeartbeat() { + _m.Called() +} + +// CemOSCEVInterface_StartHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartHeartbeat' +type CemOSCEVInterface_StartHeartbeat_Call struct { + *mock.Call +} + +// StartHeartbeat is a helper method to define mock.On call +func (_e *CemOSCEVInterface_Expecter) StartHeartbeat() *CemOSCEVInterface_StartHeartbeat_Call { + return &CemOSCEVInterface_StartHeartbeat_Call{Call: _e.mock.On("StartHeartbeat")} +} + +func (_c *CemOSCEVInterface_StartHeartbeat_Call) Run(run func()) *CemOSCEVInterface_StartHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOSCEVInterface_StartHeartbeat_Call) Return() *CemOSCEVInterface_StartHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOSCEVInterface_StartHeartbeat_Call) RunAndReturn(run func()) *CemOSCEVInterface_StartHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// StopHeartbeat provides a mock function with given fields: +func (_m *CemOSCEVInterface) StopHeartbeat() { + _m.Called() +} + +// CemOSCEVInterface_StopHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopHeartbeat' +type CemOSCEVInterface_StopHeartbeat_Call struct { + *mock.Call +} + +// StopHeartbeat is a helper method to define mock.On call +func (_e *CemOSCEVInterface_Expecter) StopHeartbeat() *CemOSCEVInterface_StopHeartbeat_Call { + return &CemOSCEVInterface_StopHeartbeat_Call{Call: _e.mock.On("StopHeartbeat")} +} + +func (_c *CemOSCEVInterface_StopHeartbeat_Call) Run(run func()) *CemOSCEVInterface_StopHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CemOSCEVInterface_StopHeartbeat_Call) Return() *CemOSCEVInterface_StopHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CemOSCEVInterface_StopHeartbeat_Call) RunAndReturn(run func()) *CemOSCEVInterface_StopHeartbeat_Call { + _c.Call.Return(run) + return _c +} + // UpdateUseCaseAvailability provides a mock function with given fields: available func (_m *CemOSCEVInterface) UpdateUseCaseAvailability(available bool) { _m.Called(available) diff --git a/usecases/mocks/CsLPCInterface.go b/usecases/mocks/CsLPCInterface.go index e5d65d3e..c8e1ac4a 100644 --- a/usecases/mocks/CsLPCInterface.go +++ b/usecases/mocks/CsLPCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks @@ -859,6 +859,70 @@ func (_c *CsLPCInterface_SetFailsafeDurationMinimum_Call) RunAndReturn(run func( return _c } +// StartHeartbeat provides a mock function with given fields: +func (_m *CsLPCInterface) StartHeartbeat() { + _m.Called() +} + +// CsLPCInterface_StartHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartHeartbeat' +type CsLPCInterface_StartHeartbeat_Call struct { + *mock.Call +} + +// StartHeartbeat is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) StartHeartbeat() *CsLPCInterface_StartHeartbeat_Call { + return &CsLPCInterface_StartHeartbeat_Call{Call: _e.mock.On("StartHeartbeat")} +} + +func (_c *CsLPCInterface_StartHeartbeat_Call) Run(run func()) *CsLPCInterface_StartHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_StartHeartbeat_Call) Return() *CsLPCInterface_StartHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPCInterface_StartHeartbeat_Call) RunAndReturn(run func()) *CsLPCInterface_StartHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// StopHeartbeat provides a mock function with given fields: +func (_m *CsLPCInterface) StopHeartbeat() { + _m.Called() +} + +// CsLPCInterface_StopHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopHeartbeat' +type CsLPCInterface_StopHeartbeat_Call struct { + *mock.Call +} + +// StopHeartbeat is a helper method to define mock.On call +func (_e *CsLPCInterface_Expecter) StopHeartbeat() *CsLPCInterface_StopHeartbeat_Call { + return &CsLPCInterface_StopHeartbeat_Call{Call: _e.mock.On("StopHeartbeat")} +} + +func (_c *CsLPCInterface_StopHeartbeat_Call) Run(run func()) *CsLPCInterface_StopHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPCInterface_StopHeartbeat_Call) Return() *CsLPCInterface_StopHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPCInterface_StopHeartbeat_Call) RunAndReturn(run func()) *CsLPCInterface_StopHeartbeat_Call { + _c.Call.Return(run) + return _c +} + // UpdateUseCaseAvailability provides a mock function with given fields: available func (_m *CsLPCInterface) UpdateUseCaseAvailability(available bool) { _m.Called(available) diff --git a/usecases/mocks/CsLPPInterface.go b/usecases/mocks/CsLPPInterface.go index 984c610a..c2b07f16 100644 --- a/usecases/mocks/CsLPPInterface.go +++ b/usecases/mocks/CsLPPInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks @@ -859,6 +859,70 @@ func (_c *CsLPPInterface_SetProductionNominalMax_Call) RunAndReturn(run func(flo return _c } +// StartHeartbeat provides a mock function with given fields: +func (_m *CsLPPInterface) StartHeartbeat() { + _m.Called() +} + +// CsLPPInterface_StartHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartHeartbeat' +type CsLPPInterface_StartHeartbeat_Call struct { + *mock.Call +} + +// StartHeartbeat is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) StartHeartbeat() *CsLPPInterface_StartHeartbeat_Call { + return &CsLPPInterface_StartHeartbeat_Call{Call: _e.mock.On("StartHeartbeat")} +} + +func (_c *CsLPPInterface_StartHeartbeat_Call) Run(run func()) *CsLPPInterface_StartHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_StartHeartbeat_Call) Return() *CsLPPInterface_StartHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPPInterface_StartHeartbeat_Call) RunAndReturn(run func()) *CsLPPInterface_StartHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// StopHeartbeat provides a mock function with given fields: +func (_m *CsLPPInterface) StopHeartbeat() { + _m.Called() +} + +// CsLPPInterface_StopHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopHeartbeat' +type CsLPPInterface_StopHeartbeat_Call struct { + *mock.Call +} + +// StopHeartbeat is a helper method to define mock.On call +func (_e *CsLPPInterface_Expecter) StopHeartbeat() *CsLPPInterface_StopHeartbeat_Call { + return &CsLPPInterface_StopHeartbeat_Call{Call: _e.mock.On("StopHeartbeat")} +} + +func (_c *CsLPPInterface_StopHeartbeat_Call) Run(run func()) *CsLPPInterface_StopHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *CsLPPInterface_StopHeartbeat_Call) Return() *CsLPPInterface_StopHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *CsLPPInterface_StopHeartbeat_Call) RunAndReturn(run func()) *CsLPPInterface_StopHeartbeat_Call { + _c.Call.Return(run) + return _c +} + // UpdateUseCaseAvailability provides a mock function with given fields: available func (_m *CsLPPInterface) UpdateUseCaseAvailability(available bool) { _m.Called(available) diff --git a/usecases/mocks/EgLPCInterface.go b/usecases/mocks/EgLPCInterface.go index d727d4f6..d4f6f349 100644 --- a/usecases/mocks/EgLPCInterface.go +++ b/usecases/mocks/EgLPCInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks @@ -410,6 +410,52 @@ func (_c *EgLPCInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spin return _c } +// IsHeartbeatWithinDuration provides a mock function with given fields: entity +func (_m *EgLPCInterface) IsHeartbeatWithinDuration(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsHeartbeatWithinDuration") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// EgLPCInterface_IsHeartbeatWithinDuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsHeartbeatWithinDuration' +type EgLPCInterface_IsHeartbeatWithinDuration_Call struct { + *mock.Call +} + +// IsHeartbeatWithinDuration is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPCInterface_Expecter) IsHeartbeatWithinDuration(entity interface{}) *EgLPCInterface_IsHeartbeatWithinDuration_Call { + return &EgLPCInterface_IsHeartbeatWithinDuration_Call{Call: _e.mock.On("IsHeartbeatWithinDuration", entity)} +} + +func (_c *EgLPCInterface_IsHeartbeatWithinDuration_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPCInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPCInterface_IsHeartbeatWithinDuration_Call) Return(_a0 bool) *EgLPCInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPCInterface_IsHeartbeatWithinDuration_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *EgLPCInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(run) + return _c +} + // IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario func (_m *EgLPCInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { ret := _m.Called(entity, scenario) @@ -536,6 +582,70 @@ func (_c *EgLPCInterface_RemoveUseCase_Call) RunAndReturn(run func()) *EgLPCInte return _c } +// StartHeartbeat provides a mock function with given fields: +func (_m *EgLPCInterface) StartHeartbeat() { + _m.Called() +} + +// EgLPCInterface_StartHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartHeartbeat' +type EgLPCInterface_StartHeartbeat_Call struct { + *mock.Call +} + +// StartHeartbeat is a helper method to define mock.On call +func (_e *EgLPCInterface_Expecter) StartHeartbeat() *EgLPCInterface_StartHeartbeat_Call { + return &EgLPCInterface_StartHeartbeat_Call{Call: _e.mock.On("StartHeartbeat")} +} + +func (_c *EgLPCInterface_StartHeartbeat_Call) Run(run func()) *EgLPCInterface_StartHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPCInterface_StartHeartbeat_Call) Return() *EgLPCInterface_StartHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPCInterface_StartHeartbeat_Call) RunAndReturn(run func()) *EgLPCInterface_StartHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// StopHeartbeat provides a mock function with given fields: +func (_m *EgLPCInterface) StopHeartbeat() { + _m.Called() +} + +// EgLPCInterface_StopHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopHeartbeat' +type EgLPCInterface_StopHeartbeat_Call struct { + *mock.Call +} + +// StopHeartbeat is a helper method to define mock.On call +func (_e *EgLPCInterface_Expecter) StopHeartbeat() *EgLPCInterface_StopHeartbeat_Call { + return &EgLPCInterface_StopHeartbeat_Call{Call: _e.mock.On("StopHeartbeat")} +} + +func (_c *EgLPCInterface_StopHeartbeat_Call) Run(run func()) *EgLPCInterface_StopHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPCInterface_StopHeartbeat_Call) Return() *EgLPCInterface_StopHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPCInterface_StopHeartbeat_Call) RunAndReturn(run func()) *EgLPCInterface_StopHeartbeat_Call { + _c.Call.Return(run) + return _c +} + // UpdateUseCaseAvailability provides a mock function with given fields: available func (_m *EgLPCInterface) UpdateUseCaseAvailability(available bool) { _m.Called(available) diff --git a/usecases/mocks/EgLPPInterface.go b/usecases/mocks/EgLPPInterface.go index dddd2fc2..b18ea631 100644 --- a/usecases/mocks/EgLPPInterface.go +++ b/usecases/mocks/EgLPPInterface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.43.2. DO NOT EDIT. +// Code generated by mockery v2.45.0. DO NOT EDIT. package mocks @@ -298,6 +298,52 @@ func (_c *EgLPPInterface_IsCompatibleEntityType_Call) RunAndReturn(run func(spin return _c } +// IsHeartbeatWithinDuration provides a mock function with given fields: entity +func (_m *EgLPPInterface) IsHeartbeatWithinDuration(entity spine_goapi.EntityRemoteInterface) bool { + ret := _m.Called(entity) + + if len(ret) == 0 { + panic("no return value specified for IsHeartbeatWithinDuration") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(spine_goapi.EntityRemoteInterface) bool); ok { + r0 = rf(entity) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// EgLPPInterface_IsHeartbeatWithinDuration_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsHeartbeatWithinDuration' +type EgLPPInterface_IsHeartbeatWithinDuration_Call struct { + *mock.Call +} + +// IsHeartbeatWithinDuration is a helper method to define mock.On call +// - entity spine_goapi.EntityRemoteInterface +func (_e *EgLPPInterface_Expecter) IsHeartbeatWithinDuration(entity interface{}) *EgLPPInterface_IsHeartbeatWithinDuration_Call { + return &EgLPPInterface_IsHeartbeatWithinDuration_Call{Call: _e.mock.On("IsHeartbeatWithinDuration", entity)} +} + +func (_c *EgLPPInterface_IsHeartbeatWithinDuration_Call) Run(run func(entity spine_goapi.EntityRemoteInterface)) *EgLPPInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(spine_goapi.EntityRemoteInterface)) + }) + return _c +} + +func (_c *EgLPPInterface_IsHeartbeatWithinDuration_Call) Return(_a0 bool) *EgLPPInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EgLPPInterface_IsHeartbeatWithinDuration_Call) RunAndReturn(run func(spine_goapi.EntityRemoteInterface) bool) *EgLPPInterface_IsHeartbeatWithinDuration_Call { + _c.Call.Return(run) + return _c +} + // IsScenarioAvailableAtEntity provides a mock function with given fields: entity, scenario func (_m *EgLPPInterface) IsScenarioAvailableAtEntity(entity spine_goapi.EntityRemoteInterface, scenario uint) bool { ret := _m.Called(entity, scenario) @@ -536,6 +582,70 @@ func (_c *EgLPPInterface_RemoveUseCase_Call) RunAndReturn(run func()) *EgLPPInte return _c } +// StartHeartbeat provides a mock function with given fields: +func (_m *EgLPPInterface) StartHeartbeat() { + _m.Called() +} + +// EgLPPInterface_StartHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StartHeartbeat' +type EgLPPInterface_StartHeartbeat_Call struct { + *mock.Call +} + +// StartHeartbeat is a helper method to define mock.On call +func (_e *EgLPPInterface_Expecter) StartHeartbeat() *EgLPPInterface_StartHeartbeat_Call { + return &EgLPPInterface_StartHeartbeat_Call{Call: _e.mock.On("StartHeartbeat")} +} + +func (_c *EgLPPInterface_StartHeartbeat_Call) Run(run func()) *EgLPPInterface_StartHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPPInterface_StartHeartbeat_Call) Return() *EgLPPInterface_StartHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPPInterface_StartHeartbeat_Call) RunAndReturn(run func()) *EgLPPInterface_StartHeartbeat_Call { + _c.Call.Return(run) + return _c +} + +// StopHeartbeat provides a mock function with given fields: +func (_m *EgLPPInterface) StopHeartbeat() { + _m.Called() +} + +// EgLPPInterface_StopHeartbeat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'StopHeartbeat' +type EgLPPInterface_StopHeartbeat_Call struct { + *mock.Call +} + +// StopHeartbeat is a helper method to define mock.On call +func (_e *EgLPPInterface_Expecter) StopHeartbeat() *EgLPPInterface_StopHeartbeat_Call { + return &EgLPPInterface_StopHeartbeat_Call{Call: _e.mock.On("StopHeartbeat")} +} + +func (_c *EgLPPInterface_StopHeartbeat_Call) Run(run func()) *EgLPPInterface_StopHeartbeat_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EgLPPInterface_StopHeartbeat_Call) Return() *EgLPPInterface_StopHeartbeat_Call { + _c.Call.Return() + return _c +} + +func (_c *EgLPPInterface_StopHeartbeat_Call) RunAndReturn(run func()) *EgLPPInterface_StopHeartbeat_Call { + _c.Call.Return(run) + return _c +} + // UpdateUseCaseAvailability provides a mock function with given fields: available func (_m *EgLPPInterface) UpdateUseCaseAvailability(available bool) { _m.Called(available)