fofbcontrol/seroutput.py

101 lines
3.2 KiB
Python

import os
from PyQt4 import QtGui, QtCore, uic
from labels import cm
base_dir = os.path.dirname(os.path.realpath(__file__))
class SERWindow(QtGui.QWidget):
def __init__(self, main_window, parent=None):
QtGui.QWidget.__init__(self, parent)
uic.loadUi("%s/ui/ser.ui" % base_dir, self)
self.main_window = main_window
self.units = self.main_window.units
self.addAttribute = lambda dev, attr: self.main_window.addAttribute(dev, attr)
self.list_layout = QtGui.QVBoxLayout()
self.ContentFrame.setLayout(self.list_layout)
self.liberas = {}
def addLibera(self, dev):
print "[ INFO]: SER: add Libera %s" % dev
libera = SERWidget(self.main_window, dev)
self.connect(self, QtCore.SIGNAL("update"), libera.update)
self.liberas[dev] = libera
self.list_layout.addWidget(libera)
def update(self, cache):
self.emit(QtCore.SIGNAL("update"), cache)
def showEvent(self, evt):
self.emit(QtCore.SIGNAL("show"))
evt.accept()
def hideEvent(self, evt):
self.emit(QtCore.SIGNAL("hide"))
evt.accept()
class SERWidget(QtGui.QWidget):
def __init__(self, main_window, device, parent=None):
QtGui.QWidget.__init__(self, parent)
uic.loadUi("%s/ui/serwidget.ui" % base_dir, self)
self.main_window = main_window
self.units = self.main_window.units
self.addAttribute = lambda dev, attr: self.main_window.addAttribute(dev, attr)
self.device = device
self.IDLabel.setText(device)
self.M1IDLabel.setModel(device, "GdxSERM1Id")
self.M1OffLabel.setModel(device, "GdxSERM1Output")
self.M1OffLabel.setColorMap(cm.SER_OFF)
self.M1ManualLabel.setModel(device, "GdxSERM1Output")
self.M1ManualLabel.setColorMap(cm.SER_MANUAL)
self.M1FOFBLabel.setModel(device, "GdxSERM1Output")
self.M1FOFBLabel.setColorMap(cm.SER_FOFB)
self.M1FOFBValueLabel.setModel(device, "GdxSERM1FOFB")
self.M2IDLabel.setModel(device, "GdxSERM2Id")
self.M2OffLabel.setModel(device, "GdxSERM2Output")
self.M2OffLabel.setColorMap(cm.SER_OFF)
self.M2ManualLabel.setModel(device, "GdxSERM2Output")
self.M2ManualLabel.setColorMap(cm.SER_MANUAL)
self.M2FOFBLabel.setModel(device, "GdxSERM2Output")
self.M2FOFBLabel.setColorMap(cm.SER_FOFB)
self.M2FOFBValueLabel.setModel(device, "GdxSERM2FOFB")
self.M3IDLabel.setModel(device, "GdxSERM3Id")
self.M3OffLabel.setModel(device, "GdxSERM3Output")
self.M3OffLabel.setColorMap(cm.SER_OFF)
self.M3ManualLabel.setModel(device, "GdxSERM3Output")
self.M3ManualLabel.setColorMap(cm.SER_MANUAL)
self.M3FOFBLabel.setModel(device, "GdxSERM3Output")
self.M3FOFBLabel.setColorMap(cm.SER_FOFB)
self.M3FOFBValueLabel.setModel(device, "GdxSERM3FOFB")
self.M4IDLabel.setModel(device, "GdxSERM4Id")
self.M4OffLabel.setModel(device, "GdxSERM4Output")
self.M4OffLabel.setColorMap(cm.SER_OFF)
self.M4ManualLabel.setModel(device, "GdxSERM4Output")
self.M4ManualLabel.setColorMap(cm.SER_MANUAL)
self.M4FOFBLabel.setModel(device, "GdxSERM4Output")
self.M4FOFBLabel.setColorMap(cm.SER_FOFB)
self.M4FOFBValueLabel.setModel(device, "GdxSERM4FOFB")
def update(self, cache):
self.emit(QtCore.SIGNAL("update"), cache)
# def showEvent(self, evt):
# self.emit(QtCore.SIGNAL("show"))
# evt.accept()
# def hideEvent(self, evt):
# self.emit(QtCore.SIGNAL("hide"))
# evt.accept()