116 lines
3 KiB
Go
116 lines
3 KiB
Go
package charger
|
|
|
|
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
|
|
|
|
import (
|
|
"reflect"
|
|
|
|
"github.com/evcc-io/evcc/api"
|
|
)
|
|
|
|
func decorateKeba(base *Keba, meter func() (float64, error), meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error), identifier func() (string, error), statusReasoner func() (api.Reason, error), phaseSwitcher func(int) error, phaseGetter func() (int, error)) api.Charger {
|
|
caps := make(map[reflect.Type]any)
|
|
|
|
if meter != nil {
|
|
caps[reflect.TypeFor[api.Meter]()] = &decorateKebaMeterImpl{meter: meter}
|
|
}
|
|
|
|
if meterEnergy != nil {
|
|
caps[reflect.TypeFor[api.MeterEnergy]()] = &decorateKebaMeterEnergyImpl{meterEnergy: meterEnergy}
|
|
}
|
|
|
|
if phaseCurrents != nil {
|
|
caps[reflect.TypeFor[api.PhaseCurrents]()] = &decorateKebaPhaseCurrentsImpl{phaseCurrents: phaseCurrents}
|
|
}
|
|
|
|
if identifier != nil {
|
|
caps[reflect.TypeFor[api.Identifier]()] = &decorateKebaIdentifierImpl{identifier: identifier}
|
|
}
|
|
|
|
if statusReasoner != nil {
|
|
caps[reflect.TypeFor[api.StatusReasoner]()] = &decorateKebaStatusReasonerImpl{statusReasoner: statusReasoner}
|
|
}
|
|
|
|
if phaseSwitcher != nil {
|
|
caps[reflect.TypeFor[api.PhaseSwitcher]()] = &decorateKebaPhaseSwitcherImpl{phaseSwitcher: phaseSwitcher}
|
|
}
|
|
|
|
if phaseGetter != nil {
|
|
caps[reflect.TypeFor[api.PhaseGetter]()] = &decorateKebaPhaseGetterImpl{phaseGetter: phaseGetter}
|
|
}
|
|
|
|
if len(caps) == 0 {
|
|
return base
|
|
}
|
|
|
|
return &decorateKebaCapable{Keba: base, caps: caps}
|
|
}
|
|
|
|
type decorateKebaCapable struct {
|
|
*Keba
|
|
caps map[reflect.Type]any
|
|
}
|
|
|
|
func (d *decorateKebaCapable) Capability(typ reflect.Type) (any, bool) {
|
|
c, ok := d.caps[typ]
|
|
if !ok && reflect.TypeOf(d).Implements(typ) {
|
|
return d, true
|
|
}
|
|
return c, ok
|
|
}
|
|
|
|
type decorateKebaIdentifierImpl struct {
|
|
identifier func() (string, error)
|
|
}
|
|
|
|
func (impl *decorateKebaIdentifierImpl) Identify() (string, error) {
|
|
return impl.identifier()
|
|
}
|
|
|
|
type decorateKebaMeterImpl struct {
|
|
meter func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateKebaMeterImpl) CurrentPower() (float64, error) {
|
|
return impl.meter()
|
|
}
|
|
|
|
type decorateKebaMeterEnergyImpl struct {
|
|
meterEnergy func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateKebaMeterEnergyImpl) TotalEnergy() (float64, error) {
|
|
return impl.meterEnergy()
|
|
}
|
|
|
|
type decorateKebaPhaseCurrentsImpl struct {
|
|
phaseCurrents func() (float64, float64, float64, error)
|
|
}
|
|
|
|
func (impl *decorateKebaPhaseCurrentsImpl) Currents() (float64, float64, float64, error) {
|
|
return impl.phaseCurrents()
|
|
}
|
|
|
|
type decorateKebaPhaseGetterImpl struct {
|
|
phaseGetter func() (int, error)
|
|
}
|
|
|
|
func (impl *decorateKebaPhaseGetterImpl) GetPhases() (int, error) {
|
|
return impl.phaseGetter()
|
|
}
|
|
|
|
type decorateKebaPhaseSwitcherImpl struct {
|
|
phaseSwitcher func(int) error
|
|
}
|
|
|
|
func (impl *decorateKebaPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
|
return impl.phaseSwitcher(p0)
|
|
}
|
|
|
|
type decorateKebaStatusReasonerImpl struct {
|
|
statusReasoner func() (api.Reason, error)
|
|
}
|
|
|
|
func (impl *decorateKebaStatusReasonerImpl) StatusReason() (api.Reason, error) {
|
|
return impl.statusReasoner()
|
|
}
|