diff --git a/src/sl-decimators.py b/src/sl-decimators.py index bee8add0a831d8a2140a8a6ab7c6d2e27a604400..bd3412915d9775dca28564e3f5a8bd5a3f8a657d 100644 --- a/src/sl-decimators.py +++ b/src/sl-decimators.py @@ -12,7 +12,8 @@ devicelist['3'] = PyTango.DeviceProxy('srv-tango-srf-01:20000/f/timing/rttrigger devicelist['4'] = PyTango.DeviceProxy('srv-tango-srf-01:20000/f/timing/rttrigger_sl.04') devicelist['5'] = PyTango.DeviceProxy('srv-tango-srf-01:20000/f/timing/rttrigger_sl.05') devicelist['contollo'] = PyTango.DeviceProxy('srv-tango-srf-01:20000/ec-sl-slpsr-01/rtevr/ff100000') - +devicelist['frequenza'] = PyTango.DeviceProxy('srv-tango-srf-01:20000/f/timing/bunchnumber_f') +selettore = PyTango.DeviceProxy("srv-tango-srf-01:20000/sl/laser/calendar_sl.01").activityNum class Finestra(QTabWidget): def __init__(self, parent=None): @@ -26,6 +27,8 @@ class Finestra(QTabWidget): self.paginagenerale_1off = QPushButton('OFF') self.paginagenerale_1off.clicked.connect(self.spegni1) self.paginagenerale_1conf = QToolButton() + self.paginagenerale_1conf.setArrowType(4) + self.paginagenerale_1conf.clicked.connect(lambda: self.setCurrentIndex(1)) self.paginagenerale_2facileindicatore = QLineEdit() self.paginagenerale_2etichetta = QLabel('f/timing/rttrigger_sl.02') self.paginagenerale_2modalita = LineEditRO() @@ -34,6 +37,8 @@ class Finestra(QTabWidget): self.paginagenerale_2off = QPushButton('OFF') self.paginagenerale_2off.clicked.connect(self.spegni2) self.paginagenerale_2conf = QToolButton() + self.paginagenerale_2conf.setArrowType(4) + self.paginagenerale_2conf.clicked.connect(lambda: self.setCurrentIndex(2)) self.paginagenerale_3facileindicatore = QLineEdit() self.paginagenerale_3etichetta = QLabel('f/timing/rttrigger_sl.03') self.paginagenerale_3modalita = LineEditRO() @@ -42,6 +47,8 @@ class Finestra(QTabWidget): self.paginagenerale_3off = QPushButton('OFF') self.paginagenerale_3off.clicked.connect(self.spegni3) self.paginagenerale_3conf = QToolButton() + self.paginagenerale_3conf.setArrowType(4) + self.paginagenerale_3conf.clicked.connect(lambda: self.setCurrentIndex(3)) self.paginagenerale_4facileindicatore = QLineEdit() self.paginagenerale_4etichetta = QLabel('f/timing/rttrigger_sl.04') self.paginagenerale_4modalita = LineEditRO() @@ -50,6 +57,8 @@ class Finestra(QTabWidget): self.paginagenerale_4off = QPushButton('OFF') self.paginagenerale_4off.clicked.connect(self.spegni4) self.paginagenerale_4conf = QToolButton() + self.paginagenerale_4conf.setArrowType(4) + self.paginagenerale_4conf.clicked.connect(lambda: self.setCurrentIndex(4)) self.paginagenerale_5facileindicatore = QLineEdit() self.paginagenerale_5etichetta = QLabel('f/timing/rttrigger_sl.05') self.paginagenerale_5modalita = LineEditRO() @@ -58,6 +67,8 @@ class Finestra(QTabWidget): self.paginagenerale_5off = QPushButton('OFF') self.paginagenerale_5off.clicked.connect(self.spegni5) self.paginagenerale_5conf = QToolButton() + self.paginagenerale_5conf.setArrowType(4) + self.paginagenerale_5conf.clicked.connect(lambda: self.setCurrentIndex(5)) self.LO_paginagenerale = QGridLayout() self.LO_paginagenerale.addWidget(self.paginagenerale_1facileindicatore, 10, 0, 1, 1) self.LO_paginagenerale.addWidget(self.paginagenerale_1etichetta, 10, 1, 1, 1) @@ -432,6 +443,7 @@ class Finestra(QTabWidget): self.insertTab(3, self.paginadeci3, 'rttrigger_sl.03') self.insertTab(4, self.paginadeci4, 'rttrigger_sl.04') self.insertTab(5, self.paginadeci5, 'rttrigger_sl.05') + self.setWindowTitle("SL/SLU DECIMATORS") self.show() #timer self.timer = QBasicTimer() @@ -446,41 +458,76 @@ class Finestra(QTabWidget): def update(self): try: tmp = devicelist['contollo'].read_attribute('ChannelsState') - if tmp.value[0] == 10: - self.paginagenerale_1facileindicatore.setText('ON') - self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") - self.paginagenerale_2facileindicatore.setText('?') - self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - self.paginagenerale_3facileindicatore.setText('?') - self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - elif tmp.value[0] == 1 and tmp.value[1] == 10 and tmp.value[2] == 1: - self.paginagenerale_1facileindicatore.setText('OFF') - self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - self.paginagenerale_2facileindicatore.setText('ON') - self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") - self.paginagenerale_3facileindicatore.setText('OFF') - self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - elif tmp.value[0] == 1 and tmp.value[1] == 1 and tmp.value[2] == 10: - self.paginagenerale_1facileindicatore.setText('OFF') - self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - self.paginagenerale_2facileindicatore.setText('OFF') - self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - self.paginagenerale_3facileindicatore.setText('ON') - self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") - elif tmp.value[0] == 1 and tmp.value[1] == 1 and tmp.value[2] == 1: - self.paginagenerale_1facileindicatore.setText('OFF') - self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - self.paginagenerale_2facileindicatore.setText('OFF') - self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - self.paginagenerale_3facileindicatore.setText('OFF') - self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - else: - self.paginagenerale_1facileindicatore.setText('?') - self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - self.paginagenerale_2facileindicatore.setText('?') - self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") - self.paginagenerale_3facileindicatore.setText('?') - self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + if selettore >= 1 and selettore <= 6: #elite1 x fel, elite2 x slu + #decimatore 1 + if tmp.value[0] == 10 and tmp.value[1] == 10 and tmp.value[2] == 10 and tmp.value[3] == 10 and tmp.value[8] == 10 and tmp.value[10] == 10 and tmp.value[11] == 10: + self.paginagenerale_1facileindicatore.setText('ON') + self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_1facileindicatore.setText('OFF') + self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + #decimatore 2 + if tmp.value[0] == 1 and tmp.value[1] == 10 and tmp.value[2] == 1 and tmp.value[10] == 10: + self.paginagenerale_2facileindicatore.setText('ON') + self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_2facileindicatore.setText('OFF') + self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + #decimatore 3 + if tmp.value[0] == 1 and tmp.value[1] == 1 and tmp.value[2] == 10 and tmp.value[8] == 10 and tmp.value[11] == 10: + self.paginagenerale_3facileindicatore.setText('ON') + self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_3facileindicatore.setText('OFF') + self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + #decimatore 4 + if tmp.value[0] == 1 and tmp.value[1] == 10 and tmp.value[2] == 1 and tmp.value[10] == 1: + self.paginagenerale_4facileindicatore.setText('ON') + self.paginagenerale_4facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_4facileindicatore.setText('OFF') + self.paginagenerale_4facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + if tmp.value[0] == 1 and tmp.value[1] == 1 and tmp.value[2] == 10 and tmp.value[8] == 1 and tmp.value[11] == 1: + self.paginagenerale_5facileindicatore.setText('ON') + self.paginagenerale_5facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_5facileindicatore.setText('OFF') + self.paginagenerale_5facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + elif selettore >= 7 and selettore <= 11: #elite1 x slu, elite2 x fel + #decimatore 1 + if tmp.value[0] == 10 and tmp.value[1] == 10 and tmp.value[2] == 10 and tmp.value[3] == 10 and tmp.value[8] == 10 and tmp.value[10] == 10 and tmp.value[11] == 10: + self.paginagenerale_1facileindicatore.setText('ON') + self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_1facileindicatore.setText('OFF') + self.paginagenerale_1facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + #decimatore 2 + if tmp.value[0] == 1 and tmp.value[1] == 10 and tmp.value[2] == 1 and tmp.value[8] == 10 and tmp.value[10] == 10: + self.paginagenerale_2facileindicatore.setText('ON') + self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_2facileindicatore.setText('OFF') + self.paginagenerale_2facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + #decimatore 3 + if tmp.value[0] == 1 and tmp.value[1] == 1 and tmp.value[2] == 10 and tmp.value[11] == 10: + self.paginagenerale_3facileindicatore.setText('ON') + self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_3facileindicatore.setText('OFF') + self.paginagenerale_3facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + #decimatore 4 + if tmp.value[0] == 1 and tmp.value[1] == 10 and tmp.value[2] == 1 and tmp.value[8] == 1 and tmp.value[10] == 1: + self.paginagenerale_4facileindicatore.setText('ON') + self.paginagenerale_4facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_4facileindicatore.setText('OFF') + self.paginagenerale_4facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") + if tmp.value[0] == 1 and tmp.value[1] == 1 and tmp.value[2] == 10 and tmp.value[11] == 1: + self.paginagenerale_5facileindicatore.setText('ON') + self.paginagenerale_5facileindicatore.setStyleSheet("background-color: rgb(255, 255, 255)") + else: + self.paginagenerale_5facileindicatore.setText('OFF') + self.paginagenerale_5facileindicatore.setStyleSheet("background-color: rgb(200, 200, 200)") except: print('ao') try: @@ -809,6 +856,31 @@ class Finestra(QTabWidget): devicelist['5'].command_inout('Stop') def applica1(self): + try: + frequenza1050 = devicelist['frequenza'].BunchNumberFrequency + except: + frequenza1050 = -1 + try: + tmp = str(self.paginadeci1_campo_Sequence_W.text()).replace('[', '').replace(']','') + if self.paginadeci1_campo_StatusMode.isChecked(): + tmp1 = tmp.split('1') + for aaa in range(len(tmp1)): + if tmp1[aaa].count('0') > 4: + self.msgBox = QMessageBox() + self.msgBox.setIcon(QMessageBox.Question) + self.msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + self.msgBox.setText("Decimation is too strong, if the frequency of the laser is below " + str(int(frequenza1050/5)) + "Hz thermal effects might degradate beam quality. Are you sure you want to proceed?") + risp = self.msgBox.exec_() + if risp == 1024: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['1'].write_attribute('Sequence', Sequence_new) + else: + return + else: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['1'].write_attribute('Sequence', Sequence_new) + except: + print('not float ' + str(self.paginadeci1_campo_Sequence_W.text())) try: BunchNumberEnd_new = float(str(self.paginadeci1_campo_BunchNumberEnd_W.text())) devicelist['1'].write_attribute('BunchNumberEnd', BunchNumberEnd_new) @@ -829,12 +901,6 @@ class Finestra(QTabWidget): devicelist['1'].write_attribute('MaxNumCycles', MaxNumCycles_new) except: print('not float ' + str(self.paginadeci1_campo_MaxNumCycles_W.text())) - try: - tmp = str(self.paginadeci1_campo_Sequence_W.text()).replace('[', '').replace(']','') - Sequence_new = [int(aa) for aa in tmp.split(',')] - devicelist['1'].write_attribute('Sequence', Sequence_new) - except: - print('not float ' + str(self.paginadeci1_campo_Sequence_W.text())) if self.paginadeci1_campo_DelayMode.isChecked(): DelayMode_new = True else: @@ -894,6 +960,31 @@ class Finestra(QTabWidget): print('applica1 DONE') def applica2(self): + try: + frequenza1050 = devicelist['frequenza'].BunchNumberFrequency + except: + frequenza1050 = -1 + try: + tmp = str(self.paginadeci2_campo_Sequence_W.text()).replace('[', '').replace(']','') + if self.paginadeci2_campo_StatusMode.isChecked(): + tmp1 = tmp.split('1') + for aaa in range(len(tmp1)): + if tmp1[aaa].count('0') > 4: + self.msgBox = QMessageBox() + self.msgBox.setIcon(QMessageBox.Question) + self.msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + self.msgBox.setText("Decimation is too strong, if the frequency of the laser is below " + str(int(frequenza1050/5)) + "Hz thermal effects might degradate beam quality. Are you sure you want to proceed?") + risp = self.msgBox.exec_() + if risp == 1024: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['2'].write_attribute('Sequence', Sequence_new) + else: + return + else: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['2'].write_attribute('Sequence', Sequence_new) + except: + print('not float ' + str(self.paginadeci2_campo_Sequence_W.text())) try: BunchNumberEnd_new = float(str(self.paginadeci2_campo_BunchNumberEnd_W.text())) devicelist['2'].write_attribute('BunchNumberEnd', BunchNumberEnd_new) @@ -914,12 +1005,6 @@ class Finestra(QTabWidget): devicelist['2'].write_attribute('MaxNumCycles', MaxNumCycles_new) except: print('not float ' + str(self.paginadeci2_campo_MaxNumCycles_W.text())) - try: - tmp = str(self.paginadeci2_campo_Sequence_W.text()).replace('[', '').replace(']','') - Sequence_new = [int(aa) for aa in tmp.split(',')] - devicelist['2'].write_attribute('Sequence', Sequence_new) - except: - print('not float ' + str(self.paginadeci2_campo_Sequence_W.text())) if self.paginadeci2_campo_DelayMode.isChecked(): DelayMode_new = True else: @@ -979,6 +1064,31 @@ class Finestra(QTabWidget): print('applica2 DONE') def applica3(self): + try: + frequenza1050 = devicelist['frequenza'].BunchNumberFrequency + except: + frequenza1050 = -1 + try: + tmp = str(self.paginadeci3_campo_Sequence_W.text()).replace('[', '').replace(']','') + if self.paginadeci3_campo_StatusMode.isChecked(): + tmp1 = tmp.split('1') + for aaa in range(len(tmp1)): + if tmp1[aaa].count('0') > 4: + self.msgBox = QMessageBox() + self.msgBox.setIcon(QMessageBox.Question) + self.msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + self.msgBox.setText("Decimation is too strong, if the frequency of the laser is below " + str(int(frequenza1050/5)) + "Hz thermal effects might degradate beam quality. Are you sure you want to proceed?") + risp = self.msgBox.exec_() + if risp == 1024: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['3'].write_attribute('Sequence', Sequence_new) + else: + return + else: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['3'].write_attribute('Sequence', Sequence_new) + except: + print('not float ' + str(self.paginadeci3_campo_Sequence_W.text())) try: BunchNumberEnd_new = float(str(self.paginadeci3_campo_BunchNumberEnd_W.text())) devicelist['3'].write_attribute('BunchNumberEnd', BunchNumberEnd_new) @@ -999,12 +1109,6 @@ class Finestra(QTabWidget): devicelist['3'].write_attribute('MaxNumCycles', MaxNumCycles_new) except: print('not float ' + str(self.paginadeci3_campo_MaxNumCycles_W.text())) - try: - tmp = str(self.paginadeci3_campo_Sequence_W.text()).replace('[', '').replace(']','') - Sequence_new = [int(aa) for aa in tmp.split(',')] - devicelist['3'].write_attribute('Sequence', Sequence_new) - except: - print('not float ' + str(self.paginadeci3_campo_Sequence_W.text())) if self.paginadeci3_campo_DelayMode.isChecked(): DelayMode_new = True else: @@ -1064,6 +1168,31 @@ class Finestra(QTabWidget): print('applica3 DONE') def applica4(self): + try: + frequenza1050 = devicelist['frequenza'].BunchNumberFrequency + except: + frequenza1050 = -1 + try: + tmp = str(self.paginadeci4_campo_Sequence_W.text()).replace('[', '').replace(']','') + if self.paginadeci4_campo_StatusMode.isChecked(): + tmp1 = tmp.split('1') + for aaa in range(len(tmp1)): + if tmp1[aaa].count('0') > 4: + self.msgBox = QMessageBox() + self.msgBox.setIcon(QMessageBox.Question) + self.msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + self.msgBox.setText("Decimation is too strong, if the frequency of the laser is below " + str(int(frequenza1050/5)) + "Hz thermal effects might degradate beam quality. Are you sure you want to proceed?") + risp = self.msgBox.exec_() + if risp == 1024: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['4'].write_attribute('Sequence', Sequence_new) + else: + return + else: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['4'].write_attribute('Sequence', Sequence_new) + except: + print('not float ' + str(self.paginadeci3_campo_Sequence_W.text())) try: BunchNumberEnd_new = float(str(self.paginadeci4_campo_BunchNumberEnd_W.text())) devicelist['4'].write_attribute('BunchNumberEnd', BunchNumberEnd_new) @@ -1084,12 +1213,6 @@ class Finestra(QTabWidget): devicelist['4'].write_attribute('MaxNumCycles', MaxNumCycles_new) except: print('not float ' + str(self.paginadeci4_campo_MaxNumCycles_W.text())) - try: - tmp = str(self.paginadeci4_campo_Sequence_W.text()).replace('[', '').replace(']','') - Sequence_new = [int(aa) for aa in tmp.split(',')] - devicelist['4'].write_attribute('Sequence', Sequence_new) - except: - print('not float ' + str(self.paginadeci4_campo_Sequence_W.text())) if self.paginadeci4_campo_DelayMode.isChecked(): DelayMode_new = True else: @@ -1149,6 +1272,31 @@ class Finestra(QTabWidget): print('applica4 DONE') def applica5(self): + try: + frequenza1050 = devicelist['frequenza'].BunchNumberFrequency + except: + frequenza1050 = -1 + try: + tmp = str(self.paginadeci5_campo_Sequence_W.text()).replace('[', '').replace(']','') + if self.paginadeci5_campo_StatusMode.isChecked(): + tmp1 = tmp.split('1') + for aaa in range(len(tmp1)): + if tmp1[aaa].count('0') > 4: + self.msgBox = QMessageBox() + self.msgBox.setIcon(QMessageBox.Question) + self.msgBox.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel) + self.msgBox.setText("Decimation is too strong, if the frequency of the laser is below " + str(int(frequenza1050/5)) + "Hz thermal effects might degradate beam quality. Are you sure you want to proceed?") + risp = self.msgBox.exec_() + if risp == 1024: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['5'].write_attribute('Sequence', Sequence_new) + else: + return + else: + Sequence_new = [int(aa) for aa in tmp.split(',')] + devicelist['5'].write_attribute('Sequence', Sequence_new) + except: + print('not float ' + str(self.paginadeci1_campo_Sequence_W.text())) try: BunchNumberEnd_new = float(str(self.paginadeci5_campo_BunchNumberEnd_W.text())) devicelist['5'].write_attribute('BunchNumberEnd', BunchNumberEnd_new)