Skip to content

Commit

Permalink
Planner: publish overrun duration (#13126)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Mar 28, 2024
1 parent 72d33b5 commit 6446d92
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
6 changes: 3 additions & 3 deletions assets/js/components/ChargingPlan.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<span class="targetTimeLabel"> {{ targetTimeLabel() }}</span>
<div
class="extraValue text-nowrap"
:class="{ 'text-warning': planOverrun }"
:class="{ 'text-warning': planTimeUnreachable }"
>
{{ targetSocLabel }}
</div>
Expand Down Expand Up @@ -125,7 +125,7 @@ export default {
planActive: Boolean,
planEnergy: Number,
planTime: String,
planOverrun: Boolean,
planTimeUnreachable: Boolean,
rangePerSoc: Number,
smartCostLimit: Number,
smartCostType: String,
Expand All @@ -146,7 +146,7 @@ export default {
},
computed: {
buttonColor: function () {
if (this.planOverrun) {
if (this.planTimeUnreachable) {
return "text-warning";
}
if (!this.enabled) {
Expand Down
6 changes: 2 additions & 4 deletions assets/js/components/ChargingPlanWarnings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ export default {
if (planTime && this.endTime) {
const dateWanted = new Date(planTime);
const dateEstimated = new Date(this.endTime);
// account for rounding errors
dateWanted.setSeconds(60);
dateEstimated.setSeconds(0);
return dateWanted < dateEstimated;
// 1 minute tolerance
return dateEstimated - dateWanted > 60 * 1e3;
}
return false;
},
Expand Down
6 changes: 5 additions & 1 deletion assets/js/components/Loadpoint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default {
vehicles: Array,
planActive: Boolean,
planProjectedStart: String,
planOverrun: Boolean,
planOverrun: Number,
planEnergy: Number,
planTime: String,
effectivePlanTime: String,
Expand Down Expand Up @@ -241,6 +241,10 @@ export default {
const features = this.vehicle?.features || [];
return features.includes("Offline") && features.includes("Retryable");
},
planTimeUnreachable: function () {
// 1 minute tolerance
return this.planOverrun > 60;
},
socBasedCharging: function () {
return this.vehicleHasSoc || this.vehicleSoc > 0;
},
Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/Vehicle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default {
planEnergy: Number,
planProjectedStart: String,
planTime: String,
planOverrun: Boolean,
planTimeUnreachable: Boolean,
pvAction: String,
pvRemainingInterpolated: Number,
smartCostActive: Boolean,
Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/VehicleSoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
class="plan-marker"
data-bs-toggle="tooltip"
:class="{
'plan-marker--warning': planOverrun,
'plan-marker--warning': planTimeUnreachable,
'plan-marker--error': planMarkerUnreachable,
}"
:style="{ left: `${planMarkerPosition}%` }"
Expand Down Expand Up @@ -91,7 +91,7 @@ export default {
effectiveLimitSoc: Number,
limitEnergy: Number,
planEnergy: Number,
planOverrun: Boolean,
planTimeUnreachable: Boolean,
chargedEnergy: Number,
socBasedCharging: Boolean,
socBasedPlanning: Boolean,
Expand Down
4 changes: 2 additions & 2 deletions core/loadpoint_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (lp *Loadpoint) plannerActive() (active bool) {
}()

var planStart time.Time
var planOverrun bool
var planOverrun time.Duration
defer func() {
lp.publish(keys.PlanProjectedStart, planStart)
lp.publish(keys.PlanOverrun, planOverrun)
Expand Down Expand Up @@ -125,7 +125,7 @@ func (lp *Loadpoint) plannerActive() (active bool) {
var overrun string
if excessDuration := requiredDuration - lp.clock.Until(planTime); excessDuration > 0 {
overrun = fmt.Sprintf("overruns by %v, ", excessDuration.Round(time.Second))
planOverrun = true
planOverrun = excessDuration
}

planStart = planner.Start(plan)
Expand Down

0 comments on commit 6446d92

Please sign in to comment.