Replace combinatorial decorators with capability registry (BC) (#28565)
This commit is contained in:
parent
33d2de24c1
commit
00967eb57e
101 changed files with 2416 additions and 44670 deletions
|
|
@ -3,53 +3,37 @@ 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 decorateDsmr(base api.Meter, meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error)) api.Meter {
|
||||
switch {
|
||||
case meterEnergy == nil && phaseCurrents == nil:
|
||||
return base
|
||||
caps := make(map[reflect.Type]any)
|
||||
|
||||
case meterEnergy != nil && phaseCurrents == nil:
|
||||
return &struct {
|
||||
api.Meter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
Meter: base,
|
||||
MeterEnergy: &decorateDsmrMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case meterEnergy == nil && phaseCurrents != nil:
|
||||
return &struct {
|
||||
api.Meter
|
||||
api.PhaseCurrents
|
||||
}{
|
||||
Meter: base,
|
||||
PhaseCurrents: &decorateDsmrPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
}
|
||||
|
||||
case meterEnergy != nil && phaseCurrents != nil:
|
||||
return &struct {
|
||||
api.Meter
|
||||
api.MeterEnergy
|
||||
api.PhaseCurrents
|
||||
}{
|
||||
Meter: base,
|
||||
MeterEnergy: &decorateDsmrMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
PhaseCurrents: &decorateDsmrPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
}
|
||||
if meterEnergy != nil {
|
||||
caps[reflect.TypeFor[api.MeterEnergy]()] = &decorateDsmrMeterEnergyImpl{meterEnergy: meterEnergy}
|
||||
}
|
||||
|
||||
return nil
|
||||
if phaseCurrents != nil {
|
||||
caps[reflect.TypeFor[api.PhaseCurrents]()] = &decorateDsmrPhaseCurrentsImpl{phaseCurrents: phaseCurrents}
|
||||
}
|
||||
|
||||
if len(caps) == 0 {
|
||||
return base
|
||||
}
|
||||
|
||||
return &decorateDsmrCapable{Meter: base, caps: caps}
|
||||
}
|
||||
|
||||
type decorateDsmrCapable struct {
|
||||
api.Meter
|
||||
caps map[reflect.Type]any
|
||||
}
|
||||
|
||||
func (d *decorateDsmrCapable) Capability(typ reflect.Type) (any, bool) {
|
||||
c, ok := d.caps[typ]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
type decorateDsmrMeterEnergyImpl struct {
|
||||
|
|
|
|||
|
|
@ -3,699 +3,53 @@ 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 {
|
||||
switch {
|
||||
case battery == nil && maxACPowerGetter == nil:
|
||||
return base
|
||||
caps := make(map[reflect.Type]any)
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && maxACPowerGetter == nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatterySocLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatterySocLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && maxACPowerGetter != nil:
|
||||
return &struct {
|
||||
*E3dc
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MaxACPowerGetter
|
||||
}{
|
||||
E3dc: base,
|
||||
Battery: &decorateE3dcBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateE3dcBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateE3dcBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateE3dcBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateE3dcBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MaxACPowerGetter: &decorateE3dcMaxACPowerGetterImpl{
|
||||
maxACPowerGetter: maxACPowerGetter,
|
||||
},
|
||||
}
|
||||
if battery != nil {
|
||||
caps[reflect.TypeFor[api.Battery]()] = &decorateE3dcBatteryImpl{battery: battery}
|
||||
}
|
||||
|
||||
return nil
|
||||
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]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
type decorateE3dcBatteryImpl struct {
|
||||
|
|
|
|||
|
|
@ -3,42 +3,37 @@ 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 decorateGoodWeWifi(base *goodWeWiFi, battery func() (float64, error), batteryCapacity func() float64) api.Meter {
|
||||
switch {
|
||||
case battery == nil:
|
||||
return base
|
||||
caps := make(map[reflect.Type]any)
|
||||
|
||||
case battery != nil && batteryCapacity == nil:
|
||||
return &struct {
|
||||
*goodWeWiFi
|
||||
api.Battery
|
||||
}{
|
||||
goodWeWiFi: base,
|
||||
Battery: &decorateGoodWeWifiBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil:
|
||||
return &struct {
|
||||
*goodWeWiFi
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
}{
|
||||
goodWeWiFi: base,
|
||||
Battery: &decorateGoodWeWifiBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateGoodWeWifiBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
}
|
||||
if battery != nil {
|
||||
caps[reflect.TypeFor[api.Battery]()] = &decorateGoodWeWifiBatteryImpl{battery: battery}
|
||||
}
|
||||
|
||||
return nil
|
||||
if batteryCapacity != nil {
|
||||
caps[reflect.TypeFor[api.BatteryCapacity]()] = &decorateGoodWeWifiBatteryCapacityImpl{batteryCapacity: batteryCapacity}
|
||||
}
|
||||
|
||||
if len(caps) == 0 {
|
||||
return base
|
||||
}
|
||||
|
||||
return &decorateGoodWeWifiCapable{goodWeWiFi: base, caps: caps}
|
||||
}
|
||||
|
||||
type decorateGoodWeWifiCapable struct {
|
||||
*goodWeWiFi
|
||||
caps map[reflect.Type]any
|
||||
}
|
||||
|
||||
func (d *decorateGoodWeWifiCapable) Capability(typ reflect.Type) (any, bool) {
|
||||
c, ok := d.caps[typ]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
type decorateGoodWeWifiBatteryImpl struct {
|
||||
|
|
|
|||
|
|
@ -3,699 +3,53 @@ 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 decorateLgEss(base *LgEss, meterEnergy func() (float64, error), batteryCapacity func() float64, battery func() (float64, error), batterySocLimiter func() (float64, float64), batteryPowerLimiter func() (float64, float64), batteryController func(api.BatteryMode) error) api.Meter {
|
||||
switch {
|
||||
case battery == nil && meterEnergy == nil:
|
||||
return base
|
||||
caps := make(map[reflect.Type]any)
|
||||
|
||||
case battery == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*LgEss
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
LgEss: base,
|
||||
Battery: &decorateLgEssBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decorateLgEssBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decorateLgEssBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decorateLgEssBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decorateLgEssBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decorateLgEssMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
if meterEnergy != nil {
|
||||
caps[reflect.TypeFor[api.MeterEnergy]()] = &decorateLgEssMeterEnergyImpl{meterEnergy: meterEnergy}
|
||||
}
|
||||
|
||||
return nil
|
||||
if batteryCapacity != nil {
|
||||
caps[reflect.TypeFor[api.BatteryCapacity]()] = &decorateLgEssBatteryCapacityImpl{batteryCapacity: batteryCapacity}
|
||||
}
|
||||
|
||||
if battery != nil {
|
||||
caps[reflect.TypeFor[api.Battery]()] = &decorateLgEssBatteryImpl{battery: battery}
|
||||
}
|
||||
|
||||
if batterySocLimiter != nil {
|
||||
caps[reflect.TypeFor[api.BatterySocLimiter]()] = &decorateLgEssBatterySocLimiterImpl{batterySocLimiter: batterySocLimiter}
|
||||
}
|
||||
|
||||
if batteryPowerLimiter != nil {
|
||||
caps[reflect.TypeFor[api.BatteryPowerLimiter]()] = &decorateLgEssBatteryPowerLimiterImpl{batteryPowerLimiter: batteryPowerLimiter}
|
||||
}
|
||||
|
||||
if batteryController != nil {
|
||||
caps[reflect.TypeFor[api.BatteryController]()] = &decorateLgEssBatteryControllerImpl{batteryController: batteryController}
|
||||
}
|
||||
|
||||
if len(caps) == 0 {
|
||||
return base
|
||||
}
|
||||
|
||||
return &decorateLgEssCapable{LgEss: base, caps: caps}
|
||||
}
|
||||
|
||||
type decorateLgEssCapable struct {
|
||||
*LgEss
|
||||
caps map[reflect.Type]any
|
||||
}
|
||||
|
||||
func (d *decorateLgEssCapable) Capability(typ reflect.Type) (any, bool) {
|
||||
c, ok := d.caps[typ]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
type decorateLgEssBatteryImpl struct {
|
||||
|
|
|
|||
|
|
@ -42,31 +42,31 @@ func NewMovingAverageFromConfig(ctx context.Context, other map[string]any) (api.
|
|||
|
||||
// decorate energy reading
|
||||
var totalEnergy func() (float64, error)
|
||||
if m, ok := m.(api.MeterEnergy); ok {
|
||||
if m, ok := api.Cap[api.MeterEnergy](m); ok {
|
||||
totalEnergy = m.TotalEnergy
|
||||
}
|
||||
|
||||
// decorate battery reading
|
||||
var batterySoc func() (float64, error)
|
||||
if m, ok := m.(api.Battery); ok {
|
||||
if m, ok := api.Cap[api.Battery](m); ok {
|
||||
batterySoc = m.Soc
|
||||
}
|
||||
|
||||
// decorate currents reading
|
||||
var currents func() (float64, float64, float64, error)
|
||||
if m, ok := m.(api.PhaseCurrents); ok {
|
||||
if m, ok := api.Cap[api.PhaseCurrents](m); ok {
|
||||
currents = m.Currents
|
||||
}
|
||||
|
||||
// decorate voltages reading
|
||||
var voltages func() (float64, float64, float64, error)
|
||||
if m, ok := m.(api.PhaseVoltages); ok {
|
||||
if m, ok := api.Cap[api.PhaseVoltages](m); ok {
|
||||
voltages = m.Voltages
|
||||
}
|
||||
|
||||
// decorate powers reading
|
||||
var powers func() (float64, float64, float64, error)
|
||||
if m, ok := m.(api.PhasePowers); ok {
|
||||
if m, ok := api.Cap[api.PhasePowers](m); ok {
|
||||
powers = m.Powers
|
||||
}
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -19,7 +19,8 @@ func TestPV(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
// must not have soc/capacity
|
||||
assert.Implements(t, new(api.MaxACPowerGetter), m)
|
||||
_, ok := api.Cap[api.MaxACPowerGetter](m)
|
||||
assert.True(t, ok, "MaxACPowerGetter")
|
||||
}
|
||||
func TestBattery(t *testing.T) {
|
||||
m, err := NewConfigurableFromConfig(t.Context(), map[string]any{
|
||||
|
|
@ -35,6 +36,8 @@ func TestBattery(t *testing.T) {
|
|||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Implements(t, new(api.Battery), m)
|
||||
assert.Implements(t, new(api.BatteryCapacity), m)
|
||||
_, ok := api.Cap[api.Battery](m)
|
||||
assert.True(t, ok, "Battery")
|
||||
_, ok = api.Cap[api.BatteryCapacity](m)
|
||||
assert.True(t, ok, "BatteryCapacity")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,699 +3,53 @@ 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 {
|
||||
switch {
|
||||
case battery == nil && meterEnergy == nil:
|
||||
return base
|
||||
caps := make(map[reflect.Type]any)
|
||||
|
||||
case battery == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController == nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter == nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter == nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity == nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy == nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
}
|
||||
|
||||
case battery != nil && batteryCapacity != nil && batteryController != nil && batteryPowerLimiter != nil && batterySocLimiter != nil && meterEnergy != nil:
|
||||
return &struct {
|
||||
*PowerWall
|
||||
api.Battery
|
||||
api.BatteryCapacity
|
||||
api.BatteryController
|
||||
api.BatteryPowerLimiter
|
||||
api.BatterySocLimiter
|
||||
api.MeterEnergy
|
||||
}{
|
||||
PowerWall: base,
|
||||
Battery: &decoratePowerWallBatteryImpl{
|
||||
battery: battery,
|
||||
},
|
||||
BatteryCapacity: &decoratePowerWallBatteryCapacityImpl{
|
||||
batteryCapacity: batteryCapacity,
|
||||
},
|
||||
BatteryController: &decoratePowerWallBatteryControllerImpl{
|
||||
batteryController: batteryController,
|
||||
},
|
||||
BatteryPowerLimiter: &decoratePowerWallBatteryPowerLimiterImpl{
|
||||
batteryPowerLimiter: batteryPowerLimiter,
|
||||
},
|
||||
BatterySocLimiter: &decoratePowerWallBatterySocLimiterImpl{
|
||||
batterySocLimiter: batterySocLimiter,
|
||||
},
|
||||
MeterEnergy: &decoratePowerWallMeterEnergyImpl{
|
||||
meterEnergy: meterEnergy,
|
||||
},
|
||||
}
|
||||
if meterEnergy != nil {
|
||||
caps[reflect.TypeFor[api.MeterEnergy]()] = &decoratePowerWallMeterEnergyImpl{meterEnergy: meterEnergy}
|
||||
}
|
||||
|
||||
return nil
|
||||
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 {
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -3,87 +3,41 @@ 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 decorateShelly(base *Shelly, phaseVoltages func() (float64, float64, float64, error), phaseCurrents func() (float64, float64, float64, error), phasePowers func() (float64, float64, float64, error)) api.Meter {
|
||||
switch {
|
||||
case phaseCurrents == nil && phaseVoltages == nil:
|
||||
return base
|
||||
caps := make(map[reflect.Type]any)
|
||||
|
||||
case phaseCurrents == nil && phaseVoltages != nil:
|
||||
return &struct {
|
||||
*Shelly
|
||||
api.PhaseVoltages
|
||||
}{
|
||||
Shelly: base,
|
||||
PhaseVoltages: &decorateShellyPhaseVoltagesImpl{
|
||||
phaseVoltages: phaseVoltages,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseCurrents != nil && phasePowers == nil && phaseVoltages == nil:
|
||||
return &struct {
|
||||
*Shelly
|
||||
api.PhaseCurrents
|
||||
}{
|
||||
Shelly: base,
|
||||
PhaseCurrents: &decorateShellyPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseCurrents != nil && phasePowers == nil && phaseVoltages != nil:
|
||||
return &struct {
|
||||
*Shelly
|
||||
api.PhaseCurrents
|
||||
api.PhaseVoltages
|
||||
}{
|
||||
Shelly: base,
|
||||
PhaseCurrents: &decorateShellyPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
PhaseVoltages: &decorateShellyPhaseVoltagesImpl{
|
||||
phaseVoltages: phaseVoltages,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseCurrents != nil && phasePowers != nil && phaseVoltages == nil:
|
||||
return &struct {
|
||||
*Shelly
|
||||
api.PhaseCurrents
|
||||
api.PhasePowers
|
||||
}{
|
||||
Shelly: base,
|
||||
PhaseCurrents: &decorateShellyPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
PhasePowers: &decorateShellyPhasePowersImpl{
|
||||
phasePowers: phasePowers,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseCurrents != nil && phasePowers != nil && phaseVoltages != nil:
|
||||
return &struct {
|
||||
*Shelly
|
||||
api.PhaseCurrents
|
||||
api.PhasePowers
|
||||
api.PhaseVoltages
|
||||
}{
|
||||
Shelly: base,
|
||||
PhaseCurrents: &decorateShellyPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
PhasePowers: &decorateShellyPhasePowersImpl{
|
||||
phasePowers: phasePowers,
|
||||
},
|
||||
PhaseVoltages: &decorateShellyPhaseVoltagesImpl{
|
||||
phaseVoltages: phaseVoltages,
|
||||
},
|
||||
}
|
||||
if phaseVoltages != nil {
|
||||
caps[reflect.TypeFor[api.PhaseVoltages]()] = &decorateShellyPhaseVoltagesImpl{phaseVoltages: phaseVoltages}
|
||||
}
|
||||
|
||||
return nil
|
||||
if phaseCurrents != nil {
|
||||
caps[reflect.TypeFor[api.PhaseCurrents]()] = &decorateShellyPhaseCurrentsImpl{phaseCurrents: phaseCurrents}
|
||||
}
|
||||
|
||||
if phasePowers != nil {
|
||||
caps[reflect.TypeFor[api.PhasePowers]()] = &decorateShellyPhasePowersImpl{phasePowers: phasePowers}
|
||||
}
|
||||
|
||||
if len(caps) == 0 {
|
||||
return base
|
||||
}
|
||||
|
||||
return &decorateShellyCapable{Shelly: base, caps: caps}
|
||||
}
|
||||
|
||||
type decorateShellyCapable struct {
|
||||
*Shelly
|
||||
caps map[reflect.Type]any
|
||||
}
|
||||
|
||||
func (d *decorateShellyCapable) Capability(typ reflect.Type) (any, bool) {
|
||||
c, ok := d.caps[typ]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
type decorateShellyPhaseCurrentsImpl struct {
|
||||
|
|
|
|||
|
|
@ -3,87 +3,41 @@ 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 decorateTasmota(base *Tasmota, phaseVoltages func() (float64, float64, float64, error), phaseCurrents func() (float64, float64, float64, error), phasePowers func() (float64, float64, float64, error)) api.Meter {
|
||||
switch {
|
||||
case phaseCurrents == nil && phaseVoltages == nil:
|
||||
return base
|
||||
caps := make(map[reflect.Type]any)
|
||||
|
||||
case phaseCurrents == nil && phaseVoltages != nil:
|
||||
return &struct {
|
||||
*Tasmota
|
||||
api.PhaseVoltages
|
||||
}{
|
||||
Tasmota: base,
|
||||
PhaseVoltages: &decorateTasmotaPhaseVoltagesImpl{
|
||||
phaseVoltages: phaseVoltages,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseCurrents != nil && phasePowers == nil && phaseVoltages == nil:
|
||||
return &struct {
|
||||
*Tasmota
|
||||
api.PhaseCurrents
|
||||
}{
|
||||
Tasmota: base,
|
||||
PhaseCurrents: &decorateTasmotaPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseCurrents != nil && phasePowers == nil && phaseVoltages != nil:
|
||||
return &struct {
|
||||
*Tasmota
|
||||
api.PhaseCurrents
|
||||
api.PhaseVoltages
|
||||
}{
|
||||
Tasmota: base,
|
||||
PhaseCurrents: &decorateTasmotaPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
PhaseVoltages: &decorateTasmotaPhaseVoltagesImpl{
|
||||
phaseVoltages: phaseVoltages,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseCurrents != nil && phasePowers != nil && phaseVoltages == nil:
|
||||
return &struct {
|
||||
*Tasmota
|
||||
api.PhaseCurrents
|
||||
api.PhasePowers
|
||||
}{
|
||||
Tasmota: base,
|
||||
PhaseCurrents: &decorateTasmotaPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
PhasePowers: &decorateTasmotaPhasePowersImpl{
|
||||
phasePowers: phasePowers,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseCurrents != nil && phasePowers != nil && phaseVoltages != nil:
|
||||
return &struct {
|
||||
*Tasmota
|
||||
api.PhaseCurrents
|
||||
api.PhasePowers
|
||||
api.PhaseVoltages
|
||||
}{
|
||||
Tasmota: base,
|
||||
PhaseCurrents: &decorateTasmotaPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
PhasePowers: &decorateTasmotaPhasePowersImpl{
|
||||
phasePowers: phasePowers,
|
||||
},
|
||||
PhaseVoltages: &decorateTasmotaPhaseVoltagesImpl{
|
||||
phaseVoltages: phaseVoltages,
|
||||
},
|
||||
}
|
||||
if phaseVoltages != nil {
|
||||
caps[reflect.TypeFor[api.PhaseVoltages]()] = &decorateTasmotaPhaseVoltagesImpl{phaseVoltages: phaseVoltages}
|
||||
}
|
||||
|
||||
return nil
|
||||
if phaseCurrents != nil {
|
||||
caps[reflect.TypeFor[api.PhaseCurrents]()] = &decorateTasmotaPhaseCurrentsImpl{phaseCurrents: phaseCurrents}
|
||||
}
|
||||
|
||||
if phasePowers != nil {
|
||||
caps[reflect.TypeFor[api.PhasePowers]()] = &decorateTasmotaPhasePowersImpl{phasePowers: phasePowers}
|
||||
}
|
||||
|
||||
if len(caps) == 0 {
|
||||
return base
|
||||
}
|
||||
|
||||
return &decorateTasmotaCapable{Tasmota: base, caps: caps}
|
||||
}
|
||||
|
||||
type decorateTasmotaCapable struct {
|
||||
*Tasmota
|
||||
caps map[reflect.Type]any
|
||||
}
|
||||
|
||||
func (d *decorateTasmotaCapable) Capability(typ reflect.Type) (any, bool) {
|
||||
c, ok := d.caps[typ]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
type decorateTasmotaPhaseCurrentsImpl struct {
|
||||
|
|
|
|||
|
|
@ -3,27 +3,33 @@ 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 decorateTqEm(base api.Meter, phaseCurrents func() (float64, float64, float64, error)) api.Meter {
|
||||
switch {
|
||||
case phaseCurrents == nil:
|
||||
return base
|
||||
caps := make(map[reflect.Type]any)
|
||||
|
||||
case phaseCurrents != nil:
|
||||
return &struct {
|
||||
api.Meter
|
||||
api.PhaseCurrents
|
||||
}{
|
||||
Meter: base,
|
||||
PhaseCurrents: &decorateTqEmPhaseCurrentsImpl{
|
||||
phaseCurrents: phaseCurrents,
|
||||
},
|
||||
}
|
||||
if phaseCurrents != nil {
|
||||
caps[reflect.TypeFor[api.PhaseCurrents]()] = &decorateTqEmPhaseCurrentsImpl{phaseCurrents: phaseCurrents}
|
||||
}
|
||||
|
||||
return nil
|
||||
if len(caps) == 0 {
|
||||
return base
|
||||
}
|
||||
|
||||
return &decorateTqEmCapable{Meter: base, caps: caps}
|
||||
}
|
||||
|
||||
type decorateTqEmCapable struct {
|
||||
api.Meter
|
||||
caps map[reflect.Type]any
|
||||
}
|
||||
|
||||
func (d *decorateTqEmCapable) Capability(typ reflect.Type) (any, bool) {
|
||||
c, ok := d.caps[typ]
|
||||
return c, ok
|
||||
}
|
||||
|
||||
type decorateTqEmPhaseCurrentsImpl struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue