104 lines
2.8 KiB
Go
104 lines
2.8 KiB
Go
package meter
|
|
|
|
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/evcc-io/evcc/api"
|
|
)
|
|
|
|
func decorateE3dc(base *E3dc, battery func() (float64, error), batteryCapacity func() float64, batteryController func(api.BatteryMode) error, batterySocLimiter func() (float64, float64), batteryPowerLimiter func() (float64, float64), maxACPowerGetter func() float64) api.Meter {
|
|
caps := make(map[reflect.Type]any)
|
|
|
|
if battery != nil {
|
|
caps[reflect.TypeFor[api.Battery]()] = &decorateE3dcBatteryImpl{battery: battery}
|
|
}
|
|
|
|
if batteryCapacity != nil {
|
|
caps[reflect.TypeFor[api.BatteryCapacity]()] = &decorateE3dcBatteryCapacityImpl{batteryCapacity: batteryCapacity}
|
|
}
|
|
|
|
if batteryController != nil {
|
|
caps[reflect.TypeFor[api.BatteryController]()] = &decorateE3dcBatteryControllerImpl{batteryController: batteryController}
|
|
}
|
|
|
|
if batterySocLimiter != nil {
|
|
caps[reflect.TypeFor[api.BatterySocLimiter]()] = &decorateE3dcBatterySocLimiterImpl{batterySocLimiter: batterySocLimiter}
|
|
}
|
|
|
|
if batteryPowerLimiter != nil {
|
|
caps[reflect.TypeFor[api.BatteryPowerLimiter]()] = &decorateE3dcBatteryPowerLimiterImpl{batteryPowerLimiter: batteryPowerLimiter}
|
|
}
|
|
|
|
if maxACPowerGetter != nil {
|
|
caps[reflect.TypeFor[api.MaxACPowerGetter]()] = &decorateE3dcMaxACPowerGetterImpl{maxACPowerGetter: maxACPowerGetter}
|
|
}
|
|
|
|
if len(caps) == 0 {
|
|
return base
|
|
}
|
|
|
|
return &decorateE3dcCapable{E3dc: base, caps: caps}
|
|
}
|
|
|
|
type decorateE3dcCapable struct {
|
|
*E3dc
|
|
caps map[reflect.Type]any
|
|
}
|
|
|
|
func (d *decorateE3dcCapable) 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 decorateE3dcBatteryImpl struct {
|
|
battery func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateE3dcBatteryImpl) Soc() (float64, error) {
|
|
return impl.battery()
|
|
}
|
|
|
|
type decorateE3dcBatteryCapacityImpl struct {
|
|
batteryCapacity func() float64
|
|
}
|
|
|
|
func (impl *decorateE3dcBatteryCapacityImpl) Capacity() float64 {
|
|
return impl.batteryCapacity()
|
|
}
|
|
|
|
type decorateE3dcBatteryControllerImpl struct {
|
|
batteryController func(api.BatteryMode) error
|
|
}
|
|
|
|
func (impl *decorateE3dcBatteryControllerImpl) SetBatteryMode(p0 api.BatteryMode) error {
|
|
return impl.batteryController(p0)
|
|
}
|
|
|
|
type decorateE3dcBatteryPowerLimiterImpl struct {
|
|
batteryPowerLimiter func() (float64, float64)
|
|
}
|
|
|
|
func (impl *decorateE3dcBatteryPowerLimiterImpl) GetPowerLimits() (float64, float64) {
|
|
return impl.batteryPowerLimiter()
|
|
}
|
|
|
|
type decorateE3dcBatterySocLimiterImpl struct {
|
|
batterySocLimiter func() (float64, float64)
|
|
}
|
|
|
|
func (impl *decorateE3dcBatterySocLimiterImpl) GetSocLimits() (float64, float64) {
|
|
return impl.batterySocLimiter()
|
|
}
|
|
|
|
type decorateE3dcMaxACPowerGetterImpl struct {
|
|
maxACPowerGetter func() float64
|
|
}
|
|
|
|
func (impl *decorateE3dcMaxACPowerGetterImpl) MaxACPower() float64 {
|
|
return impl.maxACPowerGetter()
|
|
}
|