evcc-io/meter/powerwall_decorators.go

101 lines
2.9 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 decoratePowerWall(base *PowerWall, meterEnergy func() (float64, error), battery func() (float64, error), batteryCapacity func() float64, batterySocLimiter func() (float64, float64), batteryPowerLimiter func() (float64, float64), batteryController func(api.BatteryMode) error) api.Meter {
caps := make(map[reflect.Type]any)
if meterEnergy != nil {
caps[reflect.TypeFor[api.MeterEnergy]()] = &decoratePowerWallMeterEnergyImpl{meterEnergy: meterEnergy}
}
if battery != nil {
caps[reflect.TypeFor[api.Battery]()] = &decoratePowerWallBatteryImpl{battery: battery}
}
if batteryCapacity != nil {
caps[reflect.TypeFor[api.BatteryCapacity]()] = &decoratePowerWallBatteryCapacityImpl{batteryCapacity: batteryCapacity}
}
if batterySocLimiter != nil {
caps[reflect.TypeFor[api.BatterySocLimiter]()] = &decoratePowerWallBatterySocLimiterImpl{batterySocLimiter: batterySocLimiter}
}
if batteryPowerLimiter != nil {
caps[reflect.TypeFor[api.BatteryPowerLimiter]()] = &decoratePowerWallBatteryPowerLimiterImpl{batteryPowerLimiter: batteryPowerLimiter}
}
if batteryController != nil {
caps[reflect.TypeFor[api.BatteryController]()] = &decoratePowerWallBatteryControllerImpl{batteryController: batteryController}
}
if len(caps) == 0 {
return base
}
return &decoratePowerWallCapable{PowerWall: base, caps: caps}
}
type decoratePowerWallCapable struct {
*PowerWall
caps map[reflect.Type]any
}
func (d *decoratePowerWallCapable) Capability(typ reflect.Type) (any, bool) {
c, ok := d.caps[typ]
return c, ok
}
type decoratePowerWallBatteryImpl struct {
battery func() (float64, error)
}
func (impl *decoratePowerWallBatteryImpl) Soc() (float64, error) {
return impl.battery()
}
type decoratePowerWallBatteryCapacityImpl struct {
batteryCapacity func() float64
}
func (impl *decoratePowerWallBatteryCapacityImpl) Capacity() float64 {
return impl.batteryCapacity()
}
type decoratePowerWallBatteryControllerImpl struct {
batteryController func(api.BatteryMode) error
}
func (impl *decoratePowerWallBatteryControllerImpl) SetBatteryMode(p0 api.BatteryMode) error {
return impl.batteryController(p0)
}
type decoratePowerWallBatteryPowerLimiterImpl struct {
batteryPowerLimiter func() (float64, float64)
}
func (impl *decoratePowerWallBatteryPowerLimiterImpl) GetPowerLimits() (float64, float64) {
return impl.batteryPowerLimiter()
}
type decoratePowerWallBatterySocLimiterImpl struct {
batterySocLimiter func() (float64, float64)
}
func (impl *decoratePowerWallBatterySocLimiterImpl) GetSocLimits() (float64, float64) {
return impl.batterySocLimiter()
}
type decoratePowerWallMeterEnergyImpl struct {
meterEnergy func() (float64, error)
}
func (impl *decoratePowerWallMeterEnergyImpl) TotalEnergy() (float64, error) {
return impl.meterEnergy()
}