From af7622d7abd8e37b42bca056a499a69189c524f3 Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Wed, 12 Jul 2023 10:20:00 +0800 Subject: [PATCH] simple: refactor IPC set_dataset --- artiq/applets/simple.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/artiq/applets/simple.py b/artiq/applets/simple.py index 8adb064d2..7aab32b05 100644 --- a/artiq/applets/simple.py +++ b/artiq/applets/simple.py @@ -19,8 +19,15 @@ class AppletControlIPC: def __init__(self, ipc): self.ipc = ipc - def set_dataset(self, key, value, persist=None): - self.ipc.set_dataset(key, value, persist) + def set_dataset(self, key, value, unit=None, scale=None, precision=None, persist=None): + metadata = {} + if unit is not None: + metadata["unit"] = unit + if scale is not None: + metadata["scale"] = scale + if precision is not None: + metadata["precision"] = precision + self.ipc.set_dataset(key, value, metadata, persist) def mutate_dataset(self, key, index, value): mod = {"action": "setitem", "path": [key, 1], "key": index, "value": value} @@ -112,10 +119,11 @@ class AppletIPCClient(AsyncioChildComm): self.mod_cb = mod_cb self.listen_task = loop.create_task(self.listen()) - def set_dataset(self, key, value, persist=None): + def set_dataset(self, key, value, metadata, persist=None): self.write_pyon({"action": "set_dataset", "key": key, "value": value, + "metadata": metadata, "persist": persist}) def update_dataset(self, mod):