-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Planner: fix continuous plan execution #27227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Planner: fix continuous plan execution #27227
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- The newly added
requiredDuration > strategy.Preconditionchecks are repeated in multiple branches; consider extracting this into a named predicate or restructuring the switch to avoid duplication and make the intent clearer. - The added continuous-plan condition combines several time comparisons in a single
case; breaking this out into well-named intermediate variables (e.g.,wouldInterruptContinuous) or a helper function would improve readability and make the business rules easier to reason about. - For both the precondition-related checks and the continuous-plan condition, review whether strict
>vs>=behavior is intended at the thresholds, and consider documenting or encoding these boundary decisions explicitly to avoid subtle off-by-one timing issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The newly added `requiredDuration > strategy.Precondition` checks are repeated in multiple branches; consider extracting this into a named predicate or restructuring the switch to avoid duplication and make the intent clearer.
- The added continuous-plan condition combines several time comparisons in a single `case`; breaking this out into well-named intermediate variables (e.g., `wouldInterruptContinuous`) or a helper function would improve readability and make the business rules easier to reason about.
- For both the precondition-related checks and the continuous-plan condition, review whether strict `>` vs `>=` behavior is intended at the thresholds, and consider documenting or encoding these boundary decisions explicitly to avoid subtle off-by-one timing issues.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
@andig it solves the issues reported for continuous planning. From my point of view we may go for it. Let's just discuss the open comment because it is relevant for non-continuous planning, would be valid to change in another PR probably |
|
@iseeberg79 I guess this needs tests |
|
Very difficult to unit test, I tried but it got way to complicated |
core/loadpoint_plan.go
Outdated
| 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 | ||
| case strategy.Continuous && requiredDuration > strategy.Precondition && planStart.After(lp.clock.Now()) && planStart.Before(planTime.Add(-requiredDuration-strategy.Precondition)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be so complicated? The plan has already started- why check for plan start? Shouldn't this just be
case strategy.Continuous && requiredDuration > strategy.Precondition:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ATM I believe we could skip a redundant, defensive planStart.After(lp.clock.Now()) but need to keep the additional condition having repeating plans in focus - I'll double-check this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reduced condition should be fine indeed. There are other checks guarding what I intended to check. I'll analyze a charging session in detail, it should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- The new
strategy.Continuous && requiredDuration > strategy.Preconditioncase encodes a fairly specific behavioral rule; consider adding a short inline comment explaining why this condition is the right threshold to avoid interrupting continuous charging. - To make the new debug log more useful when diagnosing planner behavior, consider including
requiredDurationandstrategy.Preconditionvalues in the message alongside theplanStarttime.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `strategy.Continuous && requiredDuration > strategy.Precondition` case encodes a fairly specific behavioral rule; consider adding a short inline comment explaining why this condition is the right threshold to avoid interrupting continuous charging.
- To make the new debug log more useful when diagnosing planner behavior, consider including `requiredDuration` and `strategy.Precondition` values in the message alongside the `planStart` time.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Rein damit? |
This comment has been minimized.
This comment has been minimized.
|
Ladevorgang erfolgreich: Start/Ziel und Precondition zum geplanten Zeitpunkt, Lademenge (Energie+SoC) zutreffend. Log Analyse ohne Auffälliges |
Fix #27129
Testplan:
The debug logs for above charging sessions completed the last days show no unfortunate behavior.