Skip to content
Snippets Groups Projects
Commit 01377eae authored by Andrea Orlati's avatar Andrea Orlati Committed by GitHub
Browse files

fix issue #538: changed the name of the python program in order to run it...

fix issue #538: changed the name of the python program in order to run it through a bash script. The script (#544)

turns off the stdout messages in order to provide a clearer output to the user. Improved user messages in case of problems.
slighly changed the default beviour when linking to a component. Default is the calibration tool, if the currently selected
recorder is different a warning is given but the GUI is started all the same.
parent 204e91b7
No related branches found
No related tags found
No related merge requests found
...@@ -66,7 +66,7 @@ lllll_OBJECTS = ...@@ -66,7 +66,7 @@ lllll_OBJECTS =
# #
# Scripts (public and local) # Scripts (public and local)
# ---------------------------- # ----------------------------
SCRIPTS = SCRIPTS = calibrationtoolclient
SCRIPTS_L = SCRIPTS_L =
# #
...@@ -78,7 +78,7 @@ TCL_SCRIPTS_L = ...@@ -78,7 +78,7 @@ TCL_SCRIPTS_L =
# #
# Python stuff (public and local) # Python stuff (public and local)
# ---------------------------- # ----------------------------
PY_SCRIPTS = calibrationtoolclient PY_SCRIPTS = _ctc
PY_SCRIPTS_L = PY_SCRIPTS_L =
PY_MODULES = customwidgets calibrationtool_ui PY_MODULES = customwidgets calibrationtool_ui
......
...@@ -12,9 +12,10 @@ import ACS, ACS__POA # Import the Python CORBA ...@@ -12,9 +12,10 @@ import ACS, ACS__POA # Import the Python CORBA
from PyQt4 import Qt from PyQt4 import Qt
from PyQt4.QtCore import pyqtSlot,QThread,QMutex,QTimer from PyQt4.QtCore import pyqtSlot,QThread,QMutex,QTimer
import PyQt4.Qwt5 as Qwt import PyQt4.Qwt5 as Qwt
import sys,getopt import sys,getopt,os
from time import sleep from time import sleep
import math import math
from IRAPy import logger,userLogger
...@@ -28,6 +29,7 @@ __version__ = '$Id' ...@@ -28,6 +29,7 @@ __version__ = '$Id'
@version $Id$ @version $Id$
''' '''
DEFAULT_COMPONENT="MANAGEMENT/CalibrationTool"
class MyWorker(QThread): class MyWorker(QThread):
def __init__(self,component,parent=None): def __init__(self,component,parent=None):
...@@ -166,42 +168,83 @@ class MyWorker(QThread): ...@@ -166,42 +168,83 @@ class MyWorker(QThread):
pass pass
class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog): class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
def __init__(self,compname,parent=None): def __init__(self,compname,parent=None):
Qt.QDialog.__init__(self)
self.scheduler=None
self.antennaBoss=None
self.component=None
self.componentName=DEFAULT_COMPONENT
self.managerConnected=False
self.thread=None
try:
self.simpleClient = PySimpleClient() self.simpleClient = PySimpleClient()
self.managerConnected=True
except Exception,ex:
newEx = ClientErrorsImpl.CouldntLogManagerExImpl(exception=ex, create=1)
logger.logException(newEx)
print "Please check the system is up and running......"
sys.exit(-1)
try: try:
scheduler= self.simpleClient.getDefaultComponent("IDL:alma/Management/Scheduler:1.0") self.scheduler= self.simpleClient.getDefaultComponent("IDL:alma/Management/Scheduler:1.0")
antennaBoss =self.simpleClient.getDefaultComponent("IDL:alma/Antenna/AntennaBoss:1.0") except Exception,ex:
newEx = ClientErrorsImpl.CouldntAccessComponentExImpl(exception=ex, create=1)
newEx.setComponentName("IDL:alma/Management/Scheduler:1.0")
logger.logException(newEx)
print "Please check the system is up and running and scheduler component is alive!"
sys.exit(-1)
try:
self.antennaBoss =self.simpleClient.getDefaultComponent("IDL:alma/Antenna/AntennaBoss:1.0")
except Exception,ex:
newEx = ClientErrorsImpl.CouldntAccessComponentExImpl(exception=ex, create=1)
newEx.setComponentName("IDL:alma/Antenna/AntennaBoss:1.0")
logger.logException(newEx)
print "Please check the system is up and running and antenna boss is alive!"
sys.exit(-1)
#choose default recorder #choose default recorder
if compname=='default': if compname=='default':
try:
recorder=scheduler._get_currentRecorder() recorder=self.scheduler._get_currentRecorder()
(recordername,compl)=recorder.get_sync() (recordername,compl)=recorder.get_sync()
self.componentname=recordername except Exception,ex:
print recordername newEx = ClientErrorsImpl.CouldntAccessPropertyExImpl(exception=ex, create=1)
logger.logException(newEx)
print "Please check scheduler component is alive and responsive|"
sys.exit(-1)
print "Starting with default component: " + DEFAULT_COMPONENT
if recordername!=DEFAULT_COMPONENT:
print "Be aware that the in-use recorder is currently " + recordername
self.componentName=DEFAULT_COMPONENT
else: else:
self.componentname=compname self.componentName=compname
print self.componentname print "Starting with component: " + self.componentName
component= self.simpleClient.getComponent(self.componentname)
self.thread=MyWorker([component,scheduler,antennaBoss,self.simpleClient]) try:
self.component= self.simpleClient.getComponent(self.componentName)
except Exception,ex:
newEx = ClientErrorsImpl.CouldntAccessComponentExImpl(exception=ex, create=1)
newEx.setComponentName(self.componentName)
logger.logException(newEx)
print "Please check the system is up and running and " + self.componentName + " is alive!"
sys.exit(-1)
self.thread=MyWorker([self.component,self.scheduler,self.antennaBoss,self.simpleClient])
Qt.QDialog.__init__(self)
self.setupUi(self) self.setupUi(self)
# self.qwtPlot_datax.setAxisScale(Qwt.QwtPlot.xBottom, 0,1000) # self.qwtPlot_datax.setAxisScale(Qwt.QwtPlot.xBottom, 0,1000)
self.qwtPlot_datax.setAxisAutoScale(Qwt.QwtPlot. yLeft) self.qwtPlot_datax.setAxisAutoScale(Qwt.QwtPlot. yLeft)
self.setWindowTitle(self.componentname) self.setWindowTitle(self.componentName)
self.qwtPlot_datax.setAxisTitle(Qwt.QwtPlot.yLeft, "Ta(K)") self.qwtPlot_datax.setAxisTitle(Qwt.QwtPlot.yLeft, "Ta(K)")
self.qwtPlot_datay.setAxisTitle(Qwt.QwtPlot.yLeft, "Ta(K)") self.qwtPlot_datay.setAxisTitle(Qwt.QwtPlot.yLeft, "Ta(K)")
self.connect(self.thread,Qt.SIGNAL("arrayDataX"),self.qwtPlot_datay.setX) self.connect(self.thread,Qt.SIGNAL("arrayDataX"),self.qwtPlot_datay.setX)
self.connect(self.thread,Qt.SIGNAL("arrayDataY"),self.qwtPlot_datay.setVal) self.connect(self.thread,Qt.SIGNAL("arrayDataY"),self.qwtPlot_datay.setVal)
...@@ -223,16 +266,6 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog): ...@@ -223,16 +266,6 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
self.connect(self.thread,Qt.SIGNAL("isRecording"),self.isRecording) self.connect(self.thread,Qt.SIGNAL("isRecording"),self.isRecording)
self.connect(self.thread,Qt.SIGNAL("scanAxis"),self.scanAxis) self.connect(self.thread,Qt.SIGNAL("scanAxis"),self.scanAxis)
except Exception,ex:
newEx = ClientErrorsImpl.CouldntAccessComponentExImpl(exception=ex, create=1)
# newEx.setComponentName(self.componentname)
#ACS_LOG_ERROR
newEx.log(self.simpleClient.getLogger(),ACSLog.ACS_LOG_ERROR)
self.simpleClient.disconnect()
sys.exit(-1)
@pyqtSlot(Qt.QObject,name="isRecording") @pyqtSlot(Qt.QObject,name="isRecording")
def isRecording(self,rec): def isRecording(self,rec):
if rec==False: if rec==False:
...@@ -242,9 +275,6 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog): ...@@ -242,9 +275,6 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
palette.setColor(role, Qt.QColor('gray')) palette.setColor(role, Qt.QColor('gray'))
self.recording.setPalette(palette) self.recording.setPalette(palette)
self.BScanaxis.setEnabled(False) self.BScanaxis.setEnabled(False)
if rec==True: if rec==True:
self.recording.setText("ON") self.recording.setText("ON")
palette = self.recording.palette() palette = self.recording.palette()
...@@ -256,7 +286,6 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog): ...@@ -256,7 +286,6 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
@pyqtSlot(Qt.QObject,name="scanAxis") # decorator for the slot @pyqtSlot(Qt.QObject,name="scanAxis") # decorator for the slot
def scanAxis(self,scanaxis): def scanAxis(self,scanaxis):
self.BScanaxis.setText(str(scanaxis)) self.BScanaxis.setText(str(scanaxis))
if 'SUBR' not in str(scanaxis): if 'SUBR' not in str(scanaxis):
self.scanAxisLabel.setText('ScanAxis - Pointing') self.scanAxisLabel.setText('ScanAxis - Pointing')
xaxis_text="Direction (Deg)" xaxis_text="Direction (Deg)"
...@@ -266,47 +295,45 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog): ...@@ -266,47 +295,45 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
self.scanAxisLabel.setText('ScanAxis - Focus') self.scanAxisLabel.setText('ScanAxis - Focus')
xaxis_text="Distance (mm)" xaxis_text="Distance (mm)"
hpbw_label_text='HPBW(mm)' hpbw_label_text='HPBW(mm)'
peakOffsetLabel_text='PeakOffset(mm)' peakOffsetLabel_text='PeakOffset(mm)'
self.qwtPlot_datax.setAxisTitle(Qwt.QwtPlot.xBottom, xaxis_text) self.qwtPlot_datax.setAxisTitle(Qwt.QwtPlot.xBottom, xaxis_text)
self.qwtPlot_datay.setAxisTitle(Qwt.QwtPlot.xBottom, xaxis_text) self.qwtPlot_datay.setAxisTitle(Qwt.QwtPlot.xBottom, xaxis_text)
self.hpbw_label.setText(hpbw_label_text) self.hpbw_label.setText(hpbw_label_text)
self.peakOffsetLabel.setText(peakOffsetLabel_text) self.peakOffsetLabel.setText(peakOffsetLabel_text)
@pyqtSlot(Qt.QObject,name="scalePlots") # decorator for the slot @pyqtSlot(Qt.QObject,name="scalePlots") # decorator for the slot
def scalePlots(self,val): def scalePlots(self,val):
self.qwtPlot_datay.setAxisScale(QwtPlot.xBottom, min(val), max(val)) self.qwtPlot_datay.setAxisScale(QwtPlot.xBottom, min(val), max(val))
def run(self): def run(self):
self.thread.start() self.thread.start()
def __del__(self): def __del__(self):
self.thread.run=False #__del__ apparently is called twice, I have no clue and it should be investigated
if self.thread:
if self.thread.isRunning:
self.thread.quit()
if self.managerConnected:
try: try:
self.simpleClient.releaseComponent(self.componentname) if self.component:
self.simpleClient.releaseComponent(self.component._get_name())
if self.scheduler:
self.simpleClient.releaseComponent(self.scheduler._get_name()) self.simpleClient.releaseComponent(self.scheduler._get_name())
self.simpleClient.releaseComponent(self.boss._get_name()) if self.antennaBoss:
self.simpleClient.releaseComponent(self.antennaBoss._get_name())
self.simpleClient.disconnect()
except Exception,ex: except Exception,ex:
print "exception" print "Error in application cleanup"
print "end app"
def usage(nameapp):
print nameapp+" [component name]"
def usage():
print "calibrationtoolclient [component name]"
print
print "If no component name is provided, the default "+DEFAULT_COMPONENT+" will be used"
def main(args): def main(args):
sys.tracebacklimit=0
try: try:
opts, args = getopt.getopt(sys.argv[1:],"h",["help"]) opts, args = getopt.getopt(sys.argv[1:],"h",["help"])
except getopt.GetoptError, err: except getopt.GetoptError, err:
...@@ -324,13 +351,15 @@ def main(args): ...@@ -324,13 +351,15 @@ def main(args):
else: else:
componentname=args[0] componentname=args[0]
print componentname
app = Qt.QApplication(args) app = Qt.QApplication(args)
a=Application(componentname) #passa il nome del component al costruttore a=Application(componentname) #passa il nome del component al costruttore
sleep(1)
a.run() a.run()
p=a.show() p=a.show()
sys.exit(app.exec_()) sys.exit(app.exec_())
sleep(2) sleep(2)
print "Application closed!"
if __name__=='__main__': if __name__=='__main__':
main(sys.argv) main(sys.argv)
#! /bin/bash
# ***********************************************************************
# Who when What
# Andrea Orlati(andrea.orlati@inaf.it) 22/05/2020 Creation
#************************************************************************
export ACS_LOG_STDOUT=11
_ctc $1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment