From: Philipp Klaus Date: Mon, 28 Aug 2017 15:31:03 +0000 (+0200) Subject: DASH: structure dashboard.py with section comments X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=48d3ffbbbbaf2bbd42f3156eea3eef20e22b773d;p=mvd_epics.git DASH: structure dashboard.py with section comments --- diff --git a/python_suite/dashboard/dashboard.py b/python_suite/dashboard/dashboard.py index 61d27e6..5718a18 100755 --- a/python_suite/dashboard/dashboard.py +++ b/python_suite/dashboard/dashboard.py @@ -13,6 +13,8 @@ HISTORY = {} GC_LAST_RUN = time.time() HISTORY_LENGTH=30*60 +# ------------ History management functions ------------ + def history_garbage_collection(): global HISTORY, GC_LAST_RUN if GC_LAST_RUN > (time.time() - 5): @@ -37,6 +39,8 @@ def register_pv_value_in_history(pv_name, ts, value): HISTORY[pv_name].append( [ts-0.1, HISTORY[pv_name][-1][1]] ) HISTORY[pv_name].append( [ts, value] ) +# ------------ Callback functions for the PyEpics Channel Access events ------------ + def cb_connection_change(**kwargs): global CONFIG @@ -108,6 +112,8 @@ def cb_value_update(**kwargs): if pv['unit'] == 'deg C': pv['unit'] = '°C' if pv['unit'] == 'g/m3': pv['unit'] = 'g/m³' +# ---------- Bottle plugins / decorators ---------- + def json_replace_nan(): """ Custom JSON decorator for Bottle routes. @@ -137,6 +143,8 @@ def json_replace_nan(): return wrapper return decorator +# ---------- Bottle routes ---------- + @route('/') def index(): redirect('/list/general_overview') @@ -178,6 +186,8 @@ def api_history(name): def static_content(path): return static_file(path, root='./static/') +# ---------- main() function - managing CLI arg parsing / startup ---------- + def main(): global CONFIG, PVS, HISTORY