"""A2a condition-streaming live smoke on a `rig.py up --conditions` run (plan ยง9 A2; the full gate is A4). Raises the SOURCE scripted alarm `ScalarHigh` (scalar register 20 := 150) through the device control API, then runs the probe's `--scenario conditions` on both SOURCE data listeners: the Primary must stream a snapshot (total, records with the active alarm, snapshot_complete) and, after the probe clears the alarm (scalar := 0), a delta record; the Secondary must refuse the condition item (Primary-only). Evidence lands in the run's restricted `evidence/` folder. """ import argparse import json import sys import time import scenarios def main(argv=None): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--run-id", required=True) parser.add_argument("--settle-seconds", type=int, default=8) arguments = parser.parse_args(argv) runner = scenarios.ScenarioRunner(arguments.run_id) runner.active, runner.deadline = "A2a", time.monotonic() + 600 runner.publish() runner.device("set", address=20, value=150) time.sleep(arguments.settle_seconds) output = runner.folder / "A2a-conditions-wire.json" result = runner.process(["dotnet", str(runner.probe_dll), "--manifest", str(runner.manifest_path), "--scenario", "conditions", # The UNS export root is the equipment, addressed by its catalog identifier (the EquipmentId). "--equipment", runner.manifest["fixture"]["browse_roots"]["uns"], "--subject", runner.manifest["fixture"]["browse_subjects"]["uns"], "--output", str(output)], "A2a-conditions-wire", timeout=240) wire = scenarios.restricted_json(output) if output.exists() else {"passed": False, "stderr": result.stderr[-4000:]} runner.device("set", address=20, value=0) print(json.dumps(wire, indent=2)[:20000]) return 0 if wire.get("passed") else 1 if __name__ == "__main__": sys.exit(main())