Skip to content
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Commit 5faa7c7

Browse files
committed
Various updates
- Update to latest spine and eebus libs - Do not save features but check for them every time needed
1 parent b49d80e commit 5faa7c7

29 files changed

+630
-583
lines changed

emobility/api.go

+24-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package emobility
22

3+
import "github.com/enbility/spine-go/api"
4+
35
//go:generate mockgen -source emobility.go -destination mock_emobility_test.go -package emobility
46

57
// used by emobility and implemented by the CEM
@@ -43,48 +45,48 @@ type EmobilityDataProvider interface {
4345
// used by the CEM and implemented by emobility
4446
type EMobilityInterface interface {
4547
// return if an EV is connected
46-
EVConnected() bool
48+
EVConnected(remoteEntity api.EntityRemoteInterface) bool
4749

4850
// return the current charge state of the EV
49-
EVCurrentChargeState() (EVChargeStateType, error)
51+
EVCurrentChargeState(remoteEntity api.EntityRemoteInterface) (EVChargeStateType, error)
5052

5153
// return the number of ac connected phases of the EV or 0 if it is unknown
52-
EVConnectedPhases() (uint, error)
54+
EVConnectedPhases(remoteEntity api.EntityRemoteInterface) (uint, error)
5355

5456
// return the charged energy measurement in Wh of the connected EV
5557
//
5658
// possible errors:
5759
// - ErrDataNotAvailable if no such measurement is (yet) available
5860
// - and others
59-
EVChargedEnergy() (float64, error)
61+
EVChargedEnergy(remoteEntity api.EntityRemoteInterface) (float64, error)
6062

6163
// return the last power measurement for each phase of the connected EV
6264
//
6365
// possible errors:
6466
// - ErrDataNotAvailable if no such measurement is (yet) available
6567
// - and others
66-
EVPowerPerPhase() ([]float64, error)
68+
EVPowerPerPhase(remoteEntity api.EntityRemoteInterface) ([]float64, error)
6769

6870
// return the last current measurement for each phase of the connected EV
6971
//
7072
// possible errors:
7173
// - ErrDataNotAvailable if no such measurement is (yet) available
7274
// - and others
73-
EVCurrentsPerPhase() ([]float64, error)
75+
EVCurrentsPerPhase(remoteEntity api.EntityRemoteInterface) ([]float64, error)
7476

7577
// return the min, max, default limits for each phase of the connected EV
7678
//
7779
// possible errors:
7880
// - ErrDataNotAvailable if no such measurement is (yet) available
7981
// - and others
80-
EVCurrentLimits() ([]float64, []float64, []float64, error)
82+
EVCurrentLimits(remoteEntity api.EntityRemoteInterface) ([]float64, []float64, []float64, error)
8183

8284
// return the current loadcontrol obligation limits
8385
//
8486
// possible errors:
8587
// - ErrDataNotAvailable if no such measurement is (yet) available
8688
// - and others
87-
EVLoadControlObligationLimits() ([]float64, error)
89+
EVLoadControlObligationLimits(remoteEntity api.EntityRemoteInterface) ([]float64, error)
8890

8991
// send new LoadControlLimits to the remote EV
9092
//
@@ -113,7 +115,7 @@ type EMobilityInterface interface {
113115
// In ISO15118-2 the usecase is only supported via VAS extensions which are vendor specific
114116
// and needs to have specific EVSE support for the specific EV brand.
115117
// In ISO15118-20 this is a standard feature which does not need special support on the EVSE.
116-
EVWriteLoadControlLimits(limits []EVLoadLimits) error
118+
EVWriteLoadControlLimits(remoteEntity api.EntityRemoteInterface, limits []EVLoadLimits) error
117119

118120
// return the current communication standard type used to communicate between EVSE and EV
119121
//
@@ -130,21 +132,21 @@ type EMobilityInterface interface {
130132
// - ErrDataNotAvailable if that information is not (yet) available
131133
// - ErrNotSupported if getting the communication standard is not supported
132134
// - and others
133-
EVCommunicationStandard() (EVCommunicationStandardType, error)
135+
EVCommunicationStandard(remoteEntity api.EntityRemoteInterface) (EVCommunicationStandardType, error)
134136

135137
// returns the identification of the currently connected EV or nil if not available
136138
//
137139
// possible errors:
138140
// - ErrDataNotAvailable if that information is not (yet) available
139141
// - and others
140-
EVIdentification() (string, error)
142+
EVIdentification(remoteEntity api.EntityRemoteInterface) (string, error)
141143

142144
// returns if the EVSE and EV combination support optimzation of self consumption
143145
//
144146
// possible errors:
145147
// - ErrDataNotAvailable if that information is not (yet) available
146148
// - and others
147-
EVOptimizationOfSelfConsumptionSupported() (bool, error)
149+
EVOptimizationOfSelfConsumptionSupported(remoteEntity api.EntityRemoteInterface) (bool, error)
148150

149151
// return if the EVSE and EV combination support providing an SoC
150152
//
@@ -155,7 +157,7 @@ type EMobilityInterface interface {
155157
// possible errors:
156158
// - ErrDataNotAvailable if no such measurement is (yet) available
157159
// - and others
158-
EVSoCSupported() (bool, error)
160+
EVSoCSupported(remoteEntity api.EntityRemoteInterface) (bool, error)
159161

160162
// return the last known SoC of the connected EV
161163
//
@@ -167,57 +169,57 @@ type EMobilityInterface interface {
167169
// - ErrNotSupported if support for SoC is not possible
168170
// - ErrDataNotAvailable if no such measurement is (yet) available
169171
// - and others
170-
EVSoC() (float64, error)
172+
EVSoC(remoteEntity api.EntityRemoteInterface) (float64, error)
171173

172174
// returns if the EVSE and EV combination support coordinated charging
173175
//
174176
// possible errors:
175177
// - ErrDataNotAvailable if that information is not (yet) available
176178
// - and others
177-
EVCoordinatedChargingSupported() (bool, error)
179+
EVCoordinatedChargingSupported(remoteEntity api.EntityRemoteInterface) (bool, error)
178180

179181
// returns the current charging stratey
180182
//
181183
// returns EVChargeStrategyTypeUnknown if it could not be determined, e.g.
182184
// if the vehicle communication is via IEC61851 or the EV doesn't provide
183185
// any information about its charging mode or plan
184-
EVChargeStrategy() EVChargeStrategyType
186+
EVChargeStrategy(remoteEntity api.EntityRemoteInterface) EVChargeStrategyType
185187

186188
// returns the current energy demand
187189
// - EVDemand: details about the actual demands from the EV
188190
// - error: if no data is available
189191
//
190192
// if duration is 0, direct charging is active, otherwise timed charging is active
191-
EVEnergyDemand() (EVDemand, error)
193+
EVEnergyDemand(remoteEntity api.EntityRemoteInterface) (EVDemand, error)
192194

193195
// returns the current charge plan
194196
// - EVChargePlan: details about the actual charge plan provided by the EV
195197
// - error: if no data is available
196-
EVChargePlan() (EVChargePlan, error)
198+
EVChargePlan(remoteEntity api.EntityRemoteInterface) (EVChargePlan, error)
197199

198200
// returns the constraints for the time slots
199201
// - EVTimeSlotConstraints: details about the time slot constraints
200202
// - error: if no data is available
201-
EVTimeSlotConstraints() (EVTimeSlotConstraints, error)
203+
EVTimeSlotConstraints(remoteEntity api.EntityRemoteInterface) (EVTimeSlotConstraints, error)
202204

203205
// send power limits data to the EV
204206
//
205207
// returns an error if sending failed or charge slot count do not meet requirements
206208
//
207209
// this needs to be invoked either <55s, idealy <15s, of receiving a call to EVRequestPowerLimits
208210
// or if the CEM requires the EV to change its charge plan
209-
EVWritePowerLimits(data []EVDurationSlotValue) error
211+
EVWritePowerLimits(remoteEntity api.EntityRemoteInterface, data []EVDurationSlotValue) error
210212

211213
// returns the constraints for incentive slots
212214
// - EVIncentiveConstraints: details about the incentive slot constraints
213215
// - error: if no data is available
214-
EVIncentiveConstraints() (EVIncentiveSlotConstraints, error)
216+
EVIncentiveConstraints(remoteEntity api.EntityRemoteInterface) (EVIncentiveSlotConstraints, error)
215217

216218
// send price slots data to the EV
217219
//
218220
// returns an error if sending failed or charge slot count do not meet requirements
219221
//
220222
// this needs to be invoked either within 20s of receiving a call to EVRequestIncentives
221223
// or if the CEM requires the EV to change its charge plan
222-
EVWriteIncentives(data []EVDurationSlotValue) error
224+
EVWriteIncentives(remoteEntity api.EntityRemoteInterface, data []EVDurationSlotValue) error
223225
}

emobility/emobility.go

-14
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package emobility
22

33
import (
44
"github.com/enbility/eebus-go/api"
5-
"github.com/enbility/eebus-go/features"
65
shipapi "github.com/enbility/ship-go/api"
76
"github.com/enbility/ship-go/util"
87
spineapi "github.com/enbility/spine-go/api"
@@ -18,19 +17,6 @@ type EMobility struct {
1817
evseEntity spineapi.EntityRemoteInterface
1918
evEntity spineapi.EntityRemoteInterface
2019

21-
evseDeviceClassification *features.DeviceClassification
22-
evseDeviceDiagnosis *features.DeviceDiagnosis
23-
24-
evDeviceClassification *features.DeviceClassification
25-
evDeviceDiagnosis *features.DeviceDiagnosis
26-
evDeviceConfiguration *features.DeviceConfiguration
27-
evElectricalConnection *features.ElectricalConnection
28-
evMeasurement *features.Measurement
29-
evIdentification *features.Identification
30-
evLoadControl *features.LoadControl
31-
evTimeSeries *features.TimeSeries
32-
evIncentiveTable *features.IncentiveTable
33-
3420
evCurrentChargeStrategy EVChargeStrategyType
3521

3622
ski string

emobility/evcoordinatedcharging_test.go

+11-7
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,22 @@ import (
66

77
"github.com/enbility/eebus-go/util"
88
"github.com/enbility/spine-go/api"
9+
"github.com/enbility/spine-go/mocks"
910
"github.com/enbility/spine-go/model"
1011
"github.com/stretchr/testify/assert"
12+
"github.com/stretchr/testify/mock"
1113
gomock "go.uber.org/mock/gomock"
1214
)
1315

1416
func Test_CoordinatedChargingScenarios(t *testing.T) {
1517
emobility, eebusService := setupEmobility(t)
1618

17-
data, err := emobility.EVChargedEnergy()
19+
mockRemoteDevice := mocks.NewDeviceRemoteInterface(t)
20+
mockRemoteEntity := mocks.NewEntityRemoteInterface(t)
21+
mockRemoteFeature := mocks.NewFeatureRemoteInterface(t)
22+
mockRemoteDevice.EXPECT().FeatureByEntityTypeAndRole(mock.Anything, mock.Anything, mock.Anything).Return(mockRemoteFeature)
23+
mockRemoteEntity.EXPECT().Device().Return(mockRemoteDevice)
24+
data, err := emobility.EVChargedEnergy(mockRemoteEntity)
1825
assert.NotNil(t, err)
1926
assert.Equal(t, 0.0, data)
2027

@@ -27,9 +34,6 @@ func Test_CoordinatedChargingScenarios(t *testing.T) {
2734
dataProviderMock := NewMockEmobilityDataProvider(ctrl)
2835
emobility.dataProvider = dataProviderMock
2936

30-
emobility.evTimeSeries = timeSeriesConfiguration(localEntity, emobility.evEntity)
31-
emobility.evIncentiveTable = incentiveTableConfiguration(localEntity, emobility.evEntity)
32-
3337
datagramtt := datagramForEntityAndFeatures(false, localDevice, localEntity, emobility.evEntity, model.FeatureTypeTypeTimeSeries, model.RoleTypeServer, model.RoleTypeClient)
3438
datagramit := datagramForEntityAndFeatures(false, localDevice, localEntity, emobility.evEntity, model.FeatureTypeTypeIncentiveTable, model.RoleTypeServer, model.RoleTypeClient)
3539

@@ -63,7 +67,7 @@ func Test_CoordinatedChargingScenarios(t *testing.T) {
6367
err = localDevice.ProcessCmd(datagramtt, remoteDevice)
6468
assert.Nil(t, err)
6569

66-
demand, err := emobility.EVEnergyDemand()
70+
demand, err := emobility.EVEnergyDemand(emobility.evEntity)
6771
assert.Nil(t, err)
6872
assert.Equal(t, 0.0, demand.MinDemand)
6973
assert.Equal(t, 0.0, demand.OptDemand)
@@ -141,7 +145,7 @@ func Test_CoordinatedChargingScenarios(t *testing.T) {
141145
err = localDevice.ProcessCmd(datagramtt, remoteDevice)
142146
assert.Nil(t, err)
143147

144-
demand, err = emobility.EVEnergyDemand()
148+
demand, err = emobility.EVEnergyDemand(emobility.evEntity)
145149
assert.Nil(t, err)
146150
assert.Equal(t, 0.0, demand.MinDemand)
147151
assert.Equal(t, 53400.0, demand.OptDemand)
@@ -235,7 +239,7 @@ func Test_CoordinatedChargingScenarios(t *testing.T) {
235239
err = localDevice.ProcessCmd(datagramtt, remoteDevice)
236240
assert.Nil(t, err)
237241

238-
demand, err = emobility.EVEnergyDemand()
242+
demand, err = emobility.EVEnergyDemand(emobility.evEntity)
239243
assert.Nil(t, err)
240244
assert.Equal(t, 600.0, demand.MinDemand)
241245
assert.Equal(t, 600.0, demand.OptDemand)

0 commit comments

Comments
 (0)