Skip to content

Commit

Permalink
Update SPINE and adopt heartbeats per local entity
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Sep 15, 2024
1 parent e7bda97 commit d392fce
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
3 changes: 2 additions & 1 deletion api/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ type Configuration struct {
// The certificate used for the service and its connections, required
certificate tls.Certificate

// The timeout to be used for sending heartbeats
// The timeout to be used for sending heartbeats and applied to all
// local entities created on setup the service
heartbeatTimeout time.Duration

// Optional set which mDNS providers should be used
Expand Down
4 changes: 2 additions & 2 deletions features/client/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func setupFeatures(
dataCon shipapi.ShipConnectionDataWriterInterface,
featureFunctions []featureFunctions) (spineapi.EntityLocalInterface, spineapi.EntityRemoteInterface) {
localDevice := spine.NewDeviceLocal("TestBrandName", "TestDeviceModel", "TestSerialNumber", "TestDeviceCode",
"TestDeviceAddress", model.DeviceTypeTypeEnergyManagementSystem, model.NetworkManagementFeatureSetTypeSmart, time.Second*4)
localEntity := spine.NewEntityLocal(localDevice, model.EntityTypeTypeCEM, spine.NewAddressEntityType([]uint{1}))
"TestDeviceAddress", model.DeviceTypeTypeEnergyManagementSystem, model.NetworkManagementFeatureSetTypeSmart)
localEntity := spine.NewEntityLocal(localDevice, model.EntityTypeTypeCEM, spine.NewAddressEntityType([]uint{1}), time.Second*4)

for i, item := range featureFunctions {
f := spine.NewFeatureLocal(uint(i+1), localEntity, item.featureType, model.RoleTypeClient)
Expand Down
4 changes: 2 additions & 2 deletions features/internal/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func setupFeatures(
featureFunctions []featureFunctions,
) (spineapi.EntityLocalInterface, spineapi.EntityRemoteInterface) {
localDevice := spine.NewDeviceLocal("TestBrandName", "TestDeviceModel", "TestSerialNumber", "TestDeviceCode",
"TestDeviceAddress", model.DeviceTypeTypeEnergyManagementSystem, model.NetworkManagementFeatureSetTypeSmart, time.Second*4)
localEntity := spine.NewEntityLocal(localDevice, model.EntityTypeTypeCEM, spine.NewAddressEntityType([]uint{1}))
"TestDeviceAddress", model.DeviceTypeTypeEnergyManagementSystem, model.NetworkManagementFeatureSetTypeSmart)
localEntity := spine.NewEntityLocal(localDevice, model.EntityTypeTypeCEM, spine.NewAddressEntityType([]uint{1}), time.Second*4)

for i, item := range featureFunctions {
f := spine.NewFeatureLocal(uint(i+1), localEntity, item.featureType, model.RoleTypeClient)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.1

require (
github.com/enbility/ship-go v0.0.0-20240909200111-0d37cebbfc21
github.com/enbility/spine-go v0.0.0-20240911140055-b637b5392906
github.com/enbility/spine-go v0.0.0-20240915104201-575c4bb4751a
github.com/stretchr/testify v1.9.0
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a h1:foChWb8lhzqa6
github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a/go.mod h1:H64mhYcAQUGUUnVqMdZQf93kPecH4M79xwH95Lddt3U=
github.com/enbility/ship-go v0.0.0-20240909200111-0d37cebbfc21 h1:ZuOja5wms/Yujch+f1wQAw5ASY8mEFUpqf/j2LFrjzA=
github.com/enbility/ship-go v0.0.0-20240909200111-0d37cebbfc21/go.mod h1:8EaCKa2WOVZ/4SpquvZStPakEarjRXQLNHhC4azvaA0=
github.com/enbility/spine-go v0.0.0-20240911140055-b637b5392906 h1:/jhq32DUM6vj/mUwy0134PP6wtP7Rm8SI5tmixZhE4I=
github.com/enbility/spine-go v0.0.0-20240911140055-b637b5392906/go.mod h1:BDvhbs+XsWDGYwd8eQOzPXc8w/avVFmWKLlSKV/gx9k=
github.com/enbility/spine-go v0.0.0-20240915104201-575c4bb4751a h1:S2oeUCg0lnlWIl/CQoB+DGGEyyhtJ5Fxxd1qnRV5pfI=
github.com/enbility/spine-go v0.0.0-20240915104201-575c4bb4751a/go.mod h1:BDvhbs+XsWDGYwd8eQOzPXc8w/avVFmWKLlSKV/gx9k=
github.com/enbility/zeroconf/v2 v2.0.0-20240827101515-f3956627c450 h1:39tnpfiV5OVfYb9sOqYmoivBzTHyNLWSYIxd9Qng1eg=
github.com/enbility/zeroconf/v2 v2.0.0-20240827101515-f3956627c450/go.mod h1:1sUbJ+VE7yLNyRzGoCMjoDWtdZ+bW4aYBKx2+Rw+9hs=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/emobility_measurement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ type EmobilityMeasurementSuite struct {

func (s *EmobilityMeasurementSuite) BeforeTest(suiteName, testName string) {
s.sut = spine.NewDeviceLocal("TestBrandName", "TestDeviceModel", "TestSerialNumber", "TestDeviceCode",
"TestDeviceAddress", model.DeviceTypeTypeEnergyManagementSystem, model.NetworkManagementFeatureSetTypeSmart, time.Second*4)
s.localEntity = spine.NewEntityLocal(s.sut, model.EntityTypeTypeCEM, spine.NewAddressEntityType([]uint{1}))
"TestDeviceAddress", model.DeviceTypeTypeEnergyManagementSystem, model.NetworkManagementFeatureSetTypeSmart)
s.localEntity = spine.NewEntityLocal(s.sut, model.EntityTypeTypeCEM, spine.NewAddressEntityType([]uint{1}), time.Second*4)
s.sut.AddEntity(s.localEntity)

f := spine.NewFeatureLocal(1, s.localEntity, model.FeatureTypeTypeElectricalConnection, model.RoleTypeClient)
Expand Down
3 changes: 1 addition & 2 deletions service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,13 @@ func (s *Service) Setup() error {
deviceAddress,
sd.DeviceType(),
sd.FeatureSet(),
sd.HeartbeatTimeout(),
)

// Create the device entities and add it to the SPINE device
for _, entityType := range sd.EntityTypes() {
entityAddressId := model.AddressEntityType(len(s.spineLocalDevice.Entities()))
entityAddress := []model.AddressEntityType{entityAddressId}
entity := spine.NewEntityLocal(s.spineLocalDevice, entityType, entityAddress)
entity := spine.NewEntityLocal(s.spineLocalDevice, entityType, entityAddress, sd.HeartbeatTimeout())
s.spineLocalDevice.AddEntity(entity)
}

Expand Down

0 comments on commit d392fce

Please sign in to comment.