Skip to content

Commit ec402c2

Browse files
Move and update api.ManufacturerData (#139)
- move api.ManufacturerData to usecases/api - fix serialization not to use SPINE schema
2 parents 7fb578c + e8d33b6 commit ec402c2

File tree

9 files changed

+46
-42
lines changed

9 files changed

+46
-42
lines changed

api/usecases.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,3 @@ type UseCaseInterface interface {
5959
// add the features
6060
AddFeatures()
6161
}
62-
63-
type ManufacturerData struct {
64-
DeviceName string `json:"deviceName,omitempty"`
65-
DeviceCode string `json:"deviceCode,omitempty"`
66-
SerialNumber string `json:"serialNumber,omitempty"`
67-
SoftwareRevision string `json:"softwareRevision,omitempty"`
68-
HardwareRevision string `json:"hardwareRevision,omitempty"`
69-
VendorName string `json:"vendorName,omitempty"`
70-
VendorCode string `json:"vendorCode,omitempty"`
71-
BrandName string `json:"brandName,omitempty"`
72-
PowerSource string `json:"powerSource,omitempty"`
73-
ManufacturerNodeIdentification string `json:"manufacturerNodeIdentification,omitempty"`
74-
ManufacturerLabel string `json:"manufacturerLabel,omitempty"`
75-
ManufacturerDescription string `json:"manufacturerDescription,omitempty"`
76-
}

usecases/api/cem_evcc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type CemEVCCInterface interface {
5757
//
5858
// parameters:
5959
// - entity: the entity of the EV
60-
ManufacturerData(entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error)
60+
ManufacturerData(entity spineapi.EntityRemoteInterface) (ManufacturerData, error)
6161

6262
// Scenario 6
6363

usecases/api/cem_evsecc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type CemEVSECCInterface interface {
1717
// - entity: the entity of the EV
1818
//
1919
// returns deviceName, serialNumber, error
20-
ManufacturerData(entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error)
20+
ManufacturerData(entity spineapi.EntityRemoteInterface) (ManufacturerData, error)
2121

2222
// the operating state data of an EVSE
2323
//

usecases/api/types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ const (
1717
EVChargeStateTypeFinished EVChargeStateType = "finished"
1818
)
1919

20+
// manufacturer data type
21+
type ManufacturerData struct {
22+
DeviceName string
23+
DeviceCode string
24+
SerialNumber string
25+
SoftwareRevision string
26+
HardwareRevision string
27+
VendorName string
28+
VendorCode string
29+
BrandName string
30+
PowerSource string
31+
ManufacturerNodeIdentification string
32+
ManufacturerLabel string
33+
ManufacturerDescription string
34+
}
35+
2036
// Defines a phase specific limit data set
2137
type LoadLimitsPhase struct {
2238
Phase model.ElectricalConnectionPhaseNameType // the phase

usecases/cem/evcc/public.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,11 +193,11 @@ func (e *EVCC) Identifications(entity spineapi.EntityRemoteInterface) ([]ucapi.I
193193
func (e *EVCC) ManufacturerData(
194194
entity spineapi.EntityRemoteInterface,
195195
) (
196-
api.ManufacturerData,
196+
ucapi.ManufacturerData,
197197
error,
198198
) {
199199
if !e.IsCompatibleEntityType(entity) {
200-
return api.ManufacturerData{}, api.ErrNoCompatibleEntity
200+
return ucapi.ManufacturerData{}, api.ErrNoCompatibleEntity
201201
}
202202

203203
return internal.ManufacturerData(e.LocalEntity, entity)

usecases/cem/evsecc/public.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package evsecc
33
import (
44
"github.com/enbility/eebus-go/api"
55
"github.com/enbility/eebus-go/features/client"
6+
ucapi "github.com/enbility/eebus-go/usecases/api"
67
"github.com/enbility/eebus-go/usecases/internal"
78
spineapi "github.com/enbility/spine-go/api"
89
"github.com/enbility/spine-go/model"
@@ -13,11 +14,11 @@ import (
1314
func (e *EVSECC) ManufacturerData(
1415
entity spineapi.EntityRemoteInterface,
1516
) (
16-
api.ManufacturerData,
17+
ucapi.ManufacturerData,
1718
error,
1819
) {
1920
if !e.IsCompatibleEntityType(entity) {
20-
return api.ManufacturerData{}, api.ErrNoCompatibleEntity
21+
return ucapi.ManufacturerData{}, api.ErrNoCompatibleEntity
2122
}
2223

2324
return internal.ManufacturerData(e.LocalEntity, entity)

usecases/internal/manufacturerdata.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package internal
22

33
import (
4-
"github.com/enbility/eebus-go/api"
54
"github.com/enbility/eebus-go/features/client"
5+
ucapi "github.com/enbility/eebus-go/usecases/api"
66
spineapi "github.com/enbility/spine-go/api"
77
)
88

@@ -11,18 +11,18 @@ import (
1111
// possible errors:
1212
// - ErrNoCompatibleEntity if entity is not compatible
1313
// - and others
14-
func ManufacturerData(localEntity spineapi.EntityLocalInterface, entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error) {
14+
func ManufacturerData(localEntity spineapi.EntityLocalInterface, entity spineapi.EntityRemoteInterface) (ucapi.ManufacturerData, error) {
1515
deviceClassification, err := client.NewDeviceClassification(localEntity, entity)
1616
if err != nil {
17-
return api.ManufacturerData{}, err
17+
return ucapi.ManufacturerData{}, err
1818
}
1919

2020
data, err := deviceClassification.GetManufacturerDetails()
2121
if err != nil {
22-
return api.ManufacturerData{}, err
22+
return ucapi.ManufacturerData{}, err
2323
}
2424

25-
ret := api.ManufacturerData{
25+
ret := ucapi.ManufacturerData{
2626
DeviceName: Deref((*string)(data.DeviceName)),
2727
DeviceCode: Deref((*string)(data.DeviceCode)),
2828
SerialNumber: Deref((*string)(data.SerialNumber)),

usecases/mocks/CemEVCCInterface.go

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

usecases/mocks/CemEVSECCInterface.go

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)