• 大小: 15KB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2021-05-10
  • 语言: Python
  • 标签: python  pyside2  pyserial  

资源简介

使用python开发的一个串口上位机应用,主要使用的工具包有pyside2、PyQtgraphy、pyserial。程序入口文件为data_app.py

资源截图

代码片段和文件信息

# encoding: utf-8
import sys
import serial
import serial.tools.list_ports
from PySide2.QtCore import QTimer QTime QRegExp
from PySide2.QtGui import QIcon QRegExpValidator
from PySide2.QtWidgets import QWidget QApplication QMainWindow QMessageBox
import pyqtgraph as pg
from data_deal import Data_Deal
from MainWindow import Ui_MainWindow

class Data_App(QWidget Ui_MainWindow):
    def __init__(self):
        super().__init__()
        # 创建串口实例对象
        self.serial = serial.Serial()
        # 创建 QTimer 实例对象
        self.timer1 = QTimer()
        self.timer2 = QTimer()
        self.time = QTime()
        self.now_time = ‘‘
        # 创建显示窗口
        self.main_window = QMainWindow()
        self.setupUi(self.main_window)
        self.retranslateUi(self.main_window)
        # 正则表达式相关
        bit_3_validator = QRegExpValidator()
        bit_3_validator.setRegExp(QRegExp(‘[0-9]{13}‘))
        self.fresh_waste_edit.setValidator(bit_3_validator)
        self.fresh_edit.setValidator(bit_3_validator)
        self.waste_edit.setValidator(bit_3_validator)
        self.blood_edit.setValidator(bit_3_validator)
        self.ultrafiltration_edit.setValidator(bit_3_validator)
        self.debug_send_edit.setValidator(bit_3_validator)

        # 储存所有存在的串口 字典
        self.Com_Dict = {}
        # 创建新csv文件标志
        self.create_file_flag = True
        self.write_data_flag = False
        # 要保存的当前的文件名
        self.now_file_name = None
        # 串口接收的字符串
        self.received_bit_data = None
        self.received_data = None
        # 图像对象
        self.fresh_pressure_plot = None
        self.waste_pressure_plot = None
        self.fresh_flow_plot = None
        self.waste_flow_plot = None
        self.blood_flow_plot = None
        self.artery_pressure_plot = None
        self.vein_pressure_plot = None
        self.weight_1_plot = None
        self.weight_2_plot = None
        self.weight_3_plot = None
        self.tmp_plot = None
        # self.ph_plot = None
        # self.temperature_plot = None
        # 保存收到的数据 list
        self.x = 0
        self.list_fresh_pressure = [0] * 10
        self.list_waste_pressure = [0] * 10
        self.list_fresh_flow = [0]*10
        self.list_waste_flow = [0]*10
        self.list_blood_flow = [0]*10
        self.list_artery_pressure = [0]*10
        self.list_vein_pressure = [0]*10
        self.list_weight_1 = [0]*10
        self.list_weight_2 = [0]*10
        self.list_weight_3 = [0]*10
        self.list_tmp = [0]*10
        # self.list_ph = [0]*1000
        # 接收到的最新的数据
        self.flag = ““
        self.fresh_pressure_data = 0
        self.waste_pressure_data = 0
        self.fresh_flow_data = 0
        self.waste_flow_data = 0
        self.blood_flow_data = 0
        self.artery_pressure_data = 0
        self.vein_pressure_data = 0
        self.weight_1_data = 0
        self.weight_2_data = 0
        self.weight_3_data = 0
        # 跨膜压
        self.tmp_data = 0
        self.initial_temperature_data = 0
        self.proc

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       29531  2020-07-29 16:34  serial-python\data_app.py
     文件        4709  2020-07-22 17:15  serial-python\data_deal.py
     文件       37393  2020-07-14 15:24  serial-python\MainWindow.py
     文件       42366  2020-07-10 16:55  serial-python\MainWindow.ui

评论

共有 条评论