From 79c6d9125b7780cace1aacf9dbcd25abc20b86a5 Mon Sep 17 00:00:00 2001 From: Jens Hedegaard Nielsen Date: Wed, 16 Aug 2017 13:27:15 +0200 Subject: [PATCH] Fix monitor for channel parameters (#61) --- qcodes/monitor/monitor.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qcodes/monitor/monitor.py b/qcodes/monitor/monitor.py index 04dc9f91a88..df0bfc560d8 100644 --- a/qcodes/monitor/monitor.py +++ b/qcodes/monitor/monitor.py @@ -34,7 +34,7 @@ def _get_metadata(*parameters) -> Dict[float, list]: """ - Return a dict that contains the paraemter metadata grouped by the + Return a dict that contains the parameter metadata grouped by the instrument it belongs to. """ ts = time.time() @@ -45,16 +45,20 @@ def _get_metadata(*parameters) -> Dict[float, list]: if _meta: meta = _meta() else: - raise ValueError("Input is not a paraemter; Refusing to proceed") + raise ValueError("Input is not a parameter; Refusing to proceed") # convert to string meta['value'] = str(meta['value']) if meta["ts"] is not None: meta["ts"] = time.mktime(meta["ts"].timetuple()) meta["name"] = parameter.label or parameter.name meta["unit"] = parameter.unit - accumulator = metas.get(str(parameter._instrument), []) + # find the base instrument in case this is a channel parameter + baseinst = parameter._instrument + while hasattr(baseinst, '_parent'): + baseinst = baseinst._parent + accumulator = metas.get(str(baseinst), []) accumulator.append(meta) - metas[str(parameter._instrument)] = accumulator + metas[str(baseinst)] = accumulator parameters = [] for instrument in metas: temp = {"instrument": instrument, "parameters": metas[instrument]} @@ -117,7 +121,7 @@ def run(self): def stop(self): """ - Shutodwn the server, close the event loop and join the thread + Shutdown the server, close the event loop and join the thread """ # this contains the server # or any exception