Skip to content
Snippets Groups Projects
Commit 796844ed authored by Lorenzo Pivetta's avatar Lorenzo Pivetta
Browse files

Initial import

parent 4bbb6207
No related branches found
No related tags found
No related merge requests found
Makefile 0 → 100644
NAME = slu-trigger-gui
MAIN = slu-trigger.py
DIRNAME = $(NAME:-gui=)
PY_FILES += $(wildcard src/*.py)
default: bin ${PY_FILES}
@cp ${PY_FILES} bin/${DIRNAME}
@echo "#!/bin/bash\nexec /runtime/bin/${DIRNAME}/${MAIN}" > bin/${NAME}
@chmod +x bin/${NAME} bin/${DIRNAME}/${MAIN}
bin:
@test -d $@ || mkdir -p $@/${DIRNAME}
clean:
@rm -fr bin/ src/*~
.PHONY: clean
#!/usr/bin/python
# restore PIL trigger values and reset Legend BWD interlock
import PyTango
import os
import csv
import time
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
devicetrgEVR = PyTango.DeviceProxy('ec-slu-ehf-01/evr/ff100000')
class MainWindow(QDialog):
def __init__(self, parent = None):
super(MainWindow, self).__init__(parent)
#canali
self.scialuppa = []
self.riga0 = canaleEVR('MASTER', devicetrgEVR, 0, 'totem ccd')
self.riga0.sorgente = 'EVR 0'
self.scialuppa.append(self.riga0)
self.riga1 = canaleEVR('TOTEM2', devicetrgEVR, 1, 'delay line mercury')
self.riga1.sorgente = 'EVR 1'
self.scialuppa.append(self.riga1)
self.riga2 = canaleEVR('TIMEX-TIMER', devicetrgEVR, 2, 'timex-timer')
self.riga2.sorgente = 'EVR 2'
self.scialuppa.append(self.riga2)
self.riga3 = canaleEVR('LDM-MAGNEDYN', devicetrgEVR, 3, 'ldm-magnedyn')
self.riga3.sorgente = 'EVR 3'
self.scialuppa.append(self.riga3)
self.riga4 = canaleEVR('DIPROI', devicetrgEVR, 4, 'diproi')
self.riga4.sorgente = 'EVR 4'
self.scialuppa.append(self.riga4)
self.riga5 = canaleEVR('Spare', devicetrgEVR, 5, 'spare')
self.riga5.sorgente = 'EVR 5'
self.scialuppa.append(self.riga5)
self.titoli = titolicanali(self.riga0.name.geometry(), self.riga0.devicelist.geometry(), self.riga0.delay_read.geometry(), self.riga0.delay_reference.geometry(), self.riga0.delay_write.geometry(), self.riga0.delay_alarm_low.geometry(), self.riga0.delay_alarm_hi.geometry(), self.riga0.width_read.geometry(), self.riga0.width_write.geometry(), self.riga0.enable_read.geometry(), self.riga0.enable_write.geometry(), self.riga0.applica.geometry())
self.titoli.sorgente = 'titoli 0'
self.scialuppa.append(self.titoli)
self.scrollArea = QScrollArea(self)
self.scrollArea.setWidgetResizable(True)
self.scrollAreaWidgetContents = QWidget(self.scrollArea)
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
#lo_canali = QVBoxLayout()
lo_canali = QVBoxLayout(self.scrollAreaWidgetContents)
lo_canali.addWidget(self.titoli)
lo_canali.addWidget(self.riga0)
lo_canali.addWidget(self.riga1)
lo_canali.addWidget(self.riga2)
lo_canali.addWidget(self.riga3)
lo_canali.addWidget(self.riga4)
lo_canali.addWidget(self.riga5)
lo_canali.setSpacing(0)
for i in range(len(self.scialuppa)):
self.scialuppa[i].delay_alarm_low.hide()
self.scialuppa[i].delay_alarm_hi.hide()
self.scialuppa[i].width_read.hide()
self.scialuppa[i].width_write.hide()
self.scialuppa[i].enable_write.hide()
self.scialuppa[i].delay_reference.hide()
#altro
self.tempodiriferimento = 0
self.EVR_State = QLineEdit('')
self.EVR_State.setReadOnly(1)
self.copyreadtowrite = QPushButton('copy READ to WRITE')
self.copyreadtowrite.clicked.connect(self.funzionecopyreadtowrite)
self.applicatutti = QPushButton('Apply all')
self.applicatutti.clicked.connect(self.funzioneapplicatutti)
lo = QGridLayout()
lo.addWidget(QLabel('EVR:'), 1, 0, 1, 1)
lo.addWidget(self.EVR_State, 1, 1, 1, 1)
lo.addWidget(self.scrollArea, 10, 0, 10, 8)
lo.addWidget(self.copyreadtowrite, 20, 2, 1, 2)
lo.addWidget(self.applicatutti, 20, 6, 1, 2)
self.setLayout(lo)
self.setWindowTitle("SLU trigger")
self.show()
self.setStyleSheet("QDialog {background-color: rgb(200, 255, 200)}")
#creo il timer
self.timer = QBasicTimer()
self.timer.start(8000, self)
self.update()
def __del__(self):
self.timer.stop()
pass
def timerEvent(self, event):
self.update()
def update(self):
print(' ')
#lettura stati device
tempista2 = time.time()
lettura_stato_evr = str(devicetrgEVR.State())
if lettura_stato_evr == 'ON':
self.EVR_State.setText(lettura_stato_evr)
self.EVR_State.setStyleSheet("background-color: rgb(0, 255, 0)")
else:
self.EVR_State.setText(lettura_stato_evr)
self.EVR_State.setStyleSheet("background-color: rgb(255, 0, 0)")
print('stati letti ' + str(time.time()-tempista2))
#leggo tutto EVR
tempista3 = time.time()
EVR_ritardi = devicetrgEVR.ChanDelay
time.sleep(0.05)
#EVR_durate = devicetrgEVR.ChanWidth
#time.sleep(0.05)
EVR_abilitazioni = devicetrgEVR.ChanEnable
for i in range(len(self.scialuppa)):
[strumento, canale] = self.scialuppa[i].sorgente.split(' ')
if strumento == 'EVR':
self.scialuppa[i].delay_read.setText(str(EVR_ritardi[int(canale)]))
#self.scialuppa[i].width_read.setText(str(EVR_durate[int(canale)]))
self.scialuppa[i].enable_write.setChecked(EVR_abilitazioni[int(canale)])
if EVR_abilitazioni[int(canale)]:
self.scialuppa[i].enable_read.setStyleSheet("background-color: rgb(0, 255, 0)")
else:
self.scialuppa[i].enable_read.setStyleSheet("background-color: rgb(255, 0, 0)")
print('EVR letto ' + str(time.time()-tempista3))
def funzionecopyreadtowrite(self):
for i in range(len(self.scialuppa)):
[strumento, canale] = self.scialuppa[i].sorgente.split(' ')
if strumento != 'titoli':
self.scialuppa[i].delay_write.setValue(float(self.scialuppa[i].delay_read.text()))
def funzioneapplicatutti(self):
for i in range(len(self.scialuppa)):
if self.scialuppa[i].sorgente != 'titoli 0':
self.scialuppa[i].funzioneapplica()
class canaleEVR(QWidget):
def __init__(self, nome, dev, ch, info, parent = None):
super(canaleEVR, self).__init__(parent)
self.name = QLabel('EVR - ' + nome)
self.name.setMinimumWidth(180)
self.devicelist = QPushButton('i')
self.devicelist.clicked.connect(lambda: self.funzionemostradevice(info))
self.devicelist.setMaximumWidth(20)
self.delay_read = QLineEdit('')
self.delay_read.setReadOnly(1)
self.delay_read.setFont(font_importante)
self.delay_read.setStyleSheet("background-color: rgb(220, 220, 220)")
self.delay_reference = QLineEdit('')
self.delay_reference.setReadOnly(1)
self.delay_reference.setStyleSheet("background-color: rgb(220, 220, 220)")
self.delay_write = QDoubleSpinBox()
self.delay_write.setDecimals(3)
self.delay_write.setMaximum(10000000.000)
self.delay_write.setSingleStep(12.675)
self.delay_alarm_low = QLineEdit('')
self.delay_alarm_low.setStyleSheet("background-color: rgb(220, 220, 220)")
self.delay_alarm_hi = QLineEdit('')
self.delay_alarm_hi.setStyleSheet("background-color: rgb(220, 220, 220)")
self.width_read = QLineEdit('')
self.width_read.setReadOnly(1)
self.width_read.setStyleSheet("background-color: rgb(220, 220, 220)")
self.width_write = QLineEdit('')
self.enable_read = QLineEdit('')
self.enable_read.setMaximumWidth(20)
self.enable_write = QCheckBox()
self.applica = QPushButton('Apply')
self.applica.clicked.connect(lambda: self.funzioneapplica())
self.dev = dev
self.ch = ch
layoutriga = QHBoxLayout()
layoutriga.addWidget(self.name)
layoutriga.addWidget(self.devicelist)
layoutriga.addWidget(self.delay_reference)
layoutriga.addWidget(self.delay_read)
layoutriga.addWidget(self.delay_write)
layoutriga.addWidget(self.delay_alarm_low)
layoutriga.addWidget(self.delay_alarm_hi)
layoutriga.addWidget(self.width_read)
layoutriga.addWidget(self.width_write)
layoutriga.addWidget(self.enable_read)
layoutriga.addWidget(self.enable_write)
layoutriga.addWidget(self.applica)
self.setLayout(layoutriga)
def funzionemostradevice(self, info):
msg = QMessageBox()
msg.setIcon(QMessageBox.Information)
msg.setInformativeText(info)
titolone = self.sorgente.split(' ')
msg.setText('Event receiver channel ' + str(titolone[1]))
msg.setWindowTitle('Info')
msg.exec_()
def funzioneapplica(self):
print(self.delay_write.value())
eval('self.dev.write_attribute("Chan' + str(self.ch) + 'Delay", float(self.delay_write.value()))')
class titolicanali(QWidget):
def __init__(self, in1, in2, in3, in4, in5, in6, in7, in8, in9, in10, in11, in12, parent = None):
super(titolicanali, self).__init__(parent)
self.name = QLabel('NAME')
self.name.setGeometry(in1)
self.name.setAlignment(Qt.AlignRight)
self.devicelist = QLabel(' ')
self.devicelist.setGeometry(in2)
self.delay_read = QLabel('READ')
self.delay_read.setFont(font_importante)
self.delay_read.setAlignment(Qt.AlignRight)
self.delay_read.setGeometry(in3)
self.delay_reference = QLabel('Ref. value')
self.delay_reference.setAlignment(Qt.AlignRight)
self.delay_reference.setGeometry(in4)
self.delay_write = QLabel('')
self.delay_write.setAlignment(Qt.AlignRight)
self.delay_write.setGeometry(in5)
self.delay_alarm_low = QLabel('Alarm lo')
self.delay_alarm_low.setAlignment(Qt.AlignRight)
self.delay_alarm_low.setGeometry(in6)
self.delay_alarm_hi = QLabel('Alarm hi')
self.delay_alarm_hi.setAlignment(Qt.AlignRight)
self.delay_alarm_hi.setGeometry(in7)
self.width_read = QLabel('Width R')
self.width_read.setAlignment(Qt.AlignRight)
self.width_read.setGeometry(in8)
self.width_write = QLabel('Width W')
self.width_write.setAlignment(Qt.AlignRight)
self.width_write.setGeometry(in9)
self.enable_read = QLabel(' ')
self.enable_read.setGeometry(in10)
self.enable_write = QLabel('ACTIVE')
self.enable_write.setAlignment(Qt.AlignRight)
self.enable_write.setGeometry(in11)
self.applica = QLabel(' ')
self.applica.setGeometry(in12)
layoutriga = QHBoxLayout()
layoutriga.addWidget(self.name)
layoutriga.addWidget(self.devicelist)
layoutriga.addWidget(self.delay_reference)
layoutriga.addWidget(self.delay_read)
layoutriga.addWidget(self.delay_write)
layoutriga.addWidget(self.delay_alarm_low)
layoutriga.addWidget(self.delay_alarm_hi)
layoutriga.addWidget(self.width_read)
layoutriga.addWidget(self.width_write)
layoutriga.addWidget(self.enable_read)
layoutriga.addWidget(self.enable_write)
layoutriga.addWidget(self.applica)
self.setLayout(layoutriga)
#####################
if __name__ == '__main__':
app = QApplication([])
try:
tmpdim = sys.argv[1]
tmpdim = tmpdim.split('x')
dimensione = [float(tmpdim[0]), float(tmpdim[1])]
except:
screen = QDesktopWidget().screenGeometry()
larghezzaaltezza = [screen.width(), screen.height()]
print(larghezzaaltezza)
if max(larghezzaaltezza) > 3000:
dimensione = max(larghezzaaltezza)*0.38
elif max(larghezzaaltezza) > 2000:
dimensione = max(larghezzaaltezza)*0.6
elif max(larghezzaaltezza) > 1000:
dimensione = max(larghezzaaltezza)*0.7
else:
dimensione = max(larghezzaaltezza)*2
font_grande = QFont("Arial", round(dimensione/35.0), -1, False)
font_importante = QFont("Arial", round(dimensione/110.0), 1, True)
font_pannello = QFont("Arial", round(dimensione/130.0), -1, False)
app.setFont(font_pannello)
window = MainWindow()
window.resize(larghezzaaltezza[0]/5, larghezzaaltezza[1]/5)
window.show()
app.exec_()
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment