From d72122d2fc04d2c4e7bc1eb5276b84e204210620 Mon Sep 17 00:00:00 2001 From: andig Date: Wed, 28 Dec 2022 19:26:20 +0100 Subject: [PATCH] Planner: at max power to log message --- core/loadpoint.go | 8 ++++++-- core/planner/planner.go | 2 -- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/core/loadpoint.go b/core/loadpoint.go index 50be60bb0..c369a23a2 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -754,9 +754,11 @@ func (lp *Loadpoint) plannerActive() (active bool) { } var requiredDuration time.Duration + maxPower := lp.GetMaxPower() + if energy, ok := lp.remainingChargeEnergy(); ok { if energy > 0 { - requiredDuration = time.Duration(energy * 1e3 / lp.GetMaxPower() * float64(time.Hour)) + requiredDuration = time.Duration(energy * 1e3 / maxPower * float64(time.Hour)) } } else { // TODO vehicle soc limit @@ -764,10 +766,12 @@ func (lp *Loadpoint) plannerActive() (active bool) { if lp.Soc.target > 0 { targetSoc = lp.Soc.target } - requiredDuration = lp.socEstimator.RemainingChargeDuration(targetSoc, lp.GetMaxPower()) + requiredDuration = lp.socEstimator.RemainingChargeDuration(targetSoc, maxPower) } requiredDuration = time.Duration(float64(requiredDuration) / soc.ChargeEfficiency) + lp.log.DEBUG.Printf("planning %v until %v at %.0fW", requiredDuration.Round(time.Second), lp.targetTime.Round(time.Second).Local(), maxPower) + slotEnd, active, err := lp.planner.Active(requiredDuration, lp.targetTime) if err != nil { lp.log.ERROR.Println("planner:", err) diff --git a/core/planner/planner.go b/core/planner/planner.go index f32e73ed1..010e5e3aa 100644 --- a/core/planner/planner.go +++ b/core/planner/planner.go @@ -122,8 +122,6 @@ func (t *Planner) Active(requiredDuration time.Duration, targetTime time.Time) ( requiredDuration -= durationAfterRates } - t.log.DEBUG.Printf("planning %v until %v", requiredDuration.Round(time.Second), targetTime.Round(time.Second).Local()) - plan := t.Plan(rates, requiredDuration, targetTime) var activeSlot api.Rate