Skip to content

Commit

Permalink
Move and update api.ManufacturerData (#139)
Browse files Browse the repository at this point in the history
- move api.ManufacturerData to usecases/api
- fix serialization not to use SPINE schema
  • Loading branch information
DerAndereAndi authored Nov 6, 2024
2 parents 7fb578c + e8d33b6 commit ec402c2
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 42 deletions.
15 changes: 0 additions & 15 deletions api/usecases.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,3 @@ type UseCaseInterface interface {
// add the features
AddFeatures()
}

type ManufacturerData struct {
DeviceName string `json:"deviceName,omitempty"`
DeviceCode string `json:"deviceCode,omitempty"`
SerialNumber string `json:"serialNumber,omitempty"`
SoftwareRevision string `json:"softwareRevision,omitempty"`
HardwareRevision string `json:"hardwareRevision,omitempty"`
VendorName string `json:"vendorName,omitempty"`
VendorCode string `json:"vendorCode,omitempty"`
BrandName string `json:"brandName,omitempty"`
PowerSource string `json:"powerSource,omitempty"`
ManufacturerNodeIdentification string `json:"manufacturerNodeIdentification,omitempty"`
ManufacturerLabel string `json:"manufacturerLabel,omitempty"`
ManufacturerDescription string `json:"manufacturerDescription,omitempty"`
}
2 changes: 1 addition & 1 deletion usecases/api/cem_evcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type CemEVCCInterface interface {
//
// parameters:
// - entity: the entity of the EV
ManufacturerData(entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error)
ManufacturerData(entity spineapi.EntityRemoteInterface) (ManufacturerData, error)

// Scenario 6

Expand Down
2 changes: 1 addition & 1 deletion usecases/api/cem_evsecc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type CemEVSECCInterface interface {
// - entity: the entity of the EV
//
// returns deviceName, serialNumber, error
ManufacturerData(entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error)
ManufacturerData(entity spineapi.EntityRemoteInterface) (ManufacturerData, error)

// the operating state data of an EVSE
//
Expand Down
16 changes: 16 additions & 0 deletions usecases/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ const (
EVChargeStateTypeFinished EVChargeStateType = "finished"
)

// manufacturer data type
type ManufacturerData struct {
DeviceName string
DeviceCode string
SerialNumber string
SoftwareRevision string
HardwareRevision string
VendorName string
VendorCode string
BrandName string
PowerSource string
ManufacturerNodeIdentification string
ManufacturerLabel string
ManufacturerDescription string
}

// Defines a phase specific limit data set
type LoadLimitsPhase struct {
Phase model.ElectricalConnectionPhaseNameType // the phase
Expand Down
4 changes: 2 additions & 2 deletions usecases/cem/evcc/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ func (e *EVCC) Identifications(entity spineapi.EntityRemoteInterface) ([]ucapi.I
func (e *EVCC) ManufacturerData(
entity spineapi.EntityRemoteInterface,
) (
api.ManufacturerData,
ucapi.ManufacturerData,
error,
) {
if !e.IsCompatibleEntityType(entity) {
return api.ManufacturerData{}, api.ErrNoCompatibleEntity
return ucapi.ManufacturerData{}, api.ErrNoCompatibleEntity
}

return internal.ManufacturerData(e.LocalEntity, entity)
Expand Down
5 changes: 3 additions & 2 deletions usecases/cem/evsecc/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package evsecc
import (
"github.com/enbility/eebus-go/api"
"github.com/enbility/eebus-go/features/client"
ucapi "github.com/enbility/eebus-go/usecases/api"
"github.com/enbility/eebus-go/usecases/internal"
spineapi "github.com/enbility/spine-go/api"
"github.com/enbility/spine-go/model"
Expand All @@ -13,11 +14,11 @@ import (
func (e *EVSECC) ManufacturerData(
entity spineapi.EntityRemoteInterface,
) (
api.ManufacturerData,
ucapi.ManufacturerData,
error,
) {
if !e.IsCompatibleEntityType(entity) {
return api.ManufacturerData{}, api.ErrNoCompatibleEntity
return ucapi.ManufacturerData{}, api.ErrNoCompatibleEntity
}

return internal.ManufacturerData(e.LocalEntity, entity)
Expand Down
10 changes: 5 additions & 5 deletions usecases/internal/manufacturerdata.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package internal

import (
"github.com/enbility/eebus-go/api"
"github.com/enbility/eebus-go/features/client"
ucapi "github.com/enbility/eebus-go/usecases/api"
spineapi "github.com/enbility/spine-go/api"
)

Expand All @@ -11,18 +11,18 @@ import (
// possible errors:
// - ErrNoCompatibleEntity if entity is not compatible
// - and others
func ManufacturerData(localEntity spineapi.EntityLocalInterface, entity spineapi.EntityRemoteInterface) (api.ManufacturerData, error) {
func ManufacturerData(localEntity spineapi.EntityLocalInterface, entity spineapi.EntityRemoteInterface) (ucapi.ManufacturerData, error) {
deviceClassification, err := client.NewDeviceClassification(localEntity, entity)
if err != nil {
return api.ManufacturerData{}, err
return ucapi.ManufacturerData{}, err
}

data, err := deviceClassification.GetManufacturerDetails()
if err != nil {
return api.ManufacturerData{}, err
return ucapi.ManufacturerData{}, err
}

ret := api.ManufacturerData{
ret := ucapi.ManufacturerData{
DeviceName: Deref((*string)(data.DeviceName)),
DeviceCode: Deref((*string)(data.DeviceCode)),
SerialNumber: Deref((*string)(data.SerialNumber)),
Expand Down
16 changes: 8 additions & 8 deletions usecases/mocks/CemEVCCInterface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 10 additions & 8 deletions usecases/mocks/CemEVSECCInterface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ec402c2

Please sign in to comment.