Exemple #1
0
    def __init__(self, config, **kwargs):
        super().__init__(config=config, **kwargs)

        # not needed in this version but remember to use it when starting to handle threads
        # threading
        # self._threadlock = Mutex()

        self.threadpool = QtCore.QThreadPool()
    def __init__(self, app, path):
        super().__init__()
        self.app = app
        self.path_set = settings.Path(self, path)
        uic.loadUi(str(self.path['main'] / 'UI' / 'main_window.ui'),
                   self)  # ~0.4 sec
        self.splitter.moveSplitter(
            0, 1)  # moves splitter 0 as close to 1 as possible
        self.setWindowIcon(
            QtGui.QIcon(
                str(self.path['main'] / 'UI' / 'graphics' / 'main_icon.png')))

        # Start threadpools
        self.threadpool = QtCore.QThreadPool()
        self.threadpool.setMaxThreadCount(
            2
        )  # Sets thread count to 1 (1 for gui - this is implicit, 1 for calc)

        # Set selected tabs
        for tab_widget in [self.option_tab_widget, self.plot_tab_widget]:
            tab_widget.setCurrentIndex(0)

        # Set Clipboard
        self.clipboard = QApplication.clipboard()

        self.var = {'reactor': {'t_unit_conv': 1}}
        self.SIM = reactors.Simulation_Result()
        self.mech_loaded = False
        self.run_block = True
        self.convert_units = convert_units.Convert_Units(self)
        self.series = settings.series(self)

        self.sim_explorer = sim_explorer_widget.SIM_Explorer_Widgets(self)
        self.plot = plot(self)
        options_panel_widgets.Initialize(self)
        self.mech = mech_fcns.Chemical_Mechanism()

        # Setup save sim
        self.save_sim = save_widget.Save_Dialog(self)
        self.save_sim_button.clicked.connect(self.save_sim.execute)
        self.action_Save.triggered.connect(self.save_sim.execute)

        if shut_down['bool']:
            sys.exit()
        else:
            self.show()
            self.app.processEvents()  # allow everything to draw properly

        # Initialize Settings
        self.initialize_settings()  # ~ 4 sec

        # Setup help menu
        self.version = version
        help_menu.HelpMenu(self)
Exemple #3
0
    def __init__(self,
                 task_list_to_run,
                 error_callback=None,
                 ui_callback=None,
                 post_tasks_to_run=None):
        """
        :param task_list_to_run: a list of dicts that hold task information. The format is:
            {
                'func': this is the function to call - do not put parenthesis, ie do
                _create_asset_list_for_update_report, not _create_asset_list_for_update_report()
                'params': any parameters, pass as a list
                'finish signal': the pyqt signal to connect to for when a method finishes
                'error signal': the pyqt signal to connect to for when a method errors
                'thread task': True means put task in thread, False does not. Only thread non threaded methods. If
                               the method in 'func' creates threads, set this to False otherwise errors will occur.
                'desc': string description describing what this method does. shown in activity log.
            }
        :param post_tasks_to_run: optional task(s) to call when main task(s) finish. a list of dicts in format:
            {
                'func': this is the function(s) to call, pass as a list
                'params': any parameters, pass as a list
            }
        Note optionally you can later call the set_post_tasks method - useful if the post tasks depend on this windows
        creation
        :param error_callback: optional error callback/function for when errors occur
        :param ui_callback: optional ui callback to update a ui
        """
        # setup threading
        self._thread_pool = QtCore.QThreadPool()
        logger.info("Multi-threading with maximum %d threads" %
                    self._thread_pool.maxThreadCount())

        # this tells the next_step_in_task_list() method to not get any more tasks from the task list defined by
        # the class variable task_list
        self._stop_tasks = False
        # function to call if error occurs
        self._error_callback = error_callback
        # function to call to update a ui
        self._ui_callback = ui_callback

        # method vars for setup and updating
        self._task_list = task_list_to_run
        self._method_to_run = None
        self._method_params = None
        self._method_finish_signal = None
        self._method_error_signal = None

        # tasks to run after the main task list runs
        self._post_tasks = post_tasks_to_run
Exemple #4
0
    def __init__(self, backend='csv', gui=None):
        QtCore.QObject.__init__(self)

        # on NFS, QFileSystemWatcher does not work, create a timer to poll the
        # directory for files
        self.file_timer = QtCore.QTimer(self)
        self.file_timer.timeout.connect(self.check_dir)
        self.file_timer.start(1000)

        self.thread_pool = QtCore.QThreadPool()
        self.thread_pool.setMaxThreadCount(10)
        self.threads = {}
        self.backend = backend
        self.gui = gui
        self.reset()
        self.connections = 0
        self.paths = []
Exemple #5
0
    def __init__(self,
                 database=None,
                 ip_addr=None,
                 username=None,
                 password=None):
        """
        If no user name, password and ip provided, CGT must be open
        :param database: the CGT database to connect to
        :param ip_addr: optional ip address (no http://)
        :param username: optional username
        :param password:  optional password
        """

        self.thread_pool = QtCore.QThreadPool()
        self.thread_total = 0.0
        self.threads_done = 0.0
        self.thread_pool.setMaxThreadCount(3)

        if username == "":
            username = None
        if password == "":
            password = None

        # cgt connection member variables
        connection, database, error = self.login_cgt(ip_addr=ip_addr,
                                                     username=username,
                                                     password=password,
                                                     database=database)

        self.connection_error_msg = ""

        if error:
            self.connection = None
            self.database = None
            # save the message
            self.connection_error_msg = error
        else:
            self.connection = connection
            self.database = database
Exemple #6
0
    def batchProcess(self):
        combos = self.getBatchParams()
        if not combos:
            return

        path = self.batch_outputDir.text()
        if path is None or path == "":
            path = self.setBatchOutput()
            if not path:
                return

        _params = self.getparams()
        self.threadpool = QtCore.QThreadPool()
        for combo in combos:
            nbeam = combo[3][0]
            nbeam = int((nbeam - 1) / 2) + 1 if not isinstance(nbeam, str) else nbeam
            params = _params.copy()
            params.update(
                {
                    "wave": combo[0],
                    "NA_inner": combo[1],
                    "NA_outer": combo[2],
                    "n_beam": nbeam,
                    "spacing": combo[3][1],
                    "shift_x": combo[4],
                    "shift_y": combo[5],
                    "tilt": round(combo[6], 2),
                }
            )
            # for now, enforce "reasonable" cropping for single and 3-beam patterns
            if nbeam == 1:
                params["crop"] = 0.0291
            elif isinstance(params["spacing"], float) and params["spacing"] >= 6:
                params["crop"] = 0.06
            logger.debug("SLM batch params: {}".format(params))
            worker = PatternWriteThread(path, params)
            self.writeThreadpool.start(worker)
Exemple #7
0
    def __init__(self, parent=None):
        super(SLMdialog, self).__init__(parent)
        self.setupUi(self)
        self.setWindowTitle("LLSpy :: SLM Pattern Generator")
        self.autofill = False
        self.mode = "square"
        self.dithered = False
        self.writeThreadpool = QtCore.QThreadPool()

        # TODO: figure out why windows sucks at multithreading
        if sys.platform.startswith("win"):
            self.writeThreadpool.setMaxThreadCount(1)

        self.PatternPresetsCombo.addItems(self.PRESETS)

        self.fudgeSpin.valueChanged.connect(self.updateSpacing)
        self.wavelengthSpin.valueChanged.connect(self.updateSpacing)
        self.innerNASpin.valueChanged.connect(self.updateSpacing)
        self.autoSpacingCheckBox.toggled.connect(self.toggleAutoSpace)

        # self.slmBinaryLabel.setStyleSheet("background-color: rgb(111, 174, 255);")
        self.slmBinaryLabel = QtWidgets.QLabel(self)
        self.slmBinaryLabel.setBackgroundRole(QtGui.QPalette.Base)
        self.slmBinaryLabel.setSizePolicy(
            QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored
        )
        # self.slmBinaryLabel.setGeometry(QtCore.QRect(0, 0, 476, 150))
        self.slmBinaryLabel.setFixedWidth(476)
        self.slmBinaryLabel.setFixedHeight(150)
        # self.slmBinaryLabel.setScaledContents(True)

        self.sampleIntensityLabel = QtWidgets.QLabel(self)
        self.sampleIntensityLabel.setBackgroundRole(QtGui.QPalette.Base)
        self.sampleIntensityLabel.setSizePolicy(
            QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored
        )
        # self.sampleIntensityLabel.setGeometry(QtCore.QRect(0, 0, 476, 150))
        self.sampleIntensityLabel.setFixedWidth(476)
        self.sampleIntensityLabel.setFixedHeight(150)

        self.maskIntensityLabel = QtWidgets.QLabel(self)
        self.maskIntensityLabel.setBackgroundRole(QtGui.QPalette.Base)
        self.maskIntensityLabel.setSizePolicy(
            QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored
        )

        self.upperRightScroll.setBackgroundRole(QtGui.QPalette.Dark)
        self.lowerLeftScroll.setBackgroundRole(QtGui.QPalette.Dark)
        self.lowerRightScroll.setBackgroundRole(QtGui.QPalette.Dark)
        self.upperRightScroll.setWidget(self.maskIntensityLabel)
        self.lowerLeftScroll.setWidget(self.slmBinaryLabel)
        self.lowerRightScroll.setWidget(self.sampleIntensityLabel)

        font = QtGui.QFont()
        # font.setFamily("Helvetica")
        font.setBold(True)
        font.setWeight(60)

        self.lowerLeftTitle = QtWidgets.QLabel(self.lowerLeftScroll)
        self.lowerLeftTitle.setGeometry(QtCore.QRect(5, 5, 170, 16))
        self.lowerLeftTitle.setFont(font)
        self.lowerLeftTitle.setStyleSheet("color:#777;")
        self.lowerLeftTitle.setObjectName("lowerLeftTitle")
        self.lowerLeftTitle.setText("binary SLM mask")

        self.lowerRightTitle = QtWidgets.QLabel(self.lowerRightScroll)
        self.lowerRightTitle.setGeometry(QtCore.QRect(5, 5, 170, 16))
        self.lowerRightTitle.setFont(font)
        self.lowerRightTitle.setStyleSheet("color:#777;")
        self.lowerRightTitle.setObjectName("lowerRightTitle")
        self.lowerRightTitle.setText("Intensity At Sample")

        self.upperRightTitle = QtWidgets.QLabel(self.upperRightScroll)
        self.upperRightTitle.setGeometry(QtCore.QRect(5, 5, 170, 16))
        self.upperRightTitle.setFont(font)
        self.upperRightTitle.setStyleSheet("color:#777;")
        self.upperRightTitle.setObjectName("upperRightTitle")
        self.upperRightTitle.setText("Intensity After Mask")

        self.ditherButton = QtWidgets.QPushButton(self.lowerRightScroll)
        self.ditherButton.setCheckable(True)
        w = self.lowerRightScroll.width()
        self.ditherButton.setGeometry(QtCore.QRect(w - 64, 4, 60, 25))
        self.ditherButton.setStyleSheet("color:#000;")
        self.ditherButton.setText("Dither")
        self.ditherButton.setFlat(True)
        self.ditherButton.setAutoFillBackground(True)
        self.ditherButton.clicked.connect(self.setDitherState)

        self.previewPatternButton.clicked.connect(self.previewPattern)
        self.writeFileButton.clicked.connect(self.writeFile)
        self.batchProcessButton.clicked.connect(self.batchProcess)
        self.chooseBatchOutputDir.clicked.connect(self.setBatchOutput)

        self.PatternPresetsCombo.currentTextChanged.connect(self.updatePreset)
        self.SLMmodelCombo.currentTextChanged.connect(self.setSLM)
        self.SLMmodelCombo.clear()
        self.SLMmodelCombo.addItems(list(SLMs.keys()))
        self.setSLM("SXGA-3DM")
        self.PatternPresetsCombo.setCurrentText("Square Lattice, Fill Chip")

        lutnames = sorted([lut.title() for lut in QLuts.keys()])
        self.maskLUTCombo.addItems(lutnames)
        self.maskLUTCombo.setCurrentText("Inferno")
        self.maskLUTCombo.currentTextChanged.connect(self.plotMaskIntensity)
        self.sampleLUTCombo.addItems(lutnames)
        self.sampleLUTCombo.setCurrentText("Viridis")
        self.sampleLUTCombo.currentTextChanged.connect(self.plotSampleIntensity)

        rangeRX = QtCore.QRegExp(r"[\d.-]+:?([\d.-]+)?:?([\d.-]+)?")
        rangeValidator = QtGui.QRegExpValidator(rangeRX)
        self.batch_tilt.setValidator(rangeValidator)
        self.batch_xShift.setValidator(rangeValidator)
        self.batch_yShift.setValidator(rangeValidator)

        numCommaRX = QtCore.QRegExp(r"[\d,.]+")
        numCommaValidator = QtGui.QRegExpValidator(numCommaRX)
        self.batch_outerNA.setValidator(numCommaValidator)
        self.batch_innerNA.setValidator(numCommaValidator)
        numCommaRX = QtCore.QRegExp(r"[\d,]+")
        self.batch_wave.setValidator(QtGui.QRegExpValidator(numCommaRX))
Exemple #8
0
    def __init__(self, config, **kwargs):
        super().__init__(config=config, **kwargs)

        self.threadpool = QtCore.QThreadPool()
Exemple #9
0
    def __init__(self, config, **kwargs):
        super().__init__(config=config, **kwargs)
        # activate if necessary
        # self.threadlock = Mutex()

        self.threadpool = QtCore.QThreadPool()