Ejemplo n.º 1
0
    def refreshDatarefList(self):
        self.datarefTableWidget.setRowCount(0)

        datarefslist = XPrefData.getXPDatarefList(
            self.selectCategoryComboBox.currentText(),
            self.filterDatarefsLineEdit.text())

        index = 0
        for dataref in datarefslist:
            self.datarefTableWidget.insertRow(index)

            item = QtWidgets.QTableWidgetItem(dataref[0])
            self.datarefTableWidget.setItem(index, 0, item)

            item = QtWidgets.QTableWidgetItem(dataref[1])
            self.datarefTableWidget.setItem(index, 1, item)

            item = QtWidgets.QTableWidgetItem(dataref[2])
            self.datarefTableWidget.setItem(index, 2, item)

            item = QtWidgets.QTableWidgetItem(dataref[3])
            self.datarefTableWidget.setItem(index, 3, item)

            item = QtWidgets.QTableWidgetItem(dataref[4])
            self.datarefTableWidget.setItem(index, 4, item)

            item = QtWidgets.QTableWidgetItem(dataref[5])
            self.datarefTableWidget.setItem(index, 5, item)

            index = index + 1

        self.datarefTableWidget.resizeColumnsToContents()
        #self.datarefTableWidget.resizeRowsToContents()
        self.datarefTableWidget.verticalHeader().hide()
Ejemplo n.º 2
0
    def show(self, componentID, ardSerialNr=None):
        self.repopulating = True
        self.componentID = componentID
        componentData = self.ardXMLconfig.getComponentData(
            componentID, self.componentType)

        self.nameLineEdit.setText(componentData['name'])
        self.IDlineEdit.setText(componentData['id'])
        pinIndex = self.PIN_comboBox.findText(componentData['pin'])
        self.PIN_comboBox.setCurrentIndex(pinIndex)

        state = componentData['state']

        self.pwmOutputLineEdit.setText('')
        self.drefLineEdit.setText('')
        self.drefIndexLineEdit.setText('')
        self.drefInfoLabel.setText('')

        actions = componentData['actions']
        if len(actions) >= 1:
            dataref = actions[0]['cmddref']
            self.pwmOutputLineEdit.setText(actions[0]['setToValue'])
            self.drefLineEdit.setText(dataref)
            self.drefIndexLineEdit.setText(actions[0]['index'])

            drefdata = XPrefData.getXPDataref(dataref)
            drefdescr = drefdata[2] + ", " + drefdata[4] + ", " + drefdata[5]
            self.drefInfoLabel.setText(drefdescr)

        self.repopulating = False
        super().show()
    def refreshCommandList(self):
        self.commandsTableWidget.setRowCount(0)

        commandslist = XPrefData.getXPCommandList(
            self.selectCategoryComboBox.currentText(),
            self.filterCommandsLineEdit.text())

        index = 0
        for command in commandslist:
            self.commandsTableWidget.insertRow(index)

            item = QtWidgets.QTableWidgetItem(command[0])
            self.commandsTableWidget.setItem(index, 0, item)

            item = QtWidgets.QTableWidgetItem(command[1])
            self.commandsTableWidget.setItem(index, 1, item)

            item = QtWidgets.QTableWidgetItem(command[2])
            self.commandsTableWidget.setItem(index, 2, item)

            index = index + 1

        self.commandsTableWidget.resizeColumnsToContents()
        self.commandsTableWidget.resizeRowsToContents()
        self.commandsTableWidget.verticalHeader().hide()
Ejemplo n.º 4
0
    def editXPDataref(self):
        logging.debug("Edit XP dref")
        text = self.drefLineEdit.text()

        self.pickXPDatarefDialog.datarefLineEdit.setText(text)

        returnCode = self.pickXPDatarefDialog.exec()

        if returnCode == 1:  # command selected
            dataref = self.pickXPDatarefDialog.datarefLineEdit.text()
            self.drefLineEdit.setText(dataref)
            drefdata = XPrefData.getXPDataref(dataref)
            drefdescr = drefdata[2] + ", " + drefdata[4] + ", " + drefdata[5]
            self.drefInfoLabel.setText(drefdescr)
            self.actionSave.setEnabled(True)
Ejemplo n.º 5
0
    def editXPDataref(self):
        callingQwidgetButton = self.sender()

        parentitem = callingQwidgetButton.parent()
        parenttable = parentitem.parentTable
        logging.debug("parent table: " + str(parenttable))
        index = parenttable.indexAt(parentitem.pos())
        row = index.row()
        logging.debug("edit XP dataref row: " + str(row))
        text = parentitem.lineEdit.text()

        self.pickXPDatarefDialog.datarefLineEdit.setText(text)

        returnCode = self.pickXPDatarefDialog.exec()

        if returnCode == 1:  # command selected
            dataref = self.pickXPDatarefDialog.datarefLineEdit.text()
            parentitem.lineEdit.setText(dataref)

            # default index to 0
            item = QtWidgets.QTableWidgetItem('0')
            parenttable.setItem(row, 1, item)

            # default Set to value to 0.0
            item = QtWidgets.QTableWidgetItem('0.0')
            parenttable.setItem(row, 2, item)

            # retrieve dref data
            drefList = XPrefData.getXPDatarefList(None, dataref)
            if len(drefList) > 0:  # we have found the dataref
                item = QtWidgets.QTableWidgetItem(drefList[0][2])  # type
                parenttable.setItem(row, 4, item)

                item = QtWidgets.QTableWidgetItem(drefList[0][4])  # unit
                parenttable.setItem(row, 5, item)

            parenttable.resizeColumnsToContents()
            parenttable.setColumnWidth(0, self.DREFCMD_COLSIZE)

            self.updateXMLdata()
            self.actionSave.setEnabled(True)
Ejemplo n.º 6
0
    def show(self, componentID, ardSerialNr=None):
        self.repopulating = True
        self.componentID = componentID
        componentData = self.ardXMLconfig.getComponentData(
            componentID, self.componentType)

        self.nameLineEdit.setText(componentData['name'])
        self.IDlineEdit.setText(componentData['id'])
        self.multiplierLineEdit.setText(componentData['multiplier'])
        self.IDlineEdit.setText(componentData['id'])
        check_state = QtCore.Qt.Unchecked
        if componentData['acceleration'] == 'True':
            check_state = QtCore.Qt.Checked
        self.acceleration_checkBox.setCheckState(check_state)

        pinIndex = self.PINA_comboBox.findText(componentData['pin'])
        self.PINA_comboBox.setCurrentIndex(pinIndex)

        pinIndex = self.PINB_comboBox.findText(componentData['pin2'])
        self.PINB_comboBox.setCurrentIndex(pinIndex)

        stepsIndex = self.steps_comboBox.findText(
            componentData['stepsPerNotch'])
        self.steps_comboBox.setCurrentIndex(stepsIndex)

        ################### TO UPDATE
        switchState = componentData['state']
        if switchState == 'on':
            self.switchStateButton.setChecked(True)
        else:
            self.switchStateButton.setChecked(False)
        ######################

        self.UP_CMDS_TABLE.setRowCount(0)
        self.DOWN_CMDS_TABLE.setRowCount(0)

        actions = componentData['actions']
        for action in actions:
            if action['state'] == 'up':
                if action['action_type'] == 'cmd':
                    index = self.UP_CMDS_TABLE.rowCount()
                    self.UP_CMDS_TABLE.insertRow(index)

                    editWidget = pyXPdatarefCommandEditWidget.datarefCommandEditWidget(
                        self.UP_CMDS_TABLE)
                    editWidget.lineEdit.setText(action['cmddref'])
                    editWidget.lineEdit.editingFinished.connect(
                        self.updateXMLdata)
                    editWidget.lookupDREFCMDbutton.clicked.connect(
                        self.editXPCommand)
                    self.UP_CMDS_TABLE.setCellWidget(index, 0, editWidget)

                    check_state = QtCore.Qt.Unchecked
                    if action['continuous'] == 'True':
                        check_state = QtCore.Qt.Checked

                    item = QtWidgets.QTableWidgetItem()
                    item.setCheckState(check_state)
                    self.UP_CMDS_TABLE.setItem(index, 1, item)

                if action['action_type'] == 'dref':
                    index = self.UP_DREFS_TABLE.rowCount()
                    self.UP_DREFS_TABLE.insertRow(index)

                    editWidget = pyXPdatarefCommandEditWidget.datarefCommandEditWidget(
                        self.UP_DREFS_TABLE)
                    editWidget.lineEdit.setText(action['cmddref'])
                    editWidget.lineEdit.editingFinished.connect(
                        self.updateXMLdata)
                    editWidget.lookupDREFCMDbutton.clicked.connect(
                        self.editXPDataref)
                    self.UP_DREFS_TABLE.setCellWidget(index, 0, editWidget)

                    item = QtWidgets.QTableWidgetItem(action['index'])
                    self.UP_DREFS_TABLE.setItem(index, 1, item)
                    item = QtWidgets.QTableWidgetItem(action['setToValue'])
                    self.UP_DREFS_TABLE.setItem(index, 2, item)

                    check_state = QtCore.Qt.Unchecked
                    if action['continuous'] == 'True':
                        check_state = QtCore.Qt.Checked

                    item = QtWidgets.QTableWidgetItem()
                    item.setCheckState(check_state)
                    self.UP_DREFS_TABLE.setItem(index, 3, item)

                    drefList = XPrefData.getXPDatarefList(
                        None, action['cmddref'])
                    if len(drefList) > 0:  # we have found the dataref
                        item = QtWidgets.QTableWidgetItem(
                            drefList[0][2])  # type
                        self.UP_DREFS_TABLE.setItem(index, 4, item)

                        item = QtWidgets.QTableWidgetItem(
                            drefList[0][4])  # unit
                        self.UP_DREFS_TABLE.setItem(index, 5, item)

            if action['state'] == 'down':
                if action['action_type'] == 'cmd':
                    index = self.DOWN_CMDS_TABLE.rowCount()
                    self.DOWN_CMDS_TABLE.insertRow(index)

                    editWidget = pyXPdatarefCommandEditWidget.datarefCommandEditWidget(
                        self.DOWN_CMDS_TABLE)
                    editWidget.lineEdit.setText(action['cmddref'])
                    editWidget.lineEdit.editingFinished.connect(
                        self.updateXMLdata)
                    editWidget.lookupDREFCMDbutton.clicked.connect(
                        self.editXPCommand)
                    self.DOWN_CMDS_TABLE.setCellWidget(index, 0, editWidget)

                    check_state = QtCore.Qt.Unchecked
                    if action['continuous'] == 'True':
                        check_state = QtCore.Qt.Checked

                    item = QtWidgets.QTableWidgetItem()
                    item.setCheckState(check_state)
                    self.DOWN_CMDS_TABLE.setItem(index, 1, item)

                if action['action_type'] == 'dref':
                    index = self.DOWN_DREFS_TABLE.rowCount()
                    self.DOWN_DREFS_TABLE.insertRow(index)

                    editWidget = pyXPdatarefCommandEditWidget.datarefCommandEditWidget(
                        self.DOWN_DREFS_TABLE)
                    editWidget.lineEdit.setText(action['cmddref'])
                    editWidget.lineEdit.editingFinished.connect(
                        self.updateXMLdata)
                    editWidget.lookupDREFCMDbutton.clicked.connect(
                        self.editXPDataref)
                    self.DOWN_DREFS_TABLE.setCellWidget(index, 0, editWidget)

                    item = QtWidgets.QTableWidgetItem(action['index'])
                    self.DOWN_DREFS_TABLE.setItem(index, 1, item)
                    item = QtWidgets.QTableWidgetItem(action['setToValue'])
                    self.DOWN_DREFS_TABLE.setItem(index, 2, item)

                    check_state = QtCore.Qt.Unchecked
                    if action['continuous'] == 'True':
                        check_state = QtCore.Qt.Checked

                    item = QtWidgets.QTableWidgetItem()
                    item.setCheckState(check_state)
                    self.DOWN_DREFS_TABLE.setItem(index, 3, item)

                    drefList = XPrefData.getXPDatarefList(
                        None, action['cmddref'])
                    if len(drefList) > 0:  # we have found the dataref
                        item = QtWidgets.QTableWidgetItem(
                            drefList[0][2])  # type
                        self.DOWN_DREFS_TABLE.setItem(index, 4, item)

                        item = QtWidgets.QTableWidgetItem(
                            drefList[0][4])  # unit
                        self.DOWN_DREFS_TABLE.setItem(index, 5, item)

        self.UP_CMDS_TABLE.resizeColumnsToContents()
        self.UP_CMDS_TABLE.resizeRowsToContents()
        self.UP_CMDS_TABLE.setColumnWidth(0, self.DREFCMD_COLSIZE)

        self.DOWN_CMDS_TABLE.resizeColumnsToContents()
        self.DOWN_CMDS_TABLE.resizeRowsToContents()
        self.DOWN_CMDS_TABLE.setColumnWidth(0, self.DREFCMD_COLSIZE)

        self.UP_DREFS_TABLE.resizeColumnsToContents()
        self.UP_DREFS_TABLE.resizeRowsToContents()
        self.UP_DREFS_TABLE.setColumnWidth(0, self.DREFCMD_COLSIZE)

        self.DOWN_DREFS_TABLE.resizeColumnsToContents()
        self.DOWN_DREFS_TABLE.resizeRowsToContents()
        self.DOWN_DREFS_TABLE.setColumnWidth(0, self.DREFCMD_COLSIZE)

        self.repopulating = False
        super().show()
Ejemplo n.º 7
0
	def initialise(self):
		logging.debug("Running as user: "+getpass.getuser())
		self.loadConfig()
		XPrefData.loadXPReferenceFiles()

		XPUDP.pyXPUDPServer.initialiseUDPXMLConfig(UDPconfigFile)

		XPUDP.pyXPUDPServer.start()

		self.updatingCompPanel = True
		self._refreshingArduinoTree = False

		self.ardXMLconfig = lib.arduinoXMLconfig.arduinoConfig()
		self.ardXMLconfig.registerFileLoadedStatusCallback(self.handleArdFileLoadedStatusChanged)
		self.ardXMLconfig.loadConfigFile(self.ardConfigFile)
		self.ardXMLconfig.registerArduinoAttributeChangedCallback(self.handleArduinoAttributeChange)

		self.arduinoList = []

		self.refreshArduinoList()

		self.deleteConfirmDialog = deleteConfirmationDialog.DeleteConfirmationDialog()
		self.unsavedChangesConfirmationDialog = unsavedChangesConfirmationDialog.unsavedChangesConfirmationDialog()

		self.addArduinoDialog = pyXPaddArduinoDialog.pyXPAddArduinoDialog()
		self.pickXPCommandDialog = pyXPpickXPCommandDialog.pyXPpickXPCommandDialog()
		self.pickXPCommandDialog.refreshCommandList()
		self.editXPUDPConfigDialog = pyXPUDPConfigDialog.pyXPUDPConfigDialog(UDPconfigFile)
		#switch edit form
		self.ardSwitchEditForm = pyXPswitchEditForm.pyXPswitchEditForm(self.editPaneWidget, self.ardXMLconfig, self.actionSave)
		self.horizontalLayoutEditPane.addWidget(self.ardSwitchEditForm)
		self.ardSwitchEditForm.nameUpdated.connect(self.updateComponentName)

		#rot encoder edit form
		self.ardRotencoderEditForm = pyXProtencoderEditForm.pyXProtencoderEditForm(self.editPaneWidget, self.ardXMLconfig, self.actionSave)
		self.horizontalLayoutEditPane.addWidget(self.ardRotencoderEditForm)
		self.ardRotencoderEditForm.nameUpdated.connect(self.updateComponentName)

		#potentiometer edit form
		self.ardPotentiometerEditForm = pyXPpotentiometerEditForm.pyXPpotentiometerEditForm(self.editPaneWidget, self.ardXMLconfig, self.actionSave)
		self.horizontalLayoutEditPane.addWidget(self.ardPotentiometerEditForm)
		self.ardPotentiometerEditForm.nameUpdated.connect(self.updateComponentName)

		#PWM edit form
		self.ardPWMEditForm = pyXPpwmEditForm.pyXPpwmEditForm(self.editPaneWidget, self.ardXMLconfig, self.actionSave)
		self.horizontalLayoutEditPane.addWidget(self.ardPWMEditForm)
		self.ardPWMEditForm.nameUpdated.connect(self.updateComponentName)

		#Digital output edit form
		self.ardDigOutputEditForm = pyXPdigOutputEditForm.pyXPdigOutputEditForm(self.editPaneWidget, self.ardXMLconfig, self.actionSave)
		self.horizontalLayoutEditPane.addWidget(self.ardDigOutputEditForm)
		self.ardDigOutputEditForm.nameUpdated.connect(self.updateComponentName)

		#Servo edit form
		self.ardServoEditForm = pyXPservoEditForm.pyXPservoEditForm(self.editPaneWidget, self.ardXMLconfig, self.actionSave)
		self.horizontalLayoutEditPane.addWidget(self.ardServoEditForm)
		self.ardServoEditForm.nameUpdated.connect(self.updateComponentName)

		self.ardBaudComboBox.addItems(lib.arduinoXMLconfig.ARD_BAUD)

		self.refreshArduinoTree()
		self.ardSwitchEditForm.hide()
		self.arduinoEditForm.hide()
		self.ardPotentiometerEditForm.hide()
		self.ardPWMEditForm.hide()
		self.ardDigOutputEditForm.hide()
		self.ardServoEditForm.hide()
		self.ardRotencoderEditForm.hide()

		self.actionSave.setEnabled(False)
		self.updatingCompPanel = False
    def show(self, componentID, ardSerialNr=None):
        self.repopulating = True
        self.componentID = componentID
        componentData = self.ardXMLconfig.getComponentData(
            componentID, self.componentType)

        self.nameLineEdit.setText(componentData['name'])
        self.IDlineEdit.setText(componentData['id'])
        pinIndex = self.PIN_comboBox.findText(componentData['pin'])
        self.PIN_comboBox.setCurrentIndex(pinIndex)

        state = componentData['state']
        self.valueLabel.setText(state)
        try:
            self.valueSlider.setValue(int(state))
        except:
            logging.debug('could not convert state to int, state value: ' +
                          state)

        self.CMDS_TABLE.setRowCount(0)

        actions = componentData['actions']
        for action in actions:
            if action['action_type'] == 'cmd':
                index = self.CMDS_TABLE.rowCount()
                self.CMDS_TABLE.insertRow(index)
                editWidget = pyXPdatarefCommandEditWidget.datarefCommandEditWidget(
                    self)
                editWidget.lineEdit.setText(action['cmddref'])
                editWidget.lineEdit.editingFinished.connect(self.updateXMLdata)
                editWidget.lookupDREFCMDbutton.clicked.connect(
                    self.editXPCommand)
                self.CMDS_TABLE.setCellWidget(index, 0, editWidget)

                item = QtWidgets.QTableWidgetItem(action['state'])
                item.setToolTip(
                    '<html><head/><body><p>Enter intervals where the command should be sent. </p><p>For example to send the command if the pot value is between 0 and 200 or between 600 and 800, enter: </p><p><span style=" color:#0000ff;">[0,200], [600,800]</span></p></body></html>'
                )
                self.CMDS_TABLE.setItem(index, 1, item)

            if action['action_type'] == 'dref':
                index = self.DREFS_TABLE.rowCount()
                self.DREFS_TABLE.insertRow(index)
                editWidget = pyXPdatarefCommandEditWidget.datarefCommandEditWidget(
                    self)
                editWidget.lineEdit.setText(action['cmddref'])
                editWidget.lineEdit.editingFinished.connect(self.updateXMLdata)
                editWidget.lookupDREFCMDbutton.clicked.connect(
                    self.editXPDataref)
                self.DREFS_TABLE.setCellWidget(index, 0, editWidget)

                item = QtWidgets.QTableWidgetItem(action['index'])
                self.DREFS_TABLE.setItem(index, 1, item)
                item = QtWidgets.QTableWidgetItem(action['setToValue'])
                item.setToolTip(
                    '<html><head/><body><p>Enter series of points [pot input value, output dataref value]. The output value of the dataref in between 2 points will be linearly interpolated. </p><p>Note that the potentiometer value varies between 0 and 1023 (this is the raw output reading from the ADC of the arduino)</p><p>For example to set the dataref to vary linearly between 10 and 300 when the potentiometer value varies between 0 and 1023, enter: </p><p><span style=" color:#0000ff;">[0,10], [1023,300]</span></p></body></html>'
                )
                self.DREFS_TABLE.setItem(index, 2, item)

                drefList = XPrefData.getXPDatarefList(None, action['cmddref'])
                if len(drefList) > 0:  # we have found the dataref
                    item = QtWidgets.QTableWidgetItem(drefList[0][2])  # type
                    self.DREFS_TABLE.setItem(index, 3, item)

                    item = QtWidgets.QTableWidgetItem(drefList[0][4])  # unit
                    self.DREFS_TABLE.setItem(index, 4, item)

        self.CMDS_TABLE.resizeRowsToContents()
        self.CMDS_TABLE.resizeColumnsToContents()
        self.CMDS_TABLE.setColumnWidth(0, self.DREFCMD_COLSIZE)

        self.DREFS_TABLE.resizeColumnsToContents()
        self.DREFS_TABLE.resizeRowsToContents()
        self.DREFS_TABLE.setColumnWidth(0, self.DREFCMD_COLSIZE)

        self.repopulating = False
        super().show()