58 lines
1.2 KiB
Go
58 lines
1.2 KiB
Go
package meter
|
|
|
|
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
|
|
|
|
import (
|
|
"github.com/evcc-io/evcc/api"
|
|
)
|
|
|
|
func decorateZendure(base *Zendure, battery func() (float64, error), batteryCapacity func() float64) api.Meter {
|
|
switch {
|
|
case battery == nil:
|
|
return base
|
|
|
|
case battery != nil && batteryCapacity == nil:
|
|
return &struct {
|
|
*Zendure
|
|
api.Battery
|
|
}{
|
|
Zendure: base,
|
|
Battery: &decorateZendureBatteryImpl{
|
|
battery: battery,
|
|
},
|
|
}
|
|
|
|
case battery != nil && batteryCapacity != nil:
|
|
return &struct {
|
|
*Zendure
|
|
api.Battery
|
|
api.BatteryCapacity
|
|
}{
|
|
Zendure: base,
|
|
Battery: &decorateZendureBatteryImpl{
|
|
battery: battery,
|
|
},
|
|
BatteryCapacity: &decorateZendureBatteryCapacityImpl{
|
|
batteryCapacity: batteryCapacity,
|
|
},
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type decorateZendureBatteryImpl struct {
|
|
battery func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateZendureBatteryImpl) Soc() (float64, error) {
|
|
return impl.battery()
|
|
}
|
|
|
|
type decorateZendureBatteryCapacityImpl struct {
|
|
batteryCapacity func() float64
|
|
}
|
|
|
|
func (impl *decorateZendureBatteryCapacityImpl) Capacity() float64 {
|
|
return impl.batteryCapacity()
|
|
}
|