Skip to content
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

Repeating plans: improve overrun behavior #17834

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions core/loadpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,13 @@ type Loadpoint struct {
socEstimator *soc.Estimator

// charge planning
planner *planner.Planner
planTime time.Time // time goal
planEnergy float64 // Plan charge energy in kWh (dumb vehicles)
planSlotEnd time.Time // current plan slot end time
planActive bool // charge plan exists and has a currently active slot
planner *planner.Planner
planTime time.Time // time goal
planEnergy float64 // Plan charge energy in kWh (dumb vehicles)
planSlotEnd time.Time // current plan slot end time
planActive bool // charge plan exists and has a currently active slot
planActiveTime time.Time // needed to calculate the EffectivePlanTime
planActiveSoc int // needed to calculate the EffectivePlanSoc

// cached state
status api.ChargeStatus // Charger status
Expand Down
20 changes: 17 additions & 3 deletions core/loadpoint_effective.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ func (lp *Loadpoint) nextVehiclePlan() (time.Time, int, int) {

// EffectivePlanSoc returns the soc target for the current plan
func (lp *Loadpoint) EffectivePlanSoc() int {
if lp.planActive {
return lp.planActiveSoc
}

_, soc, _ := lp.nextVehiclePlan()
lp.planActiveSoc = soc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Diese implizite Zustandsveränderung in einem Getter ist nicht gut und von außen nicht erwartbar.
Das Setzen und Zurücksetzen von lp.planActiveSoc und lp.planActiveTime sollte immer in Sync mit lp.planActive passieren. Ggf. können wir die Notwendigkeit für planActive sogar ersetzen bzw. daraus ableiten ob es eine planActiveTime gibt.


return soc
}

Expand All @@ -95,12 +101,20 @@ func (lp *Loadpoint) EffectivePlanId() int {

// EffectivePlanTime returns the effective plan time
func (lp *Loadpoint) EffectivePlanTime() time.Time {
var ts time.Time

if lp.planActive {
return lp.planActiveTime
}

if lp.socBasedPlanning() {
ts, _, _ := lp.nextVehiclePlan()
return ts
ts, _, _ = lp.nextVehiclePlan()
} else {
ts, _ = lp.GetPlanEnergy()
}

ts, _ := lp.GetPlanEnergy()
lp.planActiveTime = ts

return ts
}

Expand Down
2 changes: 1 addition & 1 deletion core/loadpoint_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func (lp *Loadpoint) finishPlan() {
} else if v := lp.GetVehicle(); v != nil {
vehicle.Settings(lp.log, v).SetPlanSoc(time.Time{}, 0)
}
lp.log.DEBUG.Println("plan: deleting expired plan")
}

// remainingPlanEnergy returns missing energy amount in kWh
Expand Down Expand Up @@ -105,7 +106,6 @@ func (lp *Loadpoint) plannerActive() (active bool) {

// keep overrunning plans as long as a vehicle is connected
if lp.clock.Until(planTime) < 0 && (!lp.planActive || !lp.connected()) {
lp.log.DEBUG.Println("plan: deleting expired plan")
lp.finishPlan()
return false
}
Expand Down
Loading