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):
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
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.
return wrapper
return decorator
+# ---------- Bottle routes ----------
+
@route('/')
def index():
redirect('/list/general_overview')
def static_content(path):
return static_file(path, root='./static/')
+# ---------- main() function - managing CLI arg parsing / startup ----------
+
def main():
global CONFIG, PVS, HISTORY