├── Icon ├── jjj.jpg ├── jjjresize.jpg ├── meidui.jpg ├── senbo.jpg ├── xinbo.png └── 协议.xlsx ├── README.md ├── __pycache__ └── GUI.cpython-36.pyc ├── src ├── GUI.py ├── MyFigure.py ├── MySerial.py ├── UI.py ├── __pycache__ │ ├── MyFigure.cpython-36.pyc │ ├── MySerial.cpython-36.pyc │ ├── UI.cpython-36.pyc │ └── command.cpython-36.pyc ├── command.py ├── frame_1.py ├── frame_2.py ├── main.py ├── mywindow.py └── pytool1.py └── zhilingji ├── 1.1夹试管.xls ├── 2.1夹试管卡纸.xls ├── 3.1抓离心好的试管回来.xls ├── 4.1卡纸注射.xls ├── 5.孵育.xls ├── 6.去离心.xls ├── 7.离心结束拍照.xls ├── pytool1.py ├── zhilingji.txt ├── 协议.xlsx └── 流程综述.txt /Icon/jjj.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/Icon/jjj.jpg -------------------------------------------------------------------------------- /Icon/jjjresize.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/Icon/jjjresize.jpg -------------------------------------------------------------------------------- /Icon/meidui.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/Icon/meidui.jpg -------------------------------------------------------------------------------- /Icon/senbo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/Icon/senbo.jpg -------------------------------------------------------------------------------- /Icon/xinbo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/Icon/xinbo.png -------------------------------------------------------------------------------- /Icon/协议.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/Icon/协议.xlsx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # python-pyqt5-opencv 4 | 基于python的上位机显示图像和数据通信 5 | 运行于vscode,兼容各种平台 6 | 7 | 主要用来和32单片机通信,通过发特定指令(指令集在zhiling文件夹中),然后间接控制电机转动 8 | 9 | -------------------------------------------------------------------------------- /__pycache__/GUI.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/__pycache__/GUI.cpython-36.pyc -------------------------------------------------------------------------------- /src/GUI.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtWidgets 3 | from PyQt5.QtWidgets import QSplitter,QFrame,QLabel,QPushButton,QLineEdit,QComboBox 4 | from PyQt5.QtWidgets import QHBoxLayout,QVBoxLayout,QGridLayout,QFormLayout 5 | from PyQt5.QtWidgets import QMainWindow 6 | from PyQt5.QtCore import Qt 7 | from PyQt5.QtGui import QIcon,QPixmap 8 | # import matplotlib 9 | # matplotlib.use("QT5Agg") 10 | # from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 11 | # from matplotlib.figure import Figure 12 | # import matplotlib.pyplot as plt 13 | # import numpy as np 14 | from MyFigure import MyFigure 15 | 16 | 17 | # #创建一个matplotlib图形绘制类 18 | # class MyFigure(FigureCanvas): 19 | # def __init__(self,width=1, height=1, dpi=100): 20 | # #第一步:创建一个创建Figure 21 | # self.fig = Figure(figsize=(width, height), dpi=dpi) 22 | # #第二步:在父类中激活Figure窗口 23 | # super(MyFigure,self).__init__(self.fig) #此句必不可少,否则不能显示图形 24 | # #第三步:创建一个子图,用于绘制图形用,111表示子图编号,如matlab的subplot(1,1,1) 25 | # #self.axes = self.fig.add_subplot(111) 26 | # #第四步:就是画图,【可以在此类中画,也可以在其它类中画】 27 | # def plotsin(self): 28 | # self.axes0 = self.fig.add_subplot(111) 29 | # # t = np.arange(0.0, 3.0, 0.01) 30 | # # s = np.sin(2 * np.pi * t) 31 | # # self.axes0.plot(t, s) 32 | 33 | # x=(0,1,2,3,4,5,6,7,8) 34 | # y1=(1,3,2,4,56,7,7,7,5) 35 | # self.axes0.plot(x,y1) 36 | 37 | 38 | class MyWindow(QtWidgets.QWidget): 39 | 40 | def __init__(self): 41 | super().__init__() 42 | 43 | self.F = MyFigure(width=1,height=1,dpi=100) 44 | self.F.plotsin() 45 | # 开始: 46 | wlayout = QtWidgets.QHBoxLayout() # 全局布局(1个):水平 47 | 48 | hlayout = QHBoxLayout() # 局部布局(4个):水平、竖直、网格、表单 49 | 50 | vlayout = QGridLayout() 51 | vlayout.setDefaultPositioning(100,100) 52 | vlayout.setAlignment(Qt.AlignTop) 53 | vlayout.setVerticalSpacing(30) 54 | 55 | glayout = QGridLayout() 56 | glayout.setAlignment(Qt.AlignLeft) 57 | glayout.setRowStretch 58 | glayout.setHorizontalSpacing(80) 59 | flayout = QFormLayout() 60 | 61 | baud = ['12800','115200','230400','256000','460800','921600','1382400'] 62 | serials = ['COM1','COM2','COM3','COM4','COM5','COM6','COM7','COM8', 63 | 'COM9','COM10','COM11'] 64 | self.fasong_btn1 = QPushButton('发送', self) 65 | self.fasong_btn2 = QPushButton('发送',self) 66 | self.fasong_btn3 = QPushButton('发送',self) 67 | self.receive_btn = QPushButton("接收",self) 68 | self.receive_btn.setFixedSize(80,60) 69 | self.com_box = QComboBox() 70 | self.com_box.addItems(baud) 71 | #self.bel = QLabel("串口选择") 72 | self.c_baud = QLabel("波特率") 73 | 74 | self.line_text1 = QLineEdit() 75 | self.line_text2 = QLineEdit() 76 | self.line_text3 = QLineEdit() 77 | 78 | # self.hwg_pic = QLabel(self) # 准备四个部件 79 | # self.hwg_pic.setPixmap(QPixmap("Icon/meidui.jpg")) 80 | # self.hwg_pic.setScaledContents(True) 81 | 82 | # hlayout.addWidget(self.hwg_pic) 83 | hlayout.addWidget(self.F) 84 | vlayout.setDefaultPositioning(10,10) 85 | #vlayout.addWidget(self.bel,0,0) 86 | vlayout.addWidget(self.receive_btn,0,0) 87 | vlayout.addWidget(self.com_box,1,1) 88 | vlayout.addWidget(self.c_baud,1,0) 89 | 90 | glayout.addWidget(self.line_text1,0,0) 91 | glayout.addWidget(self.fasong_btn1,0,1) 92 | glayout.addWidget(self.line_text2,1,0) 93 | glayout.addWidget(self.fasong_btn2,1,1) 94 | glayout.addWidget(self.line_text3,2,0) 95 | glayout.addWidget(self.fasong_btn3,2,1) 96 | 97 | #菜单和工具栏 98 | tools_bar = QMainWindow(self) 99 | menubar = tools_bar.menuBar() 100 | #menubar = tools_bar.menuBar() 101 | 102 | 103 | 104 | 105 | hwg = QFrame(self) 106 | hwg.setFrameShape(QFrame.StyledPanel) 107 | hwg.setMinimumSize(100,100) 108 | 109 | 110 | vwg = QFrame(self) 111 | vwg.setFrameShape(QFrame.StyledPanel) 112 | vwg.setMinimumSize(100,100) 113 | 114 | gwg = QFrame(self) 115 | gwg.setFrameShape(QFrame.StyledPanel) 116 | gwg.setMinimumSize(100,100) 117 | 118 | hwg.setLayout(hlayout) 119 | vwg.setLayout(vlayout) 120 | gwg.setLayout(glayout) 121 | 122 | 123 | splitter1 = QSplitter(Qt.Horizontal) 124 | splitter1.addWidget(hwg) 125 | splitter1.addWidget(vwg) 126 | splitter1.setSizes([600,140]) 127 | splitter2=QSplitter(Qt.Vertical) 128 | splitter2.addWidget(splitter1) 129 | splitter2.addWidget(gwg) 130 | splitter2.setSizes([600,140]) 131 | 132 | wlayout.addWidget(splitter2) 133 | self.setLayout(wlayout) # 窗体本尊设置全局布局 134 | 135 | self.setGeometry(300, 300, 800, 800) 136 | self.setWindowTitle('吴洪岩') 137 | self.setWindowIcon(QIcon('Icon/meidui.JPG')) 138 | self.show() 139 | def plotcos(self): 140 | t = np.arange(0.0, 5.0, 0.01) 141 | s = np.cos(2 * np.pi * t) 142 | self.F.axes.plot(t, s) 143 | self.F.fig.suptitle("cos") 144 | 145 | 146 | if __name__=="__main__": 147 | app = QtWidgets.QApplication(sys.argv) 148 | win = MyWindow() 149 | win.show() 150 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/MyFigure.py: -------------------------------------------------------------------------------- 1 | import matplotlib 2 | matplotlib.use("QT5Agg") 3 | from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas 4 | from matplotlib.figure import Figure 5 | import matplotlib.pyplot as plt 6 | import numpy as np 7 | 8 | 9 | #创建一个matplotlib图形绘制类 10 | class MyFigure(FigureCanvas): 11 | def __init__(self,width=1, height=1, dpi=100): 12 | #第一步:创建一个创建Figure 13 | self.fig = Figure(figsize=(width, height), dpi=dpi) 14 | plt.xlabel('时间/t') 15 | plt.ylabel('温度/℃') 16 | #第二步:在父类中激活Figure窗口 17 | super(MyFigure,self).__init__(self.fig) #此句必不可少,否则不能显示图形 18 | #第三步:创建一个子图,用于绘制图形用,111表示子图编号,如matlab的subplot(1,1,1) 19 | #self.axes = self.fig.add_subplot(111) 20 | #第四步:就是画图,【可以在此类中画,也可以在其它类中画】 21 | def plotsin(self): 22 | self.axes0 = self.fig.add_subplot(111) 23 | # t = np.arange(0.0, 3.0, 0.01) 24 | # s = np.sin(2 * np.pi * t) 25 | # self.axes0.plot(t, s) 26 | x=(0,1,2,3,4,5,6,7,8) 27 | y1=(21,23,22,24,28,27,27,27,25) 28 | self.axes0.plot(x,y1) -------------------------------------------------------------------------------- /src/MySerial.py: -------------------------------------------------------------------------------- 1 | import serial 2 | import serial.tools.list_ports 3 | import re 4 | import time 5 | import threading 6 | 7 | class MySerial(): 8 | def __init__(self): 9 | super().__init__() 10 | self.receivedata='pok' 11 | self.initSerial() 12 | def initSerial(self): 13 | #self.comnumber = self.getcom() 14 | self.ser=serial.Serial('COM8',9600,timeout=0.8) 15 | #threading.Thread(target=self.ReadData).start() 16 | # #系统自动获取当前连接的COM口 17 | # def getcom(self): 18 | # port_list = list(serial.tools.list_ports.comports()) 19 | # p1 = re.compile(r'[(](.*?)[)]', re.S) 20 | # com='' 21 | # if len(port_list) == 1: 22 | # for i in range(0,len(port_list)): 23 | # com=(re.findall(p1,str(port_list[i]))[0]) 24 | # print(com) 25 | # return com 26 | 27 | def ReadData(self): 28 | #while True: 29 | self.ser.flush() 30 | self.ser.flushInput() 31 | #time.sleep(0.8) 32 | self.receivedata = self.ser.readline().decode("UTF-8") 33 | #print(self.receivedata.replace('\r\n','')) 34 | #self.ser.close() 35 | return self.receivedata.replace('\r\n','') 36 | 37 | def SendData(self,data): 38 | 39 | #32接收到的消息是以\r\n***\r\n格式的 40 | self.ser.flush() 41 | self.ser.flushOutput() 42 | self.ser.write(bytes.fromhex('0D 0A')) 43 | self.ser.write(bytes.fromhex(data)) 44 | time.sleep(0.6) 45 | self.ser.write(bytes.fromhex('0D 0A')) 46 | self.ser.flush() 47 | 48 | # if __name__ == "__main__": 49 | # sad=MySerial() 50 | # # while True: 51 | # sad.SendData('AA A0 01 01 00 00 10 ff ') 52 | # n=sad.ReadData() 53 | # print(n.replace('\r\n','')) -------------------------------------------------------------------------------- /src/UI.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtCore, QtGui,QtWidgets 3 | from PyQt5.QtCore import Qt,QBasicTimer 4 | from PyQt5.QtWidgets import QWidget,QMessageBox,QStackedWidget,QProgressBar 5 | from PyQt5.QtWidgets import QPushButton,QHBoxLayout,QVBoxLayout,QStackedLayout,QGridLayout 6 | from PyQt5.QtWidgets import QFrame,QSplitter,QTextEdit,QLineEdit,QSplitter 7 | from PyQt5.QtGui import QIcon 8 | from PyQt5.Qt import QSize,QFont 9 | from MyFigure import MyFigure 10 | import threading 11 | class mywindow(QWidget): 12 | def __init__(self): 13 | super().__init__() 14 | self.initUI() 15 | def initUI(self): 16 | self.F = MyFigure(width=1,height=1,dpi=100) 17 | self.F.plotsin() 18 | 19 | self.timer = QBasicTimer() 20 | self.step = 0 21 | 22 | 23 | #self.workmodule1.clicked.connect(self.workmodule_1) 24 | 25 | 26 | #全局布局 27 | self.GlobalLayout=QHBoxLayout() 28 | #三个按钮 29 | self.fasong_btn1 = QPushButton('存储', self) 30 | self.fasong_btn1.setFont(QFont("微软雅黑",20,QFont.Bold)) 31 | self.fasong_btn1.setFixedSize(140,60) 32 | self.fasong_btn1.clicked.connect(self.cunchu) 33 | self.fasong_btn2 = QPushButton('温度',self) 34 | self.fasong_btn2.setFont(QFont("微软雅黑",20,QFont.Bold)) 35 | self.fasong_btn2.setFixedSize(140,60) 36 | self.fasong_btn2.clicked.connect(self.wendu) 37 | self.fasong_btn3 = QPushButton('工作状态',self) 38 | self.fasong_btn3.setFont(QFont("微软雅黑",12,QFont.Bold)) 39 | self.fasong_btn3.setFixedSize(140,60) 40 | self.fasong_btn3.clicked.connect(self.work) 41 | 42 | #工作模式按钮 43 | self.workmodule1=QPushButton('模式1',self) 44 | self.workmodule1.setFont(QFont("微软雅黑",18,QFont.Bold)) 45 | self.workmodule1.setFixedSize(100,100) 46 | #self.workmodule1.clicked.connect(self.workmodule_1) 47 | self.workmodule1.clicked.connect(self.doAction) 48 | self.workmodule2=QPushButton('模式2',self) 49 | self.workmodule2.setFont(QFont("微软雅黑",18,QFont.Bold)) 50 | self.workmodule2.setFixedSize(100,100) 51 | self.workmodule3=QPushButton('模式3',self) 52 | self.workmodule3.setFont(QFont("微软雅黑",18,QFont.Bold)) 53 | self.workmodule3.setFixedSize(100,100) 54 | 55 | #存储按钮 56 | self.cunchu_btn1 = QPushButton('',self) 57 | self.cunchu_btn1.clicked.connect(self.cunchu_btn1_1) 58 | self.cunchu_btn1.setFixedSize(90,90) 59 | self.cunchu_btn1.setStyleSheet("QPushButton{color:black}" 60 | "QPushButton:hover{color:red}" 61 | "QPushButton{background-color:rgb(255,0,0)}" 62 | "QPushButton{border:2px}" 63 | "QPushButton{border-radius:10px}" 64 | "QPushButton{padding:2px 4px}") 65 | self.cunchu_btn2 = QPushButton('',self) 66 | self.cunchu_btn2.setFixedSize(90,90) 67 | self.cunchu_btn3 = QPushButton('',self) 68 | self.cunchu_btn3.setFixedSize(90,90) 69 | self.cunchu_btn4 = QPushButton('',self) 70 | self.cunchu_btn4.setFixedSize(90,90) 71 | self.cunchu_btn5 = QPushButton('',self) 72 | self.cunchu_btn5.setFixedSize(90,90) 73 | self.cunchu_btn6 = QPushButton('',self) 74 | self.cunchu_btn6.setFixedSize(90,90) 75 | self.cunchu_btn7 = QPushButton('',self) 76 | self.cunchu_btn7.setFixedSize(90,90) 77 | self.cunchu_btn8 = QPushButton('',self) 78 | self.cunchu_btn8.setFixedSize(90,90) 79 | self.cunchu_btn9 = QPushButton('',self) 80 | self.cunchu_btn9.setFixedSize(90,90) 81 | self.cunchu_btn10 = QPushButton('',self) 82 | self.cunchu_btn10.setFixedSize(90,90) 83 | self.cunchu_btn11 = QPushButton('',self) 84 | self.cunchu_btn11.setFixedSize(90,90) 85 | self.cunchu_btn12 = QPushButton('',self) 86 | self.cunchu_btn12.setFixedSize(90,90) 87 | self.cunchu_btn13 = QPushButton('',self) 88 | self.cunchu_btn13.setFixedSize(90,90) 89 | self.cunchu_btn14 = QPushButton('',self) 90 | self.cunchu_btn14.setFixedSize(90,90) 91 | self.cunchu_btn15 = QPushButton('',self) 92 | self.cunchu_btn15.setFixedSize(90,90) 93 | self.cunchu_btn16 = QPushButton('',self) 94 | self.cunchu_btn16.setFixedSize(90,90) 95 | self.cunchu_btn17 = QPushButton('',self) 96 | self.cunchu_btn17.setFixedSize(90,90) 97 | self.cunchu_btn18 = QPushButton('',self) 98 | self.cunchu_btn18.setFixedSize(90,90) 99 | self.cunchu_btn19 = QPushButton('',self) 100 | self.cunchu_btn19.setFixedSize(90,90) 101 | self.cunchu_btn20 = QPushButton('',self) 102 | self.cunchu_btn20.setFixedSize(90,90) 103 | self.cunchu_btn21 = QPushButton('',self) 104 | self.cunchu_btn21.setFixedSize(90,90) 105 | self.cunchu_btn22 = QPushButton('',self) 106 | self.cunchu_btn22.setFixedSize(90,90) 107 | self.cunchu_btn23 = QPushButton('',self) 108 | self.cunchu_btn23.setFixedSize(90,90) 109 | self.cunchu_btn24 = QPushButton('',self) 110 | self.cunchu_btn24.setFixedSize(90,90) 111 | self.cunchu_btn25 = QPushButton('',self) 112 | self.cunchu_btn25.setFixedSize(90,90) 113 | self.cunchu_btn26 = QPushButton('',self) 114 | self.cunchu_btn26.setFixedSize(90,90) 115 | self.cunchu_btn27 = QPushButton('',self) 116 | self.cunchu_btn27.setFixedSize(90,90) 117 | self.cunchu_btn28 = QPushButton('',self) 118 | self.cunchu_btn28.setFixedSize(90,90) 119 | self.cunchu_btn29 = QPushButton('',self) 120 | self.cunchu_btn29.setFixedSize(90,90) 121 | self.cunchu_btn30 = QPushButton('',self) 122 | self.cunchu_btn30.setFixedSize(90,90) 123 | self.cunchu_btn31 = QPushButton('',self) 124 | self.cunchu_btn31.setFixedSize(90,90) 125 | self.cunchu_btn32 = QPushButton('',self) 126 | self.cunchu_btn32.setFixedSize(90,90) 127 | self.cunchu_btn33 = QPushButton('',self) 128 | self.cunchu_btn33.setFixedSize(90,90) 129 | self.cunchu_btn34 = QPushButton('',self) 130 | self.cunchu_btn34.setFixedSize(90,90) 131 | self.cunchu_btn35 = QPushButton('',self) 132 | self.cunchu_btn35.setFixedSize(90,90) 133 | self.cunchu_btn36 = QPushButton('',self) 134 | self.cunchu_btn36.setFixedSize(90,90) 135 | 136 | self.cunchu_btn2.setStyleSheet("QPushButton{color:black}" 137 | "QPushButton:hover{color:red}" 138 | "QPushButton{background-color:rgb(255,0,0)}" 139 | "QPushButton{border:2px}" 140 | "QPushButton{border-radius:10px}" 141 | "QPushButton{padding:2px 4px}") 142 | self.cunchu_btn3.setStyleSheet("QPushButton{color:black}" 143 | "QPushButton:hover{color:red}" 144 | "QPushButton{background-color:rgb(255,0,0)}" 145 | "QPushButton{border:2px}" 146 | "QPushButton{border-radius:10px}" 147 | "QPushButton{padding:2px 4px}") 148 | self.cunchu_btn4.setStyleSheet("QPushButton{color:black}" 149 | "QPushButton:hover{color:red}" 150 | "QPushButton{background-color:rgb(255,0,0)}" 151 | "QPushButton{border:2px}" 152 | "QPushButton{border-radius:10px}" 153 | "QPushButton{padding:2px 4px}") 154 | self.cunchu_btn5.setStyleSheet("QPushButton{color:black}" 155 | "QPushButton:hover{color:red}" 156 | "QPushButton{background-color:rgb(255,0,0)}" 157 | "QPushButton{border:2px}" 158 | "QPushButton{border-radius:10px}" 159 | "QPushButton{padding:2px 4px}") 160 | self.cunchu_btn6.setStyleSheet("QPushButton{color:black}" 161 | "QPushButton:hover{color:red}" 162 | "QPushButton{background-color:rgb(255,0,0)}" 163 | "QPushButton{border:2px}" 164 | "QPushButton{border-radius:10px}" 165 | "QPushButton{padding:2px 4px}") 166 | self.cunchu_btn7.setStyleSheet("QPushButton{color:black}" 167 | "QPushButton:hover{color:red}" 168 | "QPushButton{background-color:rgb(255,0,0)}" 169 | "QPushButton{border:2px}" 170 | "QPushButton{border-radius:10px}" 171 | "QPushButton{padding:2px 4px}") 172 | self.cunchu_btn8.setStyleSheet("QPushButton{color:black}" 173 | "QPushButton:hover{color:red}" 174 | "QPushButton{background-color:rgb(255,0,0)}" 175 | "QPushButton{border:2px}" 176 | "QPushButton{border-radius:10px}" 177 | "QPushButton{padding:2px 4px}") 178 | self.cunchu_btn9.setStyleSheet("QPushButton{color:black}" 179 | "QPushButton:hover{color:red}" 180 | "QPushButton{background-color:rgb(255,0,0)}" 181 | "QPushButton{border:2px}" 182 | "QPushButton{border-radius:10px}" 183 | "QPushButton{padding:2px 4px}") 184 | self.cunchu_btn10.setStyleSheet("QPushButton{color:black}" 185 | "QPushButton:hover{color:red}" 186 | "QPushButton{background-color:rgb(255,0,0)}" 187 | "QPushButton{border:2px}" 188 | "QPushButton{border-radius:10px}" 189 | "QPushButton{padding:2px 4px}") 190 | self.cunchu_btn11.setStyleSheet("QPushButton{color:black}" 191 | "QPushButton:hover{color:red}" 192 | "QPushButton{background-color:rgb(255,0,0)}" 193 | "QPushButton{border:2px}" 194 | "QPushButton{border-radius:10px}" 195 | "QPushButton{padding:2px 4px}") 196 | self.cunchu_btn12.setStyleSheet("QPushButton{color:black}" 197 | "QPushButton:hover{color:red}" 198 | "QPushButton{background-color:rgb(255,0,0)}" 199 | "QPushButton{border:2px}" 200 | "QPushButton{border-radius:10px}" 201 | "QPushButton{padding:2px 4px}") 202 | 203 | self.cunchu_btn13.setStyleSheet("QPushButton{color:black}" 204 | "QPushButton:hover{color:red}" 205 | "QPushButton{background-color:rgb(255,0,0)}" 206 | "QPushButton{border:2px}" 207 | "QPushButton{border-radius:10px}" 208 | "QPushButton{padding:2px 4px}") 209 | self.cunchu_btn14.setStyleSheet("QPushButton{color:black}" 210 | "QPushButton:hover{color:red}" 211 | "QPushButton{background-color:rgb(255,0,0)}" 212 | "QPushButton{border:2px}" 213 | "QPushButton{border-radius:10px}" 214 | "QPushButton{padding:2px 4px}") 215 | self.cunchu_btn15.setStyleSheet("QPushButton{color:black}" 216 | "QPushButton:hover{color:red}" 217 | "QPushButton{background-color:rgb(255,0,0)}" 218 | "QPushButton{border:2px}" 219 | "QPushButton{border-radius:10px}" 220 | "QPushButton{padding:2px 4px}") 221 | self.cunchu_btn16.setStyleSheet("QPushButton{color:black}" 222 | "QPushButton:hover{color:red}" 223 | "QPushButton{background-color:rgb(255,0,0)}" 224 | "QPushButton{border:2px}" 225 | "QPushButton{border-radius:10px}" 226 | "QPushButton{padding:2px 4px}") 227 | self.cunchu_btn17.setStyleSheet("QPushButton{color:black}" 228 | "QPushButton:hover{color:red}" 229 | "QPushButton{background-color:rgb(255,0,0)}" 230 | "QPushButton{border:2px}" 231 | "QPushButton{border-radius:10px}" 232 | "QPushButton{padding:2px 4px}") 233 | self.cunchu_btn18.setStyleSheet("QPushButton{color:black}" 234 | "QPushButton:hover{color:red}" 235 | "QPushButton{background-color:rgb(255,0,0)}" 236 | "QPushButton{border:2px}" 237 | "QPushButton{border-radius:10px}" 238 | "QPushButton{padding:2px 4px}") 239 | self.cunchu_btn19.setStyleSheet("QPushButton{color:black}" 240 | "QPushButton:hover{color:red}" 241 | "QPushButton{background-color:rgb(255,0,0)}" 242 | "QPushButton{border:2px}" 243 | "QPushButton{border-radius:10px}" 244 | "QPushButton{padding:2px 4px}") 245 | self.cunchu_btn20.setStyleSheet("QPushButton{color:black}" 246 | "QPushButton:hover{color:red}" 247 | "QPushButton{background-color:rgb(255,0,0)}" 248 | "QPushButton{border:2px}" 249 | "QPushButton{border-radius:10px}" 250 | "QPushButton{padding:2px 4px}") 251 | self.cunchu_btn21.setStyleSheet("QPushButton{color:black}" 252 | "QPushButton:hover{color:red}" 253 | "QPushButton{background-color:rgb(255,0,0)}" 254 | "QPushButton{border:2px}" 255 | "QPushButton{border-radius:10px}" 256 | "QPushButton{padding:2px 4px}") 257 | self.cunchu_btn22.setStyleSheet("QPushButton{color:black}" 258 | "QPushButton:hover{color:red}" 259 | "QPushButton{background-color:rgb(255,0,0)}" 260 | "QPushButton{border:2px}" 261 | "QPushButton{border-radius:10px}" 262 | "QPushButton{padding:2px 4px}") 263 | self.cunchu_btn23.setStyleSheet("QPushButton{color:black}" 264 | "QPushButton:hover{color:red}" 265 | "QPushButton{background-color:rgb(255,0,0)}" 266 | "QPushButton{border:2px}" 267 | "QPushButton{border-radius:10px}" 268 | "QPushButton{padding:2px 4px}") 269 | self.cunchu_btn24.setStyleSheet("QPushButton{color:black}" 270 | "QPushButton:hover{color:red}" 271 | "QPushButton{background-color:rgb(255,0,0)}" 272 | "QPushButton{border:2px}" 273 | "QPushButton{border-radius:10px}" 274 | "QPushButton{padding:2px 4px}") 275 | self.cunchu_btn25.setStyleSheet("QPushButton{color:black}" 276 | "QPushButton:hover{color:red}" 277 | "QPushButton{background-color:rgb(255,0,0)}" 278 | "QPushButton{border:2px}" 279 | "QPushButton{border-radius:10px}" 280 | "QPushButton{padding:2px 4px}") 281 | self.cunchu_btn26.setStyleSheet("QPushButton{color:black}" 282 | "QPushButton:hover{color:red}" 283 | "QPushButton{background-color:rgb(255,0,0)}" 284 | "QPushButton{border:2px}" 285 | "QPushButton{border-radius:10px}" 286 | "QPushButton{padding:2px 4px}") 287 | self.cunchu_btn27.setStyleSheet("QPushButton{color:black}" 288 | "QPushButton:hover{color:red}" 289 | "QPushButton{background-color:rgb(255,0,0)}" 290 | "QPushButton{border:2px}" 291 | "QPushButton{border-radius:10px}" 292 | "QPushButton{padding:2px 4px}") 293 | self.cunchu_btn28.setStyleSheet("QPushButton{color:black}" 294 | "QPushButton:hover{color:red}" 295 | "QPushButton{background-color:rgb(255,0,0)}" 296 | "QPushButton{border:2px}" 297 | "QPushButton{border-radius:10px}" 298 | "QPushButton{padding:2px 4px}") 299 | self.cunchu_btn29.setStyleSheet("QPushButton{color:black}" 300 | "QPushButton:hover{color:red}" 301 | "QPushButton{background-color:rgb(255,0,0)}" 302 | "QPushButton{border:2px}" 303 | "QPushButton{border-radius:10px}" 304 | "QPushButton{padding:2px 4px}") 305 | self.cunchu_btn30.setStyleSheet("QPushButton{color:black}" 306 | "QPushButton:hover{color:red}" 307 | "QPushButton{background-color:rgb(255,0,0)}" 308 | "QPushButton{border:2px}" 309 | "QPushButton{border-radius:10px}" 310 | "QPushButton{padding:2px 4px}") 311 | self.cunchu_btn31.setStyleSheet("QPushButton{color:black}" 312 | "QPushButton:hover{color:red}" 313 | "QPushButton{background-color:rgb(255,0,0)}" 314 | "QPushButton{border:2px}" 315 | "QPushButton{border-radius:10px}" 316 | "QPushButton{padding:2px 4px}") 317 | self.cunchu_btn32.setStyleSheet("QPushButton{color:black}" 318 | "QPushButton:hover{color:red}" 319 | "QPushButton{background-color:rgb(255,0,0)}" 320 | "QPushButton{border:2px}" 321 | "QPushButton{border-radius:10px}" 322 | "QPushButton{padding:2px 4px}") 323 | self.cunchu_btn33.setStyleSheet("QPushButton{color:black}" 324 | "QPushButton:hover{color:red}" 325 | "QPushButton{background-color:rgb(255,0,0)}" 326 | "QPushButton{border:2px}" 327 | "QPushButton{border-radius:10px}" 328 | "QPushButton{padding:2px 4px}") 329 | self.cunchu_btn34.setStyleSheet("QPushButton{color:black}" 330 | "QPushButton:hover{color:red}" 331 | "QPushButton{background-color:rgb(255,0,0)}" 332 | "QPushButton{border:2px}" 333 | "QPushButton{border-radius:10px}" 334 | "QPushButton{padding:2px 4px}") 335 | self.cunchu_btn35.setStyleSheet("QPushButton{color:black}" 336 | "QPushButton:hover{color:red}" 337 | "QPushButton{background-color:rgb(255,0,0)}" 338 | "QPushButton{border:2px}" 339 | "QPushButton{border-radius:10px}" 340 | "QPushButton{padding:2px 4px}") 341 | self.cunchu_btn36.setStyleSheet("QPushButton{color:black}" 342 | "QPushButton:hover{color:red}" 343 | "QPushButton{background-color:rgb(255,0,0)}" 344 | "QPushButton{border:2px}" 345 | "QPushButton{border-radius:10px}" 346 | "QPushButton{padding:2px 4px}") 347 | #左边框 348 | vlayout = QVBoxLayout(self) 349 | vlayout.addWidget(self.fasong_btn1) 350 | vlayout.addWidget(self.fasong_btn2) 351 | vlayout.addWidget(self.fasong_btn3) 352 | 353 | 354 | 355 | #hbox = QHBoxLayout(self) 356 | ###将界面分割成可以自由拉伸的三个窗口 357 | #第一个,左上角,图像显示框 358 | self.topleft = QFrame(self) 359 | self.topleft.setFrameShape(QFrame.StyledPanel) 360 | self.topleft.setLayout(vlayout) 361 | #第二个,右上角串口选择框 362 | 363 | self.topright = QStackedWidget(self) 364 | self.topright.setStyleSheet("background:url(:Icon/meidui.jpg)") 365 | 366 | CunFrame = QFrame() 367 | CunFrame.setFrameShape(QFrame.StyledPanel) 368 | 369 | Cunlayout = QGridLayout() 370 | Cunlayout.addWidget(self.cunchu_btn1,0,0) 371 | Cunlayout.addWidget(self.cunchu_btn2,0,1) 372 | Cunlayout.addWidget(self.cunchu_btn3,0,2) 373 | Cunlayout.addWidget(self.cunchu_btn4,0,3) 374 | Cunlayout.addWidget(self.cunchu_btn5,0,4) 375 | Cunlayout.addWidget(self.cunchu_btn6,0,5) 376 | 377 | Cunlayout.addWidget(self.cunchu_btn7,1,0) 378 | Cunlayout.addWidget(self.cunchu_btn8,1,1) 379 | Cunlayout.addWidget(self.cunchu_btn9,1,2) 380 | Cunlayout.addWidget(self.cunchu_btn10,1,3) 381 | Cunlayout.addWidget(self.cunchu_btn11,1,4) 382 | Cunlayout.addWidget(self.cunchu_btn12,1,5) 383 | 384 | Cunlayout.addWidget(self.cunchu_btn13,2,0) 385 | Cunlayout.addWidget(self.cunchu_btn14,2,1) 386 | Cunlayout.addWidget(self.cunchu_btn15,2,2) 387 | Cunlayout.addWidget(self.cunchu_btn16,2,3) 388 | Cunlayout.addWidget(self.cunchu_btn17,2,4) 389 | Cunlayout.addWidget(self.cunchu_btn18,2,5) 390 | 391 | Cunlayout.addWidget(self.cunchu_btn19,3,0) 392 | Cunlayout.addWidget(self.cunchu_btn20,3,1) 393 | Cunlayout.addWidget(self.cunchu_btn21,3,2) 394 | Cunlayout.addWidget(self.cunchu_btn22,3,3) 395 | Cunlayout.addWidget(self.cunchu_btn23,3,4) 396 | Cunlayout.addWidget(self.cunchu_btn24,3,5) 397 | 398 | Cunlayout.addWidget(self.cunchu_btn25,4,0) 399 | Cunlayout.addWidget(self.cunchu_btn26,4,1) 400 | Cunlayout.addWidget(self.cunchu_btn27,4,2) 401 | Cunlayout.addWidget(self.cunchu_btn28,4,3) 402 | Cunlayout.addWidget(self.cunchu_btn29,4,4) 403 | Cunlayout.addWidget(self.cunchu_btn30,4,5) 404 | 405 | Cunlayout.addWidget(self.cunchu_btn31,5,0) 406 | Cunlayout.addWidget(self.cunchu_btn32,5,1) 407 | Cunlayout.addWidget(self.cunchu_btn33,5,2) 408 | Cunlayout.addWidget(self.cunchu_btn34,5,3) 409 | Cunlayout.addWidget(self.cunchu_btn35,5,4) 410 | Cunlayout.addWidget(self.cunchu_btn36,5,5) 411 | 412 | CunFrame.setLayout(Cunlayout) 413 | self.topright.addWidget(CunFrame) 414 | 415 | #温度 416 | WenFrame = QFrame(self) 417 | WenFrame.setFrameShape(QFrame.StyledPanel) 418 | Wenlayout = QHBoxLayout() 419 | Wenlayout.addWidget(self.F) 420 | WenFrame.setLayout(Wenlayout) 421 | self.topright.addWidget(WenFrame) 422 | 423 | 424 | #工作状态 425 | WorkFrame = QFrame(self) 426 | WorkFrame.setFrameShape(QFrame.StyledPanel) 427 | Worklayout = QVBoxLayout() 428 | 429 | 430 | self.WeiZhi_btn = QPushButton('未知血型',self) 431 | self.WeiZhi_btn.setFont(QFont("微软雅黑",16,QFont.Bold)) 432 | self.WeiZhi_btn.setFixedSize(140,80) 433 | self.YiZhi_btn = QPushButton('已知血型',self) 434 | self.YiZhi_btn.setFont(QFont("微软雅黑",16,QFont.Bold)) 435 | self.YiZhi_btn.setFixedSize(140,80) 436 | self.ChuXue_btn = QPushButton('直接出血',self) 437 | self.ChuXue_btn.setFont(QFont("微软雅黑",16,QFont.Bold)) 438 | self.ChuXue_btn.setFixedSize(140,80) 439 | 440 | hFrame = QFrame() 441 | vFrame = QFrame() 442 | #vFrame.setFocus() 443 | hwg = QHBoxLayout() 444 | vwg = QVBoxLayout() 445 | 446 | hwg.addWidget(self.WeiZhi_btn) 447 | hwg.addWidget(self.YiZhi_btn) 448 | hwg.addWidget(self.ChuXue_btn) 449 | 450 | self.prsbar = QProgressBar(self) 451 | self.jindu_btn = QPushButton(self) 452 | self.jindu_btn.setFixedSize(180,80) 453 | #self.lb1 = QLineEdit(self) 454 | #vwg.setAlignment(Qt.AlignVCenter) 455 | vwg.setAlignment(Qt.AlignHCenter) 456 | #vwg.addWidget(self.jindu_btn) 457 | vwg.addWidget(self.prsbar,Qt.AlignHCenter) 458 | #vwg.addWidget(self.lb1,Qt.AlignHCenter) 459 | vwg.addWidget(self.jindu_btn) 460 | 461 | hFrame.setLayout(hwg) 462 | vFrame.setLayout(vwg) 463 | 464 | Worklayout.addWidget(hFrame) 465 | Worklayout.addWidget(vFrame) 466 | 467 | WorkFrame.setLayout(Worklayout) 468 | self.topright.addWidget(WorkFrame) 469 | 470 | 471 | #第三个,底部,串口通信框 472 | self.bottom = QFrame(self) 473 | self.bottom.setFrameShape(QFrame.StyledPanel) 474 | bwg=QHBoxLayout() 475 | bwg.addWidget(self.workmodule1) 476 | bwg.addWidget(self.workmodule2) 477 | bwg.addWidget(self.workmodule3) 478 | self.bottom.setLayout(bwg) 479 | self.bottom.setStyleSheet("#MainWindow{border-image:url(Icon/xinbo.png);}") 480 | 481 | 482 | #调用splitter控件,使窗口可以拖动起来 483 | splitter1 = QSplitter(Qt.Horizontal) 484 | splitter1.addWidget(self.topleft) 485 | splitter1.addWidget(self.topright) 486 | splitter1.setSizes([80,600]) 487 | splitter2=QSplitter(Qt.Vertical) 488 | splitter2.addWidget(splitter1) 489 | splitter2.addWidget(self.bottom) 490 | splitter2.setSizes([800,200]) 491 | self.GlobalLayout.addWidget(splitter2) 492 | #topright.setLayout(hbox) 493 | self.setLayout(self.GlobalLayout) 494 | 495 | 496 | self.setGeometry(300, 300, 800, 600) 497 | self.setWindowTitle('莘博医疗') 498 | self.setWindowIcon(QIcon('Icon\senbo.jpg')) 499 | self.show() 500 | 501 | def cunchu_btn1_1(self): 502 | self.cunchu_btn1.setStyleSheet("QPushButton{color:black}" 503 | "QPushButton:hover{color:red}" 504 | "QPushButton{background-color:rgb(175,238,238)}" 505 | "QPushButton{border:2px}" 506 | "QPushButton{border-radius:10px}" 507 | "QPushButton{padding:2px 4px}") 508 | 509 | 510 | 511 | 512 | def workmodule_31(self): 513 | print(self.step) 514 | #self.jindu_btn.setText('jiaocha') 515 | if self.step == 18 : 516 | #print('asdas') 517 | self.jindu_btn.setText('交叉配血') 518 | self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) 519 | elif self.step == 40: 520 | self.jindu_btn.setText('孵育') 521 | self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) 522 | elif self.step == 60: 523 | self.jindu_btn.setText('离心') 524 | self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) 525 | elif self.step ==80: 526 | self.jindu_btn.setText('图像处理') 527 | self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) 528 | 529 | 530 | def timerEvent(self, e): 531 | if self.step == 100: 532 | self.jindu_btn.setText('检测完毕') 533 | self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) 534 | self.timer.stop() 535 | #return 536 | self.step = self.step+1 537 | self.workmodule_31() 538 | 539 | # print('jwhy') 540 | # if(int(self.step) >= 100): 541 | # self.jindu_btn.setText('离心') 542 | # print('jwhy') 543 | # self.lb1.setText('djaoisdj') 544 | self.prsbar.setValue(self.step) 545 | 546 | def doAction(self, value): 547 | if self.timer.isActive(): 548 | self.timer.stop() 549 | else: 550 | self.timer.start(700, self) 551 | self.jindu_btn.setText('离心') 552 | self.jindu_btn.setFont(QFont("微软雅黑",20,QFont.Bold)) 553 | def closeEvent(self, event): 554 | reply = QMessageBox.question(self, '提示', 555 | "Are you sure to quit?", QMessageBox.Yes | 556 | QMessageBox.No, QMessageBox.No) 557 | if reply == QMessageBox.Yes: 558 | event.accept() 559 | else: 560 | event.ignore() 561 | 562 | 563 | def cunchu(self): 564 | self.topright.setCurrentIndex(0) 565 | def wendu(self): 566 | self.topright.setCurrentIndex(1) 567 | def work(self): 568 | self.topright.setCurrentIndex(2) 569 | 570 | 571 | -------------------------------------------------------------------------------- /src/__pycache__/MyFigure.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/src/__pycache__/MyFigure.cpython-36.pyc -------------------------------------------------------------------------------- /src/__pycache__/MySerial.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/src/__pycache__/MySerial.cpython-36.pyc -------------------------------------------------------------------------------- /src/__pycache__/UI.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/src/__pycache__/UI.cpython-36.pyc -------------------------------------------------------------------------------- /src/__pycache__/command.cpython-36.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/src/__pycache__/command.cpython-36.pyc -------------------------------------------------------------------------------- /src/command.py: -------------------------------------------------------------------------------- 1 | import xlrd 2 | import os 3 | 4 | class command(): 5 | def __init__(self): 6 | super().__init__() 7 | self.fileList=[] 8 | self.sendStrList=[] #指令存储在这个二维数组内 9 | def getCommand(self): 10 | self.XLS='.xls' 11 | # 返回一个列表,其中包含在目录条目的名称 12 | self.Path = r'zhilingji' 13 | self.files = os.listdir(self.Path) 14 | for f in self.files: 15 | if(self.XLS in f): 16 | # 添加文件 17 | f.encode('GBK') 18 | self.fileList.append(f) 19 | for i in self.fileList: 20 | list_i=list(i) 21 | list_i.insert(0,'zhilingji\\') 22 | i=''.join(list_i) 23 | self.readbook = xlrd.open_workbook(i) 24 | self.sheet=self.readbook.sheet_by_index(0) 25 | self.sendStrList.append(self.sheet.col_values(0)) 26 | return self.sendStrList -------------------------------------------------------------------------------- /src/frame_1.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5.QtWidgets import QApplication, QWidget, QProgressBar, QPushButton 3 | from PyQt5.QtCore import QBasicTimer 4 | 5 | class Example(QWidget): 6 | 7 | def __init__(self): 8 | super().__init__() 9 | 10 | self.initUI() 11 | 12 | def initUI(self): 13 | 14 | self.pbar = QProgressBar(self) 15 | self.pbar.setGeometry(30, 40, 200, 25) 16 | 17 | self.btn = QPushButton('开始', self) 18 | self.btn.move(40, 80) 19 | self.btn.clicked.connect(self.doAction) 20 | 21 | self.timer = QBasicTimer() 22 | self.step = 0 23 | 24 | self.setGeometry(300, 300, 280, 170) 25 | self.setWindowTitle('进度条') 26 | self.show() 27 | 28 | def timerEvent(self, e): 29 | 30 | if self.step >= 200: 31 | self.timer.stop() 32 | self.btn.setText('完成') 33 | return 34 | self.step = self.step+1 35 | self.pbar.setValue(self.step) 36 | 37 | def doAction(self, value): 38 | 39 | if self.timer.isActive(): 40 | self.timer.stop() 41 | self.btn.setText('开始') 42 | else: 43 | self.timer.start(200, self) 44 | self.btn.setText('停止') 45 | 46 | if __name__ == '__main__': 47 | 48 | app = QApplication(sys.argv) 49 | ex = Example() 50 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/frame_2.py: -------------------------------------------------------------------------------- 1 | import serial 2 | import serial.tools.list_ports 3 | import re 4 | port_list = list(serial.tools.list_ports.comports()) 5 | p1 = re.compile(r'[(](.*?)[)]', re.S) 6 | if len(port_list) == 1: 7 | for i in range(0,len(port_list)): 8 | print(re.findall(p1,str(port_list[i]))[0]) 9 | 10 | 11 | 12 | 13 | # # coding=utf-8 14 | 15 | # import sys 16 | # from PyQt5.QtWidgets import * 17 | # from PyQt5.QtCore import * 18 | # from PyQt5.QtGui import * 19 | 20 | 21 | # class Example(QWidget): 22 | # def __init__(self): 23 | # super().__init__() 24 | # self.initUI() 25 | 26 | # def initUI(self): 27 | # hbox = QHBoxLayout(self) 28 | # left = QFrame(self) 29 | # # QFrame 控件添加StyledPanel样式能使QFrame 控件之间的界限更加明显 30 | # #left.setFrameShape(QFrame.StyledPanel) 31 | # right = QFrame(self) 32 | # #right.setFrameShape(QFrame.StyledPanel) 33 | # splitter1 = QSplitter(Qt.Horizontal) 34 | # splitter1.addWidget(left) 35 | # splitter1.setSizes([20,]) #设置分隔条位置 36 | # splitter1.addWidget(right) 37 | # hbox.addWidget(splitter1) 38 | # self.setLayout(hbox) 39 | 40 | 41 | # # 树 42 | # self.tree = QTreeWidget(left) 43 | # self.tree.setStyleSheet("background-color:#eeeeee;border:outset;color:#215b63;") 44 | # self.tree.setAutoScroll(True) 45 | # self.tree.setEditTriggers(QAbstractItemView.DoubleClicked | QAbstractItemView.EditKeyPressed) 46 | # self.tree.setTextElideMode(Qt.ElideMiddle) 47 | # #self.tree.setIndentation(30) 48 | # self.tree.setRootIsDecorated(True) 49 | # self.tree.setUniformRowHeights(False) 50 | # self.tree.setItemsExpandable(True) 51 | # self.tree.setAnimated(False) 52 | # self.tree.setHeaderHidden(True) 53 | # self.tree.setExpandsOnDoubleClick(True) 54 | # self.tree.setObjectName("tree") 55 | 56 | 57 | # # 设置根节点 58 | # root = QTreeWidgetItem(self.tree) 59 | # root.setText(0, '系统管理') 60 | # # 设置树形控件的列的宽度 61 | # #self.tree.setColumnWidth(0, 150) 62 | # # 设置子节点1 63 | # child1 = QTreeWidgetItem() 64 | # child1.setText(0, '增加人员信息') 65 | # root.addChild(child1) 66 | # # 设置子节点2 67 | # child2 = QTreeWidgetItem(root) 68 | # child2.setText(0, '查询人员信息') 69 | # # 加载根节点的所有属性与子控件 70 | # self.tree.addTopLevelItem(root) 71 | # # 设置stackedWidget 72 | # self.stackedWidget = QStackedWidget(right) 73 | 74 | # # 设置第一个面板 75 | # self.form1 = QWidget() 76 | # self.formLayout1 = QHBoxLayout(self.form1) 77 | # self.label1 = QLabel() 78 | # self.label1.setText("增加人员信息面板") 79 | # self.label1.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) 80 | # self.label1.setAlignment(Qt.AlignCenter) 81 | # self.label1.setFont(QFont("Roman times", 50, QFont.Bold)) 82 | # self.formLayout1.addWidget(self.label1) 83 | 84 | # # 设置第二个面板 85 | # self.form2 = QWidget() 86 | # self.formLayout2 = QHBoxLayout(self.form2) 87 | # self.label2 = QLabel() 88 | # self.label2.setText("查询人员信息面板") 89 | # self.label2.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) 90 | # self.label2.setAlignment(Qt.AlignCenter) 91 | # self.label2.setFont(QFont("Roman times", 50, QFont.Bold)) 92 | # self.formLayout2.addWidget(self.label2) 93 | 94 | # # 将两个面板,加入stackedWidget 95 | # self.stackedWidget.addWidget(self.form1) 96 | # self.stackedWidget.addWidget(self.form2) 97 | 98 | # # 树节点监听事件 99 | # self.tree.clicked.connect(self.onClicked) 100 | 101 | 102 | # # 窗口最大化 103 | # self.showMaximized() 104 | # self.setWindowTitle('树窗口分隔案列') 105 | # self.show() 106 | 107 | # def onClicked(self,qmodeLindex): 108 | # item=self.tree.currentItem() 109 | # print('Key=%s,value=%s'%(item.text(0),item.text(1))) 110 | # if item.text(0) == '增加人员信息': 111 | # self.on_pushButton1_clicked() 112 | # elif item.text(0) == '查询人员信息': 113 | # self.on_pushButton2_clicked() 114 | # else: 115 | # print('返回主界面') 116 | 117 | 118 | # # 按钮一:打开第一个面板 119 | # def on_pushButton1_clicked(self): 120 | # self.stackedWidget.setCurrentIndex(0) 121 | 122 | # # 按钮二:打开第二个面板 123 | # def on_pushButton2_clicked(self): 124 | # self.stackedWidget.setCurrentIndex(1) 125 | 126 | 127 | # if __name__ == '__main__': 128 | # app = QApplication(sys.argv) 129 | # ex = Example() 130 | # sys.exit(app.exec_()) 131 | 132 | -------------------------------------------------------------------------------- /src/main.py: -------------------------------------------------------------------------------- 1 | from UI import mywindow 2 | import sys 3 | from PyQt5 import QtWidgets 4 | from command import command 5 | from MySerial import MySerial 6 | import threading 7 | sys.setrecursionlimit(100000) 8 | 9 | class main_window(mywindow): 10 | def __init__(self): 11 | super().__init__() 12 | self.initwindow() 13 | def initwindow(self): 14 | # self.ser = MySerial() 15 | self.cmd=command() 16 | self.cmdlist=self.cmd.getCommand() 17 | # #print(self.cmdlist) 18 | # self.BOOL=False 19 | # self.workmodule1.clicked.connect(self.workmodule_1) 20 | # # self.workmodule2.clicked.connect(self.workmodule_2) 21 | # # self.workmodule3.clicked.connect(self.workmodule_3) 22 | 23 | # # #点击按钮后 打开指令发送线程 24 | # def workmodule_1(self): 25 | # threading.Thread(target=self.workmodule_31).start() 26 | # # def workmodule_2(self): 27 | # # threading.Thread(target=self.workmodule_32).start() 28 | # # def workmodule_3(self): 29 | # # threading.Thread(target=self.workmodule_33).start() 30 | 31 | 32 | 33 | # #按顺序发送指令 34 | # def workmodule_31(self,e): 35 | # while True: 36 | # if(self.step>=100): 37 | # self.jindu_btn.setText('交叉配血') 38 | # elif(self.step==200): 39 | # self.jindu_btn.setText('孵育') 40 | 41 | 42 | 43 | # print('why') 44 | # for i in range(len(self.cmdlist)): 45 | # for m in range(len(self.cmdlist[i])): 46 | # self.ser.SendData(self.cmdlist[i][m]) 47 | # text='' 48 | # while not('STEP' in text): 49 | # print(self.cmdlist[i][m]) 50 | # text = self.ser.ReadData() 51 | # print(text) 52 | # def workmodule_32(self): 53 | # print('why') 54 | # for i in range(len(self.cmdlist)): 55 | # for m in range(len(self.cmdlist[i])): 56 | # self.ser.SendData(self.cmdlist[i][m]) 57 | # text='' 58 | # while not('STEP' in text): 59 | # print(self.cmdlist[i][m]) 60 | # text = self.ser.ReadData() 61 | # print(text) 62 | # def workmodule_33(self): 63 | # # while True: 64 | # # i=len(self.cmdlist) 65 | # #self.ser.SendData('AA A0 01 01 00 00 10 ff ') 66 | # # text = '' 67 | # # text = self.ser.ReadData() 68 | # print('why') 69 | # for i in range(len(self.cmdlist)): 70 | # for m in range(len(self.cmdlist[i])): 71 | # #if 'STEP' in text: 72 | # # while ('step in text') 73 | # #self.ser.SendData(self.cmdlist[i][m]) 74 | # #self.ser.SendData('AA A0 01 01 00 00 10 ff ') 75 | # #ser.write(bytes.fromhex('0D 0A')) 76 | # # text=self.ser.ReadData() 77 | # # print(text+'why') 78 | # #time.sleep(1) 79 | # #print(self.cmdlist[i][m]) 80 | # self.ser.SendData(self.cmdlist[i][m]) 81 | # text='' 82 | # while not('STEP' in text): 83 | # #time.sleep(0.6) 84 | # #threading.Thread(target=self.ser.SendData,args=self.cmdlist[i][m]) 85 | # #self.ser.SendData(self.cmdlist[i][m]) 86 | # #print(self.cmdlist[i][m]) 87 | # text = self.ser.ReadData() 88 | # print(text) 89 | 90 | 91 | 92 | if __name__ == '__main__': 93 | app = QtWidgets.QApplication(sys.argv) 94 | window = main_window() 95 | # window.setObjectName("MainWindow") 96 | # window.setStyleSheet("#MainWindow{border-image:url(Icon/meidui.jpg);}") 97 | sys.exit(app.exec_()) -------------------------------------------------------------------------------- /src/mywindow.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from PyQt5 import QtCore, QtGui,QtWidgets 3 | from PyQt5.QtCore import Qt,QBasicTimer 4 | from PyQt5.QtWidgets import QWidget,QMessageBox,QStackedWidget,QProgressBar 5 | from PyQt5.QtWidgets import QPushButton,QHBoxLayout,QVBoxLayout,QStackedLayout,QGridLayout 6 | from PyQt5.QtWidgets import QFrame,QSplitter,QTextEdit,QLineEdit,QSplitter 7 | from PyQt5.QtGui import QIcon 8 | from PyQt5.Qt import QSize 9 | 10 | class mywindow(QWidget): 11 | def __init__(self): 12 | super().__init__() 13 | self.initUI() 14 | def initUI(self): 15 | 16 | self.timer = QBasicTimer() 17 | self.step = 0 18 | #全局布局 19 | self.GlobalLayout=QHBoxLayout() 20 | #三个按钮 21 | self.fasong_btn1 = QPushButton('存储', self) 22 | self.fasong_btn1.setFixedSize(100,60) 23 | self.fasong_btn1.clicked.connect(self.cunchu) 24 | self.fasong_btn2 = QPushButton('温度',self) 25 | self.fasong_btn2.setFixedSize(100,60) 26 | self.fasong_btn2.clicked.connect(self.wendu) 27 | self.fasong_btn3 = QPushButton('工作状态',self) 28 | self.fasong_btn3.setFixedSize(100,60) 29 | self.fasong_btn3.clicked.connect(self.work) 30 | 31 | #存储按钮 32 | self.cunchu_btn1 = QPushButton('',self) 33 | self.cunchu_btn1.setFixedSize(50,50) 34 | self.cunchu_btn2 = QPushButton('',self) 35 | self.cunchu_btn2.setFixedSize(50,50) 36 | self.cunchu_btn3 = QPushButton('',self) 37 | self.cunchu_btn3.setFixedSize(50,50) 38 | self.cunchu_btn4 = QPushButton('',self) 39 | self.cunchu_btn4.setFixedSize(50,50) 40 | self.cunchu_btn5 = QPushButton('',self) 41 | self.cunchu_btn5.setFixedSize(50,50) 42 | self.cunchu_btn6 = QPushButton('',self) 43 | self.cunchu_btn6.setFixedSize(50,50) 44 | self.cunchu_btn7 = QPushButton('',self) 45 | self.cunchu_btn7.setFixedSize(50,50) 46 | self.cunchu_btn8 = QPushButton('',self) 47 | self.cunchu_btn8.setFixedSize(50,50) 48 | self.cunchu_btn9 = QPushButton('',self) 49 | self.cunchu_btn9.setFixedSize(50,50) 50 | self.cunchu_btn10 = QPushButton('',self) 51 | self.cunchu_btn10.setFixedSize(50,50) 52 | self.cunchu_btn11 = QPushButton('',self) 53 | self.cunchu_btn11.setFixedSize(50,50) 54 | self.cunchu_btn12 = QPushButton('',self) 55 | self.cunchu_btn12.setFixedSize(50,50) 56 | self.cunchu_btn13 = QPushButton('',self) 57 | self.cunchu_btn13.setFixedSize(50,50) 58 | self.cunchu_btn14 = QPushButton('',self) 59 | self.cunchu_btn14.setFixedSize(50,50) 60 | self.cunchu_btn15 = QPushButton('',self) 61 | self.cunchu_btn15.setFixedSize(50,50) 62 | self.cunchu_btn16 = QPushButton('',self) 63 | self.cunchu_btn16.setFixedSize(50,50) 64 | self.cunchu_btn17 = QPushButton('',self) 65 | self.cunchu_btn17.setFixedSize(50,50) 66 | self.cunchu_btn18 = QPushButton('',self) 67 | self.cunchu_btn18.setFixedSize(50,50) 68 | self.cunchu_btn19 = QPushButton('',self) 69 | self.cunchu_btn19.setFixedSize(50,50) 70 | self.cunchu_btn20 = QPushButton('',self) 71 | self.cunchu_btn20.setFixedSize(50,50) 72 | self.cunchu_btn21 = QPushButton('',self) 73 | self.cunchu_btn21.setFixedSize(50,50) 74 | self.cunchu_btn22 = QPushButton('',self) 75 | self.cunchu_btn22.setFixedSize(50,50) 76 | self.cunchu_btn23 = QPushButton('',self) 77 | self.cunchu_btn23.setFixedSize(50,50) 78 | self.cunchu_btn24 = QPushButton('',self) 79 | self.cunchu_btn24.setFixedSize(50,50) 80 | self.cunchu_btn25 = QPushButton('',self) 81 | self.cunchu_btn25.setFixedSize(50,50) 82 | self.cunchu_btn26 = QPushButton('',self) 83 | self.cunchu_btn26.setFixedSize(50,50) 84 | self.cunchu_btn27 = QPushButton('',self) 85 | self.cunchu_btn27.setFixedSize(50,50) 86 | self.cunchu_btn28 = QPushButton('',self) 87 | self.cunchu_btn28.setFixedSize(50,50) 88 | self.cunchu_btn29 = QPushButton('',self) 89 | self.cunchu_btn29.setFixedSize(50,50) 90 | self.cunchu_btn30 = QPushButton('',self) 91 | self.cunchu_btn30.setFixedSize(50,50) 92 | self.cunchu_btn31 = QPushButton('',self) 93 | self.cunchu_btn31.setFixedSize(50,50) 94 | self.cunchu_btn32 = QPushButton('',self) 95 | self.cunchu_btn32.setFixedSize(50,50) 96 | self.cunchu_btn33 = QPushButton('',self) 97 | self.cunchu_btn33.setFixedSize(50,50) 98 | self.cunchu_btn34 = QPushButton('',self) 99 | self.cunchu_btn34.setFixedSize(50,50) 100 | self.cunchu_btn35 = QPushButton('',self) 101 | self.cunchu_btn35.setFixedSize(50,50) 102 | self.cunchu_btn36 = QPushButton('',self) 103 | self.cunchu_btn36.setFixedSize(50,50) 104 | 105 | #左边框 106 | vlayout = QVBoxLayout(self) 107 | vlayout.addWidget(self.fasong_btn1) 108 | vlayout.addWidget(self.fasong_btn2) 109 | vlayout.addWidget(self.fasong_btn3) 110 | 111 | 112 | 113 | #hbox = QHBoxLayout(self) 114 | ###将界面分割成可以自由拉伸的三个窗口 115 | #第一个,左上角,图像显示框 116 | topleft = QFrame(self) 117 | topleft.setFrameShape(QFrame.StyledPanel) 118 | topleft.setLayout(vlayout) 119 | #第二个,右上角串口选择框 120 | 121 | self.topright = QStackedWidget(self) 122 | 123 | CunFrame = QFrame() 124 | CunFrame.setFrameShape(QFrame.StyledPanel) 125 | 126 | Cunlayout = QGridLayout() 127 | Cunlayout.addWidget(self.cunchu_btn1,0,0) 128 | Cunlayout.addWidget(self.cunchu_btn2,0,1) 129 | Cunlayout.addWidget(self.cunchu_btn3,0,2) 130 | Cunlayout.addWidget(self.cunchu_btn4,0,3) 131 | Cunlayout.addWidget(self.cunchu_btn5,0,4) 132 | Cunlayout.addWidget(self.cunchu_btn6,0,5) 133 | 134 | Cunlayout.addWidget(self.cunchu_btn7,1,0) 135 | Cunlayout.addWidget(self.cunchu_btn8,1,1) 136 | Cunlayout.addWidget(self.cunchu_btn9,1,2) 137 | Cunlayout.addWidget(self.cunchu_btn10,1,3) 138 | Cunlayout.addWidget(self.cunchu_btn11,1,4) 139 | Cunlayout.addWidget(self.cunchu_btn12,1,5) 140 | 141 | Cunlayout.addWidget(self.cunchu_btn13,2,0) 142 | Cunlayout.addWidget(self.cunchu_btn14,2,1) 143 | Cunlayout.addWidget(self.cunchu_btn15,2,2) 144 | Cunlayout.addWidget(self.cunchu_btn16,2,3) 145 | Cunlayout.addWidget(self.cunchu_btn17,2,4) 146 | Cunlayout.addWidget(self.cunchu_btn18,2,5) 147 | 148 | Cunlayout.addWidget(self.cunchu_btn19,3,0) 149 | Cunlayout.addWidget(self.cunchu_btn20,3,1) 150 | Cunlayout.addWidget(self.cunchu_btn21,3,2) 151 | Cunlayout.addWidget(self.cunchu_btn22,3,3) 152 | Cunlayout.addWidget(self.cunchu_btn23,3,4) 153 | Cunlayout.addWidget(self.cunchu_btn24,3,5) 154 | 155 | Cunlayout.addWidget(self.cunchu_btn25,4,0) 156 | Cunlayout.addWidget(self.cunchu_btn26,4,1) 157 | Cunlayout.addWidget(self.cunchu_btn27,4,2) 158 | Cunlayout.addWidget(self.cunchu_btn28,4,3) 159 | Cunlayout.addWidget(self.cunchu_btn29,4,4) 160 | Cunlayout.addWidget(self.cunchu_btn30,4,5) 161 | 162 | Cunlayout.addWidget(self.cunchu_btn31,5,0) 163 | Cunlayout.addWidget(self.cunchu_btn32,5,1) 164 | Cunlayout.addWidget(self.cunchu_btn33,5,2) 165 | Cunlayout.addWidget(self.cunchu_btn34,5,3) 166 | Cunlayout.addWidget(self.cunchu_btn35,5,4) 167 | Cunlayout.addWidget(self.cunchu_btn36,5,5) 168 | 169 | CunFrame.setLayout(Cunlayout) 170 | self.topright.addWidget(CunFrame) 171 | 172 | #温度 173 | WenFrame = QFrame(self) 174 | WenFrame.setFrameShape(QFrame.StyledPanel) 175 | self.topright.addWidget(WenFrame) 176 | 177 | 178 | #工作状态 179 | WorkFrame = QFrame(self) 180 | WorkFrame.setFrameShape(QFrame.StyledPanel) 181 | Worklayout = QVBoxLayout() 182 | 183 | 184 | self.WeiZhi_btn = QPushButton('未知血型',self) 185 | self.WeiZhi_btn.setFixedSize(80,60) 186 | self.YiZhi_btn = QPushButton('已知血型',self) 187 | self.YiZhi_btn.setFixedSize(80,60) 188 | self.ChuXue_btn = QPushButton('直接出血',self) 189 | self.ChuXue_btn.setFixedSize(80,60) 190 | 191 | hFrame = QFrame() 192 | vFrame = QFrame() 193 | hwg = QHBoxLayout() 194 | vwg = QVBoxLayout() 195 | 196 | hwg.addWidget(self.WeiZhi_btn) 197 | hwg.addWidget(self.YiZhi_btn) 198 | hwg.addWidget(self.ChuXue_btn) 199 | 200 | self.prsbar = QProgressBar(self) 201 | vwg.addWidget(self.prsbar) 202 | 203 | hFrame.setLayout(hwg) 204 | vFrame.setLayout(vwg) 205 | 206 | Worklayout.addWidget(hFrame) 207 | Worklayout.addWidget(vFrame) 208 | 209 | WorkFrame.setLayout(Worklayout) 210 | self.topright.addWidget(WorkFrame) 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | #第三个,底部,串口通信框 222 | bottom = QFrame(self) 223 | bottom.setFrameShape(QFrame.StyledPanel) 224 | #调用splitter控件,使窗口可以拖动起来 225 | splitter1 = QSplitter(Qt.Horizontal) 226 | splitter1.addWidget(topleft) 227 | splitter1.addWidget(self.topright) 228 | splitter1.setSizes([80,600]) 229 | splitter2=QSplitter(Qt.Vertical) 230 | splitter2.addWidget(splitter1) 231 | splitter2.addWidget(bottom) 232 | splitter2.setSizes([800,200]) 233 | self.GlobalLayout.addWidget(splitter2) 234 | #topright.setLayout(hbox) 235 | self.setLayout(self.GlobalLayout) 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | self.setGeometry(300, 300, 800, 600) 254 | self.setWindowTitle('吴洪岩') 255 | self.setWindowIcon(QIcon('Icon\meidui.JPG')) 256 | self.show() 257 | 258 | 259 | 260 | 261 | 262 | def closeEvent(self, event): 263 | reply = QMessageBox.question(self, '提示', 264 | "Are you sure to quit?", QMessageBox.Yes | 265 | QMessageBox.No, QMessageBox.No) 266 | if reply == QMessageBox.Yes: 267 | event.accept() 268 | else: 269 | event.ignore() 270 | 271 | 272 | def cunchu(self): 273 | self.topright.setCurrentIndex(0) 274 | def wendu(self): 275 | self.topright.setCurrentIndex(1) 276 | def work(self): 277 | self.topright.setCurrentIndex(2) 278 | 279 | def timerEvent(self, event): 280 | if self.step >=100: 281 | self.timer.stop() 282 | return 283 | self.step = self.step + 1 284 | self.pbar.setValue(self.step) 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | if __name__ == '__main__': 356 | app = QtWidgets.QApplication(sys.argv) 357 | window = mywindow() 358 | sys.exit(app.exec_()) 359 | -------------------------------------------------------------------------------- /src/pytool1.py: -------------------------------------------------------------------------------- 1 | import serial #导入模块 2 | import threading 3 | import xlrd 4 | import os 5 | 6 | 7 | STRGLO="" #读取的数据 8 | BOOL=True #读取标志位 9 | sendStrlist=[] 10 | recFlag=False 11 | sendNote=[] 12 | fileList = [] 13 | 14 | # 所有xls文件 15 | def printPath(): 16 | XLS='.xls' 17 | # 返回一个列表,其中包含在目录条目的名称 18 | files = os.listdir(os.getcwd()) 19 | # 先添加目录级别 20 | for f in files: 21 | if(XLS in f): 22 | # 添加文件 23 | fileList.append(f) 24 | for f in range(len(fileList)): 25 | print(f,' ',fileList[f]) 26 | ch=input('choose one:') 27 | print("open:",fileList[int(ch)]) 28 | return ch 29 | 30 | #读数代码本体实现 31 | def ReadData(ser): 32 | global STRGLO,BOOL,recFlag 33 | # 循环接收数据,此为死循环,可用线程实现 34 | while BOOL: 35 | if ser.in_waiting: 36 | STRGLO = ser.readline(ser.in_waiting).decode("UTF-8") 37 | print(STRGLO.replace('\r\n', '')) 38 | recFlag=True 39 | 40 | #打开串口 41 | # 端口,GNU / Linux上的/ dev / ttyUSB0 等 或 Windows上的 COM3 等 42 | # 波特率,标准值之一:50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400,57600,115200 43 | # 超时设置,None:永远等待操作,0为立即返回请求结果,其他值为等待超时时间(单位为秒) 44 | def DOpenPort(portx,bps,timeout): 45 | ret=False 46 | try: 47 | # 打开串口,并得到串口对象 48 | ser = serial.Serial(portx, bps, timeout=timeout) 49 | #判断是否打开成功 50 | if(ser.is_open): 51 | ret=True 52 | threading.Thread(target=ReadData, args=(ser,)).start() 53 | except Exception as e: 54 | print("---异常---:", e) 55 | return ser,ret 56 | 57 | #关闭串口 58 | def DColsePort(ser): 59 | global BOOL 60 | BOOL=False 61 | ser.close() 62 | 63 | #写数据 64 | def DWritePort(ser,text): 65 | result = ser.write(text.encode("gbk")) # 写数据 66 | return result 67 | #try: 68 | #count=DWritePort(ser,"我是东小东,哈哈") 69 | 70 | #读数据 71 | def DReadPort(): 72 | global STRGLO,recFlag 73 | while BOOL: 74 | if(recFlag == True): 75 | str0=STRGLO 76 | str1=str0 77 | STRGLO=""#清空当次读取 78 | recFlag = False 79 | return str0,str1 80 | 81 | if __name__=="__main__": 82 | ser,ret=DOpenPort("COM8",9600,1) 83 | STEP='STEP' 84 | GET='GET' 85 | if(ret==True):#判断串口是否成功打开 86 | print("open success:",ser.name) 87 | #print(ser.baudrate ) # 波特率 88 | #print(ser.bytesize) # 字节大小 89 | #print(ser.parity) # 校验位N-无校验,E-偶校验,O-奇校验 90 | #print(ser.stopbits) # 停止位 91 | #print(ser.timeout) # 读超时设置 92 | #print(ser.writeTimeout) # 写超时 93 | #print(ser.interCharTimeout) # 字符间隔超时 94 | ch = printPath(); 95 | readbook = xlrd.open_workbook(fileList[int(ch)]) 96 | sheet = readbook.sheet_by_index(0) 97 | sendStrlist = sheet.col_values(0) 98 | sendNote= sheet.col_values(1) 99 | for data in range(len(sendStrlist)): 100 | n = ser.write(bytes.fromhex(sendStrlist[data])) # 十六进制数据 101 | print('now:',sendNote[data]) 102 | ser.write(bytes.fromhex('0D 0A')) 103 | while True: 104 | str0,str1=DReadPort() 105 | if ((STEP in str0) or (STEP in str1)): 106 | break 107 | print("Send DATA Finish") 108 | DColsePort(ser) #关闭串口 -------------------------------------------------------------------------------- /zhilingji/1.1夹试管.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/zhilingji/1.1夹试管.xls -------------------------------------------------------------------------------- /zhilingji/2.1夹试管卡纸.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/zhilingji/2.1夹试管卡纸.xls -------------------------------------------------------------------------------- /zhilingji/3.1抓离心好的试管回来.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/zhilingji/3.1抓离心好的试管回来.xls -------------------------------------------------------------------------------- /zhilingji/4.1卡纸注射.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/zhilingji/4.1卡纸注射.xls -------------------------------------------------------------------------------- /zhilingji/5.孵育.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/zhilingji/5.孵育.xls -------------------------------------------------------------------------------- /zhilingji/6.去离心.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/zhilingji/6.去离心.xls -------------------------------------------------------------------------------- /zhilingji/7.离心结束拍照.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/zhilingji/7.离心结束拍照.xls -------------------------------------------------------------------------------- /zhilingji/pytool1.py: -------------------------------------------------------------------------------- 1 | import serial #导入模块 2 | import threading 3 | import xlrd 4 | import os 5 | 6 | STRGLO="" #读取的数据 7 | BOOL=True #读取标志位 8 | sendStrlist=[] 9 | recFlag=False 10 | sendNote=[] 11 | fileList = [] 12 | 13 | # 所有xls文件 14 | def printPath(): 15 | XLS='.xls' 16 | # 返回一个列表,其中包含在目录条目的名称 17 | files = os.listdir(os.getcwd()) 18 | # 先添加目录级别 19 | for f in files: 20 | if(XLS in f): 21 | # 添加文件 22 | fileList.append(f) 23 | for f in range(len(fileList)): 24 | print(f,' ',fileList[f]) 25 | ch=input('choose one:') 26 | print("open:",fileList[int(ch)]) 27 | return ch 28 | 29 | #读数代码本体实现 30 | def ReadData(ser): 31 | global STRGLO,BOOL,recFlag 32 | # 循环接收数据,此为死循环,可用线程实现 33 | while BOOL: 34 | if ser.in_waiting: 35 | STRGLO = ser.readline(ser.in_waiting).decode("utf-8") 36 | print(STRGLO.replace('\r\n', '')) 37 | recFlag=True 38 | 39 | #打开串口 40 | # 端口,GNU / Linux上的/ dev / ttyUSB0 等 或 Windows上的 COM3 等 41 | # 波特率,标准值之一:50,75,110,134,150,200,300,600,1200,1800,2400,4800,9600,19200,38400,57600,115200 42 | # 超时设置,None:永远等待操作,0为立即返回请求结果,其他值为等待超时时间(单位为秒) 43 | def DOpenPort(portx,bps,timeout): 44 | ret=False 45 | try: 46 | # 打开串口,并得到串口对象 47 | ser = serial.Serial(portx, bps, timeout=timeout) 48 | #判断是否打开成功 49 | if(ser.is_open): 50 | ret=True 51 | threading.Thread(target=ReadData, args=(ser,)).start() 52 | except Exception as e: 53 | print("---异常---:", e) 54 | return ser,ret 55 | 56 | #关闭串口 57 | def DColsePort(ser): 58 | global BOOL 59 | BOOL=False 60 | ser.close() 61 | 62 | #写数据 63 | def DWritePort(ser,text): 64 | result = ser.write(text.encode("gbk")) # 写数据 65 | return result 66 | #try: 67 | #count=DWritePort(ser,"我是东小东,哈哈") 68 | 69 | #读数据 70 | def DReadPort(): 71 | global STRGLO,recFlag 72 | while BOOL: 73 | if(recFlag == True): 74 | str0=STRGLO 75 | str1=str0 76 | STRGLO=""#清空当次读取 77 | recFlag = False 78 | return str0,str1 79 | 80 | if __name__=="__main__": 81 | ser,ret=DOpenPort("COM14",9600,1) 82 | STEP='STEP' 83 | GET='GET' 84 | if(ret==True):#判断串口是否成功打开 85 | print("open success:",ser.name) 86 | #print(ser.baudrate ) # 波特率 87 | #print(ser.bytesize) # 字节大小 88 | #print(ser.parity) # 校验位N-无校验,E-偶校验,O-奇校验 89 | #print(ser.stopbits) # 停止位 90 | #print(ser.timeout) # 读超时设置 91 | #print(ser.writeTimeout) # 写超时 92 | #print(ser.interCharTimeout) # 字符间隔超时 93 | ch = printPath(); 94 | readbook = xlrd.open_workbook(fileList[int(ch)]) 95 | sheet = readbook.sheet_by_index(0) 96 | sendStrlist = sheet.col_values(0) 97 | sendNote= sheet.col_values(1) 98 | for data in range(len(sendStrlist)): 99 | n = ser.write(bytes.fromhex(sendStrlist[data])) # 十六进制数据 100 | print('now:',sendNote[data]) 101 | ser.write(bytes.fromhex('0D 0A')) 102 | while True: 103 | str0,str1=DReadPort() 104 | if ((STEP in str0) or (STEP in str1)): 105 | break 106 | print("Send DATA Finish") 107 | DColsePort(ser) #关闭串口 -------------------------------------------------------------------------------- /zhilingji/zhilingji.txt: -------------------------------------------------------------------------------- 1 | #1.1 2 | AAA10400000050FF 1开舵机 3 | AAA10301000c00FF 2上来归位 4 | AAA10201000C00FF 3往前归位 5 | AAA10100001C00FF 4往右归为 6 | AAA10200002000FF 5向后到底 7 | AAA10101001A00FF 6向左到试管1 8 | AAA10300001000FF 7向下 9 | AAA10400000074FF 8关舵机夹试管 10 | AAA10301001000FF 9向上 11 | AAA10100001a00FF 10向右到底 12 | AAA10201002000FF 11向前到底 13 | AAA10101001200FF 12向左到离心机 14 | AAA10300000a00FF 13向下到离心机 15 | AAA10400000050FF 14开舵机放试管 16 | AAA10301000a00FF 15向上,此处暂停 17 | AAA2020100B000FF 10电机向上到底 18 | AAA20200001000FF 10电机向下一点 19 | AAA20301000100FF 减速电机出来 20 | 21 | 22 | #2.1 23 | AAA0040000003cFF 开上舵机 24 | AAA00301000c00FF 向上归位 25 | AAA00201000C00FF 向前归位 26 | AAA00100001C00FF 向右归位 27 | AAA002000003f0FF 向后一点到试管 28 | AAA00300001000FF 向下到试管 29 | AAA0040000004eFF 夹试管 30 | AAA00301001100FF 上升 31 | AAA00101001900FF 向左一点 32 | AAA00200001800FF 向后到底 33 | AAA00201000020FF 向前一点 34 | AAA00300000B00FF 向下一点 35 | AAA0040000003cFF 松开舵机放下试管 36 | AAA00301000cf0FF 上升 37 | AAA00101004200FF 向左到底 38 | AAA00100000800FF 向右一点 39 | AAA00201000b60FF 向前到卡纸 40 | AAA00300000cf0FF 向下 41 | AAA00400000053FF 夹取卡纸 42 | AAA00301000cf0FF 向上 43 | AAA00100005600FF 向右到底 44 | AAA00200000f00FF 向后到底 45 | AAA00101000500FF 向左一点到槽 46 | AAA00300000f00FF 向下 47 | AAA0040000003cFF 松开舵机放下卡纸 48 | AAA00301001000FF 向上归位 49 | AAA00201001f00FF 向前归位 50 | AAA00100000600FF 向右归位 51 | AAA20300000100FF 关舱门,加在要关的位置 52 | AAA2020000B000FF 下10号电机 53 | AAA20201000800FF 上来一点10号电机 54 | 55 | 56 | #3.1 57 | AAA10300000c00FF 16向下 58 | AAA10400000074FF 17关舵机夹试管 59 | AAA10301000C00FF 18向上 60 | AAA10100001300FF 19向右到底 61 | AAA10200001c00FF 20向后到底 62 | AAA10101000ea0FF 21向左慢移1 63 | AAA10101000a00FF 22向左慢移2 64 | AAA10300000900FF 23向下放试管 65 | AAA10400000050FF 24松开试管 66 | AAA10301000C00FF 25上来归位 67 | AAA10100001B00FF 26向右归位 68 | AAA10201002000FF 27向前归位 69 | 70 | 71 | 72 | #4.1 73 | AAA20200001000FF 10号下来到底 74 | AAA20201000100FF 10号上来一点 75 | AAA20100001D00FF 移到生理盐水位置 76 | AAA20401000200FF 针头转到生理盐水 77 | AAA30300001000FF 整体向下,需改时间 78 | AAA30700000500FF 向上抽水,需改时间 79 | AAA30301000500FF 整体向上,需改时间 80 | AAA20100002700FF 移到试管1位置 81 | AAA30300001000FF 整体向下,需改时间 82 | AAA30301000500FF 整体向上,需改时间 83 | AAA20100001C00FF 移到卡纸1位置 84 | AAA30300001000FF 整体向下,需改时间 85 | AAA30301000500FF 整体向上,需改时间 86 | AAA20100000100FF 移到卡纸2位置 87 | AAA30300001000FF 整体向下,需改时间 88 | AAA30301000500FF 整体向上,需改时间 89 | AAA20400000100FF 针头转回 90 | AAA20101002500FF 移回初始位置 91 | 92 | 93 | #5.1 94 | 95 | AAA10300000CF0FF 15向下 96 | AAA1040000007aFF 16夹取卡纸 97 | AAA10301000E00FF 17向上 98 | AAA10100000200FF 18向右归位 99 | AAA10201000A00FF 19向前一点,需要改时间 100 | AAA10101000f00FF 20步进左移1 101 | AAA10101000f00FF 21步进左移2 102 | AAA10101000f00FF 22步进左移3 103 | AAA10101000f00FF 23步进左移4 104 | AAA10101000f00FF 24步进左移5 105 | AAA10101000f00FF 25步进左移6 106 | AAA10300001000FF 26向下到底,此处暂停开始孵育 107 | 108 | 109 | 110 | #6.1 111 | 112 | AAA10301001100FF 27向上 113 | AAA10100002000FF 28步进右移1 114 | AAA10100002000FF 29步进右移2 115 | AAA10100002000FF 30步进右移3 116 | AAA101010004A0FF 32左移放卡纸,改时间 117 | AAA10300000c00FF 33向下,改时间 118 | AAA10400000050FF 34松开 119 | AAA10301000cf0FF 35向上到底,暂停等待离心 120 | 121 | 122 | #7.1 123 | AAA10300000CF0FF 15向下 124 | AAA1040000007aFF 16夹取卡纸 125 | AAA10301000E00FF 17向上 126 | AAA10100000200FF 18向右归位 127 | AAA10201000C00FF 19向前归位 128 | AAA10101000f00FF 20步进左移1 129 | AAA10101000f00FF 21步进左移2 130 | AAA10101000f00FF 22步进左移3 131 | AAA10101000f00FF 23步进左移4 132 | AAA10101000f00FF 24步进左移5 133 | AAA10101000f00FF 25步进左移6 134 | AAA10300000c00FF 26向下到底,此处暂停 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /zhilingji/协议.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1332927388/python-pyqt5-opencv/12338443cc3a2b6e89f9c304601dcd7a7dfde2a1/zhilingji/协议.xlsx -------------------------------------------------------------------------------- /zhilingji/流程综述.txt: -------------------------------------------------------------------------------- 1 | 1.下面的三维抓取机构抓取试管(待测试管)放入离心机进行离心,与此同时10号电机上去,减速电机推出试管架。 2 | 2.上面的三维抓取机构抓取一个试管与一个微柱凝胶卡,放入ABS板上,10号电机将其送下去。 3 | 3.下面的三维抓取机构将离心好的试管同样放入ABS板上 4 | 4.转盘式微量移液机构吸取两支试管所需的液体分别放入微柱凝胶卡的主侧与次侧(主侧:献血者红细胞悬液50ul+患者血清25ul   次侧:患者红细胞悬液50ul+献血者血浆25ul) 5 | 5.下面的三维夹取机构夹取微柱凝胶卡放入孵育机构里面进行孵育 6 | 6.孵育完后,在夹取放入离心机构里进行离心 7 | 7.离心结束抓取去拍照。 --------------------------------------------------------------------------------