def ToggleSolenoid(self, button: 'SolenoidButton'): index = self._solenoidButtons.index(button) AppGlobals.Rig().SetSolenoidState( self.device.startNumber + index, not AppGlobals.Rig().GetSolenoidState(self.device.startNumber + index)) AppGlobals.Rig().FlushStates() self.Update()
def closeEvent(self, event): if not self.CloseChip(): event.ignore() return self.updateWorker.terminate() AppGlobals.Rig().SaveDevices() super().closeEvent(event)
def UpdateList(self): for item in self._deviceItems: item.deleteLater() self._deviceItems = [] for device in AppGlobals.Rig().savedDevices: if device.IsDeviceAvailable() and \ device not in [deviceItem.device for deviceItem in self._deviceItems]: newItem = DeviceItem(device) newItem.numberChanged.connect(self.SortList) self._deviceItems.append(newItem) self._deviceLayout.addWidget(newItem) self.SortList()
def Update(self): text = self._valve.name + "\n(" + str(self._valve.solenoidNumber) + ")" if text != self.valveToggleButton.text(): self.valveToggleButton.setText(text) lastState = self.valveToggleButton.property("valveState") newState = { True: "OPEN", False: "CLOSED" }[AppGlobals.Rig().GetSolenoidState(self._valve.solenoidNumber)] if lastState != newState: self.valveToggleButton.setProperty("valveState", newState) self.valveToggleButton.setStyle(self.valveToggleButton.style())
def Rescan(self): AppGlobals.Rig().Rescan() self.UpdateList()
def UpdateValveState(self): self._solenoidButton.setChecked(AppGlobals.Rig().GetSolenoidState( self._number))
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 Toggle(self): AppGlobals.Rig().SetSolenoidState( self._valve.solenoidNumber, not AppGlobals.Rig().GetSolenoidState(self._valve.solenoidNumber), True)