def createUi(self): palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Foreground, QtGui.QColor(111, 88, 100)) layout = QtGui.QHBoxLayout() layout.setMargin(2) layout.addSpacing(5) lCurrentVelocity = QtGui.QLabel("<b>Current Value</b>") layout.addWidget(lCurrentVelocity) layout.addSpacing(5) self.currentVelocity = QtGui.QLCDNumber() self.currentVelocity.setMaximumHeight(25) self.currentVelocity.setPalette(palette) self.currentVelocity.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.currentVelocity) layout.addSpacing(30) lSetpoint = QtGui.QLabel("<b>Setpoint</b>") layout.addWidget(lSetpoint) layout.addSpacing(5) self.positionBar = PositionBar() self.positionBar.setMinimumWidth(200) self.positionBar.setMinimumHeight(15) self.positionBar.setMaximumHeight(30) self.positionBar.setValue(0) self.positionBar.setBarColor(QtGui.QColor(0,0,255)) self.positionBar.valueChanged.connect(self.positionBarValueChanged) layout.addWidget(self.positionBar) #layout.addSpacing(5) self.leServoPosition = QtGui.QLineEdit() self.leServoPosition.setMaximumWidth(50) layout.addWidget(self.leServoPosition) layout.addSpacing(30) self.bStartEngine = QtGui.QPushButton("Start") self.bStartEngine.clicked.connect(self.startEngine) layout.addWidget(self.bStartEngine) layout.addStretch() self.setLayout(layout)
class EngineControlWidget(QtGui.QWidget): def __init__(self, serial=None, engine_nr=Engines.EngineLeft): super(EngineControlWidget, self).__init__() self.serial_connection = serial self.engine_nr = engine_nr self.minValue = 0 self.maxValue = 100 self.createUi() def createUi(self): palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Foreground, QtGui.QColor(111, 88, 100)) layout = QtGui.QHBoxLayout() layout.setMargin(2) layout.addSpacing(5) lCurrentVelocity = QtGui.QLabel("<b>Current Value</b>") layout.addWidget(lCurrentVelocity) layout.addSpacing(5) self.currentVelocity = QtGui.QLCDNumber() self.currentVelocity.setMaximumHeight(25) self.currentVelocity.setPalette(palette) self.currentVelocity.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.currentVelocity) layout.addSpacing(30) lSetpoint = QtGui.QLabel("<b>Setpoint</b>") layout.addWidget(lSetpoint) layout.addSpacing(5) self.positionBar = PositionBar() self.positionBar.setMinimumWidth(200) self.positionBar.setMinimumHeight(15) self.positionBar.setMaximumHeight(30) self.positionBar.setValue(0) self.positionBar.setBarColor(QtGui.QColor(0,0,255)) self.positionBar.valueChanged.connect(self.positionBarValueChanged) layout.addWidget(self.positionBar) #layout.addSpacing(5) self.leServoPosition = QtGui.QLineEdit() self.leServoPosition.setMaximumWidth(50) layout.addWidget(self.leServoPosition) layout.addSpacing(30) self.bStartEngine = QtGui.QPushButton("Start") self.bStartEngine.clicked.connect(self.startEngine) layout.addWidget(self.bStartEngine) layout.addStretch() self.setLayout(layout) def startEngine(self): try: position = self.leServoPosition.displayText() except: return if not self.checkValue(float(position)): return self.positionBar.setValue(int(position)) self.actualPositionServo.display(position) print "Position: " + position #command = CommandMessage(CommandType.SETSERVOPOS) #command.addArgument(str(1)) #command.addArgument(str(position)) #self.serial_connection.writeCommand(command) def setMinValue(self, value): self.minValue = value def setMaxValue(self, value): self.maxValue = value def checkValue(self, value): if value < self.minValue or value > self.maxValue: return False else: return True def positionBarValueChanged(self, value): self.leServoPosition.setText(str(value))
def _createUI(self): mainLayout = QtGui.QVBoxLayout() #mainLayout.setMargin(0) #mainLayout.addSpacing(5) # Channel 1 lChannel1 = HeadingLabel() lChannel1.setText("Channel 1") mainLayout.addWidget(lChannel1) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel1 = PositionBar() self.posBarChannel1.setMinimumWidth(250) self.posBarChannel1.setMinimumHeight(30) self.posBarChannel1.setMaximumHeight(30) self.posBarChannel1.setValue(0) self.posBarChannel1.setMoveable(False) layout.addWidget(self.posBarChannel1) self.lcdChannel1Value = QtGui.QLCDNumber() self.lcdChannel1Value.setMaximumHeight(25) self.lcdChannel1Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel1Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 2 lChannel2 = HeadingLabel() lChannel2.setText("Channel 2") mainLayout.addWidget(lChannel2) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel2 = PositionBar() self.posBarChannel2.setMinimumWidth(250) self.posBarChannel2.setMinimumHeight(30) self.posBarChannel2.setMaximumHeight(30) self.posBarChannel2.setValue(0) self.posBarChannel2.setMoveable(False) layout.addWidget(self.posBarChannel2) self.lcdChannel2Value = QtGui.QLCDNumber() self.lcdChannel2Value.setMaximumHeight(25) self.lcdChannel2Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel2Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 3 lChannel3 = HeadingLabel() lChannel3.setText("Channel 3") mainLayout.addWidget(lChannel3) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel3 = PositionBar() self.posBarChannel3.setMinimumWidth(250) self.posBarChannel3.setMinimumHeight(30) self.posBarChannel3.setMaximumHeight(30) self.posBarChannel3.setValue(0) self.posBarChannel3.setMoveable(False) layout.addWidget(self.posBarChannel3) self.lcdChannel3Value = QtGui.QLCDNumber() self.lcdChannel3Value.setMaximumHeight(25) self.lcdChannel3Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel3Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 4 lChannel4 = HeadingLabel() lChannel4.setText("Channel 4") mainLayout.addWidget(lChannel4) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel4 = PositionBar() self.posBarChannel4.setMinimumWidth(250) self.posBarChannel4.setMinimumHeight(30) self.posBarChannel4.setMaximumHeight(30) self.posBarChannel4.setValue(0) self.posBarChannel4.setMoveable(False) layout.addWidget(self.posBarChannel4) self.lcdChannel4Value = QtGui.QLCDNumber() self.lcdChannel4Value.setMaximumHeight(25) self.lcdChannel4Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel4Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 5 lChannel5 = HeadingLabel() lChannel5.setText("Channel 5") mainLayout.addWidget(lChannel5) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel5 = PositionBar() self.posBarChannel5.setMinimumWidth(250) self.posBarChannel5.setMinimumHeight(30) self.posBarChannel5.setMaximumHeight(30) self.posBarChannel5.setValue(0) self.posBarChannel5.setMoveable(False) layout.addWidget(self.posBarChannel5) self.lcdChannel5Value = QtGui.QLCDNumber() self.lcdChannel5Value.setMaximumHeight(25) self.lcdChannel5Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel5Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 6 lChannel6 = HeadingLabel() lChannel6.setText("Channel 6") mainLayout.addWidget(lChannel6) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel6 = PositionBar() self.posBarChannel6.setMinimumWidth(250) self.posBarChannel6.setMinimumHeight(30) self.posBarChannel6.setMaximumHeight(30) self.posBarChannel6.setValue(0) self.posBarChannel6.setMoveable(False) layout.addWidget(self.posBarChannel6) self.lcdChannel6Value = QtGui.QLCDNumber() self.lcdChannel6Value.setMaximumHeight(25) self.lcdChannel6Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel6Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 7 lChannel7 = HeadingLabel() lChannel7.setText("Channel 7") mainLayout.addWidget(lChannel7) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel7 = PositionBar() self.posBarChannel7.setMinimumWidth(250) self.posBarChannel7.setMinimumHeight(30) self.posBarChannel7.setMaximumHeight(30) self.posBarChannel7.setValue(0) self.posBarChannel7.setMoveable(False) layout.addWidget(self.posBarChannel7) self.lcdChannel7Value = QtGui.QLCDNumber() self.lcdChannel7Value.setMaximumHeight(25) self.lcdChannel7Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel7Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addStretch() self.setLayout(mainLayout)
class ServoControlWidget(QtGui.QWidget): def __init__(self, controller=None, servo_nr=1): super(ServoControlWidget, self).__init__() if controller is None: raise Exception self.controller = controller self.servo_nr = servo_nr self.minValue = 0 self.maxValue = 180 self.createUi() def createUi(self): palette = QtGui.QPalette() palette.setColor(QtGui.QPalette.Foreground, QtGui.QColor(111, 88, 100)) layout = QtGui.QHBoxLayout() layout.setMargin(2) layout.addSpacing(5) lActualPosition = QtGui.QLabel("<b>Current Value</b>") layout.addWidget(lActualPosition) layout.addSpacing(5) self.actualPositionServo = QtGui.QLCDNumber() self.actualPositionServo.setMaximumHeight(25) self.actualPositionServo.setPalette(palette) self.actualPositionServo.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.actualPositionServo) layout.addSpacing(30) lMove1 = QtGui.QLabel("<b>Setpoint</b>") layout.addWidget(lMove1) layout.addSpacing(5) self.positionBar = PositionBar() self.positionBar.setMinimumWidth(200) self.positionBar.setMinimumHeight(15) self.positionBar.setMaximumHeight(30) self.positionBar.setValue(0) self.positionBar.setBarColor(QtGui.QColor(0,0,255)) self.positionBar.valueChanged.connect(self.positionBarValueChanged) layout.addWidget(self.positionBar) #layout.addSpacing(50) self.leServoPosition = QtGui.QLineEdit() self.leServoPosition.setMaximumWidth(50) layout.addWidget(self.leServoPosition) layout.addSpacing(30) self.startServo = QtGui.QPushButton("Move") self.startServo.clicked.connect(self.startServoClicked) layout.addWidget(self.startServo) layout.addStretch() self.setLayout(layout) def runMoveServo(self, position): if not self.checkValue(float(position)): return #command = SetServoPosCommand(self.servo_nr, position) #self.controller.writeCommand(command) self.controller.setServoPos(self.servo_nr, position) def setMinValue(self, value): self.minValue = value def setMaxValue(self, value): self.maxValue = value def checkValue(self, value): if value < self.minValue or value > self.maxValue: return False else: return True def startServoClicked(self): try: position = self.leServoPosition.displayText() except: return if not self.checkValue(float(position)): return self.positionBar.setValue(int(position)) #self.actualPositionServo.display(position) self.runMoveServo(int(position)) def positionBarValueChanged(self, value): self.leServoPosition.setText(str(value)) self.runMoveServo(value) def updateServoPosition(self, pos): if not pos: return self.actualPositionServo.display(int(pos))
class ReceiverStatusPage(QtGui.QWidget): def __init__(self, controller): super(ReceiverStatusPage, self).__init__() if controller is None: raise Exception self.controllerManager = controller self.controllerManager.board_status_updated.connect(self._boardStatusUpdated) self._createUI() def _createUI(self): mainLayout = QtGui.QVBoxLayout() #mainLayout.setMargin(0) #mainLayout.addSpacing(5) # Channel 1 lChannel1 = HeadingLabel() lChannel1.setText("Channel 1") mainLayout.addWidget(lChannel1) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel1 = PositionBar() self.posBarChannel1.setMinimumWidth(250) self.posBarChannel1.setMinimumHeight(30) self.posBarChannel1.setMaximumHeight(30) self.posBarChannel1.setValue(0) self.posBarChannel1.setMoveable(False) layout.addWidget(self.posBarChannel1) self.lcdChannel1Value = QtGui.QLCDNumber() self.lcdChannel1Value.setMaximumHeight(25) self.lcdChannel1Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel1Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 2 lChannel2 = HeadingLabel() lChannel2.setText("Channel 2") mainLayout.addWidget(lChannel2) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel2 = PositionBar() self.posBarChannel2.setMinimumWidth(250) self.posBarChannel2.setMinimumHeight(30) self.posBarChannel2.setMaximumHeight(30) self.posBarChannel2.setValue(0) self.posBarChannel2.setMoveable(False) layout.addWidget(self.posBarChannel2) self.lcdChannel2Value = QtGui.QLCDNumber() self.lcdChannel2Value.setMaximumHeight(25) self.lcdChannel2Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel2Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 3 lChannel3 = HeadingLabel() lChannel3.setText("Channel 3") mainLayout.addWidget(lChannel3) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel3 = PositionBar() self.posBarChannel3.setMinimumWidth(250) self.posBarChannel3.setMinimumHeight(30) self.posBarChannel3.setMaximumHeight(30) self.posBarChannel3.setValue(0) self.posBarChannel3.setMoveable(False) layout.addWidget(self.posBarChannel3) self.lcdChannel3Value = QtGui.QLCDNumber() self.lcdChannel3Value.setMaximumHeight(25) self.lcdChannel3Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel3Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 4 lChannel4 = HeadingLabel() lChannel4.setText("Channel 4") mainLayout.addWidget(lChannel4) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel4 = PositionBar() self.posBarChannel4.setMinimumWidth(250) self.posBarChannel4.setMinimumHeight(30) self.posBarChannel4.setMaximumHeight(30) self.posBarChannel4.setValue(0) self.posBarChannel4.setMoveable(False) layout.addWidget(self.posBarChannel4) self.lcdChannel4Value = QtGui.QLCDNumber() self.lcdChannel4Value.setMaximumHeight(25) self.lcdChannel4Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel4Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 5 lChannel5 = HeadingLabel() lChannel5.setText("Channel 5") mainLayout.addWidget(lChannel5) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel5 = PositionBar() self.posBarChannel5.setMinimumWidth(250) self.posBarChannel5.setMinimumHeight(30) self.posBarChannel5.setMaximumHeight(30) self.posBarChannel5.setValue(0) self.posBarChannel5.setMoveable(False) layout.addWidget(self.posBarChannel5) self.lcdChannel5Value = QtGui.QLCDNumber() self.lcdChannel5Value.setMaximumHeight(25) self.lcdChannel5Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel5Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 6 lChannel6 = HeadingLabel() lChannel6.setText("Channel 6") mainLayout.addWidget(lChannel6) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel6 = PositionBar() self.posBarChannel6.setMinimumWidth(250) self.posBarChannel6.setMinimumHeight(30) self.posBarChannel6.setMaximumHeight(30) self.posBarChannel6.setValue(0) self.posBarChannel6.setMoveable(False) layout.addWidget(self.posBarChannel6) self.lcdChannel6Value = QtGui.QLCDNumber() self.lcdChannel6Value.setMaximumHeight(25) self.lcdChannel6Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel6Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 7 lChannel7 = HeadingLabel() lChannel7.setText("Channel 7") mainLayout.addWidget(lChannel7) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel7 = PositionBar() self.posBarChannel7.setMinimumWidth(250) self.posBarChannel7.setMinimumHeight(30) self.posBarChannel7.setMaximumHeight(30) self.posBarChannel7.setValue(0) self.posBarChannel7.setMoveable(False) layout.addWidget(self.posBarChannel7) self.lcdChannel7Value = QtGui.QLCDNumber() self.lcdChannel7Value.setMaximumHeight(25) self.lcdChannel7Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel7Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addStretch() self.setLayout(mainLayout) def _boardStatusUpdated(self): boardStatus = self.controllerManager.boardStatus #self.posBarChannel1.setValue(boardStatus.inputChannel1)