检测后赋码如果返回200也保存赋码结果
添加电机下降按钮 每次赋码结果采用不同的颜色
This commit is contained in:
@@ -86,4 +86,8 @@
|
||||
分析工具添加导出数据和分析结果html文件
|
||||
2023.10.22
|
||||
添加毛刺过滤算法,去除基线漂移算法
|
||||
2023.10.25
|
||||
检测后赋码如果返回200也保存赋码结果
|
||||
添加电机下降按钮
|
||||
每次赋码结果采用不同的颜色
|
||||
|
||||
|
@@ -210,4 +210,14 @@ def show_xy(xy_list:list):
|
||||
ax.legend()
|
||||
index+=1
|
||||
plt.show()
|
||||
show_xy([(x,y2),(x,y3),(x,y4)])
|
||||
# show_xy([(x,y2),(x,y3),(x,y4)])
|
||||
|
||||
|
||||
# def calc_bytes(a,b,c,i,j,k):
|
||||
# ta=((a&((1<<i)-1))<<(16-i))
|
||||
# tb=((b&((1<<j)-1))<<(16-i-j))
|
||||
# tc=((c&((1<<k)-1))<<(16-i-j-k))
|
||||
# t=ta|tb|tc
|
||||
# return bytearray([t>>8,t&0xff])
|
||||
|
||||
# print(calc_bytes(20,15,13,5,7,4).hex(' '))
|
@@ -57,9 +57,10 @@ class coder(QObject):
|
||||
self.autoinc_id=False
|
||||
self.autotest_is_open=0
|
||||
self.uid_length=16
|
||||
self.code_list_backcolor=False
|
||||
self.ser=prot.protu()
|
||||
self.widget = QWidget()
|
||||
self.widget.resize(1500, 800)
|
||||
self.widget.resize(1500, 900)
|
||||
self.widget.setWindowTitle("批检仪赋码工具")
|
||||
self.com_but_init()
|
||||
self.combsp_init()
|
||||
@@ -76,6 +77,7 @@ class coder(QObject):
|
||||
self.autotest_but_init()
|
||||
self.stop_but_init()
|
||||
self.code_but_init()
|
||||
self.moterdown_init()
|
||||
self.recv_handler_table_init()
|
||||
self.device_type_init()
|
||||
self.widget.destroyed.connect(self.quit)
|
||||
@@ -189,7 +191,7 @@ class coder(QObject):
|
||||
# 提示信息
|
||||
def infotext_init(self):
|
||||
self.infotext=QLabel(self.widget)
|
||||
self.infotext.setGeometry(QRect(30, 765, 1200, 15))
|
||||
self.infotext.setGeometry(QRect(30, 865, 1200, 15))
|
||||
self.infotext.setText("请打开串口以开始赋码")
|
||||
def set_infotext(self,text:str):
|
||||
try:
|
||||
@@ -261,7 +263,15 @@ class coder(QObject):
|
||||
self.code_but.setGeometry(QRect(1250, 330, 93, 28))
|
||||
self.code_but.clicked.connect(self.code_but_clicked)
|
||||
self.code_but.setText("赋码")
|
||||
|
||||
|
||||
# 电机下降
|
||||
def moterdown_init(self):
|
||||
self.moterdown=QPushButton(self.widget)
|
||||
self.moterdown.setObjectName(u"moteerup")
|
||||
self.moterdown.setGeometry(QRect(1250, 370, 93, 28))
|
||||
self.moterdown.setText("电机下降")
|
||||
self.moterdown.clicked.connect(self.cmd_moter_down)
|
||||
|
||||
# 初始化设备类型选择框
|
||||
def device_type_init(self):
|
||||
self.device_type_list = QComboBox(self.widget)
|
||||
@@ -281,13 +291,20 @@ class coder(QObject):
|
||||
def code_list_init(self):
|
||||
self.code_list=QTableWidget(self.widget)
|
||||
self.code_list.setObjectName(u"code_list")
|
||||
self.code_list.setGeometry(QRect(30, 50, 1200, 700))
|
||||
self.code_list.setGeometry(QRect(30, 50, 1200, 800))
|
||||
self.code_list.setColumnCount(6)
|
||||
self.code_list.setHorizontalHeaderLabels(list(["创建时间","通道号","注码结果","管壳码","UID","密码"]))
|
||||
self.code_list.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.Stretch)
|
||||
|
||||
# 添加数据
|
||||
def code_list_add(self,code_line:str):
|
||||
stat=self.code_list_backcolor
|
||||
if(stat==True):
|
||||
bkcolor=QColor()
|
||||
bkcolor.setRgb(150,150,150,255)
|
||||
else:
|
||||
bkcolor=QColor()
|
||||
bkcolor.setRgb(255,255,255,255)
|
||||
code_strs=code_line.split(",")
|
||||
errcode=int(code_strs[2])
|
||||
code_strs[2]=cpars.code_errinfo(errcode)
|
||||
@@ -295,8 +312,9 @@ class coder(QObject):
|
||||
self.code_list.insertRow(RowCont)
|
||||
for i in range(6):
|
||||
self.code_list.setItem(RowCont,i,QTableWidgetItem(code_strs[i]))
|
||||
if(errcode!=0):
|
||||
self.code_list.item(RowCont,i).setBackground(Qt.GlobalColor.red)
|
||||
self.code_list.item(RowCont,i).setBackground(bkcolor)
|
||||
if(errcode!=0):
|
||||
self.code_list.item(RowCont,2).setBackground(Qt.GlobalColor.red)
|
||||
# 滚动到底部
|
||||
def code_list_to_bottom(self):
|
||||
self.code_list.scrollToBottom()
|
||||
@@ -580,7 +598,10 @@ class coder(QObject):
|
||||
def cmd_moter_down(self):
|
||||
d=bytearray()
|
||||
d.append(0x03)
|
||||
self.ser.send(0x40,d)
|
||||
try:
|
||||
self.ser.send(0x40,d)
|
||||
except Exception as e:
|
||||
self.set_infotext("发送命令失败,是否没有打开串口?")
|
||||
print("moter down.")
|
||||
|
||||
# 发送赋码指令
|
||||
@@ -671,7 +692,7 @@ class coder(QObject):
|
||||
ack_i=i[1]
|
||||
if(ack_i!=0):
|
||||
# 接触异常则忽略
|
||||
if(ack_i!=3):
|
||||
if((ack_i!=3) and (ack_i!=200)):
|
||||
ack=False
|
||||
str_start=STR_RED
|
||||
print(str_start+"addr:",i[0],"ack:",ack_i,STR_END)
|
||||
@@ -680,6 +701,7 @@ class coder(QObject):
|
||||
print("\t","psw_code:",i[4])
|
||||
acks_list.append(str(ack_i))
|
||||
if(ack==True):
|
||||
self.code_list_backcolor=not self.code_list_backcolor
|
||||
s=""
|
||||
time=get_time()
|
||||
for i in self.code_list_lock:
|
||||
|
@@ -93,7 +93,7 @@ def code_errinfo(errcode:int):
|
||||
s=i.split(":")
|
||||
if(int(s[0])==errcode):
|
||||
return s[1]
|
||||
return "未定义的错误码"
|
||||
return "{d}未定义的错误码".format(d=errcode)
|
||||
|
||||
|
||||
# 通道数
|
||||
|
21
daemon/uart_test.py
Normal file
21
daemon/uart_test.py
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
|
||||
import serial
|
||||
import serial.tools.list_ports
|
||||
|
||||
|
||||
|
||||
|
||||
ser = serial.Serial(port="/dev/ttySTM1", baudrate=115200,bytesize=serial.EIGHTBITS,parity=serial.PARITY_NONE,
|
||||
stopbits=serial.STOPBITS_ONE,timeout=None)
|
||||
|
||||
|
||||
|
||||
# file=open("/dev/ttySTM1","wb")
|
||||
# file.write(b"tVersion.txt=\"V1.04\"")
|
||||
# file.write(bytearray([0xff,0xff,0xff]))
|
||||
|
||||
ser.write(b"tVersion.txt=\"V1.04\"")
|
||||
ser.write(bytearray([0xff,0xff,0xff]))
|
||||
|
||||
|
Reference in New Issue
Block a user