Exemplo n.º 1
0
def main():
    ''' Initiate PyQT application '''
    app = QApplication(sys.argv)
    ''' Reference to the logger from the subclass '''
    subclasslog = logsub.logger
    ''' initialise an instance of logging widget with a logger '''
    logwidget1 = lw.loggerWidget(logger)
    ''' initialise an instance of the logging Widget  and add loggers'''
    logwidget2 = lw.loggerWidget()
    logwidget2.addLogger(logger)
    logwidget2.addLogger(logger2)
    logwidget2.addLogger(subclasslog)
    ''' or we can initialise with a list of loggers '''
    logwidget3 = lw.loggerWidget([logger, logger2, subclasslog])

    tab = QTabWidget()
    tab.resize(800, 500)
    tab.addTab(logwidget1, "Single Log")
    tab.addTab(logwidget2, "2 Logs added")
    tab.addTab(logwidget3, "Initialised with 2 Logs")
    layout = QWidget()
    tab.addTab(layout, "Another Tab")
    ''' Display the Qt App '''
    tab.show()
    ''' Output some logging info! '''
    test()
    logsub.test()
    ''' Default PyQT exit handler '''
    sys.exit(app.exec_())
Exemplo n.º 2
0
def main():
    ''' Initiate PyQT application '''
    app = QApplication(sys.argv)

    ''' initialise an instance of logging widget with a logger '''
    logwidget1 = lw.loggerWidget(logger)
    zmqlog1 = lw.zmqPublishLogger(logger, port=5556, ipaddress='148.79.112.154', logName='network')
    zmqlog1.setLogName('differentName')
    zmqlog1.setIPAddress(ipaddress='148.79.112.153')

    tab = QTabWidget()
    tab.resize(800,500)
    tab.addTab(logwidget1,"Single Log")
    widget = QWidget()
    layout = QVBoxLayout()
    button = QPushButton("test logs")
    button.clicked.connect(test)
    layout.addWidget(button)
    widget.setLayout(layout)
    tab.addTab(widget,"Another Tab")

    ''' Display the Qt App '''
    tab.show()

    ''' Default PyQT exit handler '''
    sys.exit(app.exec_())
Exemplo n.º 3
0
def main():
    ''' Initiate PyQT application '''
    app = QApplication(sys.argv)
    ''' Reference to the logger from the subclass '''
    subclasslog = logsub.logger
    ''' initialise an instance of logging widget with a logger '''
    logwidget1 = lw.loggerWidget(logger)
    logwidget1.setDebugColour('red')
    #    zmqlog1 = lw.loggerNetwork(logger, port=5556, ipaddress='148.79.112.153')
    sys.stdout = lw.redirectLogger(logwidget1, 'stdout')
    ''' initialise an instance of the logging Widget  and add loggers'''
    logwidget2 = lw.loggerWidget()
    ''' set colours of different log levels '''
    logwidget2.setLogColours(debugcolour='blue',
                             infocolour='green',
                             warningcolour='black',
                             errorcolour='orange',
                             criticalcolour='brown')
    logwidget2.setDateColumnWidth(160)
    logwidget2.setLevelColumnWidth(100)
    logwidget2.addLogger(logger)
    logwidget2.addLogger(logger2)
    logwidget2.addLogger(subclasslog)
    ''' or we can initialise with a list of loggers '''
    logwidget3 = lw.loggerWidget([logger, logger2, subclasslog])
    logwidget3.setColumnWidths(200, 300, 400)

    tab = QTabWidget()
    tab.resize(800, 500)
    tab.addTab(logwidget1, "Single Log")
    tab.addTab(logwidget2, "2 Logs added")
    tab.addTab(logwidget3, "Initialised with 2 Logs")
    layout = QWidget()
    tab.addTab(layout, "Another Tab")
    ''' Display the Qt App '''
    tab.show()
    ''' Output some logging info! '''
    test()
    logsub.test()
    print "this is a test"
    ''' Default PyQT exit handler '''
    sys.exit(app.exec_())
Exemplo n.º 4
0
 def __init__(self, sys_argv):
     #App is launched here based on inputs from the Master app. Cumbersome, I know...
     super(dlyApp, self).__init__(sys_argv)
     self.bpm = vbpmc.init()
     if sys_argv[1] == "VELA_INJ":
         self.contType = "VELA_INJ"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_VELA_INJ_BPM_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_VELA_INJ_BPM_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_VELA_INJ_BPM_Controller()
     elif sys_argv[1] == "VELA_BA1":
         self.contType = "VELA_BA1"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_VELA_BA1_BPM_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_VELA_BA1_BPM_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_VELA_BA1_BPM_Controller()
     elif sys_argv[1] == "VELA_BA2":
         self.contType = "VELA_BA2"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_VELA_BA2_BPM_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_VELA_BA2_BPM_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_VELA_BA2_BPM_Controller()
     elif sys_argv[1] == "CLARA_INJ":
         self.contType = "CLARA_INJ"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_CLARA_INJ_BPM_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_CLARA_INJ_BPM_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_CLARA_INJ_BPM_Controller()
     elif sys_argv[1] == "CLARA_2_VELA":
         self.contType = "C2V"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_CLARA_2_VELA_BPM_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_CLARA_2_VELA_BPM_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_CLARA_2_VELA_BPM_Controller()
     self.view = dlymainView.dlyUi_TabWidget()
     self.MainWindow = QtGui.QTabWidget()
     self.view.setupUi(self.MainWindow, self.bpmCont, sys_argv[1],
                       sys_argv[2])
     self.model = dlymainModel.dlyModel(self.bpmCont)
     self.controller = dlymainController.dlyController(
         self.view, self.model, self.bpmCont)
     self.logwidget1 = lw.loggerWidget([logger, dlymainController.logger])
     self.MainWindow.addTab(self.logwidget1, "Log")
     self.MainWindow.show()
Exemplo n.º 5
0
def main():
    ''' Initiate PyQT application '''
    app = QApplication(sys.argv)

    ''' Reference to the logger from the subclass '''
    subclasslog = logsub.logger

    ''' initialise an instance of logging widget with a logger '''
    logwidget1 = lw.loggerWidget(logger)
    zmqreceiver = lw.zmqReceiverLogger(port=5556)
    logwidget1.setDebugColour('red')

    tab = QTabWidget()
    tab.resize(800,500)
    tab.addTab(logwidget1,"Single Log")

    ''' Display the Qt App '''
    tab.show()

    ''' Default PyQT exit handler '''
    sys.exit(app.exec_())
Exemplo n.º 6
0
	def __init__(self, view, model):
		'''define model and view'''
		self.view = view
		self.model = model
		'''1 Create Momentum Graphs'''
		monitor = pg.GraphicsView()
		layout = pg.GraphicsLayout(border=(100,100,100))
		monitor.setCentralItem(layout)
		'''1.1 create graph for BPM Y and Y position monitoring'''
		self.xdict = {0:'X', 1:'Y'}
		self.positionGraph_1 = layout.addPlot(title="BPM XX")
		self.positionGraph_2 = layout.addPlot(title="BPM XX")
		self.positionGraph_3 = layout.addPlot(title="BPM XX")
		self.positionGraph_1.axes['bottom']['item'].setTicks([self.xdict.items()])
		self.positionGraph_2.axes['bottom']['item'].setTicks([self.xdict.items()])
		self.positionGraph_3.axes['bottom']['item'].setTicks([self.xdict.items()])
		self.bg1 = pg.BarGraphItem(x=self.xdict.keys(), height=[-0.3,0.2], width=1)
		self.bg2 = pg.BarGraphItem(x=self.xdict.keys(), height=[-0.3,0.2], width=1)
		self.bg3 = pg.BarGraphItem(x=self.xdict.keys(), height=[-0.3,0.2], width=1)
		self.positionGraph_1.setYRange(-1,1)
		self.positionGraph_2.setYRange(-1,1)
		self.positionGraph_3.setYRange(-1,1)
		self.positionGraph_1.addItem(self.bg1)
		self.positionGraph_2.addItem(self.bg2)
		self.positionGraph_3.addItem(self.bg3)
		layout.nextRow()
		'''1.2 Create plave to diplay and image of a YAG screen'''
		yagImageBox = layout.addViewBox(lockAspect=True, colspan=2)
		self.YAGImage = pg.ImageItem(np.random.normal(size=(1392,1040)))
		yagImageBox.addItem(self.YAGImage)
		self.displayMom = layout.addLabel('MOMENTUM = MeV/c')
		self.view.horizontalLayout_4.addWidget(monitor)

		'''2. Create Momentum Spread Graphs'''
		monitor_s = pg.GraphicsView()
		layout_s = pg.GraphicsLayout(border=(100,100,100))
		monitor_s.setCentralItem(layout_s)
		self.dispersionGraph  = layout_s.addPlot(title="Dispersion")
		self.displayDisp = layout_s.addLabel('DISPERSION = pixels per Ampere')
		layout_s.nextRow()
		self.profileGraph  = layout_s.addPlot(title="Fit to YAG Profile")
		self.displayMom_S = layout_s.addLabel('Momentum Spread =  MeV/c')
		self.view.horizontalLayout_5.addWidget(monitor_s)

		'''Create logs for each procedure (and combined on log Tab)'''
		self.FullLog = lw.loggerWidget([self.model.PL,self.model.PSL,self.model.deets])
		self.FullLog.setLogColours(debugcolour='blue',infocolour='green',warningcolour='orange',errorcolour='red',criticalcolour='purple')
		self.pLog = lw.loggerWidget(self.model.PL)
		self.pLog.setColumnWidths(155,40,80)
		self.pLog.setLogColours(debugcolour='blue',infocolour='green',warningcolour='orange',errorcolour='red',criticalcolour='purple')
		self.psLog = lw.loggerWidget(self.model.PSL)
		self.psLog.setColumnWidths(155,40,80)
		self.psLog.setLogColours(debugcolour='blue',infocolour='green',warningcolour='orange',errorcolour='red',criticalcolour='purple')
		self.view.gridLayout_3.addWidget(self.FullLog)
		self.view.gridLayout_2.addWidget(self.psLog , 9,0,1,2)
		self.view.gridLayout.addWidget(self.pLog , 8,0,1,2)


		'''Threads for updating graphs and labels'''
		self.timer = QtCore.QTimer()
		self.timer.timeout.connect(self.updateDisplays)
		self.timer.start(500)

		'''Connections to GUI Buttons'''
		self.view.pushButton.clicked.connect(self.model.measureMomentum)
		self.view.pushButton_s.clicked.connect(self.model.measureMomentumSpread)
		self.view.checkBox_all.stateChanged.connect(self.setChecks_mom)
		self.view.checkBox_all_s.stateChanged.connect(self.setChecks_mom_s)
		self.view.pushButton_refreshImage.clicked.connect(self.refreshImage)
Exemplo n.º 7
0
    def __init__(self, parent = None):
        super(striptool_Demo_Magnets, self).__init__(parent)

        self.setWindowTitle("striptool_Demo_Magnets")
        self.statusBar = QStatusBar()
        self.setStatusBar(self.statusBar)

        ''' Initiate logger (requires loggerWidget - comment out if not available)'''
        self.logwidget1 = lw.loggerWidget([logger,striptool.logger])

        ''' These are some options for pyqtgraph that make the graph black-on-white, and turn on antialiasing, which is nicer on the eye '''
        pg.setConfigOptions(antialias=True)
        pg.setConfigOption('background', 'w')
        pg.setConfigOption('foreground', 'k')

        ''' initialise an instance of the stripPlot Widget '''
        self.sp = striptool.stripPlot(plotRateBar=False)

        ''' Here we create a tab layout widget, and put the 3 stripplots into a grid layout in one of the tabs
            In the second tab we put the first stripplot. NB: the stripplot "sp" can only exist in one place at a time!
            Comment out line 83 to see the difference. '''
        self.tab = QTabWidget()
        self.GUISplitter = QtGui.QSplitter()
        self.GUISplitter.setHandleWidth(14)
        self.GUISplitter.setOrientation(Qt.Vertical)
        self.GUISplitter.setStyleSheet("QSplitter::handle{background-color:transparent;}");
        self.GUISplitter.addWidget(stable.signalTable(self.sp))
        self.GUISplitter.addWidget(self.sp)
        handle = self.GUISplitter.handle(1)
        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        self.splitterbutton = QtGui.QToolButton(handle)
        self.splitterbutton.setArrowType(QtCore.Qt.DownArrow)
        self.splitterbutton.clicked.connect(
            lambda: self.handleSplitterButton(False))
        self.GUISplitter.splitterMoved.connect(self.handleSplitterButtonArrow)
        layout.addWidget(self.splitterbutton)
        handle.setLayout(layout)
        self.GUISplitter.setStretchFactor(0,1)
        self.GUISplitter.setStretchFactor(1,4)
        self.handleSplitterButton(up=True)


        self.tab.addTab(self.GUISplitter,"Strip Plot")
        ''' Here we connect the QTabWidget signal "currentChanged" to a function defined above. This will pause plots not currently visible
            whenever the tabs are changed. This reduces the load as only visible plots are updated. '''
        self.tab.currentChanged.connect(lambda x: self.pausePlots(self.tab))

        ''' Add loggerWidget Tab (requires loggerWidget - comment out if not available)'''
        self.tab.addTab(self.logwidget1,"Log")

        ''' This starts the plotting timer (by default at 1 Hz) '''
        self.sp.start()

        ''' modify the plot scale to 10 secs '''
        self.sp.setPlotScale(60)

        ''' Display the Qt App '''
        self.setCentralWidget(self.tab)

        self.sp.plotWidget.statusChanged.connect(self.updateStatusBar)
Exemplo n.º 8
0
 def __init__(self, sys_argv):
     #App is launched here based on inputs from the Master app. Cumbersome, I know...
     super(attCalApp, self).__init__(sys_argv)
     self.bpm = vbpmc.init()
     self.scope = vcsc.init()
     self.logger = logging.getLogger(__name__)
     if sys_argv[1] == "VELA_INJ":
         self.contType = "VELA_INJ"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_VELA_INJ_BPM_Controller()
             self.scopeCont = self.scope.virtual_VELA_INJ_Scope_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_VELA_INJ_BPM_Controller()
             self.scopeCont = self.scope.offline_VELA_INJ_Scope_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_VELA_INJ_BPM_Controller()
             self.scopeCont = self.scope.physical_VELA_INJ_Scope_Controller()
     elif sys_argv[1] == "VELA_BA1":
         self.contType = "VELA_BA1"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_VELA_BA1_BPM_Controller()
             self.scopeCont = self.scope.virtual_VELA_INJ_Scope_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_VELA_BA1_BPM_Controller()
             self.scopeCont = self.scope.offline_VELA_INJ_Scope_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_VELA_BA1_BPM_Controller()
             self.scopeCont = self.scope.physical_VELA_INJ_Scope_Controller()
     elif sys_argv[1] == "VELA_BA2":
         self.contType = "VELA_BA2"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_VELA_BA2_BPM_Controller()
             self.scopeCont = self.scope.virtual_VELA_INJ_Scope_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_VELA_BA2_BPM_Controller()
             self.scopeCont = self.scope.offline_VELA_INJ_Scope_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_VELA_BA2_BPM_Controller()
             self.scopeCont = self.scope.physical_VELA_INJ_Scope_Controller()
     elif sys_argv[1] == "CLARA_INJ":
         self.contType = "CLARA_INJ"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_CLARA_INJ_BPM_Controller()
             self.scopeCont = self.scope.virtual_CLARA_INJ_Scope_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_CLARA_INJ_BPM_Controller()
             self.scopeCont = self.scope.offline_CLARA_INJ_Scope_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_CLARA_INJ_BPM_Controller()
             self.scopeCont = self.scope.physical_CLARA_INJ_Scope_Controller()
     elif sys_argv[1] == "CLARA_2_VELA":
         self.contType = "CLARA_2_VELA"
         if sys_argv[2] == "Virtual":
             self.bpmCont = self.bpm.virtual_CLARA_2_VELA_BPM_Controller()
             self.scopeCont = self.scope.virtual_CLARA_INJ_Scope_Controller()
         elif sys_argv[2] == "Offline":
             self.bpmCont = self.bpm.offline_CLARA_2_VELA_BPM_Controller()
             self.scopeCont = self.scope.offline_CLARA_INJ_Scope_Controller()
         elif sys_argv[2] == "Physical":
             self.bpmCont = self.bpm.physical_CLARA_2_VELA_BPM_Controller()
             self.scopeCont = self.scope.physical_CLARA_INJ_Scope_Controller()
     else:
         self.bpmCont = self.bpm.virtual_VELA_INJ_BPM_Controller()
         self.scopeCont = self.scope.virtual_VELA_INJ_Scope_Controller()
     self.view = attCalmainView.attCalUi_TabWidget()
     self.MainWindow = QtGui.QTabWidget()
     self.view.setupUi(self.MainWindow, self.bpmCont, sys_argv[1], sys_argv[2])
     self.model = attCalmainModel.attCalModel(self.bpmCont, self.scopeCont)
     self.controller = attCalmainController.attCalController(self.view, self.model, self.bpmCont, self.scopeCont)
     self.logwidget1 = lw.loggerWidget([self.logger, attCalmainController.logger])
     self.MainWindow.addTab(self.logwidget1,"Log")
     self.MainWindow.show()