From 6bdb76e9ea8980e10fcb61357d9035e7bc18f322 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Mon, 22 May 2017 16:48:00 +0800 Subject: [PATCH] core device logging controller WIP (#691) --- RELEASE_NOTES.rst | 5 ++ artiq/examples/drtio/device_db.py | 10 +++- artiq/examples/master/device_db.py | 10 +++- artiq/examples/phaser/device_db.py | 13 ++++-- artiq/frontend/aqctl_corelog.py | 55 ++++++++++++++++++++++ doc/manual/default_network_ports.rst | 69 ++++++++++++++-------------- 6 files changed, 122 insertions(+), 40 deletions(-) create mode 100755 artiq/frontend/aqctl_corelog.py diff --git a/RELEASE_NOTES.rst b/RELEASE_NOTES.rst index e6fc5e4e1..fa8a83f58 100644 --- a/RELEASE_NOTES.rst +++ b/RELEASE_NOTES.rst @@ -38,6 +38,11 @@ Release notes * Controllers are now named ``aqctl_XXX`` instead of ``XXX_controller``. * In the device database, the "comm" device has been folded into the "core" device. Move the "host" argument into the "core" device, and remove the "comm" device. +* The core device log now contains important information about events such as + RTIO collisions. A new controller ``aqctl_corelog`` must be running to forward + those logs to the master. See the example device databases to see how to + instantiate this controller. Using ``artiq_session`` ensures that a controller + manager is running simultaneously with the master. 2.3 diff --git a/artiq/examples/drtio/device_db.py b/artiq/examples/drtio/device_db.py index 2de6862c8..bf64b6df9 100644 --- a/artiq/examples/drtio/device_db.py +++ b/artiq/examples/drtio/device_db.py @@ -2,12 +2,20 @@ # The RTIO channel numbers here are for NIST CLOCK on KC705. # The list of devices here is not exhaustive. +core_addr = "kc705.lab.m-labs.hk" + device_db = { "core": { "type": "local", "module": "artiq.coredevice.core", "class": "Core", - "arguments": {"host": "kc705.lab.m-labs.hk", "ref_period": 2e-9} + "arguments": {"host": core_addr, "ref_period": 2e-9} + }, + "core_log": { + "type": "controller", + "host": "::1", + "port": 1068, + "command": "aqctl_corelog -p {port} --bind {bind} " + core_addr }, "core_cache": { "type": "local", diff --git a/artiq/examples/master/device_db.py b/artiq/examples/master/device_db.py index b53f53734..0af7c28c1 100644 --- a/artiq/examples/master/device_db.py +++ b/artiq/examples/master/device_db.py @@ -2,12 +2,20 @@ # The RTIO channel numbers here are for NIST CLOCK on KC705. # The list of devices here is not exhaustive. +core_addr = "kc705.lab.m-labs.hk" + device_db = { "core": { "type": "local", "module": "artiq.coredevice.core", "class": "Core", - "arguments": {"host": "kc705.lab.m-labs.hk", "ref_period": 1e-9} + "arguments": {"host": core_addr, "ref_period": 1e-9} + }, + "core_log": { + "type": "controller", + "host": "::1", + "port": 1068, + "command": "aqctl_corelog -p {port} --bind {bind} " + core_addr }, "core_cache": { "type": "local", diff --git a/artiq/examples/phaser/device_db.py b/artiq/examples/phaser/device_db.py index d1397efb9..e487e0711 100644 --- a/artiq/examples/phaser/device_db.py +++ b/artiq/examples/phaser/device_db.py @@ -1,14 +1,19 @@ # The RTIO channel numbers here are for Phaser on KC705. +core_addr = "kc705aux.lab.m-labs.hk" + device_db = { "core": { "type": "local", "module": "artiq.coredevice.core", "class": "Core", - "arguments": { - "host": "kc705aux.lab.m-labs.hk", - "ref_period": 5e-9/6 - } + "arguments": {"host": core_addr, "ref_period": 5e-9/6} + }, + "core_log": { + "type": "controller", + "host": "::1", + "port": 1068, + "command": "aqctl_corelog -p {port} --bind {bind} " + core_addr }, "core_cache": { "type": "local", diff --git a/artiq/frontend/aqctl_corelog.py b/artiq/frontend/aqctl_corelog.py new file mode 100755 index 000000000..fbff64691 --- /dev/null +++ b/artiq/frontend/aqctl_corelog.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 + +import argparse +import asyncio + +from artiq.protocols.pc_rpc import Server +from artiq.tools import * + + +def get_argparser(): + parser = argparse.ArgumentParser( + description="ARTIQ controller for core device logs") + simple_network_args(parser, 1068) + parser.add_argument("core_addr", + help="hostname or IP address of the core device") + verbosity_args(parser) + return parser + + +class PingTarget: + def ping(self): + return True + + +async def get_logs(host): + while True: + print("TODO: not implemented. host:", host) + await asyncio.sleep(2) + + +def main(): + args = get_argparser().parse_args() + init_logger(args) + + loop = asyncio.get_event_loop() + try: + get_logs_task = asyncio.ensure_future(get_logs(args.core_addr)) + try: + server = Server({"corelog": PingTarget()}, None, True) + loop.run_until_complete(server.start(bind_address_from_args(args), args.port)) + try: + loop.run_until_complete(server.wait_terminate()) + finally: + loop.run_until_complete(server.stop()) + finally: + get_logs_task.cancel() + try: + loop.run_until_complete(get_logs_task) + except asyncio.CancelledError: + pass + finally: + loop.close() + +if __name__ == "__main__": + main() diff --git a/doc/manual/default_network_ports.rst b/doc/manual/default_network_ports.rst index e3e669019..188270095 100644 --- a/doc/manual/default_network_ports.rst +++ b/doc/manual/default_network_ports.rst @@ -1,37 +1,38 @@ Default network ports ===================== -+--------------------------+--------------+ -| Component | Default port | -+==========================+==============+ -| Core device (management) | 1380 | -+--------------------------+--------------+ -| Core device (main) | 1381 | -+--------------------------+--------------+ -| Core device (analyzer) | 1382 | -+--------------------------+--------------+ -| Core device (mon/inj) | 1383 | -+--------------------------+--------------+ -| Master (logging input) | 1066 | -+--------------------------+--------------+ -| Master (broadcasts) | 1067 | -+--------------------------+--------------+ -| InfluxDB bridge | 3248 | -+--------------------------+--------------+ -| Controller manager | 3249 | -+--------------------------+--------------+ -| Master (notifications) | 3250 | -+--------------------------+--------------+ -| Master (control) | 3251 | -+--------------------------+--------------+ -| PDQ2 | 3252 | -+--------------------------+--------------+ -| LDA | 3253 | -+--------------------------+--------------+ -| Novatech 409B | 3254 | -+--------------------------+--------------+ -| Thorlabs T-Cube | 3255 | -+--------------------------+--------------+ -| Korad KA3005P | 3256 | -+--------------------------+--------------+ - ++--------------------------------+--------------+ +| Component | Default port | ++================================+==============+ +| Core device (management) | 1380 | ++--------------------------------+--------------+ +| Core device (main) | 1381 | ++--------------------------------+--------------+ +| Core device (analyzer) | 1382 | ++--------------------------------+--------------+ +| Core device (mon/inj) | 1383 | ++--------------------------------+--------------+ +| Master (logging input) | 1066 | ++--------------------------------+--------------+ +| Master (broadcasts) | 1067 | ++--------------------------------+--------------| +| Core device logging controller | 1068 | ++--------------------------------+--------------+ +| InfluxDB bridge | 3248 | ++--------------------------------+--------------+ +| Controller manager | 3249 | ++--------------------------------+--------------+ +| Master (notifications) | 3250 | ++--------------------------------+--------------+ +| Master (control) | 3251 | ++--------------------------------+--------------+ +| PDQ2 | 3252 | ++--------------------------------+--------------+ +| LDA | 3253 | ++--------------------------------+--------------+ +| Novatech 409B | 3254 | ++--------------------------------+--------------+ +| Thorlabs T-Cube | 3255 | ++--------------------------------+--------------+ +| Korad KA3005P | 3256 | ++--------------------------------+--------------+