]> jspc29.x-matter.uni-frankfurt.de Git - mvd_epics.git/commitdiff
DASH: structure dashboard.py with section comments
authorPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Mon, 28 Aug 2017 15:31:03 +0000 (17:31 +0200)
committerPhilipp Klaus <klaus@physik.uni-frankfurt.de>
Mon, 28 Aug 2017 15:31:03 +0000 (17:31 +0200)
python_suite/dashboard/dashboard.py

index 61d27e69ad26a30b18139e96293ce3fffbe185f6..5718a182901912507ed4d016381391aac0d5e318 100755 (executable)
@@ -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