diff --git a/epics/html/wsgi/wsgi_isttok_archive.py b/epics/html/wsgi/wsgi_isttok_archive.py new file mode 100644 index 0000000..9380937 --- /dev/null +++ b/epics/html/wsgi/wsgi_isttok_archive.py @@ -0,0 +1,210 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +Created on Thu Feb 8 16:34:35 2018 + +@author: joao_loureiro/bernardo carvalho +add EPICS path to /etc/apache2/envvars + +""" + +import epics +import time +import os + +os.environ['MPLCONFIGDIR'] = '/var/www/html/matplotlib' + +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt +import matplotlib.ticker as mtick +from matplotlib.ticker import FuncFormatter + +import mpld3 +from mpld3 import plugins, utils + +import numpy as np +import MySQLdb + +os.environ['EPICS_CA_ADDR_LIST']= '192.168.1.110 192.168.1.152' +os.environ['EPICS_CA_AUTO_ADDR_LIST']= 'NO' + +def format_tick_labels(x, pos): + return f"{x:5.2g}" + +class HelloWorld(mpld3.plugins.PluginBase): # inherit from PluginBase + """Hello World plugin""" + + JAVASCRIPT = """ + mpld3.register_plugin("helloworld", HelloWorld); + HelloWorld.prototype = Object.create(mpld3.Plugin.prototype); + HelloWorld.prototype.constructor = HelloWorld; + function HelloWorld(fig, props){ + mpld3.Plugin.call(this, fig, props); + }; + + HelloWorld.prototype.draw = function(){ + // FIXME: this is a very brittle way to select the y-axis element + var ax = this.fig.axes[0].elements[1]; + + // see https://github.com/mbostock/d3/wiki/Formatting#d3_format + // for d3js formating documentation + ax.axis.tickFormat(d3.format(",.3e")); + + // TODO: use a function for tick values that + // updates when values pan and zoom + //ax.axis.tickValues([1,100,1000]); + + // HACK: use reset to redraw figure + this.fig.reset(); + } + """ + def __init__(self): + self.dict_ = {"type": "helloworld"} + +style_tooltip = """ + +""" + +def text_with_tooltip(text, tooltip): + html = '
sys path: ' + os.environ['PATH'] + '
' \ diff --git a/epics/html/wsgi/wsgi_isttok_status.py b/epics/html/wsgi/wsgi_isttok_status.py index d68db9b..bb437de 100644 --- a/epics/html/wsgi/wsgi_isttok_status.py +++ b/epics/html/wsgi/wsgi_isttok_status.py @@ -15,44 +15,50 @@ Created on December 8 16:34:35 2019 @author: bernardo carvalho@IPFN """ # -from epics import caget, caput, cainfo +from epics import caget, caput, cainfo, PV import os #os.environ['EPICS_CA_ADDR_LIST'] = 'localhost 192.168.1.110 192.168.1.120' -os.environ['EPICS_CA_ADDR_LIST'] = 'localhost 192.168.1.110' +#os.environ['EPICS_CA_ADDR_LIST'] = 'localhost 192.168.1.110' +os.environ['EPICS_CA_ADDR_LIST'] = '192.168.1.110' os.environ['EPICS_CA_AUTO_ADDR_LIST'] = 'NO' def application(environ,start_response): status = '200 OK' - RPump1press = caget('ISTTOK:central:RPump1-Pressure', as_string=True) -# RPump2press = caget('ISTTOK:central:RPump2-Pressure') - TMPump1press = caget('ISTTOK:central:TMPump1-PressureAdmission', as_string=True) - VVesselpress = caget('ISTTOK:central:VVessel-Pressure', as_string=True) -# RPump1press = caget('ISTTOK:vacuum:RPump1-Pressure') -# RPump2press = caget('ISTTOK:vacuum:RPump2-Pressure') -# TMPump1press = caget('ISTTOK:vacuum:TMPump1-PressureAdmission') -# VVesselpress = caget('ISTTOK:vacuum:VVessel-Pressure') - rpiCurrentTime = caget('ISTTOK:central:CurrentTime', as_string=True) - opState = caget('ISTTOK:central:OPSTATE.VAL', as_string=True) - pulseNum = caget('ISTTOK:central:PULSE-NUMBER', as_string=True) - OnBattery = caget('ISTTOK:central:UPS-OnBattery', as_string=True) -# cainfo not working - RPump1Info = cainfo("ISTTOK:central:RPump1-Pressure", print_out=False) html = '\n' \ 'RPump1-Pressure: ' + str(RPump1press) + ' mBar
' - html += 'RPump1-Pressure: ' + RPump1press + ' mBar
' - # html += 'RPump2-Pressure: ' + str(RPump2press) + ' mBar
' - html += 'TMPump1-PressureAdmission: ' + TMPump1press + ' mBar
' - html += 'VVessel-Pressure: ' + VVesselpress + ' mBar
' - html += 'OPSTATE: ' + opState + ', UPS-OnBattery: '+ OnBattery+ '
' - html += 'Note: you can try to login to rpi-isttok machine and do: ' - html += '
caput ISTTOK:central:OPREQ START' - html += '
PULSE-NUMBER: ' + pulseNum + '
' - html += 'Rpi CurrentTime: ' + rpiCurrentTime + '
' - html += '' + RPump1Info + '' + '\n
RPump1-Pressure: ' + RPump1press + ' mBar. ALARM Status:' +RPpreAlarm+'
' + else: + html += 'TMPump1-PressureAdmission: ' + TMPump1press + ' mBar
' + html += 'VVessel-Pressure: ' + VVesselpress + ' mBar
' + html += 'OPSTATE: ' + opState + ', UPS-OnBattery: '+ OnBattery+ '
' + html += 'OPREQ: ' + opReq + '
' + if opReqN == 0: + html += 'Note: you can try to login to rpi-isttok machine and do: ' + html += '
caput ISTTOK:central:OPREQ START' + html += '
PULSE-NUMBER: ' + pulseNum + '
' + html += 'Rpi CurrentTime: ' + rpiCurrentTime + '
' + else: + html += 'RPump1-Pressure: ' + str(RPump1press) + ' mBar
' # return [html] +# RPump1press = caget('ISTTOK:vacuum:RPump1-Pressure') +# RPump2press = caget('ISTTOK:vacuum:RPump2-Pressure') + # html += 'RPump2-Pressure: ' + str(RPump2press) + ' mBar
' +# TMPump1press = caget('ISTTOK:vacuum:TMPump1-PressureAdmission') +# VVesselpress = caget('ISTTOK:vacuum:VVessel-Pressure') +# RPump2press = caget('ISTTOK:central:RPump2-Pressure') +# html += '' + RPump1Info + ''