Documentation
¶
Overview ¶
Package site holds a running site: a named group of chargers owned by one process.
Index ¶
- func NewPacer(perSecond float64) func(ctx context.Context) error
- type Config
- type Member
- type MemberState
- type Site
- func (s *Site) CSMS() []string
- func (s *Site) Charger(id string) *charger.Charger
- func (s *Site) EVParams(chargePointID, preset string, given ev.Overrides) (ev.Params, error)
- func (s *Site) Has(id string) bool
- func (s *Site) Inspect(id string) (Member, *charger.State, bool)
- func (s *Site) Kill(id string) (string, error)
- func (s *Site) Len() int
- func (s *Site) Name() string
- func (s *Site) Powered() int
- func (s *Site) Remove(id string, force bool) (string, error)
- func (s *Site) Restart(id string) (string, error)
- func (s *Site) Run(ctx context.Context, powerOn func(chargePointID string) bool) error
- func (s *Site) Speed() float64
- func (s *Site) Start(id string) (string, error)
- func (s *Site) States() []MemberState
- func (s *Site) Stop(id string) (string, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Name string
// Speed multiplies the rate of EV charging. Zero means 1.
Speed float64
// ConnectRate is the most new connections to open per second. Zero
// means no limit.
ConnectRate float64
// Presets holds the EV presets by name.
Presets map[string]ev.Overrides
// Log, if set, receives the log of every charger.
Log func(charger.Entry)
// Diagnostics, if set, returns the log of one charger between two
// moments, for GetDiagnostics.
Diagnostics func(chargePointID string, from, to time.Time) ([]byte, error)
// Store, if set, keeps the chargers' state.
Store Store
Timing charger.Timing
}
Config describes a site.
type Member ¶
type Member struct {
// ID is the charge point ID.
ID string
// Name is the charger's name, unique on the machine.
Name string
Model *model.Model
CSMS charger.CSMS
// EV names the EV preset used when a plug does not name one.
EV string
}
Member is a charger of a site, whether powered on or not.
type MemberState ¶
type MemberState struct {
Name string
// Powered says whether the charger is powered on.
Powered bool
charger.Snapshot
}
MemberState is a member and where it stands.
type Site ¶
type Site struct {
// contains filtered or unexported fields
}
Site is a running site.
func (*Site) Charger ¶
Charger returns the charger with the given charge point ID if it is powered on, and nil otherwise.
func (*Site) EVParams ¶
EVParams works out the EV to plug into a charger. From weakest to strongest: the built-in EV, the charger's default preset, the preset named with the plug, and the parameters given with the plug.
func (*Site) Inspect ¶
Inspect returns a charger of the site with its state: as it is now when the charger is powered on, and as it was saved otherwise. The state is nil for a charger that has never run.
func (*Site) Remove ¶
Remove takes a charger out of the site and wipes its saved state. A charger that is powered on is refused unless force is set, which stops it first.
func (*Site) Run ¶
Run powers on the chargers for which powerOn reports true (all of them when it is nil) and keeps the site running until ctx is cancelled, which shuts every charger down in an orderly way, or until the last powered charger has been stopped.
func (*Site) States ¶
func (s *Site) States() []MemberState
States returns where every charger of the site stands, sorted by charge point ID.
type Store ¶
type Store interface {
// LoadState returns a charger's saved state, or nil if it has none.
LoadState(chargePointID string) (*charger.State, error)
SaveState(chargePointID string, state charger.State) error
// Remove deletes a charger and its state.
Remove(chargePointID string) error
}
Store is where a site keeps the state of its chargers.