From 0c79ea3ce8a3b0d8d45e712ab54d97ff690abfd9 Mon Sep 17 00:00:00 2001
From: Claudio Scafuri <claudio.scafuri@elettra.eu>
Date: Thu, 11 Apr 2024 15:34:14 +0200
Subject: [PATCH] tests and fixes

---
 FRTND_E/active_frntd_e.py | 69 +++++++++++++++++++++++++++------------
 1 file changed, 48 insertions(+), 21 deletions(-)

diff --git a/FRTND_E/active_frntd_e.py b/FRTND_E/active_frntd_e.py
index fa05519..5b88d3a 100644
--- a/FRTND_E/active_frntd_e.py
+++ b/FRTND_E/active_frntd_e.py
@@ -39,7 +39,7 @@ class Worker(QtCore.QThread):
         self.nanoesca_stopper_value = -1  # 0: closed , 1:open, -1 : unknown
 
         self.superescastopper = 0
-        self.superescashutterindex = 0
+        self.superescastopperindex = 0
         self.superesca_stopper_value = -1  # 0: closed , 1:open, -1 : unknown
 
         self.superescashutter = 0
@@ -71,20 +71,23 @@ class Worker(QtCore.QThread):
         self.nanoescashutter=self.nanoescastopper # the tango device is the same of the stopper
 
     # ---------------------------------------------------------------------------------------------------
-        # tango device for nanoesca - geco device
+        # tango device for superesca - geco device
         self.superescastopper = 0
         self.superescastopperindex = 0
         self.superesca_stopper_value = -1  # 0: closed , 1:open, -1 : unknown
         try:
             self.superescastopper = tango.DeviceProxy(
-                "bl024-control-01:20000/controls/interlock/geco")
+                "bl024-control-01.blcs:20000/controls/interlock/geco")
+            
         except tango.DevFailed as e:
+            print("failed STP_S02-04-F.01")
             self.superescastopper = 0
 
         self.superescashutter = 0
         self.superescashutterindex = 0
         self.superesca_shutter_value = -1  # 0: closed , 1:open, -1 : unknown
         self.superscashutter = self.superescastopper  # the tango device is the same of the stopper
+       
     # ---------------------------------------------------------------------------------------------------
         
         # tango device for vuvphotemission - geco device
@@ -130,9 +133,10 @@ class Worker(QtCore.QThread):
             self.nanoesca_shutter_value = -1
 
         try:
-            self.superesca_stopper_value = self.nanoescastopper.read_attribute("STP_S02-04-F.01").value
-            self.superesca_shutter_value = self.nanoescashutter.read_attribute("SHT_S02-04-F.01").value
+            self.superesca_stopper_value = self.superescastopper.read_attribute("STP_S02-04-F.01").value
+            self.superesca_shutter_value = self.superscashutter.read_attribute("SHT_S02-04-F.01").value
         except tango.DevFailed as e:
+            print("superesca read failed")
             self.superesca_stopper_value = -1
             self.superesca_shutter_value = -1
 
@@ -201,7 +205,7 @@ class Worker(QtCore.QThread):
             self.emit(
                 QtCore.SIGNAL("ExecuteError(PyQt_PyObject,PyQt_PyObject)"),
                 self.BL,
-                "geco/STP_S02-04.01",
+                "geco/STP_S02-04-F.01",
             )
         if errtable is None:
             self.emit(QtCore.SIGNAL("ExecuteThread(PyQt_PyObject)"), self.BL)
@@ -213,7 +217,7 @@ class Worker(QtCore.QThread):
             )
         #close superesca shutter
         try:
-            self.superescashutter.write_attribute("SHT_S02-04-F.01",0)
+            self.superscashutter.write_attribute("SHT_S02-04-F.01",0)
         except tango.DevFailed as e:
             self.emit(
                 QtCore.SIGNAL("ExecuteError(PyQt_PyObject,PyQt_PyObject)"),
@@ -235,7 +239,8 @@ class Worker(QtCore.QThread):
 
         #close vuvphotoemission/spectromicro shutter
         try:
-            self.vuvphotoemissionshutter.write_attribute("SHTFE_S03-04.01",0)
+       
+            self.vuvphotemissionshutter.write_attribute("SHTFE_S03-04.01",0)
         except tango.DevFailed as e:
             self.emit(
                 QtCore.SIGNAL("ExecuteError(PyQt_PyObject,PyQt_PyObject)"),
@@ -301,7 +306,7 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
         self.redbrush = QtGui.QBrush(QtGui.QColor("red"))
         self.graybrush = QtGui.QBrush(QtGui.QColor("gray"))
         n = self.BL.nentries
-        self.tableWidget.setRowCount(n + 5)
+        self.tableWidget.setRowCount(n + 7)
         row = 0
         for entry in self.BL.bltable:
             bname = entry[2]
@@ -362,6 +367,7 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
         self.thread.syrmepstopperindex = row
         self.syrmepstopperindex = row
         row = row + 1
+        
         #palette = self.label.palette()
         #palette.setBrush(QtGui.QPalette.Window, self.graybrush)
         #self.label.setPalette(palette)
@@ -383,7 +389,6 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
         self.nanoescastopperindex = row
         row = row + 1
         
-        
         bname = "1.2 Nanospec. / NanoESCA"
         objname = "geco/SHFE_S01-04.01"
         stname = "UNKNOWN"
@@ -397,11 +402,8 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
         self.tableWidget.setRowHeight(row, 22)
         self.thread.nanoescashutterindex = row
         self.nanoescashutterindex = row
-        
         row = row + 1
-        # ==========================================================
-
-
+        
         bname = "2.2 SuperESCA/ESCAmicro"
         objname = "geco/STP_S02-04-F.01"
         stname = "UNKNOWN"
@@ -414,8 +416,7 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
         self.tableWidget.setItem(row, 2, col2)
         self.tableWidget.setRowHeight(row, 22)
         self.thread.superescastopperindex = row
-        self.nsuperescastopperindex  = row
-
+        self.superescastopperindex  = row
         row = row + 1
 
         bname = "2.2 SuperESCA/ESCAmicro"
@@ -432,7 +433,6 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
         self.thread.superescashutterindex = row
         self.superescashutterindex = row
         row = row + 1
-        
         #----------------------------------------------------------
         palette = self.label.palette()
         palette.setBrush(QtGui.QPalette.Window, self.graybrush)
@@ -460,10 +460,10 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
 
     def redraw_table(self, mybl):
         # redraw  informations
-        row = 0
+        trow = 0
         for entry in mybl.bltable:
             stname = entry[4]
-            item = self.tableWidget.item(row, 2)
+            item = self.tableWidget.item(trow, 2)
             item.setText(stname)
             if stname == "OPEN":
                 item.setBackground(self.redbrush)
@@ -474,7 +474,7 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
             if stname == "UNKNOWN":
                 item.setBackground(self.graybrush)
             # self.tableWidget.setItem(row,2,item)
-            row = row + 1
+            trow = trow + 1
         # check syrmep tango reading
         idx = self.thread.syrmepstopperindex
         item = self.tableWidget.item(idx, 2)
@@ -542,10 +542,37 @@ class active_frntd_e(Ui_frntd_e, QtCore.QObject):
         if self.thread.nanoesca_shutter_value == -1:
             item.setBackground(self.graybrush)
             item.setText("UNKNOWN")
+            
+        #---------------------------------------------
+        # check superesca stopper tango reading
+        idx = self.thread.superescastopperindex
+        item = self.tableWidget.item(idx, 2)
+        if self.thread.superesca_stopper_value == 1:
+            item.setBackground(self.redbrush)
+            item.setText("OPEN")
+        if self.thread.superesca_stopper_value == 0:
+            item.setBackground(self.greenbrush)
+            item.setText("CLOSED")
+        if self.thread.superesca_stopper_value == -1:
+            item.setBackground(self.graybrush)
+            item.setText("UNKNOWN")
+            
+         # check superesca shutter tango reading
+        idx = self.thread.superescashutterindex
+        item = self.tableWidget.item(idx, 2)
+        if self.thread.superesca_shutter_value == 1:
+            item.setBackground(self.redbrush)
+            item.setText("OPEN")
+        if self.thread.superesca_shutter_value == 0:
+            item.setBackground(self.greenbrush)
+            item.setText("CLOSED")
+        if self.thread.superesca_shutter_value == -1:
+            item.setBackground(self.graybrush)
+            item.setText("UNKNOWN")
         
         
         #-------------------------------------------------------------------
-        all_tango_closed = self.thread.syrmep_stopper_value == 0 and self.thread.nanoesca_stopper_value == 0 and self.thread.nanoesca_shutter_value == 0
+        all_tango_closed = self.thread.syrmep_stopper_value == 0 and self.thread.nanoesca_stopper_value == 0 and self.thread.nanoesca_shutter_value == 0 and self.thread.superesca_shutter_value == 0 and self.thread.superesca_stopper_value == 0
         vuv_closed =   self.thread.vuvphotemission_shutter_value == 0 and self.thread.vuvphotemission_shutter_value == 0
         palette = self.label.palette()
         if mybl.allclosed() == 1 and all_tango_closed and vuv_closed:
-- 
GitLab