补充readme以及release change相关信息,修改clibs.running的逻辑
This commit is contained in:
36
code/aio.py
36
code/aio.py
@ -151,7 +151,7 @@ class App:
|
||||
if self.server_vers is None:
|
||||
return
|
||||
image = ctk.CTkImage(Image.open(f"{clibs.PREFIX}/media/upgrade.png"), size=(16, 16))
|
||||
var_tips.set(f" {self.server_vers.split("@")[0]}已经发布,尽快更新至最新版本! ")
|
||||
var_tips.set(f" {self.server_vers.split('@')[0]}已经发布,尽快更新至最新版本! ")
|
||||
self.label_tips.configure(text_color="#D81E06", image=image, cursor="hand2")
|
||||
self.label_tips.bind("<Button-1>", self.__goto_update)
|
||||
|
||||
@ -274,26 +274,35 @@ class App:
|
||||
def __trig_estop(self):
|
||||
def trig_estop():
|
||||
self.tabview_bottom.set("输出")
|
||||
self.__w2t("触发软急停信号已发送...\n")
|
||||
clibs.c_md.r_soft_estop(0)
|
||||
t = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
try:
|
||||
clibs.c_md.r_soft_estop(0)
|
||||
self.__w2t(f"{t} - 触发软急停信号已发送...\n")
|
||||
except Exception as Err:
|
||||
clibs.insert_logdb("WARNING", "aio", f"触发软急停失败 - {Err}")
|
||||
return
|
||||
try:
|
||||
clibs.c_hr.execution("diagnosis.open", open=False, display_open=False, overrun=True, turn_area=True, delay_motion=False)
|
||||
clibs.c_hr.execution("diagnosis.set_params", display_pdo_params=[], frequency=50, version="1.4.1")
|
||||
except Exception as Err:
|
||||
clibs.insert_logdb("WARNING", "aio", f"关闭诊断曲线失败 - {Err}")
|
||||
if clibs.running:
|
||||
clibs.running = False
|
||||
self.__w2t("程序已停止运行,执行过程中停止时需要清零后台数据,大约一分钟左右后再重新运行!!!\n", "red", "TerminateProgram")
|
||||
if clibs.running > 20:
|
||||
self.__w2t("程序已停止运行,!!执行过程中停止时需要清零后台数据!!:\n- 制动/电机电流测试大约一分钟左右\n- 耐久数据采集需至多等待一个轮次的时间\n\n下次提示出现之后才可重新运行,否则有可能会出现数据错乱的情况!!!\n", "red", "TerminateProgram")
|
||||
clibs.running = 0
|
||||
|
||||
self.__thread_it(trig_estop)
|
||||
|
||||
def __reset_estop(self):
|
||||
def reset_estop():
|
||||
self.tabview_bottom.set("输出")
|
||||
# self.text_output.delete("1.0", "end")
|
||||
self.__w2t("解除软急停信号已发送...\n")
|
||||
clibs.c_md.r_soft_estop(1)
|
||||
clibs.c_md.r_clear_alarm()
|
||||
t = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
try:
|
||||
clibs.c_md.r_soft_estop(1)
|
||||
clibs.c_md.r_clear_alarm()
|
||||
self.__w2t(f"{t} - 解除软急停信号已发送...\n")
|
||||
except Exception as Err:
|
||||
clibs.insert_logdb("WARNING", "aio", f"触发解除软急停失败 - {Err}")
|
||||
|
||||
self.__thread_it(reset_estop)
|
||||
|
||||
@staticmethod
|
||||
@ -342,12 +351,12 @@ class App:
|
||||
self.text_output.insert(ctk.END, text, tags=color)
|
||||
self.text_output.see(ctk.END)
|
||||
if desc:
|
||||
clibs.running = False
|
||||
clibs.running = 0
|
||||
raise Exception(desc)
|
||||
|
||||
@staticmethod
|
||||
def __is_running(operation):
|
||||
if clibs.running:
|
||||
if clibs.running > 0:
|
||||
messagebox.showerror(title="处理中", message=f"有程序正在运行,需等待结束后,在执行{operation}操作!")
|
||||
return "running"
|
||||
|
||||
@ -401,7 +410,6 @@ class App:
|
||||
if init_op() == "running":
|
||||
return
|
||||
|
||||
clibs.running = True
|
||||
try:
|
||||
if self.tabview_top.get() == "数据处理":
|
||||
clibs.data_dp = get_data_dp()
|
||||
@ -415,7 +423,7 @@ class App:
|
||||
except Exception as Err:
|
||||
self.__w2t(f"程序执行过程中出现异常,{Err}\n", "red")
|
||||
finally:
|
||||
clibs.running = False
|
||||
clibs.running = 0
|
||||
clibs.stop = False
|
||||
|
||||
exec_function()
|
||||
|
@ -36,7 +36,7 @@ def initialization(path, sub, data_dirs, data_files, hr, w2t):
|
||||
os.mkdir(f"{path}/j2")
|
||||
os.mkdir(f"{path}/j3")
|
||||
|
||||
load = f"load{sub.removeprefix("tool")}"
|
||||
load = f"load{sub.removeprefix('tool')}"
|
||||
for reach in ["reach33", "reach66", "reach100"]:
|
||||
for speed in ["speed33", "speed66", "speed100"]:
|
||||
dir_name = "_".join([reach, load, speed])
|
||||
@ -211,7 +211,7 @@ def run_rl(path, sub, hr, md, config_file, prj_file, result_dirs, avs, w2t):
|
||||
elif pon == "negative":
|
||||
rl_cmd = f"brake_E(j{axis}_{reach}_n, j{axis}_{reach}_p, p_speed, p_tool)"
|
||||
rl_speed = f"VelSet {speed}"
|
||||
rl_tool = f"tool p_tool = tool{sub.removeprefix("tool")}"
|
||||
rl_tool = f"tool p_tool = tool{sub.removeprefix('tool')}"
|
||||
cmd = "cd /home/luoshi/bin/controller/; "
|
||||
cmd += f'sudo sed -i "/brake_E/d" projects/{prj_name}/_build/brake/main.mod; '
|
||||
cmd += f'sudo sed -i "/DONOTDELETE/i {rl_cmd}" projects/{prj_name}/_build/brake/main.mod; '
|
||||
@ -338,7 +338,7 @@ def run_rl(path, sub, hr, md, config_file, prj_file, result_dirs, avs, w2t):
|
||||
clibs.count = 0
|
||||
break
|
||||
else:
|
||||
w2t(f"\n{sub.removeprefix("tool")}%负载的制动性能测试执行完毕,如需采集其他负载,须切换负载类型,并更换其他负载,重新执行。\n", "green")
|
||||
w2t(f"\n{sub.removeprefix('tool')}%负载的制动性能测试执行完毕,如需采集其他负载,须切换负载类型,并更换其他负载,重新执行。\n", "green")
|
||||
|
||||
|
||||
def main():
|
||||
@ -348,6 +348,7 @@ def main():
|
||||
w2t = clibs.w2t
|
||||
hr = clibs.c_hr
|
||||
md = clibs.c_md
|
||||
clibs.running = 21
|
||||
|
||||
data_dirs, data_files = clibs.traversal_files(path, w2t)
|
||||
config_file, prj_file, result_dirs, avs = initialization(path, sub, data_dirs, data_files, hr, w2t)
|
||||
|
@ -255,6 +255,7 @@ def main():
|
||||
w2t = clibs.w2t
|
||||
hr = clibs.c_hr
|
||||
md = clibs.c_md
|
||||
clibs.running = 22
|
||||
|
||||
data_dirs, data_files = clibs.traversal_files(path, w2t)
|
||||
prj_file = initialization(path, sub, data_dirs, data_files, hr, w2t)
|
||||
|
@ -72,7 +72,7 @@ log_path = f"{PREFIX}/logs"
|
||||
levels = ["DEBUG", "INFO", "WARNING", "ERROR"]
|
||||
db_state = "readwrite"
|
||||
data_dp, data_at, data_dd = {}, {}, {}
|
||||
conn, cursor, w2t, tl_prg, f_records, stop, running = None, None, None, None, None, True, False
|
||||
conn, cursor, w2t, tl_prg, f_records, stop, running = None, None, None, None, None, True, 0
|
||||
|
||||
ip_addr = "192.168.0.160"
|
||||
ssh_port, socket_port, xService_port, external_port, modbus_port, upgrade_port = 22, 5050, 6666, 8080, 502, 4567
|
||||
|
@ -196,6 +196,7 @@ def main():
|
||||
trq = int(clibs.data_dp["_trq"])
|
||||
estop = int(clibs.data_dp["_estop"])
|
||||
w2t = clibs.w2t
|
||||
clibs.running = 1
|
||||
|
||||
rawdata_dirs, result_files = clibs.traversal_files(path, w2t)
|
||||
config_file, result_files = check_files(rawdata_dirs, result_files, w2t)
|
||||
|
@ -412,6 +412,7 @@ def main():
|
||||
trqh = int(clibs.data_dp["_trqh"])
|
||||
sensor = int(clibs.data_dp["_sensor"])
|
||||
w2t = clibs.w2t
|
||||
clibs.running = 2
|
||||
insert_logdb = clibs.insert_logdb
|
||||
insert_logdb("INFO", "current", "current: 参数初始化成功")
|
||||
|
||||
|
@ -135,6 +135,7 @@ def p_iso_1000(file, p_files, ws, tmpfile):
|
||||
def main():
|
||||
path = clibs.data_dp["_path"]
|
||||
w2t = clibs.w2t
|
||||
clibs.running = 3
|
||||
dirs, files = clibs.traversal_files(path, 1)
|
||||
|
||||
filename = f"{path}/iso-results.xlsx"
|
||||
|
@ -145,6 +145,7 @@ def execution(data_files, w2t):
|
||||
def main():
|
||||
path = clibs.data_dp["_path"]
|
||||
w2t = clibs.w2t
|
||||
clibs.running = 4
|
||||
data_files = initialization(path, w2t)
|
||||
execution(data_files, w2t)
|
||||
|
||||
|
@ -60,23 +60,15 @@ def main():
|
||||
for curve in curves:
|
||||
data_plot(path, curve)
|
||||
|
||||
plt.rcParams['font.sans-serif'] = ['SimHei']
|
||||
plt.rcParams['axes.unicode_minus'] = False
|
||||
plt.rcParams['figure.dpi'] = 100
|
||||
plt.rcParams['font.size'] = 14
|
||||
plt.rcParams['lines.marker'] = 'o'
|
||||
plt.rcParams["figure.autolayout"] = True
|
||||
plt.show()
|
||||
|
||||
# threads = [threading.Thread(target=data_plot, args=(path, curve)) for curve in curves]
|
||||
# for t in threads:
|
||||
# t.daemon = True
|
||||
# t.start()
|
||||
# for curve in curves:
|
||||
# t = threading.Thread(target=data_plot, args=(path, curve))
|
||||
# t.daemon = True
|
||||
# t.start()
|
||||
|
||||
plt.rcParams['font.sans-serif'] = ['SimHei']
|
||||
plt.rcParams['axes.unicode_minus'] = False
|
||||
plt.rcParams['figure.dpi'] = 100
|
||||
plt.rcParams['font.size'] = 14
|
||||
plt.rcParams['lines.marker'] = 'o'
|
||||
plt.rcParams["figure.autolayout"] = True
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -140,10 +140,6 @@ def run_rl(path, params, curves, hr, md, w2t):
|
||||
# 7. 开始采集
|
||||
count = 0
|
||||
while clibs.running:
|
||||
if not clibs.running:
|
||||
w2t("后台数据清零完成,现在可以重新运行之前停止的程序。\n", "red")
|
||||
exit()
|
||||
|
||||
this_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
||||
next_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()+scenario_time+interval+1))
|
||||
w2t(f"[{this_time}] 当前次数:{count:09d} | 预计下次数据更新时间:{next_time}\n", "#008B8B")
|
||||
@ -157,6 +153,9 @@ def run_rl(path, params, curves, hr, md, w2t):
|
||||
change_curve_state(hr, curves, False, False)
|
||||
# 保留数据并处理输出
|
||||
gen_results(params, curves, start_time, end_time, w2t)
|
||||
else:
|
||||
w2t("后台数据清零完成,现在可以重新运行之前停止的程序。\n", "red")
|
||||
exit()
|
||||
|
||||
|
||||
def gen_results(params, curves, start_time, end_time, w2t):
|
||||
@ -255,6 +254,7 @@ def main():
|
||||
hr = clibs.c_hr
|
||||
md = clibs.c_md
|
||||
w2t = clibs.w2t
|
||||
clibs.running = 23
|
||||
|
||||
data_dirs, data_files = clibs.traversal_files(path, w2t)
|
||||
params = initialization(path, hr, data_dirs, data_files, interval, curves, w2t)
|
||||
|
Reference in New Issue
Block a user