53 lines
1.1 KiB
Go
53 lines
1.1 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 decorateVaillant(base *Vaillant, meter func() (float64, error), battery func() (float64, error)) api.Charger {
|
|
caps := make(map[reflect.Type]any)
|
|
|
|
if meter != nil {
|
|
caps[reflect.TypeFor[api.Meter]()] = &decorateVaillantMeterImpl{meter: meter}
|
|
}
|
|
|
|
if battery != nil {
|
|
caps[reflect.TypeFor[api.Battery]()] = &decorateVaillantBatteryImpl{battery: battery}
|
|
}
|
|
|
|
if len(caps) == 0 {
|
|
return base
|
|
}
|
|
|
|
return &decorateVaillantCapable{Vaillant: base, caps: caps}
|
|
}
|
|
|
|
type decorateVaillantCapable struct {
|
|
*Vaillant
|
|
caps map[reflect.Type]any
|
|
}
|
|
|
|
func (d *decorateVaillantCapable) Capability(typ reflect.Type) (any, bool) {
|
|
c, ok := d.caps[typ]
|
|
return c, ok
|
|
}
|
|
|
|
type decorateVaillantBatteryImpl struct {
|
|
battery func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateVaillantBatteryImpl) Soc() (float64, error) {
|
|
return impl.battery()
|
|
}
|
|
|
|
type decorateVaillantMeterImpl struct {
|
|
meter func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateVaillantMeterImpl) CurrentPower() (float64, error) {
|
|
return impl.meter()
|
|
}
|