forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathem2go_decorators.go
111 lines (96 loc) · 2.39 KB
/
em2go_decorators.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package charger
// Code generated by github.com/evcc-io/evcc/cmd/tools/decorate.go. DO NOT EDIT.
import (
"github.com/evcc-io/evcc/api"
)
func decorateEm2Go(base *Em2Go, chargerEx func(float64) error, phaseSwitcher func(int) error, phaseGetter func() (int, error)) api.Charger {
switch {
case chargerEx == nil && phaseSwitcher == nil:
return base
case chargerEx != nil && phaseSwitcher == nil:
return &struct {
*Em2Go
api.ChargerEx
}{
Em2Go: base,
ChargerEx: &decorateEm2GoChargerExImpl{
chargerEx: chargerEx,
},
}
case chargerEx == nil && phaseGetter == nil && phaseSwitcher != nil:
return &struct {
*Em2Go
api.PhaseSwitcher
}{
Em2Go: base,
PhaseSwitcher: &decorateEm2GoPhaseSwitcherImpl{
phaseSwitcher: phaseSwitcher,
},
}
case chargerEx != nil && phaseGetter == nil && phaseSwitcher != nil:
return &struct {
*Em2Go
api.ChargerEx
api.PhaseSwitcher
}{
Em2Go: base,
ChargerEx: &decorateEm2GoChargerExImpl{
chargerEx: chargerEx,
},
PhaseSwitcher: &decorateEm2GoPhaseSwitcherImpl{
phaseSwitcher: phaseSwitcher,
},
}
case chargerEx == nil && phaseGetter != nil && phaseSwitcher != nil:
return &struct {
*Em2Go
api.PhaseGetter
api.PhaseSwitcher
}{
Em2Go: base,
PhaseGetter: &decorateEm2GoPhaseGetterImpl{
phaseGetter: phaseGetter,
},
PhaseSwitcher: &decorateEm2GoPhaseSwitcherImpl{
phaseSwitcher: phaseSwitcher,
},
}
case chargerEx != nil && phaseGetter != nil && phaseSwitcher != nil:
return &struct {
*Em2Go
api.ChargerEx
api.PhaseGetter
api.PhaseSwitcher
}{
Em2Go: base,
ChargerEx: &decorateEm2GoChargerExImpl{
chargerEx: chargerEx,
},
PhaseGetter: &decorateEm2GoPhaseGetterImpl{
phaseGetter: phaseGetter,
},
PhaseSwitcher: &decorateEm2GoPhaseSwitcherImpl{
phaseSwitcher: phaseSwitcher,
},
}
}
return nil
}
type decorateEm2GoChargerExImpl struct {
chargerEx func(float64) error
}
func (impl *decorateEm2GoChargerExImpl) MaxCurrentMillis(p0 float64) error {
return impl.chargerEx(p0)
}
type decorateEm2GoPhaseGetterImpl struct {
phaseGetter func() (int, error)
}
func (impl *decorateEm2GoPhaseGetterImpl) GetPhases() (int, error) {
return impl.phaseGetter()
}
type decorateEm2GoPhaseSwitcherImpl struct {
phaseSwitcher func(int) error
}
func (impl *decorateEm2GoPhaseSwitcherImpl) Phases1p3p(p0 int) error {
return impl.phaseSwitcher(p0)
}