Planner: simplify short slot handling
This commit is contained in:
parent
f3727c6639
commit
4201e8fa88
1 changed files with 5 additions and 9 deletions
|
|
@ -8,11 +8,7 @@ import (
|
|||
"github.com/evcc-io/evcc/core/keys"
|
||||
"github.com/evcc-io/evcc/core/planner"
|
||||
"github.com/evcc-io/evcc/core/vehicle"
|
||||
)
|
||||
|
||||
const (
|
||||
smallSlotDuration = 15 * time.Minute // small planner slot duration we might ignore
|
||||
smallGapDuration = 30 * time.Minute // small gap duration between planner slots we might ignore
|
||||
"github.com/evcc-io/evcc/tariff"
|
||||
)
|
||||
|
||||
// TODO planActive is not guarded by mutex
|
||||
|
|
@ -174,7 +170,7 @@ func (lp *Loadpoint) plannerActive() (active bool) {
|
|||
|
||||
if active {
|
||||
// ignore short plans if not already active
|
||||
if slotRemaining := lp.clock.Until(activeSlot.End); !lp.planActive && slotRemaining < smallSlotDuration && !planner.SlotHasSuccessor(activeSlot, plan) {
|
||||
if slotRemaining := lp.clock.Until(activeSlot.End); !lp.planActive && slotRemaining < tariff.SlotDuration && !planner.SlotHasSuccessor(activeSlot, plan) {
|
||||
lp.log.DEBUG.Printf("plan: slot too short- ignoring remaining %v", slotRemaining.Round(time.Second))
|
||||
return false
|
||||
}
|
||||
|
|
@ -193,11 +189,11 @@ func (lp *Loadpoint) plannerActive() (active bool) {
|
|||
// don't stop an already running slot if goal was not met
|
||||
lp.log.DEBUG.Printf("plan: continuing until end of slot at %s", lp.planSlotEnd.Round(time.Second).Local())
|
||||
return true
|
||||
case requiredDuration < smallSlotDuration:
|
||||
case requiredDuration < tariff.SlotDuration:
|
||||
lp.log.DEBUG.Printf("plan: continuing for remaining %v", requiredDuration.Round(time.Second))
|
||||
return true
|
||||
case lp.clock.Until(planStart) < smallGapDuration:
|
||||
lp.log.DEBUG.Printf("plan: avoid re-start within %v, continuing for remaining %v", smallGapDuration, lp.clock.Until(planStart).Round(time.Second))
|
||||
case lp.clock.Until(planStart) < tariff.SlotDuration:
|
||||
lp.log.DEBUG.Printf("plan: avoid re-start within %v, continuing for remaining %v", tariff.SlotDuration, lp.clock.Until(planStart).Round(time.Second))
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue