def __init__(self, parent=None,**kwargs): super(AppWindow, self).__init__(parent) self.setupUi(self) self.setTheme("default") #self.setTheme("material2") self.statusBar = self.statusBar() self.splash = kwargs.get('splash',None) global app self.fileBrowser = fileBrowser(thumbnail_directory = 'MCA_thumbnails',app=app, clickCallback = self.loadPlot,recordToHistory = self.recordToHistory, loadList = self.loadList) self.saveLayout.addWidget(self.fileBrowser) #Calibration Menu & storage self.calibrationEnabled = False self.calPoly = np.poly1d([1,0]) self.calPolyInv = np.poly1d([1,0]) self.calibrationMenu = QtWidgets.QMenu() self.y=[]; self.y2=[]; self.spectrumTime = time.time() self.offlineData = True self._browserPath = '.' self.saved={} self.thumbList={} self.markers=[] # PLOT creation self.createMainPlot() #self.createMainPlot('w','k') #Region Widget #self.regionLayout.setAlignment(QtCore.Qt.AlignTop) self.regionWindow = regionPopup.AppWindow(self,insertRegion=self.insertRegion,getData = self.getData,hltime = self.halflifeTime,changeDirectory = self.changeDirectory,enablePeriodicSpectrumSaving = self.enablePeriodicSpectrumSaving ) self.regionWindow.widgetLayout.setAlignment(QtCore.Qt.AlignTop) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.regionWindow) #self.regionWindow.setFloating(True) self.regionWindow.close() #Spectrum History Widget self.historyWindow = historyPopup.AppWindow(self,regions = self.regionWindow.regions) self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self.historyWindow) self.historyWindow.setFloating(True) #self.historyWindow.close() #Define some keyboard shortcuts for ease of use self.shortcutActions={} self.shortcuts={"+":self.summation,"s":self.start,"f":self.fit,"u":self.load,"r":self.insertRegion,"g":self.fitWithTail,"t":self.fitWithTail,"h":self.historyWindow.show,"Ctrl+S":self.save,"o":self.selectDevice} for a in self.shortcuts: shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(a), self) shortcut.activated.connect(self.shortcuts[a]) self.shortcutActions[a] = shortcut # exporter self.exporter = PQG_ImageExporter(self.plot.plotItem)# pg.exporters.ImageExporter(self.plot.plotItem) #Auto-Update Menu self.autoUpdateMenu = QtGui.QMenu() #self.autoUpdateMenu.addAction("Interval",self.setAutoUpdateTime) self.autoUpdateTimerAction = QtWidgets.QWidgetAction(self.autoUpdateMenu) self.autoUpdateTimerInterval = QtWidgets.QSpinBox() self.autoUpdateTimerInterval.setMinimum(5);self.autoUpdateTimerInterval.setMaximum(3600);self.autoUpdateTimerInterval.setValue(constants.AUTOUPDATE_INTERVAL); self.autoUpdateTimerInterval.setSuffix(' S'); self.autoUpdateTimerInterval.valueChanged['int'].connect(self.setAutoUpdateInterval) self.autoUpdateTimerAction.setDefaultWidget(self.autoUpdateTimerInterval) self.autoUpdateMenu.addAction(self.autoUpdateTimerAction) self.autoUpdateSettings.setMenu(self.autoUpdateMenu) self.calibWindow = calPopup.AppWindow(self,application=self.setCalibration) self.splash.showMessage("<h2><font color='Black'>Connecting...</font></h2>", QtCore.Qt.AlignLeft, QtCore.Qt.black) self.splash.pbar.setValue(7) self.initializeCommunications() self.pending = { 'status':myTimer(constants.STATUS_UPDATE_INTERVAL), 'update':myTimer(constants.AUTOUPDATE_INTERVAL), 'current':myTimer(constants.CURRENT_UPDATE_INTERVAL), 'temperature':myTimer(constants.TEMPERATURE_UPDATE_INTERVAL), 'halflife':myTimer(self.regionWindow.decayInterval.value()), 'datadump':myTimer(self.regionWindow.saveAllInterval.value()*60) #convert minutes to seconds } self.temperature = decayTools.temperatureHandler() self.startTime = time.time() self.timer = QtCore.QTimer() self.timer.timeout.connect(self.updateEverything) self.timer.start(200) #Auto-Detector self.shortlist=MCALib.getFreePorts(None) self.deviceSelector.setList(self.shortlist,self.p) #self.loadPlot('DATA/212Bi.csv') #self.showGammaMarkers('137Cs') #self.loadPlot('DATA/eu152.dat') #self.loadList('DATA/list_sample.csv') self.splash.showMessage("<h2><font color='Black'>Ready!</font></h2>", QtCore.Qt.AlignLeft, QtCore.Qt.black) self.splash.pbar.setValue(8)
def __init__(self, parent=None, **kwargs): super(AppWindow, self).__init__(parent) self.setupUi(self) self.VERSION = REGISTERS.VERSIONNUM self.SPECIALS = REGISTERS.SPECIALS self.REGISTERS = REGISTERS.REGISTERS self.EXAMPLES_DIR = REGISTERS.EXAMPLES self.ADC_PINS = REGISTERS.ADC self.docks = [self.leftdock, self.rightdock] self.sensorList = [] self.controllerList = [] self.monitoring = True self.logRegisters = True self.userHexRunning = False self.uploadingHex = False self.autoUpdateUserRegisters = False self.CFile = None #'~/kuttyPy.c' self.ipy = None self.setTheme("material") examples = [ a for a in os.listdir( os.path.join(path["examples"], self.EXAMPLES_DIR)) if ('.py' in a) and a is not 'kuttyPy.py' ] #.py files except the library self.exampleList.addItems(examples) blinkindex = self.exampleList.findText('blink.py') if blinkindex != -1: #default example. blink.py present in examples directory self.exampleList.setCurrentIndex(blinkindex) ######## PYTHON CODE self.codeThread = QtCore.QThread() self.codeEval = self.codeObject(self.REGISTERS) self.codeEval.moveToThread(self.codeThread) self.codeEval.finished.connect(self.codeThread.quit) self.codeEval.logThis.connect( self.appendLog) #Connect to the log window self.logThis.connect(self.appendLog) #Connect to the log window self.logThisPlain.connect( self.appendLogPlain) #Connect to the log window self.serialGaugeSignal.connect(self.setSerialgauge) self.codeThread.started.connect(self.codeEval.execute) self.codeThread.finished.connect(self.codeFinished) ######### C CODE UPLOADER self.uploadThread = QtCore.QThread() self.UploadObject = self.uploadObject() self.UploadObject.moveToThread(self.uploadThread) self.UploadObject.finished.connect(self.uploadThread.quit) self.UploadObject.logThis.connect( self.appendLog) #Connect to the log window self.UploadObject.logThisPlain.connect( self.appendLogPlain) #Connect to the log window. add plain text self.logThis.connect(self.appendLog) #Connect to the log window self.uploadThread.started.connect(self.UploadObject.execute) self.uploadThread.finished.connect(self.codeFinished) self.commandQ = [] self.btns = {} self.registers = [] self.addPins() self.statusBar = self.statusBar() self.makeBottomMenu() global app self.initializeCommunications() self.pending = { 'status': myTimer(constants.STATUS_UPDATE_INTERVAL), 'update': myTimer(constants.AUTOUPDATE_INTERVAL), } serialgaugeoptions = { 'name': 'Serial Monitor', 'init': print, 'read': None, 'fields': ['Value'], 'min': [0], 'max': [255] } self.serialGauge = dio.DIOSENSOR(self, serialgaugeoptions) self.startTime = time.time() self.timer = QtCore.QTimer() self.timer.timeout.connect(self.updateEverything) self.timer.start(20) #Auto-Detector self.shortlist = KuttyPyLibUno.getFreePorts()
def __init__(self, parent=None, **kwargs): super(AppWindow, self).__init__(parent) self.setupUi(self) self.VERSION = REGISTERS.VERSION_ATMEGA32 #This needs to be dynamically changed when hardware is connected self.SPECIALS = REGISTERS.VERSIONS[self.VERSION]['SPECIALS'] self.REGISTERS = REGISTERS.VERSIONS[self.VERSION]['REGISTERS'] self.EXAMPLES_DIR = REGISTERS.VERSIONS[ self.VERSION]['examples directory'] self.docks = [self.padock, self.pbdock, self.pcdock, self.pddock] self.sensorList = [] self.controllerList = [] self.monitoring = True self.logRegisters = True self.userHexRunning = False self.uploadingHex = False self.autoUpdateUserRegisters = False self.CFile = None #'~/kuttyPy.c' self.ipy = None self.setTheme("material") examples = [ a for a in os.listdir( os.path.join(path["examples"], self.EXAMPLES_DIR)) if ('.py' in a) and a is not 'kuttyPy.py' ] #.py files except the library self.exampleList.addItems(examples) blinkindex = self.exampleList.findText('blink.py') if blinkindex != -1: #default example. blink.py present in examples directory self.exampleList.setCurrentIndex(blinkindex) #Define some keyboard shortcuts for ease of use self.shortcutActions = {} self.shortcuts = { "f": partial(self.setLanguage, 'fr_FR'), "e": partial(self.setLanguage, 'en_IN'), "m": partial(self.setLanguage, 'ml_IN') } for a in self.shortcuts: shortcut = QtWidgets.QShortcut(QtGui.QKeySequence(a), self) shortcut.activated.connect(self.shortcuts[a]) self.shortcutActions[a] = shortcut ######## PYTHON CODE self.codeThread = QtCore.QThread() self.codeEval = self.codeObject(self.REGISTERS) self.codeEval.moveToThread(self.codeThread) self.codeEval.finished.connect(self.codeThread.quit) self.codeEval.logThis.connect( self.appendLog) #Connect to the log window self.logThis.connect(self.appendLog) #Connect to the log window self.logThisPlain.connect( self.appendLogPlain) #Connect to the log window self.serialGaugeSignal.connect(self.setSerialgauge) self.codeThread.started.connect(self.codeEval.execute) self.codeThread.finished.connect(self.codeFinished) ######### C CODE UPLOADER self.uploadThread = QtCore.QThread() self.UploadObject = self.uploadObject() self.UploadObject.moveToThread(self.uploadThread) self.UploadObject.finished.connect(self.uploadThread.quit) self.UploadObject.logThis.connect( self.appendLog) #Connect to the log window self.UploadObject.logThisPlain.connect( self.appendLogPlain) #Connect to the log window. add plain text self.logThis.connect(self.appendLog) #Connect to the log window self.uploadThread.started.connect(self.UploadObject.execute) self.uploadThread.finished.connect(self.codeFinished) self.commandQ = [] self.btns = {} self.registers = [] self.addPins() self.statusBar = self.statusBar() self.makeBottomMenu() global app self.initializeCommunications() self.pending = { 'status': myTimer(constants.STATUS_UPDATE_INTERVAL), 'update': myTimer(constants.AUTOUPDATE_INTERVAL), } serialgaugeoptions = { 'name': 'Serial Monitor', 'init': print, 'read': None, 'fields': ['Value'], 'min': [0], 'max': [1000], 'config': [{ 'name': 'Data Type', 'options': ['byte', 'ASCII'], 'function': self.configSerialGauge }] } self.serialGauge = dio.DIOSENSOR(self, serialgaugeoptions) self.startTime = time.time() self.timer = QtCore.QTimer() self.timer.timeout.connect(self.updateEverything) self.timer.start(20) #Auto-Detector self.shortlist = KuttyPyLib.getFreePorts()