]> jspc29.x-matter.uni-frankfurt.de Git - mvd_epics.git/commitdiff
dashboard: fix when value|char_value is numpy.ndarray
authorPhilipp Klaus <philipp.l.klaus@web.de>
Mon, 29 Oct 2018 10:20:33 +0000 (11:20 +0100)
committerPhilipp Klaus <philipp.l.klaus@web.de>
Mon, 29 Oct 2018 10:20:33 +0000 (11:20 +0100)
python_suite/dashboard/dashboard.py

index 98e60ca6396b85c996f06eabf22aaa1e21365a18..e6e09d4761d485a2d18b6451f5ebade2477657c6 100755 (executable)
@@ -9,6 +9,13 @@ from bottle import jinja2_view as view
 from requestlogger import WSGILogger, ApacheFormatter
 from logging.handlers import TimedRotatingFileHandler
 
+
+try:
+    import numpy as np
+    HAS_NUMPY = True
+except ImportError:
+    HAS_NUMPY = False
+
 CONFIG = None
 PVS = {}
 HISTORY = {}
@@ -80,6 +87,9 @@ def cb_value_update(**kwargs):
         if pv['name'] != kwargs['pvname']: continue
 
         history_garbage_collection()
+        for prop in ('value', 'char_value'):
+            if HAS_NUMPY and isinstance(kwargs[prop], np.ndarray):
+                kwargs[prop] = kwargs[prop].tolist()
         class_map = {
           epics.NO_ALARM :      "",
           epics.MINOR_ALARM :   "minor_alarm",