From 49f2bc4e0bff9e940832bc5e356da047798d0519 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Wed, 9 Oct 2024 17:49:54 +0200 Subject: [PATCH] Add missing files --- usecases/cem/cevc/public_scen58.go | 45 +++++++++++++++++++++++++ usecases/cem/cevc/public_scen58_test.go | 11 ++++++ 2 files changed, 56 insertions(+) create mode 100644 usecases/cem/cevc/public_scen58.go create mode 100644 usecases/cem/cevc/public_scen58_test.go 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) +}