149 lines
4 KiB
Go
149 lines
4 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 decorateCustom(base *Charger, chargerEx func(float64) error, identifier func() (string, error), phaseSwitcher func(int) error, resurrector func() error, battery func() (float64, error), socLimiter func() (int64, error), meter func() (float64, error), meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error), phaseVoltages func() (float64, float64, float64, error)) api.Charger {
|
|
caps := make(map[reflect.Type]any)
|
|
|
|
if chargerEx != nil {
|
|
caps[reflect.TypeFor[api.ChargerEx]()] = &decorateCustomChargerExImpl{chargerEx: chargerEx}
|
|
}
|
|
|
|
if identifier != nil {
|
|
caps[reflect.TypeFor[api.Identifier]()] = &decorateCustomIdentifierImpl{identifier: identifier}
|
|
}
|
|
|
|
if phaseSwitcher != nil {
|
|
caps[reflect.TypeFor[api.PhaseSwitcher]()] = &decorateCustomPhaseSwitcherImpl{phaseSwitcher: phaseSwitcher}
|
|
}
|
|
|
|
if resurrector != nil {
|
|
caps[reflect.TypeFor[api.Resurrector]()] = &decorateCustomResurrectorImpl{resurrector: resurrector}
|
|
}
|
|
|
|
if battery != nil {
|
|
caps[reflect.TypeFor[api.Battery]()] = &decorateCustomBatteryImpl{battery: battery}
|
|
}
|
|
|
|
if socLimiter != nil {
|
|
caps[reflect.TypeFor[api.SocLimiter]()] = &decorateCustomSocLimiterImpl{socLimiter: socLimiter}
|
|
}
|
|
|
|
if meter != nil {
|
|
caps[reflect.TypeFor[api.Meter]()] = &decorateCustomMeterImpl{meter: meter}
|
|
}
|
|
|
|
if meterEnergy != nil {
|
|
caps[reflect.TypeFor[api.MeterEnergy]()] = &decorateCustomMeterEnergyImpl{meterEnergy: meterEnergy}
|
|
}
|
|
|
|
if phaseCurrents != nil {
|
|
caps[reflect.TypeFor[api.PhaseCurrents]()] = &decorateCustomPhaseCurrentsImpl{phaseCurrents: phaseCurrents}
|
|
}
|
|
|
|
if phaseVoltages != nil {
|
|
caps[reflect.TypeFor[api.PhaseVoltages]()] = &decorateCustomPhaseVoltagesImpl{phaseVoltages: phaseVoltages}
|
|
}
|
|
|
|
if len(caps) == 0 {
|
|
return base
|
|
}
|
|
|
|
return &decorateCustomCapable{Charger: base, caps: caps}
|
|
}
|
|
|
|
type decorateCustomCapable struct {
|
|
*Charger
|
|
caps map[reflect.Type]any
|
|
}
|
|
|
|
func (d *decorateCustomCapable) Capability(typ reflect.Type) (any, bool) {
|
|
c, ok := d.caps[typ]
|
|
return c, ok
|
|
}
|
|
|
|
type decorateCustomBatteryImpl struct {
|
|
battery func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateCustomBatteryImpl) Soc() (float64, error) {
|
|
return impl.battery()
|
|
}
|
|
|
|
type decorateCustomChargerExImpl struct {
|
|
chargerEx func(float64) error
|
|
}
|
|
|
|
func (impl *decorateCustomChargerExImpl) MaxCurrentMillis(p0 float64) error {
|
|
return impl.chargerEx(p0)
|
|
}
|
|
|
|
type decorateCustomIdentifierImpl struct {
|
|
identifier func() (string, error)
|
|
}
|
|
|
|
func (impl *decorateCustomIdentifierImpl) Identify() (string, error) {
|
|
return impl.identifier()
|
|
}
|
|
|
|
type decorateCustomMeterImpl struct {
|
|
meter func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateCustomMeterImpl) CurrentPower() (float64, error) {
|
|
return impl.meter()
|
|
}
|
|
|
|
type decorateCustomMeterEnergyImpl struct {
|
|
meterEnergy func() (float64, error)
|
|
}
|
|
|
|
func (impl *decorateCustomMeterEnergyImpl) TotalEnergy() (float64, error) {
|
|
return impl.meterEnergy()
|
|
}
|
|
|
|
type decorateCustomPhaseCurrentsImpl struct {
|
|
phaseCurrents func() (float64, float64, float64, error)
|
|
}
|
|
|
|
func (impl *decorateCustomPhaseCurrentsImpl) Currents() (float64, float64, float64, error) {
|
|
return impl.phaseCurrents()
|
|
}
|
|
|
|
type decorateCustomPhaseSwitcherImpl struct {
|
|
phaseSwitcher func(int) error
|
|
}
|
|
|
|
func (impl *decorateCustomPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
|
return impl.phaseSwitcher(p0)
|
|
}
|
|
|
|
type decorateCustomPhaseVoltagesImpl struct {
|
|
phaseVoltages func() (float64, float64, float64, error)
|
|
}
|
|
|
|
func (impl *decorateCustomPhaseVoltagesImpl) Voltages() (float64, float64, float64, error) {
|
|
return impl.phaseVoltages()
|
|
}
|
|
|
|
type decorateCustomResurrectorImpl struct {
|
|
resurrector func() error
|
|
}
|
|
|
|
func (impl *decorateCustomResurrectorImpl) WakeUp() error {
|
|
return impl.resurrector()
|
|
}
|
|
|
|
type decorateCustomSocLimiterImpl struct {
|
|
socLimiter func() (int64, error)
|
|
}
|
|
|
|
func (impl *decorateCustomSocLimiterImpl) GetLimitSoc() (int64, error) {
|
|
return impl.socLimiter()
|
|
}
|