2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-26 19:58:25 +08:00

simple: refactor IPC set_dataset

This commit is contained in:
Simon Renblad 2023-07-12 10:20:00 +08:00 committed by Sébastien Bourdeauducq
parent 9a84575649
commit af7622d7ab

View File

@ -19,8 +19,15 @@ class AppletControlIPC:
def __init__(self, ipc): def __init__(self, ipc):
self.ipc = ipc self.ipc = ipc
def set_dataset(self, key, value, persist=None): def set_dataset(self, key, value, unit=None, scale=None, precision=None, persist=None):
self.ipc.set_dataset(key, value, persist) 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): def mutate_dataset(self, key, index, value):
mod = {"action": "setitem", "path": [key, 1], "key": index, "value": value} mod = {"action": "setitem", "path": [key, 1], "key": index, "value": value}
@ -112,10 +119,11 @@ class AppletIPCClient(AsyncioChildComm):
self.mod_cb = mod_cb self.mod_cb = mod_cb
self.listen_task = loop.create_task(self.listen()) 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", self.write_pyon({"action": "set_dataset",
"key": key, "key": key,
"value": value, "value": value,
"metadata": metadata,
"persist": persist}) "persist": persist})
def update_dataset(self, mod): def update_dataset(self, mod):