planner

package
v0.0.0-...-bd59d96 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AverageCost

func AverageCost(plan api.Rates) float64

AverageCost returns the time-weighted average cost

func Duration

func Duration(plan api.Rates) time.Duration

Duration returns the sum of all slot's durations

func End

func End(plan api.Rates) time.Time

func IsFirst

func IsFirst(r api.Rate, plan api.Rates) bool

IsFirst returns if the slot is the first slot in the plan. Does not require the plan to be sorted by start time.

func SlotAt

func SlotAt(time time.Time, plan api.Rates) api.Rate

SlotAt returns the slot for the given time or an empty slot

func SlotHasSuccessor

func SlotHasSuccessor(r api.Rate, plan api.Rates) bool

SlotHasSuccessor returns if the slot has an immediate successor. Does not require the plan to be sorted by start time.

func Start

func Start(plan api.Rates) time.Time

Start returns the earliest slot's start time

Types

type Planner

type Planner struct {
	// contains filtered or unexported fields
}

Planner plans a series of charging slots for a given (variable) tariff

func New

func New(log *util.Logger, tariff api.Tariff, opt ...func(t *Planner)) *Planner

New creates a price planner

func (*Planner) Plan

func (t *Planner) Plan(requiredDuration time.Duration, targetTime time.Time) (api.Rates, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL