def run(self):
        ProjectSelection.setProject(self.project)
        ProjectSelection.setDefaultProject(self.project)
        configureServerLogging(self.loggingQueue)
        
        self.commandReader = CommandReader(self.commandPipe)

        #The next three lines make it so that the icon in the Windows taskbar matches the icon set in Qt Designer
        import ctypes, sys
        myappid = 'TrappedIons.FPGAControlProgram' # arbitrary string
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
        
        app = QtWidgets.QApplication(["LoggingWindow"])
        logger = logging.getLogger("")
        self.commandReader.quitProcess.connect( app.quit )
        self.commandReader.start()
               
               
        with configshelve.configshelve( ProjectSelection.guiConfigFile("LoggingWindow") ) as config:
            with InstrumentLoggingUi(self.project, config) as ui:
                ui.setupUi(ui)
                ui.show()
                self.commandReader.saveConfig.connect( ui.saveConfig )
                sys.exit(app.exec_())
        
        self.dataQueue.put(FinishException())
        logger.info( "Pulser Hardware Server Process finished." )
        self.dataQueue.close()
        self.loggingQueue.put(None)
        self.loggingQueue.close()
        self.commandReader.quit()
예제 #2
0
def setProjectBaseDir(name,atStartup=False):
    with configshelve(os.path.basename(__main__.__file__)+"-project.db") as config:
        config['ProjectBaseDir'] = name
    if atStartup:
        global ProjectsBaseDir
        ProjectsBaseDir = name
        DataDirectory.DataDirectoryBase = name
예제 #3
0
    def run(self):
        ProjectSelection.setProject(self.project)
        ProjectSelection.setDefaultProject(self.project)
        configureServerLogging(self.loggingQueue)

        self.commandReader = CommandReader(self.commandPipe)

        #The next three lines make it so that the icon in the Windows taskbar matches the icon set in Qt Designer
        import ctypes, sys
        myappid = 'TrappedIons.FPGAControlProgram'  # arbitrary string
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)

        app = QtWidgets.QApplication(["LoggingWindow"])
        logger = logging.getLogger("")
        self.commandReader.quitProcess.connect(app.quit)
        self.commandReader.start()

        with configshelve.configshelve(
                ProjectSelection.guiConfigFile("LoggingWindow")) as config:
            with InstrumentLoggingUi(self.project, config) as ui:
                ui.setupUi(ui)
                ui.show()
                self.commandReader.saveConfig.connect(ui.saveConfig)
                sys.exit(app.exec_())

        self.dataQueue.put(FinishException())
        logger.info("Pulser Hardware Server Process finished.")
        self.dataQueue.close()
        self.loggingQueue.put(None)
        self.loggingQueue.close()
        self.commandReader.quit()
예제 #4
0
def setProjectBaseDir(name, atStartup=False):
    with configshelve(os.path.basename(__main__.__file__) +
                      "-project.db") as config:
        config['ProjectBaseDir'] = name
    if atStartup:
        global ProjectsBaseDir
        ProjectsBaseDir = name
        DataDirectory.DataDirectoryBase = name
예제 #5
0
 def testLoadSQLite(self):
     dbConnection = DatabaseConnectionSettings(user='******',
                                               password='******',
                                               database='unittests',
                                               host='localhost')
     with configshelve(dbConnection,
                       filename='ExperimentUi.config.db') as d:
         pass
예제 #6
0
def refreshCache():
    global DefaultProject
    global DatabaseConnectionLookup
    global DefaultProjectCached
    global LastProject
    if hasattr(__main__, '__file__'):
        with configshelve(os.path.basename(__main__.__file__)+"-project.db") as config:
            DefaultProject = config.get('DefaultProject')
            LastProject = config.get('LastProject')
            DatabaseConnectionLookup = config.get('DatabaseConnectionLookup', dict())
        DefaultProjectCached = True
예제 #7
0
def setDefaultProject(name, lastProject=None, databaseConnectionLookup=None):
    global DefaultProjectCached
    global DefaultProject
    DefaultProject = name
    if hasattr(__main__, '__file__'):
        with configshelve(os.path.basename(__main__.__file__)+"-project.db") as config:
            config['DefaultProject'] = name
            if databaseConnectionLookup:
                config['DatabaseConnectionLookup'] = databaseConnectionLookup
            if lastProject is not None:
                config['LastProject'] = lastProject
    DefaultProjectCached = True
예제 #8
0
def refreshCache():
    global DefaultProject
    global DatabaseConnectionLookup
    global DefaultProjectCached
    global LastProject
    if hasattr(__main__, '__file__'):
        with configshelve(os.path.basename(__main__.__file__) +
                          "-project.db") as config:
            DefaultProject = config.get('DefaultProject')
            LastProject = config.get('LastProject')
            DatabaseConnectionLookup = config.get('DatabaseConnectionLookup',
                                                  dict())
        DefaultProjectCached = True
예제 #9
0
def setDefaultProject(name, lastProject=None, databaseConnectionLookup=None):
    global DefaultProjectCached
    global DefaultProject
    DefaultProject = name
    if hasattr(__main__, '__file__'):
        with configshelve(os.path.basename(__main__.__file__) +
                          "-project.db") as config:
            config['DefaultProject'] = name
            if databaseConnectionLookup:
                config['DatabaseConnectionLookup'] = databaseConnectionLookup
            if lastProject is not None:
                config['LastProject'] = lastProject
    DefaultProjectCached = True
예제 #10
0
ProjectsBaseDir = os.path.expanduser("~public/Documents/experiments")
Project = None
DefaultProject = None
LastProject = None
DatabaseConnectionLookup = dict()
DatabaseConnection = None
DefaultProjectCached = False
SpecificConfigFile = None  # if nont none will be used instaed of the default


class ProjectException(Exception):
    pass


if hasattr(__main__, '__file__'):
    with configshelve(os.path.basename(__main__.__file__) +
                      "-project.db") as config:
        DefaultProject = config.get('DefaultProject')
        LastProject = config.get('LastProject')
        ProjectsBaseDir = config.get('ProjectBaseDir', ProjectsBaseDir)
        DataDirectory.DataDirectoryBase = ProjectsBaseDir
        DatabaseConnectionLookup = config.get('DatabaseConnectionLookup',
                                              dict())
    DefaultProjectCached = True


def checkProjectsDir():
    if not os.path.exists(ProjectsBaseDir):
        os.makedirs(ProjectsBaseDir)


def projects():
예제 #11
0
        try:
            if dockAreaState: self.area.restoreState(dockAreaState)
        except Exception as e:
            print(e)

    def saveConfig(self):
        self.config[self.configname + ".guiState"] = saveGuiState(self)
        self.config[self.configname + '.state'] = self.saveState()
        self.config[self.configname + '.pos'] = self.pos()
        self.config[self.configname + '.size'] = self.size()
        self.config[self.configname + '.isMaximized'] = self.isMaximized()
        self.config[self.configname + '.dockAreaState'] = self.area.saveState()
        self.awgUi.saveConfig()

    def closeEvent(self, e):
        self.saveConfig()

    def onMeasureWaveform(self):
        pass

    def onOptimize(self):
        pass


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    project = Project()
    with configshelve.configshelve(project.guiConfigFile) as config:
        ui = AWGOptimizer(DummyAWG, config)
        ui.show()
        sys.exit(app.exec_())
예제 #12
0
        self.traceControl.saveConfig()


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    project = Project(
    )  #loads in the project through the config files/config GUIs
    logger = logging.getLogger("")
    setID(
        'TrappedIons.DigitalLockUi'
    )  #Makes the icon in the Windows taskbar match the icon set in Qt Designer

    overrideConfigFile = project.projectConfig.get('configurationFile')
    overrideFileType = {
        '.yml': 'yaml',
        '.yaml': 'yaml',
        '.db': 'sqlite'
    }.get(os.path.splitext(overrideConfigFile)[1],
          'sqlite') if overrideConfigFile else None
    loadFromDate = project.projectConfig.get('configurationFile')
    with configshelve.configshelve(project.dbConnection,
                                   loadFromDate=project.projectConfig.get(
                                       'loadFromDateTime', None),
                                   filename=overrideConfigFile,
                                   filetype=overrideFileType) as config:
        with DigitalLockUi(config, project) as ui:
            ui.setupUi(ui)
            LoggingSetup.qtHandler.textWritten.connect(ui.onMessageWrite)
            ui.show()
            sys.exit(app.exec_())
예제 #13
0
        self.config['Settings.deviceSerial'] = self.settings.deviceSerial
        self.config['Settings.deviceDescription'] = self.settings.deviceDescription
        self.config['MainWindow.pos'] = self.pos()
        self.config['MainWindow.size'] = self.size()
        self.config['Settings.loggingLevel'] = self.loggingLevel
        self.config['Settings.consoleMaximumLines'] = self.consoleMaximumLines
        self.config['PlotNames'] = list(self.plotDict.keys())
        self.config['pyqtgraph-dockareastate'] = self.area.saveState()
        self.settingsDialog.saveConfig()
        self.loggerUi.saveConfig()
        self.lockControl.saveConfig()
        self.lockStatus.saveConfig()
        self.traceControl.saveConfig()

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    project = Project() #loads in the project through the config files/config GUIs
    logger = logging.getLogger("")
    setID('TrappedIons.DigitalLockUi') #Makes the icon in the Windows taskbar match the icon set in Qt Designer

    overrideConfigFile = project.projectConfig.get('configurationFile')
    overrideFileType = {'.yml': 'yaml', '.yaml': 'yaml', '.db': 'sqlite'}.get(os.path.splitext(overrideConfigFile)[1], 'sqlite') if overrideConfigFile else None
    loadFromDate = project.projectConfig.get('configurationFile')
    with configshelve.configshelve(project.dbConnection, loadFromDate=project.projectConfig.get('loadFromDateTime', None),
                                   filename=overrideConfigFile, filetype=overrideFileType) as config:
        with DigitalLockUi(config, project) as ui:
            ui.setupUi(ui)
            LoggingSetup.qtHandler.textWritten.connect(ui.onMessageWrite)
            ui.show()
            sys.exit(app.exec_())
예제 #14
0
        pass

    def closeEvent(self, e):
        self.onClose()

    def onShuttleSequence(self, cont=False):
        self.adjustUi.onShuttleEdge(0)


if __name__ == "__main__":

    class MyMainWindow(QtWidgets.QMainWindow):
        def setCentralWidget(self, widget):
            self.myCentralWidget = widget
            super(MyMainWindow, self).setCentralWidget(widget)

        def closeEvent(self, e):
            self.myCentralWidget.onClose()
            super(MyMainWindow, self).closeEvent(e)

    import sys
    from persist import configshelve
    with configshelve.configshelve("VoltageControl-test") as config:
        app = QtWidgets.QApplication(sys.argv)
        MainWindow = MyMainWindow()
        ui = VoltageControl(config)
        ui.setupUi(ui)
        MainWindow.setCentralWidget(ui)
        MainWindow.show()
        sys.exit(app.exec_())
예제 #15
0
        ]
        [self._varAsOutputChannelDict.pop(varname) for varname in deletions
         ]  #remove all values that aren't dependencies anymore
        return self._varAsOutputChannelDict

    def close(self):
        self.saveConfig()
        numTempAreas = len(self.area.tempAreas)
        for i in range(numTempAreas):
            if len(self.area.tempAreas) > 0:
                self.area.tempAreas[0].win.close()
        super(AWGUi, self).close()


if __name__ == '__main__':
    from AWG.AWGDevices import DummyAWG
    import sys
    from ProjectConfig.Project import Project
    from persist import configshelve
    from GlobalVariables.GlobalVariable import GlobalVariablesLookup
    app = QtWidgets.QApplication(sys.argv)
    project = Project()
    guiConfigFile = os.path.join(project.projectDir,
                                 '.gui-config/ExperimentUi.config.db')
    with configshelve.configshelve(guiConfigFile) as config:
        globalDict = GlobalVariablesLookup(
            config.get('GlobalVariables', dict()))
        ui = AWGUi(DummyAWG, config, globalDict)
        ui.setupUi(ui)
        ui.show()
        sys.exit(app.exec_())
예제 #16
0
        dockAreaState = self.config.get(self.configname+'.dockAreaState')
        try:
            if dockAreaState: self.area.restoreState(dockAreaState)
        except Exception as e:
            print(e)

    def saveConfig(self):
        self.config[self.configname+".guiState"] = saveGuiState(self)
        self.config[self.configname+'.state'] = self.saveState()
        self.config[self.configname+'.pos'] = self.pos()
        self.config[self.configname+'.size'] = self.size()
        self.config[self.configname+'.isMaximized'] = self.isMaximized()
        self.config[self.configname+'.dockAreaState'] = self.area.saveState()
        self.awgUi.saveConfig()

    def closeEvent(self, e):
        self.saveConfig()

    def onMeasureWaveform(self):
        pass

    def onOptimize(self):
        pass

if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    project = Project()
    with configshelve.configshelve(project.guiConfigFile) as config:
        ui = AWGOptimizer(DummyAWG, config)
        ui.show()
        sys.exit(app.exec_())
예제 #17
0
    def saveConfig(self):
        self.config[self.channelsConfigName] = self.dacChannels
        self.config[self.autoApplyConfigName] = self.autoApply
        self.config[self.guiStateConfigName] = saveGuiState(self)

    def onApply(self):
        if self.dacChannels:
            self.dac.setVoltage(0,
                                self.dacChannels[0].outputVoltage,
                                autoApply=True,
                                applyAll=True)

    def onReset(self):
        self.dac.reset(0xff)

    def onChange(self, index, name, value, string, origin):
        if self.isSetup and origin != 'value':
            self.dacTableModel.setVoltage(
                self.dacTableModel.createIndex(index, 2), value)


if __name__ == "__main__":
    import sys
    from persist import configshelve
    app = QtWidgets.QApplication(sys.argv)
    with configshelve.configshelve("test") as config:
        ui = DACUi(config, None)
        ui.setupUi(ui)
        ui.show()
        sys.exit(app.exec_())
예제 #18
0
                for channel, settings in enumerate(self.dacChannels):
                    if writeUnchecked or settings.resetAfterPP:
                        stream.setVoltage(channel, settings.outputVoltage, autoApply=self.autoApply, applyAll=True)

    def saveConfig(self):
        self.config[self.channelsConfigName] = self.dacChannels
        self.config[self.autoApplyConfigName] = self.autoApply
        self.config[self.guiStateConfigName] = saveGuiState( self )
        
    def onApply(self):
        if self.dacChannels:
            self.dac.setVoltage(0, self.dacChannels[0].outputVoltage, autoApply=True, applyAll=True )
        
    def onReset(self):
        self.dac.reset(0xff)
        
    def onChange(self, index, name, value, string, origin ):
        if self.isSetup and origin != 'value':
            self.dacTableModel.setVoltage(self.dacTableModel.createIndex(index, 2), value)

             
if __name__ == "__main__":
    import sys
    from persist import configshelve
    app = QtWidgets.QApplication(sys.argv)
    with configshelve.configshelve("test") as config:
        ui = DACUi(config, None)
        ui.setupUi(ui)
        ui.show()
        sys.exit(app.exec_())
예제 #19
0

ProjectsBaseDir = os.path.expanduser("~public/Documents/experiments")
Project = None
DefaultProject = None
LastProject = None
DatabaseConnectionLookup = dict()
DatabaseConnection = None
DefaultProjectCached = False
SpecificConfigFile = None    # if nont none will be used instaed of the default

class ProjectException(Exception):
    pass

if hasattr(__main__, '__file__'):
    with configshelve(os.path.basename(__main__.__file__)+"-project.db") as config:
        DefaultProject = config.get('DefaultProject')
        LastProject = config.get('LastProject')
        ProjectsBaseDir = config.get('ProjectBaseDir', ProjectsBaseDir)
        DataDirectory.DataDirectoryBase = ProjectsBaseDir
        DatabaseConnectionLookup = config.get('DatabaseConnectionLookup', dict())
    DefaultProjectCached = True


def checkProjectsDir():
    if not os.path.exists(ProjectsBaseDir):
        os.makedirs(ProjectsBaseDir)
    
def projects():
    checkProjectsDir()
    return [name for name in os.listdir(ProjectsBaseDir)
예제 #20
0
 def testLoadSQLite(self):
     dbConnection = DatabaseConnectionSettings(user='******', password='******', database='unittests', host='localhost')
     with configshelve(dbConnection, filename='ExperimentUi.config.db') as d:
         pass
예제 #21
0
        """dict of output channels, for use in scans"""
        for varname in self.settings.varDict:
            if varname not in self._varAsOutputChannelDict:
                self._varAsOutputChannelDict[varname] = VarAsOutputChannel(self, varname, self.globalDict)
        deletions = [varname for varname in self._varAsOutputChannelDict if varname not in self.settings.varDict]
        [self._varAsOutputChannelDict.pop(varname) for varname in deletions] #remove all values that aren't dependencies anymore
        return self._varAsOutputChannelDict

    def close(self):
        self.saveConfig()
        numTempAreas = len(self.area.tempAreas)
        for i in range(numTempAreas):
            if len(self.area.tempAreas) > 0:
                self.area.tempAreas[0].win.close()
        super(AWGUi, self).close()

if __name__ == '__main__':
    from AWG.AWGDevices import DummyAWG
    import sys
    from ProjectConfig.Project import Project
    from persist import configshelve
    from GlobalVariables.GlobalVariable import GlobalVariablesLookup
    app = QtWidgets.QApplication(sys.argv)
    project = Project()
    guiConfigFile = os.path.join(project.projectDir, '.gui-config/ExperimentUi.config.db')
    with configshelve.configshelve(guiConfigFile) as config:
        globalDict = GlobalVariablesLookup(config.get('GlobalVariables', dict()))
        ui = AWGUi(DummyAWG, config, globalDict)
        ui.setupUi(ui)
        ui.show()
        sys.exit(app.exec_())