forked from evcc-io/evcc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadapter.go
41 lines (33 loc) · 880 Bytes
/
adapter.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
package coordinator
import (
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/core/loadpoint"
)
type adapter struct {
lp loadpoint.API
c *Coordinator
}
// NewAdapter exposes the coordinator for a given loadpoint.
// Using an adapter simplifies the method signatures seen from the loadpoint.
func NewAdapter(lp loadpoint.API, c *Coordinator) API {
return &adapter{
lp: lp,
c: c,
}
}
func (a *adapter) GetVehicles(availableOnly bool) []api.Vehicle {
return a.c.GetVehicles(availableOnly)
}
func (a *adapter) Owner(v api.Vehicle) loadpoint.API {
return a.c.Owner(v)
}
func (a *adapter) Acquire(v api.Vehicle) {
a.c.acquire(a.lp, v)
}
func (a *adapter) Release(v api.Vehicle) {
a.c.release(v)
}
func (a *adapter) IdentifyVehicleByStatus() api.Vehicle {
available := a.c.availableDetectibleVehicles(a.lp)
return a.c.identifyVehicleByStatus(available)
}