68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
package charger
|
|
|
|
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/evcc-io/evcc/api"
|
|
)
|
|
|
|
func decorateKSE(base *KSE, phaseSwitcher func(int) error, phaseGetter func() (int, error), identifier func() (string, error)) api.Charger {
|
|
caps := make(map[reflect.Type]any)
|
|
|
|
if phaseSwitcher != nil {
|
|
caps[reflect.TypeFor[api.PhaseSwitcher]()] = &decorateKSEPhaseSwitcherImpl{phaseSwitcher: phaseSwitcher}
|
|
}
|
|
|
|
if phaseGetter != nil {
|
|
caps[reflect.TypeFor[api.PhaseGetter]()] = &decorateKSEPhaseGetterImpl{phaseGetter: phaseGetter}
|
|
}
|
|
|
|
if identifier != nil {
|
|
caps[reflect.TypeFor[api.Identifier]()] = &decorateKSEIdentifierImpl{identifier: identifier}
|
|
}
|
|
|
|
if len(caps) == 0 {
|
|
return base
|
|
}
|
|
|
|
return &decorateKSECapable{KSE: base, caps: caps}
|
|
}
|
|
|
|
type decorateKSECapable struct {
|
|
*KSE
|
|
caps map[reflect.Type]any
|
|
}
|
|
|
|
func (d *decorateKSECapable) Capability(typ reflect.Type) (any, bool) {
|
|
c, ok := d.caps[typ]
|
|
if !ok && reflect.TypeOf(d).Implements(typ) {
|
|
return d, true
|
|
}
|
|
return c, ok
|
|
}
|
|
|
|
type decorateKSEIdentifierImpl struct {
|
|
identifier func() (string, error)
|
|
}
|
|
|
|
func (impl *decorateKSEIdentifierImpl) Identify() (string, error) {
|
|
return impl.identifier()
|
|
}
|
|
|
|
type decorateKSEPhaseGetterImpl struct {
|
|
phaseGetter func() (int, error)
|
|
}
|
|
|
|
func (impl *decorateKSEPhaseGetterImpl) GetPhases() (int, error) {
|
|
return impl.phaseGetter()
|
|
}
|
|
|
|
type decorateKSEPhaseSwitcherImpl struct {
|
|
phaseSwitcher func(int) error
|
|
}
|
|
|
|
func (impl *decorateKSEPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
|
return impl.phaseSwitcher(p0)
|
|
}
|