From f14a20ac68c7f99c16193fc530b2f53a196c3a6f Mon Sep 17 00:00:00 2001 From: Bernardo Carvalho Date: Wed, 15 Dec 2021 18:19:17 +0000 Subject: [PATCH] Updated WSGI html python script --- epics/html/wsgi/wsgi_isttok_status.py | 75 ++++++++++++------- .../ISTTOKrpi/ISTTOKrpiApp/Db/sendmail.proto | 2 +- .../iocISTTOKrpi/save/iocISTTOKrpi.sav | 2 +- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/epics/html/wsgi/wsgi_isttok_status.py b/epics/html/wsgi/wsgi_isttok_status.py index 0f3ce00..d68db9b 100644 --- a/epics/html/wsgi/wsgi_isttok_status.py +++ b/epics/html/wsgi/wsgi_isttok_status.py @@ -1,38 +1,63 @@ -# https://tecadmin.net/install-apache-mod-wsgi-on-ubuntu-16-04-xenial -# Include in /etc/apache2/conf-available/mod-wsgi.conf : -# WSGIScriptAlias /isttok /var/www/html/wsgi_isttok_status.py -# and -# systemctl restart apache2 +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# if you change this script "touch" it to reload by apache +# e.g touch /var/www/html/wsgi_isttok_status.py +""" +Created on December 8 16:34:35 2019 + https://tecadmin.net/install-apache-mod-wsgi-on-ubuntu-16-04-xenial + + Install: + Include in /etc/apache2/conf-available/mod-wsgi.conf : + WSGIScriptAlias /isttok /var/www/html/wsgi_isttok_status.py + and do: + systemctl restart apache2 + +@author: bernardo carvalho@IPFN +""" # -#import epics from epics import caget, caput, cainfo 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_AUTO_ADDR_LIST'] = 'NO' def application(environ,start_response): status = '200 OK' - RPump1press = caget('ISTTOK:central:RPump1-Pressure') - RPump2press = caget('ISTTOK:central:RPump2-Pressure') - TMPump1press = caget('ISTTOK:central:TMPump1-PressureAdmission') - VVesselpress = caget('ISTTOK:central:VVessel-Pressure') - rpiCurrentTime = caget('ISTTOK:central:CurrentTime') - opState = caget('ISTTOK:central:OPSTATE.VAL') - pulseNum = caget('ISTTOK:central:PULSE-NUMBER') + 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' \ - '\n' \ - '

ISTTOK Present Condition

\n' - html += '

RPump1-Pressure: ' + str(RPump1press) + ' mBar

' - html += '

RPump2-Pressure: ' + str(RPump2press) + ' mBar

' - html += '

TMPump1-PressureAdmission: ' + str(TMPump1press) + ' mBar

' - html += '

VVessel-Pressure: ' + str(VVesselpress) + ' mBar

' - html += '

OPSTATE: ' + str(opState) + '

' - html += '

PULSE-NUMBER: ' + str(pulseNum) + '

' - html += '

Rpi CurrentTime: ' + str(rpiCurrentTime) + '

' + ' ISTTOK Status page' \ + ' ' \ + '\n

ISTTOK Present Condition

\n' +# html += '

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 + '
' html += '\n' \ '\n' - response_header = [('Content-type','text/html')] + response_header = [('Content-type','text/html'), + ('Content-Length', str(len(html)))] start_response(status,response_header) - html = bytes(html, encoding= 'utf-8') - return [html] + return [html.encode('UTF-8')] +# html = bytes(html, encoding= 'utf-8') +# return [html] diff --git a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/sendmail.proto b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/sendmail.proto index 3a7fe99..f4a0d63 100644 --- a/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/sendmail.proto +++ b/epics/iocs/ISTTOKrpi/ISTTOKrpiApp/Db/sendmail.proto @@ -40,7 +40,7 @@ mail_end { send { mail_start; out "Problem is: %s\n"; - out "Please check: http://epics.ipfn.ist.utl.pt/isttok"; + out "Please check: http://epics.ipfn.tecnico.ulisboa.pt/isttok"; mail_end; } diff --git a/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/save/iocISTTOKrpi.sav b/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/save/iocISTTOKrpi.sav index a77c315..7768bb5 100644 --- a/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/save/iocISTTOKrpi.sav +++ b/epics/iocs/ISTTOKrpi/iocBoot/iocISTTOKrpi/save/iocISTTOKrpi.sav @@ -1,4 +1,4 @@ -# autosave R5.3 Automatically generated - DO NOT MODIFY - 211215-162845 +# autosave R5.3 Automatically generated - DO NOT MODIFY - 211215-181848 ISTTOK:central:PULSE-NUMBER.VAL 49461 ISTTOK:central:LogMessage.VAL ISTTOK:central:LASTOPSTATE.VAL 2