From: Ole Artz Date: Wed, 2 Aug 2017 13:35:16 +0000 (+0200) Subject: DASH: dynamic status updates from EPICS CA X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=4901fc3f3e01e3fb08ad8f03d9a4a697cfceeeb7;p=mvd_epics.git DASH: dynamic status updates from EPICS CA --- diff --git a/python_suite/dashboard/.gitignore b/python_suite/dashboard/.gitignore new file mode 100644 index 0000000..d344ba6 --- /dev/null +++ b/python_suite/dashboard/.gitignore @@ -0,0 +1 @@ +config.json diff --git a/python_suite/dashboard/dashboard.py b/python_suite/dashboard/dashboard.py index 8d41242..f43c7b1 100755 --- a/python_suite/dashboard/dashboard.py +++ b/python_suite/dashboard/dashboard.py @@ -1,15 +1,50 @@ #!/usr/bin/env python +import json +import epics + from bottle import route, run, static_file from bottle import jinja2_view as view +CONFIG = None + @route('/') @view('pv_overview.jinja2') def index(): - return {} + global CONFIG + for group in CONFIG['groups']: + for pv in group['PVs']: + p = epics.PV(pv['name']) + p.get_ctrlvars() + if 'enum' in p.type: + pv['value'] = p.get(as_string=True) + else: + pv['value'] = p.get() + pv['unit'] = p.units or '' + return CONFIG @route('/static/') def static_content(path): return static_file(path, root='./static/') -run(host='', port=8080) +def main(): + global CONFIG + + import argparse + parser = argparse.ArgumentParser() + parser.add_argument('--host', default='', + help='The host (IP address) the web server should listen on.') + parser.add_argument('--port', default=4913, + help='The port the web server should listen on.') + parser.add_argument('--config', '-c', required=True, + help='The config file with the definition of process variables and EPICS hosts.') + parser.add_argument('--debug', action='store_true', + help='Set the debug mode of the web server.') + args = parser.parse_args() + + with open(args.config, 'r') as f: + CONFIG = json.load(f) + + run(host=args.host, port=args.port, debug=args.debug) + +if __name__ == "__main__": main() diff --git a/python_suite/dashboard/example.config.json b/python_suite/dashboard/example.config.json new file mode 100644 index 0000000..8fb5bd0 --- /dev/null +++ b/python_suite/dashboard/example.config.json @@ -0,0 +1,19 @@ +{ + "groups": [ + { + "name": "Cooling", + "PVs": [ + {"name": "CBM:MVD:COOLING:CC405:BathTemperatureMom"}, + {"name": "CBM:MVD:COOLING:CC405:ExternalTemperatureMom"} + ] + }, + { + "name": "Pressure", + "PVs": [ + {"name": "CBM:MVD:VACUUM:PRESTO_RECIPIENT:A:TPR2:Voltage"}, + {"name": "CBM:MVD:VACUUM:RECIPIENT:3:Pressure"}, + {"name": "CBM:MVD:VACUUM:RECIPIENT:3:Status"} + ] + } + ] +} diff --git a/python_suite/dashboard/views/pv_overview.jinja2 b/python_suite/dashboard/views/pv_overview.jinja2 index 13ff0c2..90dd9e9 100644 --- a/python_suite/dashboard/views/pv_overview.jinja2 +++ b/python_suite/dashboard/views/pv_overview.jinja2 @@ -37,9 +37,9 @@
of the Compressed Baryonic Matter
-
-

Cooling

-

HUBER_COOLING

+ {% for group in groups %} +
+

{{ group.name }}

@@ -51,192 +51,16 @@ + {% for PV in group.PVs %} - - - - - - - - - - - - - - -
Value Unit
Bath Temperature Momentum° C
External Temperature Momentum° C
Current Setpoint Value° C
-

FLOW_METER

- - - - - - - - - - - - - - - - - - - - - -
Process VariableValueUnit
Flow Inputl/min
Flow Outputl/min
-
-
-

Pressure

-

BALZERS_PKG020

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Process VariableValueUnit
Side A - IKR Voltage V
Side A - TPR2 VoltageV
Side B - IKR VoltageV
Side B - TPR2 VoltageV
-

VACOM_MVC3

-
-
-

Temperature

-

PT100_BOARD

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + {% endfor %}
Process VariableValueUnit
ID 00° C
ID 01° C
ID 02° C
ID 03° C
ID 04° C
ID 05° C
ID 06° C
ID 07° C
ID 08° C
ID 09° C
ID 10° C
ID 11° C
ID 12° C
ID 13° C
ID 14° C
ID 15° C
ID 16° C
ID 17° C{{ PV.name }}{{ PV.value }}{{ PV.unit }}
+ {% endfor %}