diff --git a/goodwe_controller/DECISIONS/SAFETY-107-refusal-under-another-writer.md b/goodwe_controller/DECISIONS/SAFETY-107-refusal-under-another-writer.md index 40e427c..a3c1062 100644 --- a/goodwe_controller/DECISIONS/SAFETY-107-refusal-under-another-writer.md +++ b/goodwe_controller/DECISIONS/SAFETY-107-refusal-under-another-writer.md @@ -37,7 +37,10 @@ probe, exactly as before the change. Then: while another writer is; 2. it does not: the refusal ends, logged "another writer", or "the battery gives power" when the reading shows it (it was "another writer" before); -3. it finds the other direction: end, then a new start, as before. +3. it finds the other direction: end, then a new start, as before. In + practice 2 comes first: SAFETY-94's evidence restarts when the ask changes + sign, so a writer that turns round ends the refusal at once and the other + way is learned ~12 cycles later (`test_safety107.py` part 3e). **Why this rule.** The end now means what SAFETY-52 meant by it: the refusal no longer describes what is on the wire, judged by the same test that learns it. diff --git a/goodwe_controller/test_safety107.py b/goodwe_controller/test_safety107.py index 8f202b9..e3f7516 100644 --- a/goodwe_controller/test_safety107.py +++ b/goodwe_controller/test_safety107.py @@ -272,6 +272,17 @@ check("the refusal carries over to the loop with no line", check("the first probe after the writer left comes PROBE_EVERY_S later", close[0] is not None and bool(probes) and probes[0] >= close[0] + control.PROBE_EVERY_S - 10.0) +# e. A writer turns round on a dead pack with no gap. The evidence restarts +# on the new sign (SAFETY-94), so the old refusal ends at once and the +# other way is learned once, ~12 cycles later. +rows, log, _ = run(1, plant=lambda u, t, cmd: ( + -2.0 - int(t) % 3 if u == "a" else round(cmd)), house=lambda t: 2000.0, + maint=False, trade=lambda t: 2000.0 if t < 300.0 else -2000.0) +e = ends(log) +print(" " + " / ".join(f"{x[0]:.0f} s {x[1][:45]}" for x in lines(log))) +check("a writer turns round on a dead pack: one end, then the other way", + len(lines(log)) == 3 and len(e) == 1 and 300.0 < e[0][0] < 400.0 + and present(nth(rows, -1)) and nth(rows, -1)[4] == -1) # ============================================================================== print("\n4. not covered: a perfectly flat reading under a writer")