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)
def __init__(self, preset: ProgramPreset): super().__init__() AppGlobals.Instance().onChipModified.connect(self.CheckForPreset) self._preset = preset self._presetNameField = QLineEdit(preset.name) self._presetNameField.textChanged.connect(self.UpdatePreset) self._presetNameLabel = QLabel() self._instanceWidget = ProgramInstanceWidget(preset.instance, True) layout = QVBoxLayout() layout.addWidget(self._presetNameField) layout.addWidget(self._presetNameLabel) layout.addWidget(self._instanceWidget) self.containerWidget.setLayout(layout) self.Update() self.CheckForPreset()
def __init__(self): super().__init__() self.viewer = ChipSceneViewer() actionsLayout = QHBoxLayout() self._actionsWidget = QWidget(self.viewer) self._actionsWidget.setLayout(actionsLayout) self._lockButton = QToolButton() self._lockButton.setText("Done") self._lockButton.clicked.connect(lambda: self.SetEditing(False)) self._editButton = QToolButton() self._editButton.setText("Edit") self._editButton.clicked.connect(lambda: self.SetEditing(True)) self._plusButton = QToolButton() self._plusButton.setText("+") self._plusButton.setPopupMode(QToolButton.InstantPopup) actionsLayout.addWidget(self._plusButton) actionsLayout.addWidget(self._lockButton) actionsLayout.addWidget(self._editButton) menu = QMenu(self._plusButton) menu.addAction("Valve").triggered.connect(self.AddValve) menu.addAction("Program Preset...").triggered.connect( self.SelectProgramPreset) menu.addAction("Image...").triggered.connect(self.BrowseForImage) self._plusButton.setMenu(menu) layout = QHBoxLayout() layout.addWidget(self.viewer) self.setLayout(layout) self._mode = Mode.VIEWING AppGlobals.Instance().onChipOpened.connect(self.LoadChip)
def UpdateParameterValue(self): lastValue = self._programInstance.parameterValues[self.parameter] if self.parameter.dataType is DataType.INTEGER: self._programInstance.parameterValues[ self.parameter] = self._valueField.value() elif self.parameter.dataType is DataType.FLOAT: self._programInstance.parameterValues[ self.parameter] = self._valueField.value() elif self.parameter.dataType is DataType.BOOLEAN: self._programInstance.parameterValues[ self.parameter] = self._valueField.currentData() elif self.parameter.dataType is DataType.STRING: self._programInstance.parameterValues[ self.parameter] = self._valueField.text() elif self.parameter.dataType is not DataType.OTHER: self._programInstance.parameterValues[ self.parameter] = self._valueField.currentData() self._programInstance.parameterVisibility[ self.parameter] = self.visibilityToggle.isChecked() if self._programInstance.parameterValues[self.parameter] != lastValue: AppGlobals.Instance().onChipModified.emit()
def CheckForPreset(self): if self._preset not in AppGlobals.Chip().programPresets: self.RemoveItem()
def StopProgram(self): AppGlobals.ProgramRunner().Stop(self.programInstance)
def RunProgram(self): if self.uniqueRun: AppGlobals.ProgramRunner().Run(self.programInstance, None) else: AppGlobals.ProgramRunner().Run(self.programInstance.Clone(), None)
def UpdateValveState(self): self._solenoidButton.setChecked(AppGlobals.Rig().GetSolenoidState( self._number))
def RunPreset(self): AppGlobals.ProgramRunner().Run(self._preset.instance)
def Toggle(self): AppGlobals.Rig().SetSolenoidState( self._valve.solenoidNumber, not AppGlobals.Rig().GetSolenoidState(self._valve.solenoidNumber), True)
def run(self) -> None: self._isRunning = True while self._isRunning: AppGlobals.ProgramRunner().Tick() self.msleep(10)
def Move(self, delta: QPointF): if delta != QPointF(): AppGlobals.Instance().onChipDataModified.emit() self._valve.position += delta self.GraphicsObject().setPos(self._valve.position)
def UpdateValve(self): self._valve.solenoidNumber = self.valveNumberDial.value() self._valve.name = self.valveNameField.text() AppGlobals.Instance().onChipDataModified.emit()
def CheckForValve(self): if self._valve not in AppGlobals.Chip().valves: self.RemoveItem()
def DeleteProgram(self, program: Program): if QMessageBox.question( self, "Confirm Deletion", "Are you sure you want to delete " + program.name + "?") is QMessageBox.Yes: AppGlobals.Chip().programs.remove(program) AppGlobals.Instance().onChipModified.emit()
def NewChip(self): if self.CloseChip(): AppGlobals.OpenChip(Chip())
def SaveProgram(self): self.program.script = self.codeEditor.Code() self.program.name = self._programNameField.text() self._parameterEditor.Save() self.modified = False AppGlobals.Instance().onChipModified.emit()
def RequestDelete(self): AppGlobals.Chip().valves.remove(self._valve) AppGlobals.Instance().onChipModified.emit()
def CheckForProgram(self): if self.program not in AppGlobals.Chip().programs: self.deleteLater()
def UpdatePreset(self): self._preset.name = self._presetNameField.text() AppGlobals.Instance().onChipDataModified.emit()
def TogglePolarity(self, button: 'SolenoidButton'): index = self._solenoidButtons.index(button) self.device.solenoidPolarities[ index] = not self.device.solenoidPolarities[index] AppGlobals.Rig().FlushStates() self.Update()
def AddValve(self): newValve = Valve() newValve.solenoidNumber = AppGlobals.Chip().NextSolenoidNumber() AppGlobals.Chip().valves.append(newValve) AppGlobals.Instance().onChipModified.emit() self.viewer.CenterItem(self.viewer.AddItem(ValveChipItem(newValve)))
def Rescan(self): AppGlobals.Rig().Rescan() self.UpdateList()
def RequestDelete(self): super().RequestDelete() AppGlobals.Chip().programPresets.remove(self._preset) AppGlobals.Instance().onChipModified.emit()