From d1486e9df1ce05dbf437bfe3baf30d1203b94c6b Mon Sep 17 00:00:00 2001 From: grabowski Date: Thu, 12 Mar 2026 13:37:21 +0700 Subject: [PATCH] Add degauss command for demagnetizing current sensor cores Co-Authored-By: Claude Opus 4.6 --- hioki3193/cli.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/hioki3193/cli.py b/hioki3193/cli.py index 65a2314..de17abc 100644 --- a/hioki3193/cli.py +++ b/hioki3193/cli.py @@ -368,6 +368,15 @@ def cmd_integration(meter: Hioki3193, args: argparse.Namespace) -> None: print(f"Integrating channels: {status}") +def cmd_degauss(meter: Hioki3193, args: argparse.Namespace) -> None: + """Degauss (demagnetize) current sensor cores.""" + channels = args.channels if args.channels else [5, 6] + items = ",".join(f"I{ch}" for ch in channels) + print(f"Degaussing: {items}") + meter.write(f":DEMAg {items}") + print("Degauss command sent. Wait for the instrument to finish.") + + def main() -> None: parser = argparse.ArgumentParser( description="HIOKI 3193-10 Power Analyzer GPIB Tool", @@ -439,6 +448,10 @@ examples: p_int = sub.add_parser("integration", help="Integration control") p_int.add_argument("action", choices=["start", "stop", "reset", "status"]) + # degauss + p_demag = sub.add_parser("degauss", help="Degauss (demagnetize) current sensor cores") + p_demag.add_argument("channels", nargs="*", type=int, help="Channel numbers (default: 5 6)") + # send p_send = sub.add_parser("send", help="Send raw SCPI/GPIB command") p_send.add_argument("raw_command", nargs="+", help="Command string (queries auto-detected by '?')") @@ -455,6 +468,7 @@ examples: "efficiency": cmd_efficiency_setup, "setup-mppt": cmd_setup_mppt, "integration": cmd_integration, + "degauss": cmd_degauss, "send": cmd_send, }