chore: fix decorating setters (#10841)
This commit is contained in:
parent
22859abd13
commit
c640ae2411
28 changed files with 85 additions and 88 deletions
|
|
@ -55,7 +55,7 @@ func init() {
|
|||
registry.Add("alfen", NewAlfenFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateAlfen -b "*Alfen" -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateAlfen -b *Alfen -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
|
||||
// NewAlfenFromConfig creates a Alfen charger from generic config
|
||||
func NewAlfenFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@ type decorateAlfenPhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateAlfenPhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateAlfenPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func init() {
|
|||
registry.Add("cfos", NewCfosPowerBrainFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateCfos -b "*CfosPowerBrain" -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateCfos -b *CfosPowerBrain -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
|
||||
// NewCfosPowerBrainFromConfig creates a cFos charger from generic config
|
||||
func NewCfosPowerBrainFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,6 @@ type decorateCfosPhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateCfosPhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateCfosPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ func init() {
|
|||
registry.Add(api.Custom, NewConfigurableFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateCustom -b *Charger -r api.Charger -t "api.ChargerEx,MaxCurrentMillis,func(float64) error" -t "api.Identifier,Identify,func() (string, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error" -t "api.Resurrector,WakeUp,func() error" -t "api.Battery,Soc,func() (float64, error)"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateCustom -b *Charger -r api.Charger -t "api.ChargerEx,MaxCurrentMillis,func(float64) error" -t "api.Identifier,Identify,func() (string, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error" -t "api.Resurrector,WakeUp,func() error" -t "api.Battery,Soc,func() (float64, error)"
|
||||
|
||||
// NewConfigurableFromConfig creates a new configurable charger
|
||||
func NewConfigurableFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -564,8 +564,8 @@ type decorateCustomChargerExImpl struct {
|
|||
chargerEx func(float64) error
|
||||
}
|
||||
|
||||
func (impl *decorateCustomChargerExImpl) MaxCurrentMillis(current float64) error {
|
||||
return impl.chargerEx(current)
|
||||
func (impl *decorateCustomChargerExImpl) MaxCurrentMillis(p0 float64) error {
|
||||
return impl.chargerEx(p0)
|
||||
}
|
||||
|
||||
type decorateCustomIdentifierImpl struct {
|
||||
|
|
@ -580,8 +580,8 @@ type decorateCustomPhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateCustomPhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateCustomPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
||||
type decorateCustomResurrectorImpl struct {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func init() {
|
|||
registry.Add("evsewifi", NewEVSEWifiFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateEVSE -b *EVSEWifi -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.ChargerEx,MaxCurrentMillis,func(current float64) error" -t "api.Identifier,Identify,func() (string, error)"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateEVSE -b *EVSEWifi -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.ChargerEx,MaxCurrentMillis,func(float64) error" -t "api.Identifier,Identify,func() (string, error)"
|
||||
|
||||
// NewEVSEWifiFromConfig creates a EVSEWifi charger from generic config
|
||||
func NewEVSEWifiFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/evcc-io/evcc/api"
|
||||
)
|
||||
|
||||
func decorateEVSE(base *EVSEWifi, meter func() (float64, error), meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error), phaseVoltages func() (float64, float64, float64, error), chargerEx func(current float64) error, identifier func() (string, error)) api.Charger {
|
||||
func decorateEVSE(base *EVSEWifi, meter func() (float64, error), meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error), phaseVoltages func() (float64, float64, float64, error), chargerEx func(float64) error, identifier func() (string, error)) api.Charger {
|
||||
switch {
|
||||
case chargerEx == nil && identifier == nil && meter == nil && meterEnergy == nil && phaseCurrents == nil && phaseVoltages == nil:
|
||||
return base
|
||||
|
|
@ -1225,11 +1225,11 @@ func decorateEVSE(base *EVSEWifi, meter func() (float64, error), meterEnergy fun
|
|||
}
|
||||
|
||||
type decorateEVSEChargerExImpl struct {
|
||||
chargerEx func(current float64) error
|
||||
chargerEx func(float64) error
|
||||
}
|
||||
|
||||
func (impl *decorateEVSEChargerExImpl) MaxCurrentMillis(current float64) error {
|
||||
return impl.chargerEx(current)
|
||||
func (impl *decorateEVSEChargerExImpl) MaxCurrentMillis(p0 float64) error {
|
||||
return impl.chargerEx(p0)
|
||||
}
|
||||
|
||||
type decorateEVSEIdentifierImpl struct {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func init() {
|
|||
registry.Add("go-e", NewGoEFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateGoE -b *GoE -r api.Charger -t "api.MeterEnergy,func() (float64, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateGoE -b *GoE -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
|
||||
// NewGoEFromConfig creates a go-e charger from generic config
|
||||
func NewGoEFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,16 @@
|
|||
package charger
|
||||
|
||||
// Code generated by github.com/andig/cmd/tools/decorate.go. DO NOT EDIT.
|
||||
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
|
||||
|
||||
import (
|
||||
"github.com/evcc-io/evcc/api"
|
||||
)
|
||||
|
||||
func decorateGoE(base *GoE, phaseSwitcher func(phases int) error) api.Charger {
|
||||
func decorateGoE(base *GoE, phaseSwitcher func(int) error) api.Charger {
|
||||
switch {
|
||||
case phaseSwitcher == nil:
|
||||
return base
|
||||
|
||||
case phaseSwitcher == nil:
|
||||
return &struct {
|
||||
*GoE
|
||||
api.MeterEnergy
|
||||
}{
|
||||
GoE: base,
|
||||
}
|
||||
|
||||
case phaseSwitcher != nil:
|
||||
return &struct {
|
||||
*GoE
|
||||
|
|
@ -29,18 +21,6 @@ func decorateGoE(base *GoE, phaseSwitcher func(phases int) error) api.Charger {
|
|||
phaseSwitcher: phaseSwitcher,
|
||||
},
|
||||
}
|
||||
|
||||
case phaseSwitcher != nil:
|
||||
return &struct {
|
||||
*GoE
|
||||
api.PhaseSwitcher
|
||||
api.MeterEnergy
|
||||
}{
|
||||
GoE: base,
|
||||
PhaseSwitcher: &decorateGoEPhaseSwitcherImpl{
|
||||
phaseSwitcher: phaseSwitcher,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -50,6 +30,6 @@ type decorateGoEPhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateGoEPhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateGoEPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ func init() {
|
|||
registry.Add("keba-modbus", NewKebaFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateKeba -b *Keba -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.Identifier,Identify,func() (string, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateKeba -b *Keba -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.Identifier,Identify,func() (string, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
|
||||
// NewKebaFromConfig creates a new Keba ModbusTCP charger
|
||||
func NewKebaFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -588,6 +588,6 @@ type decorateKebaPhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateKebaPhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateKebaPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ func NewOCPPFromConfig(other map[string]interface{}) (api.Charger, error) {
|
|||
return decorateOCPP(c, powerG, totalEnergyG, currentsG, phasesS), nil
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateOCPP -b *OCPP -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateOCPP -b *OCPP -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
|
||||
// NewOCPP creates OCPP charger
|
||||
func NewOCPP(id string, connector int, idtag string,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/evcc-io/evcc/api"
|
||||
)
|
||||
|
||||
func decorateOCPP(base *OCPP, meter func() (float64, error), meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error), phaseSwitcher func(phases int) error) api.Charger {
|
||||
func decorateOCPP(base *OCPP, meter func() (float64, error), meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error), phaseSwitcher func(int) error) api.Charger {
|
||||
switch {
|
||||
case meter == nil && meterEnergy == nil && phaseCurrents == nil && phaseSwitcher == nil:
|
||||
return base
|
||||
|
|
@ -276,6 +276,6 @@ type decorateOCPPPhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateOCPPPhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateOCPPPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ func init() {
|
|||
registry.Add("openevse", NewOpenEVSEFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateOpenEVSE -b ""*OpenEVSE" -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateOpenEVSE -b *OpenEVSE -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
|
||||
// NewOpenEVSEFromConfig creates an OpenEVSE charger from generic config
|
||||
func NewOpenEVSEFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/evcc-io/evcc/api"
|
||||
)
|
||||
|
||||
func decorateOpenEVSE(base *OpenEVSE, phaseSwitcher func(phases int) error) api.Charger {
|
||||
func decorateOpenEVSE(base *OpenEVSE, phaseSwitcher func(int) error) api.Charger {
|
||||
switch {
|
||||
case phaseSwitcher == nil:
|
||||
return base
|
||||
|
|
@ -30,6 +30,6 @@ type decorateOpenEVSEPhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateOpenEVSEPhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateOpenEVSEPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ type OpenWB struct {
|
|||
authS func(string) error
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateOpenWB -b *OpenWB -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error" -t "api.Battery,Soc,func() (float64, error)"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateOpenWB -b *OpenWB -r api.Charger -t "api.PhaseSwitcher,Phases1p3p,func(int) error" -t "api.Battery,Soc,func() (float64, error)"
|
||||
|
||||
// NewOpenWBFromConfig creates a new configurable charger
|
||||
func NewOpenWBFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -64,6 +64,6 @@ type decorateOpenWBPhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateOpenWBPhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateOpenWBPhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ func init() {
|
|||
registry.Add("phoenix-ev-eth", NewPhoenixEVEthFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decoratePhoenixEVEth -b *PhoenixEVEth -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.ChargerEx,MaxCurrentMillis,func(current float64) error" -t "api.Identifier,Identify,func() (string, error)"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decoratePhoenixEVEth -b *PhoenixEVEth -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.ChargerEx,MaxCurrentMillis,func(float64) error" -t "api.Identifier,Identify,func() (string, error)"
|
||||
|
||||
// NewPhoenixEVEthFromConfig creates a PhoenixEVEth charger from generic config
|
||||
func NewPhoenixEVEthFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -1225,11 +1225,11 @@ func decoratePhoenixEVEth(base *PhoenixEVEth, meter func() (float64, error), met
|
|||
}
|
||||
|
||||
type decoratePhoenixEVEthChargerExImpl struct {
|
||||
chargerEx func(current float64) error
|
||||
chargerEx func(float64) error
|
||||
}
|
||||
|
||||
func (impl *decoratePhoenixEVEthChargerExImpl) MaxCurrentMillis(current float64) error {
|
||||
return impl.chargerEx(current)
|
||||
func (impl *decoratePhoenixEVEthChargerExImpl) MaxCurrentMillis(p0 float64) error {
|
||||
return impl.chargerEx(p0)
|
||||
}
|
||||
|
||||
type decoratePhoenixEVEthIdentifierImpl struct {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ func init() {
|
|||
registry.Add("wallbe", NewWallbeFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateWallbe -b *Wallbe -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.ChargerEx,MaxCurrentMillis,func(current float64) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateWallbe -b *Wallbe -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.ChargerEx,MaxCurrentMillis,func(float64) error"
|
||||
|
||||
// NewWallbeFromConfig creates a Wallbe charger from generic config
|
||||
func NewWallbeFromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/evcc-io/evcc/api"
|
||||
)
|
||||
|
||||
func decorateWallbe(base *Wallbe, meter func() (float64, error), meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error), chargerEx func(current float64) error) api.Charger {
|
||||
func decorateWallbe(base *Wallbe, meter func() (float64, error), meterEnergy func() (float64, error), phaseCurrents func() (float64, float64, float64, error), chargerEx func(float64) error) api.Charger {
|
||||
switch {
|
||||
case chargerEx == nil && meter == nil && meterEnergy == nil && phaseCurrents == nil:
|
||||
return base
|
||||
|
|
@ -249,11 +249,11 @@ func decorateWallbe(base *Wallbe, meter func() (float64, error), meterEnergy fun
|
|||
}
|
||||
|
||||
type decorateWallbeChargerExImpl struct {
|
||||
chargerEx func(current float64) error
|
||||
chargerEx func(float64) error
|
||||
}
|
||||
|
||||
func (impl *decorateWallbeChargerExImpl) MaxCurrentMillis(current float64) error {
|
||||
return impl.chargerEx(current)
|
||||
func (impl *decorateWallbeChargerExImpl) MaxCurrentMillis(p0 float64) error {
|
||||
return impl.chargerEx(p0)
|
||||
}
|
||||
|
||||
type decorateWallbeMeterImpl struct {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func init() {
|
|||
registry.Add("warp-fw2", NewWarp2FromConfig) // deprecated
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateWarp2 -b *Warp2 -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.Identifier,Identify,func() (string, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateWarp2 -b *Warp2 -r api.Charger -t "api.Meter,CurrentPower,func() (float64, error)" -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.Identifier,Identify,func() (string, error)" -t "api.PhaseSwitcher,Phases1p3p,func(int) error"
|
||||
|
||||
// NewWarpFromConfig creates a new configurable charger
|
||||
func NewWarp2FromConfig(other map[string]interface{}) (api.Charger, error) {
|
||||
|
|
|
|||
|
|
@ -1260,8 +1260,8 @@ type decorateWarp2PhaseSwitcherImpl struct {
|
|||
phaseSwitcher func(int) error
|
||||
}
|
||||
|
||||
func (impl *decorateWarp2PhaseSwitcherImpl) Phases1p3p(phases int) error {
|
||||
return impl.phaseSwitcher(phases)
|
||||
func (impl *decorateWarp2PhaseSwitcherImpl) Phases1p3p(p0 int) error {
|
||||
return impl.phaseSwitcher(p0)
|
||||
}
|
||||
|
||||
type decorateWarp2PhaseVoltagesImpl struct {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import (
|
|||
"go/format"
|
||||
"io"
|
||||
"os"
|
||||
"slices"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
|
|
@ -23,7 +24,8 @@ type dynamicType struct {
|
|||
}
|
||||
|
||||
type typeStruct struct {
|
||||
Type, ShortType, Signature, Function, VarName string
|
||||
Type, ShortType, Signature, Function, VarName, ReturnTypes string
|
||||
Params []string
|
||||
}
|
||||
|
||||
func generate(out io.Writer, packageName, functionName, baseType string, dynamicTypes ...dynamicType) error {
|
||||
|
|
@ -48,14 +50,9 @@ func generate(out io.Writer, packageName, functionName, baseType string, dynamic
|
|||
},
|
||||
// contains checks if slice contains string
|
||||
"contains": func(combo []string, typ string) bool {
|
||||
for _, v := range combo {
|
||||
if v == typ {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(combo, typ)
|
||||
},
|
||||
// ordered checks if slice ordered string
|
||||
// ordered returns a slice of typeStructs ordered by dynamicType
|
||||
"ordered": func() []typeStruct {
|
||||
ordered := make([]typeStruct, 0)
|
||||
for _, k := range dynamicTypes {
|
||||
|
|
@ -65,7 +62,6 @@ func generate(out io.Writer, packageName, functionName, baseType string, dynamic
|
|||
return ordered
|
||||
},
|
||||
}).Parse(srcTmpl)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -73,12 +69,27 @@ func generate(out io.Writer, packageName, functionName, baseType string, dynamic
|
|||
for _, dt := range dynamicTypes {
|
||||
parts := strings.SplitN(dt.typ, ".", 2)
|
||||
|
||||
openingBrace := strings.Index(dt.signature, "(")
|
||||
closingBrace := strings.Index(dt.signature, ")")
|
||||
paramsStr := dt.signature[openingBrace+1 : closingBrace]
|
||||
|
||||
paramsStr = strings.TrimSpace(paramsStr)
|
||||
|
||||
var params []string
|
||||
if len(paramsStr) > 0 {
|
||||
params = strings.Split(paramsStr, ",")
|
||||
}
|
||||
|
||||
returnValuesStr := dt.signature[closingBrace+1:]
|
||||
|
||||
types[dt.typ] = typeStruct{
|
||||
Type: dt.typ,
|
||||
ShortType: parts[1],
|
||||
VarName: strings.ToLower(parts[1][:1]) + parts[1][1:],
|
||||
Signature: dt.signature,
|
||||
Function: dt.function,
|
||||
Type: dt.typ,
|
||||
ShortType: parts[1],
|
||||
VarName: strings.ToLower(parts[1][:1]) + parts[1][1:],
|
||||
Signature: dt.signature,
|
||||
Function: dt.function,
|
||||
Params: params,
|
||||
ReturnTypes: returnValuesStr,
|
||||
}
|
||||
|
||||
combos = append(combos, dt.typ)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ import (
|
|||
}
|
||||
{{- end -}}
|
||||
|
||||
func {{.Function}}(base {{.BaseType}}{{range ordered}}, {{.VarName}} func() {{slice .Signature 7}}{{end}}) {{.ReturnType}} {
|
||||
func {{.Function}}(base {{.BaseType}}{{range ordered}}, {{.VarName}} {{.Signature}}{{end}}) {{.ReturnType}} {
|
||||
{{- $basetype := .BaseType}}
|
||||
{{- $shortbase := .ShortBase}}
|
||||
{{- $prefix := .Function}}
|
||||
|
|
@ -56,8 +56,14 @@ type {{$prefix}}{{.ShortType}}Impl struct {
|
|||
{{.VarName}} {{.Signature}}
|
||||
}
|
||||
|
||||
func (impl *{{$prefix}}{{.ShortType}}Impl) {{.Function}}{{slice .Signature 4}} {
|
||||
return impl.{{.VarName}}()
|
||||
}
|
||||
func (impl *{{$prefix}}{{.ShortType}}Impl) {{.Function}}(
|
||||
{{- range $idx, $param := .Params -}}
|
||||
{{- if gt $idx 0}}, {{end -}}
|
||||
p{{$idx}} {{ $param -}}
|
||||
{{end}}){{ .ReturnTypes }} {
|
||||
return impl.{{.VarName}}(
|
||||
{{- range $idx, $param := .Params -}}
|
||||
{{- if gt $idx 0}}, {{end}}p{{- $idx -}}{{end}})
|
||||
}
|
||||
|
||||
{{end}}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ func init() {
|
|||
registry.Add(api.Custom, NewConfigurableFromConfig)
|
||||
}
|
||||
|
||||
// go:generate go run ../cmd/tools/decorate.go -f decorateMeter -b api.Meter -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.PhasePowers,Powers,func() (float64, float64, float64, error)" -t "api.Battery,Soc,func() (float64, error)" -t "api.BatteryCapacity,Capacity,func() float64" -t "api.BatteryController,SetBatteryMode,func(api.BatteryMode) error"
|
||||
//go:generate go run ../cmd/tools/decorate.go -f decorateMeter -b api.Meter -t "api.MeterEnergy,TotalEnergy,func() (float64, error)" -t "api.PhaseCurrents,Currents,func() (float64, float64, float64, error)" -t "api.PhaseVoltages,Voltages,func() (float64, float64, float64, error)" -t "api.PhasePowers,Powers,func() (float64, float64, float64, error)" -t "api.Battery,Soc,func() (float64, error)" -t "api.BatteryCapacity,Capacity,func() float64" -t "api.BatteryController,SetBatteryMode,func(api.BatteryMode) error"
|
||||
|
||||
// NewConfigurableFromConfig creates api.Meter from config
|
||||
func NewConfigurableFromConfig(other map[string]interface{}) (api.Meter, error) {
|
||||
|
|
|
|||
|
|
@ -2716,8 +2716,8 @@ type decorateMeterBatteryControllerImpl struct {
|
|||
batteryController func(api.BatteryMode) error
|
||||
}
|
||||
|
||||
func (impl *decorateMeterBatteryControllerImpl) SetBatteryMode(mode api.BatteryMode) error {
|
||||
return impl.batteryController(mode)
|
||||
func (impl *decorateMeterBatteryControllerImpl) SetBatteryMode(p0 api.BatteryMode) error {
|
||||
return impl.batteryController(p0)
|
||||
}
|
||||
|
||||
type decorateMeterMeterEnergyImpl struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue