56 lines
1.2 KiB
Go
56 lines
1.2 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 decorateGoE(base *GoE, chargeRater func() (float64, error), phaseSwitcher func(int) error) api.Charger {
|
|
caps := make(map[reflect.Type]any)
|
|
|
|
if chargeRater != nil {
|
|
caps[reflect.TypeFor[api.ChargeRater]()] = &decorateGoEChargeRaterImpl{chargeRater: chargeRater}
|
|
}
|
|
|
|
if phaseSwitcher != nil {
|
|
caps[reflect.TypeFor[api.PhaseSwitcher]()] = &decorateGoEPhaseSwitcherImpl{phaseSwitcher: phaseSwitcher}
|
|
}
|
|
|
|
if len(caps) == 0 {
|
|
return base
|
|
}
|
|
|
|
return &decorateGoECapable{GoE: base, caps: caps}
|
|
}
|
|
|
|
type decorateGoECapable struct {
|
|
*GoE
|
|
caps map[reflect.Type]any
|
|
}
|
|
|
|
func (d *decorateGoECapable) 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 decorateGoEChargeRaterImpl struct {
|
|
chargeRater func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateGoEChargeRaterImpl) ChargedEnergy() (float64, error) {
|
|
return impl.chargeRater()
|
|
}
|
|
|
|
type decorateGoEPhaseSwitcherImpl struct {
|
|
phaseSwitcher func(int) error
|
|
}
|
|
|
|
func (impl *decorateGoEPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
|
return impl.phaseSwitcher(p0)
|
|
}
|