diff --git a/goodwe_controller/test_ev60.py b/goodwe_controller/test_ev60.py index e60dd6e..625deb8 100644 --- a/goodwe_controller/test_ev60.py +++ b/goodwe_controller/test_ev60.py @@ -990,14 +990,19 @@ r1 = t1b("R") c_b = [t for t, a in rb.nz if a == 6.0] c_c = [t for t, a in rc.nz if a == 6.0] c_d = [t for t, a in rd_.nz if a == 6.0] -check(f"T22: first cut close >= RETRY_S after cut_fail_at: T2b {c_b[0]} vs " - f"100, T2c {c_c[0]} vs 100, T21b {c_d[0]} vs 870; the next ones 5 s " - f"apart ({c_b[1] - c_b[0]}, {c_c[1] - c_c[0]}, {c_d[1] - c_d[0]}); " - f"T1b's 0 A at {r1.zeros[1]} vs 0", - c_b[0] - 100 >= CM.RETRY_S and c_c[0] - 100 >= CM.RETRY_S - and c_d[0] - 870 >= CM.RETRY_S and c_b[1] - c_b[0] == 5 - and c_c[1] - c_c[0] == 5 and c_d[1] - c_d[0] == 5 - and r1.zeros[1] - r1.zeros[0] >= CM.RETRY_S) +def at(xs, i, d=-10 ** 9): + return xs[i] if len(xs) > i else d + + +b0, b1, k0, k1, d0, d1, z0, z1 = (at(c_b, 0), at(c_b, 1), at(c_c, 0), + at(c_c, 1), at(c_d, 0), at(c_d, 1), + at(r1.zeros, 0), at(r1.zeros, 1)) +check(f"T22: first cut close >= RETRY_S after cut_fail_at: T2b {b0} vs " + f"100, T2c {k0} vs 100, T21b {d0} vs 870; the next ones 5 s apart " + f"({b1 - b0}, {k1 - k0}, {d1 - d0}); T1b's 0 A at {z1} vs {z0}", + b0 - 100 >= CM.RETRY_S and k0 - 100 >= CM.RETRY_S + and d0 - 870 >= CM.RETRY_S and b1 - b0 == 5 and k1 - k0 == 5 + and d1 - d0 == 5 and z1 - z0 >= CM.RETRY_S) # T25-flag: a stale `_cap_end` cannot make a later sequence's end skip # `step`'s end-of-sequence handling (reset at each `_advance` entry) @@ -1027,8 +1032,9 @@ check(f"T25-flag: with a stale flag set before a normal change (the close is " # =========================================================================== # print("\n6. THE NEVERS OVER EVERY RUN, SOURCE CHECKS (N1-N14, T13, T23)") # =========================================================================== # -worst = max((max(per_key(r.tries).values(), default=0) - r.cap_ - for r in ALL), default=0) +worst = max((max((n + (r.pre0 if k_ == r.key0 else 0) + for k_, n in per_key(r.tries).items()), default=0) - r.cap_ + for r in ALL), default=0) check(f"N1: never more than MAX_TRIES refused or raised cut tries in one " f"quarter key, over {len(ALL)} runs (worst: {worst} over the cap)", worst <= 0 and len(ALL) > 40)