From a6039c23b91d51be720ab59d271597fb80cd4d04 Mon Sep 17 00:00:00 2001 From: premultiply Date: Wed, 2 Mar 2022 17:47:47 +0100 Subject: [PATCH] Validate charger phase wiring during charging (#2739) --- core/loadpoint.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/core/loadpoint.go b/core/loadpoint.go index ac91119ee..a544cd74b 100644 --- a/core/loadpoint.go +++ b/core/loadpoint.go @@ -1285,12 +1285,14 @@ func (lp *LoadPoint) updateChargeCurrents() { lp.publish("chargeCurrents", lp.chargeCurrents) if lp.charging() { + // Quine-McCluskey for (¬L1∧L2∧¬L3) ∨ (¬L1∧¬L2∧L3) ∨ (L1∧¬L2∧L3) ∨ (¬L1∧L2∧L3) -> ¬L1 ∧ L2 ∨ ¬L2 ∧ L3 + if !(i1 > minActiveCurrent) && (i2 > minActiveCurrent) || !(i2 > minActiveCurrent) && (i3 > minActiveCurrent) { + lp.log.WARN.Printf("invalid phase wiring between charge meter and vehicle") + } + var phases int - for l, i := range lp.chargeCurrents { - if i >= minActiveCurrent { - if l > 0 && phases == 0 { - lp.log.WARN.Printf("invalid wiring: phase %d observed active should be first phase", l+1) - } + for _, i := range lp.chargeCurrents { + if i > minActiveCurrent { phases++ } }