守护进程识别u盘后自动升级小板程序和方案

分析工具自动生成图像
This commit is contained in:
ranchuan
2023-10-19 18:17:09 +08:00
parent 6fa4ae47f0
commit 51a2cdb11a
5 changed files with 47 additions and 1575 deletions

View File

@@ -76,4 +76,6 @@
2023.10.18
批检仪赋码工具根据设备类型禁用按钮
守护进程添加升级小板功能,升级时蜂鸣器提示
2023.10.19
守护进程识别u盘后自动升级小板程序和方案
分析工具自动生成图像

1
analysis/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.json

View File

@@ -15,6 +15,7 @@ import sys
import scheme_data
import numpy as np
import threading
import os
plt.rcParams['font.sans-serif']=['SimHei']
@@ -29,6 +30,7 @@ class QFigure(QObject):
self.__canvas = FigureCanvas(self.__figure)
self.__ax = self.__figure.add_axes([0.1,0.1,0.8,0.8])
self.__ax.set_title(title)
self._title=title
def draw(self,x,y,lable:str=None,limit_max:int=None,limit_min:int=None):
line,=self.__ax.plot(x,y,)
@@ -46,6 +48,11 @@ class QFigure(QObject):
# self.__ax.yaxis.set_ticks(ticks)
self.__ax.grid(visible=True,which="major",axis="y")
self.__canvas.draw()
def save(self,path:str,perfix:str):
if not os.path.exists(path):
os.makedirs(path)
name=os.path.join(path,perfix+self._title)
self.__figure.savefig(name+'.png')
def lable(self,lablex,labley):
self.__ax.set_ylabel(labley)
self.__ax.set_xlabel(lablex)
@@ -147,7 +154,9 @@ class Analysis(QWidget):
figure.draw(range(len(data)),data,lable="原始值",limit_max=limit_max,limit_min=limit_min)
y=np.add(range(len(dat_count)),min)
figure.draw(dat_count,y,lable="权重")
figure.save(self._save_path,str(self._item_index)+".")
self.__items.append((figure,tplayout))
self._item_index+=1
# 连接的绘制的方法
def import_but_clicked(self):
@@ -159,6 +168,9 @@ class Analysis(QWidget):
if(self.titles==None):
self.__import_but.setEnabled(True)
return
self._item_index=0
self._save_path="file/"+self.sch_data.scheme_name.split('/')[-1].split('.')[0]
print(self._save_path)
for i in range(len(self.titles)):
self.addItem(datas[i],self.titles[i],[self.titles[i]])
widget.setLayout(self.__layout)

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,10 @@ import json
# 定义守护进程
# 2023.10.19
# 检测到插入sd卡时快速响5声
# 升级主板完成后连续响2声
# 小板升级完成后连续响3声
# 日志文件路径
@@ -94,7 +97,8 @@ class cfg(object):
num=self.json_obj["slave_num"]
for i in range(num):
addrs+=str(i+1)+','
return addrs[:-1]
return addrs[:-1]
return addrs
def write_info(text:str):
fm = '%Y-%m-%d %X'
@@ -123,6 +127,7 @@ class auto_updata(object):
if(ack!=self.sd_inserd_state):
if(ack==True):
write_info("sd inserd.")
self.beep_insert()
if(self.copy_file()==True):
time.sleep(5)
self.beep_tip(True)
@@ -148,9 +153,9 @@ class auto_updata(object):
_do_cmd("chmod 777 /usr/local/QDesktop-fb")
_do_cmd("cp "+self.find_file_by_type([".bin"])+" /home/root/config/checker_slave.bin")
_do_cmd("cp "+self.find_file_by_type([".pkt"])+" /home/root/config/checker_slave.pkt")
_do_cmd("cp "+self.find_file_by_type("scheme.json")+" /home/root/config/checker_ye_cfg.json")
_do_cmd("cp "+self.find_file_by_type([".json"])+" /home/root/config/checker_ye_cfg.json")
_do_cmd("cp "+self.file_path+"/cfg.json /home/root/config/cfg.json")
_do_cmd("cp "+self.find_file_by_type(".axf")+" /lib/firmware/checker_m4.axf")
_do_cmd("cp "+self.find_file_by_type([".axf"])+" /lib/firmware/checker_m4.axf")
# _do_cmd("cp "+self.find_file_by_type(".dtb")+" /boot/stm32mp157d-atk.dtb")
_do_cmd("sync")
_do_cmd("systemctl restart atk-qtapp-start.service")
@@ -160,8 +165,9 @@ class auto_updata(object):
for i in self.file_list:
sp=i.split(".")[-1]
sp='.'+sp
if(sp in types):
return self.file_path+'/'+i
if(i!="cfg.json"):
if(sp in types):
return self.file_path+'/'+i
return "unknown"
def updata_slave(self):
cfg_f=cfg()
@@ -183,6 +189,16 @@ class auto_updata(object):
a=u.send_cmd(cmd)
if(a!=None):
write_info("|--| "+a)
slave_file=self.find_file_by_type([".json"])
if(slave_file!="unknown"):
time.sleep(5)
write_info("updata scheme:"+slave_file)
u=myudp()
cmd="mcu scheme "+addrs
a=u.send_cmd(cmd)
if(a!=None):
write_info("|--| "+a)
# 升级完成时的连续三声提示
def beep_end(self):
@@ -193,6 +209,15 @@ class auto_updata(object):
b.power(False)
time.sleep(0.2)
b.close()
# 检测到sd卡插入时连续响5声
def beep_insert(self):
b=beep()
for i in range(5):
b.power(True)
time.sleep(0.05)
b.power(False)
time.sleep(0.1)
b.close()
# 升级时的蜂鸣器提示
def beep_tip(self,power:bool):
if(power==True) and (self.beep_power!=True):