53 lines
1.2 KiB
Go
53 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 decorateOpenWB(base *OpenWB, phaseSwitcher func(int) error, battery func() (float64, error)) api.Charger {
|
|
caps := make(map[reflect.Type]any)
|
|
|
|
if phaseSwitcher != nil {
|
|
caps[reflect.TypeFor[api.PhaseSwitcher]()] = &decorateOpenWBPhaseSwitcherImpl{phaseSwitcher: phaseSwitcher}
|
|
}
|
|
|
|
if battery != nil {
|
|
caps[reflect.TypeFor[api.Battery]()] = &decorateOpenWBBatteryImpl{battery: battery}
|
|
}
|
|
|
|
if len(caps) == 0 {
|
|
return base
|
|
}
|
|
|
|
return &decorateOpenWBCapable{OpenWB: base, caps: caps}
|
|
}
|
|
|
|
type decorateOpenWBCapable struct {
|
|
*OpenWB
|
|
caps map[reflect.Type]any
|
|
}
|
|
|
|
func (d *decorateOpenWBCapable) Capability(typ reflect.Type) (any, bool) {
|
|
c, ok := d.caps[typ]
|
|
return c, ok
|
|
}
|
|
|
|
type decorateOpenWBBatteryImpl struct {
|
|
battery func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateOpenWBBatteryImpl) Soc() (float64, error) {
|
|
return impl.battery()
|
|
}
|
|
|
|
type decorateOpenWBPhaseSwitcherImpl struct {
|
|
phaseSwitcher func(int) error
|
|
}
|
|
|
|
func (impl *decorateOpenWBPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
|
return impl.phaseSwitcher(p0)
|
|
}
|