예제 #1
0
    def Update(self):
        text = ""
        for message in AppGlobals.ProgramRunner().GetMessages():
            text += message.text + "\n"
        if self._console.text() != text:
            self._console.setText(text)

        for runningProgramListItem in self.runningProgramListItems.copy():
            if not AppGlobals.ProgramRunner().IsRunning(
                    runningProgramListItem.instance):
                self.runningProgramListItems.remove(runningProgramListItem)
                runningProgramListItem.deleteLater()
        for runningProgram in AppGlobals.ProgramRunner().runningPrograms:
            item = self.FindItem(runningProgram)
            if not item:
                parent = AppGlobals.ProgramRunner(
                ).runningPrograms[runningProgram].parentProgram
                parentListItem = None
                if parent:
                    parentListItem = self.FindItem(parent)
                    if not parentListItem:
                        # Add it later, once the parent item has been added
                        continue
                newItem = RunningProgramItem(runningProgram)
                newItem.onStopClicked.connect(
                    lambda instance: AppGlobals.ProgramRunner().Stop(instance))
                self.runningProgramListItems.append(newItem)
                if parentListItem:
                    parentListItem.runningChildrenListLayout.addWidget(newItem)
                else:
                    self.runningProgramsListLayout.addWidget(newItem)
예제 #2
0
파일: MainWindow.py 프로젝트: jono-m/uChip
 def CheckForKill(self):
     if AppGlobals.ProgramRunner().GetTickDelta() > 2:
         self.updateWorker.terminate()
         self.updateWorker.wait()
         AppGlobals.ProgramRunner().StopAll()
         self.updateWorker.start()
         QMessageBox.critical(self, "Timeout", "Program timed out.")
예제 #3
0
파일: MainWindow.py 프로젝트: jono-m/uChip
    def CloseChip(self) -> bool:
        if AppGlobals.ProgramRunner().runningPrograms:
            status = QMessageBox.question(
                self, "Confirm",
                "There is a program running. Are you sure you want to stop?")
            if status is not QMessageBox.Yes:
                return False
            AppGlobals.ProgramRunner().StopAll()

        if self._editorWindow.isVisible():
            if not self._editorWindow.RequestCloseAll():
                return False

        if AppGlobals.Chip().modified:
            ret = QMessageBox.warning(
                self, "Confirm",
                "The current chip project has been modified.\nDo you want to save changes?",
                QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel,
                QMessageBox.Save)
            if ret is QMessageBox.Save:
                if not self.SaveChip():
                    return False
            elif ret is QMessageBox.Cancel:
                return False

        return True
예제 #4
0
    def UpdateInstanceView(self):
        self._programNameWidget.setText(self.programInstance.program.name)
        if self.uniqueRun:
            self.runButton.setVisible(
                not AppGlobals.ProgramRunner().IsRunning(self.programInstance))
            self._stopButton.setVisible(AppGlobals.ProgramRunner().IsRunning(
                self.programInstance))
        else:
            self.runButton.setVisible(True)
            self._stopButton.setVisible(False)

        for item in self.parameterItems:
            item.UpdateFields()
예제 #5
0
    def __init__(self):
        super().__init__()

        self.runningProgramsListLayout = QVBoxLayout()

        self._console = QLabel()

        self.runningProgramListItems: List[RunningProgramItem] = []

        layout = QVBoxLayout()
        layout.addLayout(self.runningProgramsListLayout)
        clearButton = QPushButton("Clear")
        clearButton.clicked.connect(
            lambda: AppGlobals.ProgramRunner().ClearMessages())
        layout.addWidget(clearButton)
        layout.addWidget(self._console)
        self.setLayout(layout)

        timer = QTimer(self)
        timer.timeout.connect(self.Update)
        timer.start(30)
예제 #6
0
 def run(self) -> None:
     self._isRunning = True
     while self._isRunning:
         AppGlobals.ProgramRunner().Tick()
         self.msleep(10)
예제 #7
0
 def StopProgram(self):
     AppGlobals.ProgramRunner().Stop(self.programInstance)
예제 #8
0
 def RunProgram(self):
     if self.uniqueRun:
         AppGlobals.ProgramRunner().Run(self.programInstance, None)
     else:
         AppGlobals.ProgramRunner().Run(self.programInstance.Clone(), None)
예제 #9
0
 def RunPreset(self):
     AppGlobals.ProgramRunner().Run(self._preset.instance)