Commit 76eceec0 authored by LorenzoMonti's avatar LorenzoMonti
Browse files

Merge branch 'centos_7_compatibility' of https://github.com/discos/discos into srt-bandQ-receiver

parents d6d14eb4 2f97feb0
Loading
Loading
Loading
Loading
+10 −15
Original line number Diff line number Diff line
@@ -201,12 +201,7 @@ int main(int argc, char *argv[]) {
	// Change the style of the main frame 
	window.setTitleStyle(CStyle(TITLE_COLOR_PAIR,TITLE_STYLE));
	
	if (window.colorReady()) {
		window.defineColor(GRAY_COLOR,255,255,255);		
		window.defineColorPair(BLUE_GRAY,CColor::BLUE,GRAY_COLOR);
		window.defineColorPair(GRAY_BLUE,GRAY_COLOR,CColor::BLUE);		
	}
	else {
	window.defineColor(GRAY_COLOR,500,500,500);
	window.defineColorPair(BLUE_GRAY,CColor::BLUE,CColor::WHITE);
	window.defineColorPair(GRAY_BLUE,CColor::WHITE,CColor::BLUE);
	window.defineColorPair(BLACK_RED,CColor::BLACK,CColor::RED);
@@ -215,7 +210,7 @@ int main(int argc, char *argv[]) {
	window.defineColorPair(BLACK_BLUE,CColor::BLACK,CColor::BLUE);
	window.defineColorPair(BLACK_MAGENTA,CColor::BLACK,CColor::MAGENTA);
	window.defineColorPair(BLACK_WHITE,CColor::BLACK,CColor::WHITE);
	}

	ACS_LOG(LM_FULL_INFO,MODULE_NAME"::Main()",(LM_INFO,MODULE_NAME"::FRAME_INITIALIZED"));
	ACS_LOG(LM_FULL_INFO,MODULE_NAME"::Main()",(LM_INFO,MODULE_NAME"::GET_DEFAULT_COMPONENENT: %s",COMPONENT_INTERFACE_TPYE));
	
+3 −1
Original line number Diff line number Diff line
@@ -210,7 +210,9 @@ install : install_all
gui:
	pyuic4 calibrationToolClient.ui -o calibrationtool_ui.py
	
	@sed  -ie 's/Qwt5.QwtPlot/PlotProperty/g' calibrationtool_ui.py
	@sed  -ie 's/from qwt_plot import QwtPlot//g' calibrationtool_ui.py
	
	@sed  -ie 's/QwtPlot/PlotProperty/g' calibrationtool_ui.py
	
	@sed -ie '9 i\from customwidgets import *' calibrationtool_ui.py

+323 −343
Original line number Diff line number Diff line
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from Acspy.Clients.SimpleClient import PySimpleClient
import Acspy.Common.Err
import maciErrType
@@ -11,7 +12,7 @@ import ACSLog
import ACS, ACS__POA                                  # Import the Python CORBA stubs for BACI
from PyQt4 import Qt
from PyQt4.QtCore import pyqtSlot,QThread,QMutex,QTimer
import PyQt4.Qwt5 as Qwt
import PyQt4.Qwt as Qwt
import sys,getopt,os
from time import sleep
import math
@@ -19,8 +20,7 @@ from IRAPy import logger,userLogger



import calibrationtool_ui # file generated by pyuic4 but modified to include 
		          #custom widgets.
import calibrationtool_ui # file generated by pyuic4 but modified to include custom widgets.

__version__ = '$Id'

@@ -62,10 +62,10 @@ class MyWorker(QThread):
        self.offset       =self.caltool._get_offset()
        self.name        =self.boss._get_target()
        self.device      =self.caltool._get_deviceID()
                self.oldscan=0L
                self.newscan=0L
                self.oldsubscan=0L
                self.newsubscan=0L
        self.oldscan=0
        self.newscan=0
        self.oldsubscan=0
        self.newsubscan=0
        self.oldrecordingstatus=False
        self.newrecordingstatus=False
        self.azimuthOffset=self.boss._get_azimuthOffset()
@@ -74,7 +74,6 @@ class MyWorker(QThread):

    def run (self):
        try:
        	
            #arrayDataX=self.componenselft._get_arrayDataX()
            #arrayDataY=self.component._get_arrayDataY()
            while self.run:
@@ -83,16 +82,12 @@ class MyWorker(QThread):
                (arraydatax,compl)=self.arrayDataX.get_sync()
                if 'SUBR' not in str(scanaxis):
                    arraydatax[:]=[x /math.pi*180. for x in arraydatax]
                        

                self.emit(Qt.SIGNAL("arrayDataX"),arraydatax)
                (arraydatay,compl2)=self.arrayDataY.get_sync()
                        
                self.emit(Qt.SIGNAL("arrayDataY"),arraydatay)
                (datay,compl3)=self.dataY.get_sync()
                (datax,compl3)=self.dataX.get_sync()
                if 'SUBR' not in str(scanaxis):
                        
                    datax=datax/math.pi*180.
                (projectname,compl4)=self.projectname.get_sync()
                self.emit(Qt.SIGNAL("projectname"),projectname)
@@ -105,7 +100,6 @@ class MyWorker(QThread):
                (scanid,compl8)=self.scan.get_sync()
                self.emit(Qt.SIGNAL("scan"),str(scanid))
                (hpbw,compl9)=self.hpbw.get_sync()
                        
                if 'SUBR' not in str(scanaxis):
                    hpbw= hpbw/math.pi*180*60
                self.emit(Qt.SIGNAL("hpbw"),("%5.3f" % (hpbw)))
@@ -114,10 +108,8 @@ class MyWorker(QThread):
                (peakOffset,compl11)=self.peakOffset.get_sync()
                if 'SUBR' not in str(scanaxis):
                    peakOffset=peakOffset/math.pi*180
                                  
                self.emit(Qt.SIGNAL("peakOffset"),"%5.3f" % (peakOffset))
                (slope,compl12)=self.slope.get_sync()
                        
                self.emit(Qt.SIGNAL("slope"),"%5.3f" %slope)
                (offset,compl13)=self.offset.get_sync()
                self.emit(Qt.SIGNAL("offset"),"%5.3f" % offset)
@@ -128,11 +120,9 @@ class MyWorker(QThread):
                self.emit(Qt.SIGNAL("scanAxis"),scanaxis)
                (azOffset,_)=self.azimuthOffset.get_sync()
                (elOffset,_)=self.elevationOffset.get_sync()

                self.emit(Qt.SIGNAL("azoffset"),str(azOffset/math.pi*180))
                self.emit(Qt.SIGNAL("eloffset"),str(elOffset/math.pi*180))


                rec= self.caltool.isRecording()
                if rec==True:
                   self.datay_tmp.append(datay)
@@ -143,36 +133,31 @@ class MyWorker(QThread):
                self.emit(Qt.SIGNAL("isRecording"),rec)
                self.emit(Qt.SIGNAL("scanAxis"),scanaxis)

 #                       print rec
                #print(rec)
                #if (subscanid!=self.oldsubscan and scanid !=self.oldscanid):
#                                print "scan changed",self.oldsubscan,subscanid
                    #print("scan changed",self.oldsubscan,subscanid)
                    #self.oldsubscan=subscanid
                    #self.subscan=subscanid
                    #self.datax_tmp=[]
                    #self.datay_tmp=[]


                if (rec!=self.oldrecordingstatus):
                    self.oldrecordingstatus=rec
                    self.datax_tmp=[]
                    self.datay_tmp=[]


                        
                QThread.msleep(200)
                   print "Exited from thread"
            print("Exited from thread")

	      except Exception,ex:
        except Exception as ex:
            newEx = ClientErrorsImpl.CouldntAccessPropertyExImpl(exception=ex, create=1)
            newEx.setPropertyName("")
            #ACS_LOG_ERROR
            newEx.log(self.simpleClient.getLogger(),ACSLog.ACS_LOG_ERROR)

            self.run=False

    def __del__(self):
        QThread.msleep(200)
                pass


class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
@@ -189,28 +174,28 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
        try:
            self.simpleClient = PySimpleClient()
            self.managerConnected=True
		except Exception,ex:
        except Exception as ex:
            newEx = ClientErrorsImpl.CouldntLogManagerExImpl(exception=ex, create=1)
            logger.logException(newEx)
			print "Please check the system is up and running......"
            print("Please check the system is up and running......")
            sys.exit(-1)

        try:
            self.scheduler= self.simpleClient.getDefaultComponent("IDL:alma/Management/Scheduler:1.0")
		except Exception,ex:
        except Exception as 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!"
            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:
        except Exception as 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!"
            print("Please check the system is up and running and antenna boss is alive!")
            sys.exit(-1)

        #choose default recorder
@@ -218,29 +203,29 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
            try:
                recorder=self.scheduler._get_currentRecorder()
                (recordername,compl)=recorder.get_sync()
			except  Exception,ex:
            except Exception as ex:
                newEx = ClientErrorsImpl.CouldntAccessPropertyExImpl(exception=ex, create=1)
                logger.logException(newEx)
				print "Please check scheduler component is alive and responsive|" 
                print("Please check scheduler component is alive and responsive|")
                sys.exit(-1)

			print "Starting with default component: " + DEFAULT_COMPONENT	
            print("Starting with default component: " + DEFAULT_COMPONENT)
            if recordername!=DEFAULT_COMPONENT:
				print "Be aware that the in-use recorder is currently " + recordername
                print("Be aware that the in-use recorder is currently " + recordername)

            self.componentName=DEFAULT_COMPONENT

        else:
            self.componentName=compname
			print "Starting with component: " + self.componentName
            print("Starting with component: " + self.componentName)

        try:
            self.component= self.simpleClient.getComponent(self.componentName)
		except Exception,ex:
        except Exception as 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!"
            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])
@@ -275,11 +260,6 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
        self.connect(self.thread,Qt.SIGNAL("eloffset"),self.elOffsetlineEdit.setText)
        self.connect(self.thread,Qt.SIGNAL("azoffset"),self.azOffsetlineEdit.setText)





                       
    @pyqtSlot(Qt.QObject,name="isRecording")
    def isRecording(self,rec):
        if rec==False:
@@ -336,22 +316,22 @@ class Application(Qt.QDialog,calibrationtool_ui.Ui_CalibrationToolDialog):
                    self.simpleClient.releaseComponent(self.scheduler._get_name())
                if self.antennaBoss:
                    self.simpleClient.releaseComponent(self.antennaBoss._get_name())
			except Exception,ex:
				print "Error in application cleanup"                      
            except Exception as ex:
                print("Error in application cleanup")


def usage():
	print "calibrationtoolclient [component name]"
	print
	print "If no component name is provided, the default MANAGEMENT/CalibrationTool will be used" 
    print("calibrationtoolclient [component name]")
    print()
    print("If no component name is provided, the default MANAGEMENT/CalibrationTool will be used")

def main(args):
    sys.tracebacklimit=0

    try:
        opts, args = getopt.getopt(sys.argv[1:],"h",["help"])
	except getopt.GetoptError, err:
		print str(err)
    except getopt.GetoptError as err:
        print(str(err))
        usage()
        sys.exit(1)

@@ -372,7 +352,7 @@ def main(args):
    p=a.show()
    sys.exit(app.exec_())
    sleep(2)
	print "Application closed!"
    print("Application closed!")


if __name__=='__main__':
+59 −62
Original line number Diff line number Diff line
from __future__ import print_function
from PyQt4 import Qt
from PyQt4.QtCore import   pyqtSlot,QThread
import PyQt4.Qwt5 as Qwt
import PyQt4.Qwt as Qwt
'''
Custom widgets classes.

@@ -12,11 +13,7 @@ Custom widgets classes.

'''




class PlotProperty(Qwt.QwtPlot):
      
    def __init__(self,parent,*args):
        Qwt.QwtPlot.__init__(self,parent,*args)
        #self.paint=Qt.QPainter(self) # you must initialize the superclass
@@ -24,13 +21,11 @@ class PlotProperty(Qwt.QwtPlot):
        self.y=[]
        self.curve=Qwt.QwtPlotCurve('aaaa')
        self.curve.attach(self)
	p = Qt.QPalette() #
        p = Qt.QPalette()
        p.setColor(self.backgroundRole(), Qt.QColor(30, 30, 50))
        self.setPalette(p)
        self.curve.setPen(Qt.QPen(Qt.Qt.red))

     
        
#void Widget::drawCanvas(QPainter* p)
#{
#    QwtPlot::drawCanvas( p );  // <<---
@@ -41,9 +36,8 @@ class PlotProperty(Qwt.QwtPlot):

    def suspend(self):
        pass
      @pyqtSlot(Qt.QObject,name="setval")  # decorator for the slot
    					   # Qt.Object  is necessary for lists 
					  # and dictionarys

    @pyqtSlot(Qt.QObject,name="setval")  # decorator for the slot, Qt.Object is necessary for lists and dictionarys
    def setVal(self,val):
        value_decimated=[0 for i in range (len(val))]

@@ -52,13 +46,14 @@ class PlotProperty(Qwt.QwtPlot):
            step=1  #step 0 not allowed
        for i in range(0,min(len(val),1000)):
            value_decimated[int(i)] =val[int(i*step-1)]
#                self.curve.setData(self.timeData,value_decimated)       
                self.curve.setData(self.timeData,val)       
        #self.curve.setSamples(self.timeData, value_decimated)
        self.curve.setSamples(self.timeData, val)
        self.replot()
      @pyqtSlot(Qt.QObject,name="setX")  # decorator for the slot

    @pyqtSlot(Qt.QObject,name="setX")  # decorator for the slot
    def setX(self,val):
        self.timeData=[i for i in val]

    def setDataY(self,val):
        value_decimated=[0 for i in range (1000)]

@@ -67,14 +62,16 @@ class PlotProperty(Qwt.QwtPlot):
            step=1  #step 0 not allowed
        for i in  range(0,min(len(val),1000)):
            value_decimated[int(i)] =val[int(i*step)-1]
#                self.curve.setData(self.timeData,value_decimated)       
                self.curve.setData(self.timeData,val)       
                
        #self.curve.setSamples(self.timeData, value_decimated)
        self.curve.setSamples(self.timeData, val)
        self.replot()

    def setDataX(self,val):
        pass

    def setCurveColor(self,val):
        pass

    def __del__(self):
        #self.actMonwspeed.destroy()
	print "The end __oOo__"
        print("The end __oOo__")
+15 −11
Original line number Diff line number Diff line
#!/usr/bin/env python
from __future__ import print_function
"""
CustomLoggingClient implements a Tkinter interface that monitors in realtime the ACS custom
logging events generated runtime.
@@ -13,7 +14,10 @@ import sys
import logging
import bisect
import functools
try:
    import Tkinter as tk
except:
    import tkinter as tk
from IRAPy.bsqueue import BoundedSortedQueue

#DEFINE LOGGING RECORDS TOTAL ORDERING RULES
@@ -83,22 +87,22 @@ if __name__ == '__main__':
        consumer = Consumer(Management.CUSTOM_LOGGING_CHANNEL_NAME)
        consumer.addSubscription(Management.CustomLoggingData, app.handler)
        consumer.consumerReady()
    except Exception, ex:
        print "exception caught: ", ex #TODO: throw excep
    except Exception as ex:
        print("exception caught: ", ex) #TODO: throw excep
        logger.logError(ex.message)
    #try:

    def handle_signal(num, trace):
        #trace.f_locals['app'].clear()
        #trace.f_locals['consumer'].disconnect()
        print "Exiting"
        print("Exiting")
        sys.exit(0)

    signal.signal(signal.SIGINT, handle_signal)     
    signal.signal(signal.SIGUSR1, handle_signal)     
    root.mainloop()    
    #except KeyboardInterrupt, ki:
    #except KeyboardInterrupt as ki:
    #    pass
    #finally:
    #    consumer.disconnect()
    #    print "Exiting"
    #    print("Exiting")
Loading