Пример #1
0
    def connectPID(self):
        """
		Setup communication with the controller.
		"""

        try:
            if self.sender() == self.connectButton:
                port = self.portLineEdit.text()
                baud = self.speedLineEdit.text().toInt()[0]
            else:
                port = self.settings.value("com/Port",
                                           "/dev/ttyUSB0").toString()
                baud = self.settings.value("com/Baud", 19200).toInt()[0]

            self.pid = tinyPID(port=str(port), baudrate=baud)

        except:
            self.pid = None
            self.connectionLabel.setText("not connected.")
            self.emit(SIGNAL("connected(bool)"), False)
        else:
            self.emit(SIGNAL("connected(bool)"), True)
            self.connectionLabel.setText("connected.")
            self.pid.com.readlines()
            w = self.pid.w
            x = self.pid.x
            y = self.pid.y
            m = self.pid.opmode
            self.initValues(w, x, y, m)

            # loaded parameters before, now set them
            if self.newparameters == True:
                self.setScales()
                self.setParameters()
                self.newparameters = False
Пример #2
0
	def connectPID(self):
		"""
		Setup communication with the controller.
		"""
		
		try:
			if self.sender() == self.connectButton:
				port = self.portLineEdit.text()
				baud = self.speedLineEdit.text().toInt()[0]
			else:
				port = self.settings.value("com/Port", "/dev/ttyUSB0").toString()
				baud = self.settings.value("com/Baud", 19200).toInt()[0]
			
			self.pid = tinyPID(port=str(port), baudrate=baud)
			
		except:
			self.pid = None
			self.connectionLabel.setText("not connected.")
			self.emit(SIGNAL("connected(bool)"), False)
		else:
			self.emit(SIGNAL("connected(bool)"), True)
			self.connectionLabel.setText("connected.")
			self.pid.com.readlines()
			w = self.pid.w
			x = self.pid.x
			y = self.pid.y
			m = self.pid.opmode
			self.initValues(w, x, y, m)
			
			# loaded parameters before, now set them
			if self.newparameters == True:
				self.setScales()
				self.setParameters()
				self.newparameters = False
Пример #3
0
    def connectPID(self):
        """	Setup communication with the controller. """

        try:
            if self.sender() == self.connectButton:
                port = self.portLineEdit.text()
                baud = self.speedLineEdit.text().toInt()[0]
            else:
                port = self.settings.value("com/Port",
                                           "/dev/ttyUSB0").toString()
                baud = self.settings.value("com/Baud", 19200).toInt()[0]

            self.pid = tinyPID(port=str(port), baudrate=baud)

        except:
            self.disconnectPID()
        else:
            self.emit(SIGNAL("connected(bool)"), True)
            self.connectLabel.setText("connected.")
            self.pid.com.readlines()
            m = self.pid.opmode
            if m == 'a':
                self.autoRadioButton.toggle()
            else:
                self.manRadioButton.toggle()
Пример #4
0
    def connectPID(self):
        """	Setup communication with the controller. """

        try:
            if self.sender() == self.connectButton:
                port = self.portLineEdit.text()
                baud = self.speedLineEdit.text().toInt()[0]
            else:
                port = self.settings.value("com/Port", "/dev/ttyUSB0").toString()
                baud = self.settings.value("com/Baud", 19200).toInt()[0]

            self.pid = tinyPID(port=str(port), baudrate=baud)

        except:
            self.disconnectPID()
        else:
            self.emit(SIGNAL("connected(bool)"), True)
            self.connectLabel.setText("connected.")
            self.pid.com.readlines()
            m = self.pid.opmode
            if m == "a":
                self.autoRadioButton.toggle()
            else:
                self.manRadioButton.toggle()
Пример #5
0
    def __init__(self, parent=None):
        super(qwttest, self).__init__(parent)
        self.setupUi(self)

        self.pid = tinyPID(port="/dev/ttyUSB2", baudrate=19200)

        self.legend = QwtLegend(self.qwtPlot)
        self.legend.setGeometry(QRect(10, 10, 501, 401))

        gpen = QPen()
        gpen.setBrush(QColor(150, 150, 150))

        wpen = QPen()
        wpen.setBrush(QColor(0, 180, 0))
        wpen.setWidth(2)

        xpen = QPen()
        xpen.setBrush(QColor(180, 0, 0))
        xpen.setWidth(2)

        ypen = QPen()
        ypen.setBrush(QColor(0, 0, 180))
        ypen.setWidth(2)

        self.grid = QwtPlotGrid()
        self.grid.setMajPen(gpen)
        self.grid.attach(self.qwtPlot)
        self.gridEnable(False)

        self.curve_w = QwtPlotCurve("Setpoint")
        self.curve_w.attach(self.qwtPlot)
        self.curve_w.setPen(wpen)
        self.curve_w.updateLegend(self.legend)

        self.curve_y = QwtPlotCurve("Output")
        self.curve_y.attach(self.qwtPlot)
        self.curve_y.setPen(ypen)
        self.curve_y.updateLegend(self.legend)

        self.curve_x = QwtPlotCurve("Process Value")
        self.curve_x.attach(self.qwtPlot)
        self.curve_x.setPen(xpen)
        self.curve_x.updateLegend(self.legend)

        self.qwtPlot.setAxisScale(QwtPlot.yLeft, 0, 300)
        self.qwtPlot.setAxisTitle(QwtPlot.yLeft, "")
        self.qwtPlot.setAxisTitle(QwtPlot.xBottom, "t/s")
        self.qwtPlot.replot()

        self.t0 = time.time()
        self.t = []
        self.y = []
        self.w = []
        self.x = []

        self.view = 10
        self.axmin = 0
        self.axmax = self.view
        self.step = 0

        self.timer = QTimer()
        self.timer.setInterval(150)
        self.timer.start()

        self.connect(self.timer, SIGNAL("timeout()"), self.genpoint)
        self.genpoint()
Пример #6
0
	def __init__(self, parent=None):
		super(qwttest, self).__init__(parent)
		self.setupUi(self)
		
		self.pid = tinyPID(port="/dev/ttyUSB2", baudrate=19200)
		
		
		self.legend = QwtLegend(self.qwtPlot)
		self.legend.setGeometry(QRect(10, 10, 501, 401))
		
		gpen = QPen()
		gpen.setBrush(QColor(150,150,150))
		
		wpen = QPen()
		wpen.setBrush(QColor(0,180,0))
		wpen.setWidth(2)
		
		xpen = QPen()
		xpen.setBrush(QColor(180,0,0))
		xpen.setWidth(2)
		
		ypen = QPen()
		ypen.setBrush(QColor(0,0,180))
		ypen.setWidth(2)
		
		
		self.grid = QwtPlotGrid()
		self.grid.setMajPen(gpen)
		self.grid.attach(self.qwtPlot)
		self.gridEnable(False)
		
		self.curve_w = QwtPlotCurve("Setpoint")
		self.curve_w.attach(self.qwtPlot)
		self.curve_w.setPen(wpen)
		self.curve_w.updateLegend(self.legend)
		
		self.curve_y = QwtPlotCurve("Output")
		self.curve_y.attach(self.qwtPlot)
		self.curve_y.setPen(ypen)
		self.curve_y.updateLegend(self.legend)
		
		self.curve_x = QwtPlotCurve("Process Value")
		self.curve_x.attach(self.qwtPlot)
		self.curve_x.setPen(xpen)
		self.curve_x.updateLegend(self.legend)
		
		self.qwtPlot.setAxisScale(QwtPlot.yLeft, 0, 300)
		self.qwtPlot.setAxisTitle(QwtPlot.yLeft, "")
		self.qwtPlot.setAxisTitle(QwtPlot.xBottom, "t/s")
		self.qwtPlot.replot()
		
		self.t0 = time.time()
		self.t = []
		self.y = []
		self.w = []
		self.x = []
		
		self.view = 10
		self.axmin = 0
		self.axmax = self.view
		self.step = 0
		
		self.timer = QTimer()
		self.timer.setInterval(150)
		self.timer.start()
		
		self.connect(self.timer, SIGNAL("timeout()"), self.genpoint)
		self.genpoint()