Skip to content

Commit

Permalink
Merge branch 'release/v0.6.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndereAndi committed Aug 12, 2024
2 parents 105fc17 + 3a63976 commit 6bddfe6
Show file tree
Hide file tree
Showing 42 changed files with 904 additions and 327 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# eebus-go

[![Build Status](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=main)](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=main)
[![Build Status](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=master)](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=master)
[![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4)](https://godoc.org/github.com/enbility/eebus-go)
[![Coverage Status](https://coveralls.io/repos/github/enbility/eebus-go/badge.svg?branch=main)](https://coveralls.io/github/enbility/eebus-go?branch=main)
[![Coverage Status](https://coveralls.io/repos/github/enbility/eebus-go/badge.svg?branch=master)](https://coveralls.io/github/enbility/eebus-go?branch=master)
[![Go report](https://goreportcard.com/badge/github.com/enbility/eebus-go)](https://goreportcard.com/report/github.com/enbility/eebus-go)
[![CodeFactor](https://www.codefactor.io/repository/github/enbility/eebus-go/badge)](https://www.codefactor.io/repository/github/enbility/eebus-go)

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/enbility/eebus-go
go 1.21.1

require (
github.com/enbility/ship-go v0.5.2
github.com/enbility/spine-go v0.6.1
github.com/enbility/ship-go v0.5.3
github.com/enbility/spine-go v0.6.2
github.com/stretchr/testify v1.9.0
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ github.com/ahmetb/go-linq/v3 v3.2.0 h1:BEuMfp+b59io8g5wYzNoFe9pWPalRklhlhbiU3hYZ
github.com/ahmetb/go-linq/v3 v3.2.0/go.mod h1:haQ3JfOeWK8HpVxMtHHEMPVgBKiYyQ+f1/kLZh/cj9U=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/enbility/ship-go v0.5.2 h1:T9+YuP5ZpofKd463PLKq78fAaPAcGMnRAcv8c8aD5yU=
github.com/enbility/ship-go v0.5.2/go.mod h1:jewJWYQ10jNhsnhS1C4jESx3CNmDa5HNWZjBhkTug5Y=
github.com/enbility/spine-go v0.6.1 h1:6NAPE7PmCQsmfiZy/dLpnFZXEw8RK9H4USGniIw9r+Q=
github.com/enbility/spine-go v0.6.1/go.mod h1:pRGS+C5rZ5rhxTAA1whU8fC9p7lH5ixyut++yEZe470=
github.com/enbility/ship-go v0.5.3 h1:P8eA/WDz3hq18zEKzqCB697OA1sVFiZkTF51Cx4tyGU=
github.com/enbility/ship-go v0.5.3/go.mod h1:jewJWYQ10jNhsnhS1C4jESx3CNmDa5HNWZjBhkTug5Y=
github.com/enbility/spine-go v0.6.2 h1:uxEUGLcaaA3PzkaTYTe4Ic64PElFlMQcfcES0O4Dk1c=
github.com/enbility/spine-go v0.6.2/go.mod h1:6AbRXzd0fLVGFJdT60YQACe1WskwdjiznCfljQ+Ud6s=
github.com/enbility/zeroconf/v2 v2.0.0-20240210101930-d0004078577b h1:sg3c6LJ4eWffwtt9SW0lgcIX4Oh274vwdJnNFNNrDco=
github.com/enbility/zeroconf/v2 v2.0.0-20240210101930-d0004078577b/go.mod h1:BjzRRiYX6mWdOgku1xxDE+NsV8PijTby7Q7BkYVdfDU=
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=
Expand Down
18 changes: 11 additions & 7 deletions usecases/api/cs_lpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,18 @@ type CsLPCInterface interface {

// Scenario 4

// return nominal maximum active (real) power the Controllable System is
// allowed to consume due to the customer's contract.
ContractualConsumptionNominalMax() (float64, error)
// return nominal maximum active (real) power the Controllable System is allowed to consume.
//
// If the local device type is an EnergyManagementSystem, the contractual consumption
// nominal max is returned, otherwise the power consumption nominal max is returned.
ConsumptionNominalMax() (float64, error)

// set nominal maximum active (real) power the Controllable System is
// allowed to consume due to the customer's contract.
// set power nominal maximum active (real) power the Controllable System is allowed to consume.
//
// If the local device type is an EnergyManagementSystem, the contractual consumption
// nominal max is set, otherwise the power consumption nominal max is set.
//
// parameters:
// - value: contractual nominal max power consumption in W
SetContractualConsumptionNominalMax(value float64) (resultErr error)
// - value: nominal max power consumption in W
SetConsumptionNominalMax(value float64) (resultErr error)
}
18 changes: 11 additions & 7 deletions usecases/api/cs_lpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,18 @@ type CsLPPInterface interface {

// Scenario 4

// return nominal maximum active (real) power the Controllable System is
// allowed to produce due to the customer's contract.
ContractualProductionNominalMax() (float64, error)
// return nominal maximum active (real) power the Controllable System is allowed to produce.
//
// If the local device type is an EnergyManagementSystem, the contractual production
// nominal max is returned, otherwise the power production nominal max is returned.
ProductionNominalMax() (float64, error)

// set nominal maximum active (real) power the Controllable System is
// allowed to produce due to the customer's contract.
// set power nominal maximum active (real) power the Controllable System is allowed to produce.
//
// If the local device type is an EnergyManagementSystem, the contractual production
// nominal max is set, otherwise the power production nominal max is set.
//
// parameters:
// - value: contractual nominal max power production in W
SetContractualProductionNominalMax(value float64) (resultErr error)
// - value: nominal max power production in W
SetProductionNominalMax(value float64) (resultErr error)
}
4 changes: 2 additions & 2 deletions usecases/api/eg_lpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ type EgLPCInterface interface {
// Scenario 4

// return nominal maximum active (real) power the Controllable System is
// able to consume according to the device label or data sheet.
// able to consume according to the contract (EMS), device label or data sheet.
//
// parameters:
// - entity: the entity of the e.g. EVSE
PowerConsumptionNominalMax(entity spineapi.EntityRemoteInterface) (float64, error)
ConsumptionNominalMax(entity spineapi.EntityRemoteInterface) (float64, error)
}
4 changes: 2 additions & 2 deletions usecases/api/eg_lpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ type EgLPPInterface interface {
// Scenario 4

// return nominal maximum active (real) power the Controllable System is
// able to produce according to the device label or data sheet.
// able to produce according to the contract (EMS), device label or data sheet.
//
// parameters:
// - entity: the entity of the e.g. EVSE
PowerProductionNominalMax(entity spineapi.EntityRemoteInterface) (float64, error)
ProductionNominalMax(entity spineapi.EntityRemoteInterface) (float64, error)
}
4 changes: 2 additions & 2 deletions usecases/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ type LoadLimitsPhase struct {
Phase model.ElectricalConnectionPhaseNameType // the phase
IsChangeable bool // if the value can be changed via write, ignored when writing data
IsActive bool // if the limit is active
Value float64 // the limit in A
Value float64 // the limit
}

// Defines a limit data set
type LoadLimit struct {
Duration time.Duration // the duration of the limit,
IsChangeable bool // if the value can be changed via write, ignored when writing data
IsActive bool // if the limit is active
Value float64 // the limit in A
Value float64 // the limit
}

// identification
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/cevc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cevc
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-cevc-UseCaseSupportUpdate"
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/evcc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const (
)

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-evcc-UseCaseSupportUpdate"
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/evcem/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package evcem
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-evcem-UseCaseSupportUpdate"
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/evsecc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package evsecc
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remotei entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-evsecc-UseCaseSupportUpdate"
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/evsoc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package evsoc
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-evsoc-UseCaseSupportUpdate"
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/opev/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package opev
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-opev-UseCaseSupportUpdate"
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/oscev/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package oscev
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-oscev-UseCaseSupportUpdate"
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/vabd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package vabd
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-vabd-UseCaseSupportUpdate"
Expand Down
2 changes: 1 addition & 1 deletion usecases/cem/vapd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package vapd
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cem-vapd-UseCaseSupportUpdate"
Expand Down
16 changes: 8 additions & 8 deletions usecases/cs/lpc/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ func (e *LPC) deviceConnected(payload spineapi.EventPayload) {
// check if there is a DeviceDiagnosis server on one or more entities
remoteDevice := payload.Device

var deviceDiagEntites []spineapi.EntityRemoteInterface
var deviceDiagEntities []spineapi.EntityRemoteInterface

entites := remoteDevice.Entities()
for _, entity := range entites {
entities := remoteDevice.Entities()
for _, entity := range entities {
if !e.IsCompatibleEntityType(entity) {
continue
}
Expand All @@ -88,19 +88,19 @@ func (e *LPC) deviceConnected(payload spineapi.EventPayload) {
continue
}

deviceDiagEntites = append(deviceDiagEntites, entity)
deviceDiagEntities = append(deviceDiagEntities, entity)
}

logging.Log().Debug("cs-lpc:", len(deviceDiagEntites), "DeviceDiagnosis Server found")
logging.Log().Debug("cs-lpc:", len(deviceDiagEntities), "DeviceDiagnosis Server found")

// the remote device does not have a DeviceDiagnosis Server, which it should
if len(deviceDiagEntites) == 0 {
if len(deviceDiagEntities) == 0 {
return
}

// we only found one matching entity, as it should be, subscribe
if len(deviceDiagEntites) == 1 {
if localDeviceDiag, err := client.NewDeviceDiagnosis(e.LocalEntity, deviceDiagEntites[0]); err == nil {
if len(deviceDiagEntities) == 1 {
if localDeviceDiag, err := client.NewDeviceDiagnosis(e.LocalEntity, deviceDiagEntities[0]); err == nil {
e.heartbeatDiag = localDeviceDiag
if _, err := localDeviceDiag.Subscribe(); err != nil {
logging.Log().Debug(err)
Expand Down
2 changes: 1 addition & 1 deletion usecases/cs/lpc/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (s *CsLPCSuite) Test_multipleDeviceDiagServer() {
},
}
var featureInformations []model.NodeManagementDetailedDiscoveryFeatureInformationType
// 4 entites
// 4 entities
for i := 1; i < 5; i++ {
for index, feature := range remoteFeatures {
supportedFcts := []model.FunctionPropertyType{}
Expand Down
38 changes: 30 additions & 8 deletions usecases/cs/lpc/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,11 @@ func (e *LPC) IsHeartbeatWithinDuration() bool {

// Scenario 4

// return nominal maximum active (real) power the Controllable System is
// allowed to consume due to the customer's contract.
func (e *LPC) ContractualConsumptionNominalMax() (value float64, resultErr error) {
// return nominal maximum active (real) power the Controllable System is allowed to consume.
//
// If the local device type is an EnergyManagementSystem, the contractual consumption
// nominal max is returned, otherwise the power consumption nominal max is returned.
func (e *LPC) ConsumptionNominalMax() (value float64, resultErr error) {
value = 0
resultErr = api.ErrDataNotAvailable

Expand All @@ -301,7 +303,7 @@ func (e *LPC) ContractualConsumptionNominalMax() (value float64, resultErr error
ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)),
ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(0)),
CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity),
CharacteristicType: util.Ptr(model.ElectricalConnectionCharacteristicTypeTypeContractualConsumptionNominalMax),
CharacteristicType: util.Ptr(e.characteristicType()),
}
charData, err := ec.GetCharacteristicsForFilter(filter)
if err != nil || len(charData) == 0 ||
Expand All @@ -313,9 +315,14 @@ func (e *LPC) ContractualConsumptionNominalMax() (value float64, resultErr error
return charData[0].Value.GetValue(), nil
}

// set nominal maximum active (real) power the Controllable System is
// allowed to consume due to the customer's contract.
func (e *LPC) SetContractualConsumptionNominalMax(value float64) error {
// set nominal maximum active (real) power the Controllable System is allowed to consume.
//
// If the local device type is an EnergyManagementSystem, the contractual consumption
// nominal max is set, otherwise the power consumption nominal max is set.
//
// parameters:
// - value: nominal max power consumption in W
func (e *LPC) SetConsumptionNominalMax(value float64) error {
ec, err := server.NewElectricalConnection(e.LocalEntity)
if err != nil {
return err
Expand All @@ -327,7 +334,7 @@ func (e *LPC) SetContractualConsumptionNominalMax(value float64) error {
ElectricalConnectionId: electricalConnectionid,
ParameterId: parameterId,
CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity),
CharacteristicType: util.Ptr(model.ElectricalConnectionCharacteristicTypeTypeContractualConsumptionNominalMax),
CharacteristicType: util.Ptr(e.characteristicType()),
})
if err != nil || len(charList) == 0 {
return api.ErrDataNotAvailable
Expand All @@ -341,3 +348,18 @@ func (e *LPC) SetContractualConsumptionNominalMax(value float64) error {
}
return ec.UpdateCharacteristic(data, nil)
}

// returns the characteristictype depending on the local entities device devicetype
func (e *LPC) characteristicType() model.ElectricalConnectionCharacteristicTypeType {
deviceType := e.LocalEntity.Device().DeviceType()

// According to LPC V1.0 2.2, lines 400ff:
// - a HEMS provides contractual consumption nominal max
// - any other devices provides power consupmtion nominal max
characteristic := model.ElectricalConnectionCharacteristicTypeTypePowerConsumptionNominalMax
if deviceType == nil || *deviceType == model.DeviceTypeTypeEnergyManagementSystem {
characteristic = model.ElectricalConnectionCharacteristicTypeTypeContractualConsumptionNominalMax
}

return characteristic
}
8 changes: 4 additions & 4 deletions usecases/cs/lpc/public_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ func (s *CsLPCSuite) Test_IsHeartbeatWithinDuration() {
assert.True(s.T(), value)
}

func (s *CsLPCSuite) Test_ContractualConsumptionNominalMax() {
value, err := s.sut.ContractualConsumptionNominalMax()
func (s *CsLPCSuite) Test_ConsumptionNominalMax() {
value, err := s.sut.ConsumptionNominalMax()
assert.Equal(s.T(), 0.0, value)
assert.NotNil(s.T(), err)

err = s.sut.SetContractualConsumptionNominalMax(10)
err = s.sut.SetConsumptionNominalMax(10)
assert.Nil(s.T(), err)

value, err = s.sut.ContractualConsumptionNominalMax()
value, err = s.sut.ConsumptionNominalMax()
assert.Equal(s.T(), 10.0, value)
assert.Nil(s.T(), err)
}
2 changes: 1 addition & 1 deletion usecases/cs/lpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package lpc
import "github.com/enbility/eebus-go/api"

const (
// Update of the list of remote entites supporting the Use Case
// Update of the list of remote entities supporting the Use Case
//
// Use `RemoteEntities` to get the current data
UseCaseSupportUpdate api.EventType = "cs-lpc-UseCaseSupportUpdate"
Expand Down
21 changes: 14 additions & 7 deletions usecases/cs/lpc/usecase.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,19 @@ func (e *LPC) AddFeatures() {
Unit: util.Ptr(model.UnitOfMeasurementTypeW),
},
)
dcs.AddKeyValueDescription(
model.DeviceConfigurationKeyValueDescriptionDataType{
KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum),
ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeDuration),
},
)

// only add if it doesn't exist yet
filter := model.DeviceConfigurationKeyValueDescriptionDataType{
KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum),
}
if data, err := dcs.GetKeyValueDescriptionsForFilter(filter); err == nil && len(data) == 0 {
dcs.AddKeyValueDescription(
model.DeviceConfigurationKeyValueDescriptionDataType{
KeyName: util.Ptr(model.DeviceConfigurationKeyNameTypeFailsafeDurationMinimum),
ValueType: util.Ptr(model.DeviceConfigurationKeyValueTypeTypeDuration),
},
)
}

value := &model.DeviceConfigurationKeyValueValueType{
ScaledNumber: model.NewScaledNumberType(0),
Expand Down Expand Up @@ -238,7 +245,7 @@ func (e *LPC) AddFeatures() {
ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)),
ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(0)),
CharacteristicContext: util.Ptr(model.ElectricalConnectionCharacteristicContextTypeEntity),
CharacteristicType: util.Ptr(model.ElectricalConnectionCharacteristicTypeTypeContractualConsumptionNominalMax),
CharacteristicType: util.Ptr(e.characteristicType()),
Unit: util.Ptr(model.UnitOfMeasurementTypeW),
}
_, _ = ec.AddCharacteristic(newCharData)
Expand Down
Loading

0 comments on commit 6bddfe6

Please sign in to comment.