Skip to content

Commit 8641db6

Browse files
Merge branch 'dev' into fix/filterLimitsByUnitInOpevAndOscev
2 parents e14ed01 + cec3695 commit 8641db6

30 files changed

+226
-31
lines changed

api/usecases_test.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package api
2+
3+
import (
4+
"encoding/json"
5+
"testing"
6+
7+
"github.com/enbility/spine-go/mocks"
8+
"github.com/enbility/spine-go/model"
9+
"github.com/enbility/spine-go/spine"
10+
11+
"github.com/stretchr/testify/assert"
12+
)
13+
14+
func Test_RemoteEntityScenarios_Marshal(t *testing.T) {
15+
item := RemoteEntityScenarios{
16+
Entity: nil,
17+
Scenarios: nil,
18+
}
19+
value, err := json.Marshal(item)
20+
assert.Nil(t, err)
21+
assert.NotNil(t, value)
22+
assert.Equal(t, `{"Entity":null,"Scenarios":null}`, string(value))
23+
24+
item = RemoteEntityScenarios{
25+
Entity: nil,
26+
Scenarios: []uint{1, 2, 3},
27+
}
28+
value, err = json.Marshal(item)
29+
assert.Nil(t, err)
30+
assert.NotNil(t, value)
31+
assert.Equal(t, `{"Entity":null,"Scenarios":[1,2,3]}`, string(value))
32+
33+
device := mocks.NewDeviceRemoteInterface(t)
34+
deviceAddress := model.AddressDeviceType("test")
35+
device.EXPECT().Address().Return(&deviceAddress).Times(1)
36+
entity := spine.NewEntityRemote(device, model.EntityTypeTypeCEM, []model.AddressEntityType{1, 1})
37+
38+
item = RemoteEntityScenarios{
39+
Entity: entity,
40+
Scenarios: []uint{1, 2, 3},
41+
}
42+
value, err = json.Marshal(item)
43+
assert.Nil(t, err)
44+
assert.NotNil(t, value)
45+
assert.Equal(t, `{"Entity":{"Device":"test","Entity":[1,1]},"Scenarios":[1,2,3]}`, string(value))
46+
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ module github.com/enbility/eebus-go
33
go 1.22.0
44

55
require (
6-
github.com/enbility/ship-go v0.0.0-20241006160314-3a4325a1a6d6
7-
github.com/enbility/spine-go v0.0.0-20241007182100-30ee8bc405a7
6+
github.com/enbility/ship-go v0.0.0-20241118145930-d68708c5f1c0
7+
github.com/enbility/spine-go v0.0.0-20241118145803-0589320ceced
88
github.com/stretchr/testify v1.9.0
99
golang.org/x/exp/jsonrpc2 v0.0.0-20240909161429-701f63a606c0
1010
)

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a h1:foChWb8lhzqa6lWDRs6COYMdp649YlUirFP8GqoT0JQ=
66
github.com/enbility/go-avahi v0.0.0-20240909195612-d5de6b280d7a/go.mod h1:H64mhYcAQUGUUnVqMdZQf93kPecH4M79xwH95Lddt3U=
7-
github.com/enbility/ship-go v0.0.0-20241006160314-3a4325a1a6d6 h1:bjrcJ4wxEsG5rXHlXnedRzqAV9JYglj82S14Nf1oLvs=
8-
github.com/enbility/ship-go v0.0.0-20241006160314-3a4325a1a6d6/go.mod h1:JJp8EQcJhUhTpZ2LSEU4rpdaM3E2n08tswWFWtmm/wU=
9-
github.com/enbility/spine-go v0.0.0-20241007182100-30ee8bc405a7 h1:n6tv+YUMncSR9qxUs6k7d/YsKD9ujHHp5pUspIvM6sc=
10-
github.com/enbility/spine-go v0.0.0-20241007182100-30ee8bc405a7/go.mod h1:ZoI9TaJO/So/677uknrli8sc6iryD7wC5iWhVIre+MI=
7+
github.com/enbility/ship-go v0.0.0-20241118145930-d68708c5f1c0 h1:Z8j/N4DgUL8T8mINkHdq0bUbKcWtwDpno0bsKOGahPo=
8+
github.com/enbility/ship-go v0.0.0-20241118145930-d68708c5f1c0/go.mod h1:JJp8EQcJhUhTpZ2LSEU4rpdaM3E2n08tswWFWtmm/wU=
9+
github.com/enbility/spine-go v0.0.0-20241118145803-0589320ceced h1:Z2WrJ+ku7lPZqJ+uzqvIqdMpXqvAZRB3J3xW592pDXI=
10+
github.com/enbility/spine-go v0.0.0-20241118145803-0589320ceced/go.mod h1:ZoI9TaJO/So/677uknrli8sc6iryD7wC5iWhVIre+MI=
1111
github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6 h1:XOYvxKtT1oxT37w/5oEiRLuPbm9FuJPt3fiYhX0h8Po=
1212
github.com/enbility/zeroconf/v2 v2.0.0-20240920094356-be1cae74fda6/go.mod h1:BszP9qFV14mPXgyIREbgIdQtWxbAj3OKqvK02HihMoM=
1313
github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk=

usecases/cem/cevc/public_scen2.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,9 @@ func (e *CEVC) WritePowerLimits(entity spineapi.EntityRemoteInterface, data []uc
104104
for index, slot := range data {
105105
relativeStart := totalDuration
106106

107+
slotid := uint(index) //nolint:gosec // disable G115
107108
timeSeriesSlot := model.TimeSeriesSlotType{
108-
TimeSeriesSlotId: util.Ptr(model.TimeSeriesSlotIdType(index)),
109+
TimeSeriesSlotId: util.Ptr(model.TimeSeriesSlotIdType(slotid)),
109110
TimePeriod: &model.TimePeriodType{
110111
StartTime: model.NewAbsoluteOrRelativeTimeTypeFromDuration(relativeStart),
111112
},

usecases/cem/cevc/usecase.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ type CEVC struct {
1515

1616
var _ ucapi.CemCEVCInterface = (*CEVC)(nil)
1717

18+
// Add support for the Coordinated EV Charging (CEVC) use case
19+
// as a CEM actor
20+
//
21+
// Parameters:
22+
// - localEntity: The local entity which should support the use case
23+
// - eventCB: The callback to be called when an event is triggered (optional, can be nil)
1824
func NewCEVC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *CEVC {
1925
validActorTypes := []model.UseCaseActorType{
2026
model.UseCaseActorTypeEV,

usecases/cem/evcc/usecase.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ type EVCC struct {
1717

1818
var _ ucapi.CemEVCCInterface = (*EVCC)(nil)
1919

20+
// Add support for the EV Commissioning and Configuration (EVCEM) use case
21+
// as a CEM actor
22+
//
23+
// Parameters:
24+
// - service: The service implementation
25+
// - localEntity: The local entity which should support the use case
26+
// - eventCB: The callback to be called when an event is triggered (optional, can be nil)
2027
func NewEVCC(
2128
service api.ServiceInterface,
2229
localEntity spineapi.EntityLocalInterface,

usecases/cem/evcem/usecase.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,18 @@ type EVCEM struct {
1717

1818
var _ ucapi.CemEVCEMInterface = (*EVCEM)(nil)
1919

20-
func NewEVCEM(service api.ServiceInterface, localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *EVCEM {
20+
// Add support for the Measurement of Electricity during EV Charging (EVCEM) use case
21+
// as a CEM actor
22+
//
23+
// Parameters:
24+
// - service: The service implementation
25+
// - localEntity: The local entity which should support the use case
26+
// - eventCB: The callback to be called when an event is triggered (optional, can be nil)
27+
func NewEVCEM(
28+
service api.ServiceInterface,
29+
localEntity spineapi.EntityLocalInterface,
30+
eventCB api.EntityEventCallback,
31+
) *EVCEM {
2132
validActorTypes := []model.UseCaseActorType{
2233
model.UseCaseActorTypeEV,
2334
}

usecases/cem/evsecc/usecase.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ type EVSECC struct {
1515

1616
var _ ucapi.CemEVSECCInterface = (*EVSECC)(nil)
1717

18+
// Add support for the EVSE Commmissioning and Configuration (EVSECC) use case
19+
// as a CEM actor
20+
//
21+
// Parameters:
22+
// - localEntity: The local entity which should support the use case
23+
// - eventCB: The callback to be called when an event is triggered (optional, can be nil)
1824
func NewEVSECC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *EVSECC {
1925
validActorTypes := []model.UseCaseActorType{
2026
model.UseCaseActorTypeEVSE,

usecases/cem/evsoc/usecase.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ type EVSOC struct {
1515

1616
var _ ucapi.CemEVSOCInterface = (*EVSOC)(nil)
1717

18+
// Add support for the EV State of Charge (EVSOC) use case
19+
// as a CEM actor
20+
//
21+
// Parameters:
22+
// - localEntity: The local entity which should support the use case
23+
// - eventCB: The callback to be called when an event is triggered (optional, can be nil)
1824
func NewEVSOC(localEntity spineapi.EntityLocalInterface, eventCB api.EntityEventCallback) *EVSOC {
1925
validActorTypes := []model.UseCaseActorType{
2026
model.UseCaseActorTypeEV,
@@ -64,5 +70,8 @@ func (e *EVSOC) AddFeatures() {
6470
}
6571

6672
func (e *EVSOC) UpdateUseCaseAvailability(available bool) {
67-
e.LocalEntity.SetUseCaseAvailability(model.UseCaseActorTypeCEM, e.UseCaseName, available)
73+
e.LocalEntity.SetUseCaseAvailability(model.UseCaseFilterType{
74+
Actor: model.UseCaseActorTypeCEM,
75+
UseCaseName: e.UseCaseName,
76+
}, available)
6877
}

usecases/cem/opev/events.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ func (e *OPEV) HandleEvent(payload spineapi.EventPayload) {
3939
}
4040
}
4141

42+
// TODOS:
43+
// - wie gehen wir damit um, wenn subscriptions nicht erfolgreich sind
44+
// - wie gehen wir damit um, wenn bindings nicht erfolgreich sind, z.b. write implementierungen müssen prüfen ob ein binding exisiteirt
45+
// könnte prüfen ob ein binding exisitert, wenn nicht gleich einen fehler zurückliefern
46+
// - wie gehen wir damit um, wenn descriptions nicht abgefragt werden können
47+
// - wie, wenn die einen Fehler zurückgeben
48+
4249
// an EV was connected
4350
func (e *OPEV) evConnected(entity spineapi.EntityRemoteInterface) {
4451
// initialise features, e.g. subscriptions, descriptions

0 commit comments

Comments
 (0)