Skip to content

Commit

Permalink
Add missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Oct 9, 2024
1 parent 087f015 commit 49f2bc4
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
45 changes: 45 additions & 0 deletions usecases/cem/cevc/public_scen58.go
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 11 additions & 0 deletions usecases/cem/cevc/public_scen58_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 49f2bc4

Please sign in to comment.