耐久场景测试,将采集规则由固定时间间隔,修改为固定运动动作周期
This commit is contained in:
10
code/aio.py
10
code/aio.py
@ -37,7 +37,7 @@ class App:
|
||||
self.label_pages_logs = ctk.StringVar()
|
||||
self.label_pages_logs.set("-.-.-.-.-.-")
|
||||
self.entry_tips_v = None
|
||||
self.server_vers = None
|
||||
self.server_vers = ""
|
||||
self.tv_cols = {1: ["ID", 1], 2: ["time", 160], 3: ["level", 25], 4: ["module", 30], 5: ["content", 700]}
|
||||
self.chk_box_v = ctk.BooleanVar()
|
||||
self.chk_box_v.set(False)
|
||||
@ -143,12 +143,14 @@ class App:
|
||||
self.label_tips = ctk.CTkLabel(self.frame_status, textvariable=var_tips, compound="left", bg_color="#C9C9C9", font=self.f_status, anchor="e")
|
||||
self.__auth_and_vercheck()
|
||||
if local_vers == self.server_vers:
|
||||
# if True:
|
||||
image = ctk.CTkImage(Image.open(f"{clibs.PREFIX}/media/updated.png"), size=(16, 16))
|
||||
var_tips.set(" 当前是最新版本,继续保持! ")
|
||||
self.label_tips.configure(text_color="#0D8A3D", image=image)
|
||||
else:
|
||||
if self.server_vers is None:
|
||||
elif local_vers > self.server_vers:
|
||||
pass
|
||||
elif local_vers < self.server_vers:
|
||||
if self.server_vers == "":
|
||||
messagebox.showerror(title="错误", message=f"服务器版本校验失败,退出...")
|
||||
return
|
||||
image = ctk.CTkImage(Image.open(f"{clibs.PREFIX}/media/upgrade.png"), size=(16, 16))
|
||||
var_tips.set(f" {self.server_vers.split('@')[0]}已经发布,尽快更新至最新版本! ")
|
||||
|
@ -314,7 +314,7 @@ class ModbusRequest(object):
|
||||
result = self.__c.convert_from_registers(registers=results.registers, data_type=self.__c.DATATYPE.FLOAT32, word_order="little")
|
||||
return result
|
||||
|
||||
def read_brake_done(self):
|
||||
def read_capture_start(self):
|
||||
result = self.__c.read_holding_registers(40603, count=1)
|
||||
return result.registers[0]
|
||||
|
||||
|
@ -4,7 +4,6 @@ import time
|
||||
import pandas
|
||||
import math
|
||||
import csv
|
||||
import numpy
|
||||
from common import clibs
|
||||
|
||||
|
||||
@ -122,12 +121,12 @@ def run_rl(path, params, curves, hr, md, w2t):
|
||||
while True:
|
||||
scenario_time = float(f"{float(md.read_scenario_time()):.2f}")
|
||||
if scenario_time != 0:
|
||||
w2t(f"耐久工程的周期时间:{scenario_time}s | 单轮次执行时间:{scenario_time+interval}\n")
|
||||
w2t(f"耐久工程的周期时间:{scenario_time}s | 单轮次执行时间:{scenario_time+interval}~{scenario_time*2+interval}\n")
|
||||
break
|
||||
else:
|
||||
time.sleep(1)
|
||||
if (time.time() - t_start) > 300:
|
||||
w2t(f"300s 内未收到耐久工程的周期时间,需要确认RL程序和工具通信交互是否正常执行...\n", "red", "GetScenarioTimeError")
|
||||
if (time.time() - t_start) > 900:
|
||||
w2t(f"900s 内未收到耐久工程的周期时间,需要确认RL程序和工具通信交互是否正常执行...\n", "red", "GetScenarioTimeError")
|
||||
|
||||
# 6. 准备数据保存文件
|
||||
for curve in curves:
|
||||
@ -141,11 +140,19 @@ def run_rl(path, params, curves, hr, md, w2t):
|
||||
count = 0
|
||||
while clibs.running:
|
||||
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")
|
||||
next_time_1 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()+scenario_time+interval+1))
|
||||
next_time_2 = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()+scenario_time+interval+1+scenario_time))
|
||||
w2t(f"[{this_time}] 当前次数:{count:09d} | 预计下次数据更新时间:{next_time_1}~{next_time_2}\n", "#008B8B")
|
||||
count += 1
|
||||
# 固定间隔,更新一次数据,打开曲线,获取周期内电流,关闭曲线
|
||||
time.sleep(interval)
|
||||
while True:
|
||||
capture_start = md.read_capture_start()
|
||||
if capture_start == 1:
|
||||
break
|
||||
else:
|
||||
time.sleep(0.1)
|
||||
|
||||
change_curve_state(hr, curves, True, True)
|
||||
time.sleep(scenario_time)
|
||||
end_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
||||
@ -194,7 +201,7 @@ def proc_device_servo_trq_feedback(records, params, w2t):
|
||||
|
||||
for axis in range(6):
|
||||
df = pandas.DataFrame.from_dict({"device_servo_trq_feedback": d_trq[axis]})
|
||||
_ = math.sqrt(df.apply(lambda x: numpy.power((rcs[axis] * float(x.iloc[0]) / 1000), 2)).sum() / len(df))
|
||||
_ = math.sqrt((df[df.columns[0]] * rcs[axis] / 1000).pow(2).sum() / len(df))
|
||||
results.append(_)
|
||||
|
||||
path = "/".join(params["prj_file"].split("/")[:-1])
|
||||
|
Reference in New Issue
Block a user