示例#1
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)
示例#2
0
    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()
示例#3
0
    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)
示例#4
0
    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()
示例#5
0
 def CheckForPreset(self):
     if self._preset not in AppGlobals.Chip().programPresets:
         self.RemoveItem()
示例#6
0
 def StopProgram(self):
     AppGlobals.ProgramRunner().Stop(self.programInstance)
示例#7
0
 def RunProgram(self):
     if self.uniqueRun:
         AppGlobals.ProgramRunner().Run(self.programInstance, None)
     else:
         AppGlobals.ProgramRunner().Run(self.programInstance.Clone(), None)
示例#8
0
文件: RigViewer.py 项目: jono-m/uChip
 def UpdateValveState(self):
     self._solenoidButton.setChecked(AppGlobals.Rig().GetSolenoidState(
         self._number))
示例#9
0
 def RunPreset(self):
     AppGlobals.ProgramRunner().Run(self._preset.instance)
示例#10
0
 def Toggle(self):
     AppGlobals.Rig().SetSolenoidState(
         self._valve.solenoidNumber,
         not AppGlobals.Rig().GetSolenoidState(self._valve.solenoidNumber),
         True)
示例#11
0
 def run(self) -> None:
     self._isRunning = True
     while self._isRunning:
         AppGlobals.ProgramRunner().Tick()
         self.msleep(10)
示例#12
0
 def Move(self, delta: QPointF):
     if delta != QPointF():
         AppGlobals.Instance().onChipDataModified.emit()
     self._valve.position += delta
     self.GraphicsObject().setPos(self._valve.position)
示例#13
0
 def UpdateValve(self):
     self._valve.solenoidNumber = self.valveNumberDial.value()
     self._valve.name = self.valveNameField.text()
     AppGlobals.Instance().onChipDataModified.emit()
示例#14
0
 def CheckForValve(self):
     if self._valve not in AppGlobals.Chip().valves:
         self.RemoveItem()
示例#15
0
 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()
示例#16
0
 def NewChip(self):
     if self.CloseChip():
         AppGlobals.OpenChip(Chip())
示例#17
0
 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()
示例#18
0
 def RequestDelete(self):
     AppGlobals.Chip().valves.remove(self._valve)
     AppGlobals.Instance().onChipModified.emit()
示例#19
0
 def CheckForProgram(self):
     if self.program not in AppGlobals.Chip().programs:
         self.deleteLater()
示例#20
0
 def UpdatePreset(self):
     self._preset.name = self._presetNameField.text()
     AppGlobals.Instance().onChipDataModified.emit()
示例#21
0
文件: RigViewer.py 项目: jono-m/uChip
 def TogglePolarity(self, button: 'SolenoidButton'):
     index = self._solenoidButtons.index(button)
     self.device.solenoidPolarities[
         index] = not self.device.solenoidPolarities[index]
     AppGlobals.Rig().FlushStates()
     self.Update()
示例#22
0
 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)))
示例#23
0
文件: RigViewer.py 项目: jono-m/uChip
 def Rescan(self):
     AppGlobals.Rig().Rescan()
     self.UpdateList()
示例#24
0
 def RequestDelete(self):
     super().RequestDelete()
     AppGlobals.Chip().programPresets.remove(self._preset)
     AppGlobals.Instance().onChipModified.emit()