From 8b49d3b6e4acb704f2e9f79d600d9af4f8587435 Mon Sep 17 00:00:00 2001 From: gitea Date: Fri, 19 Jul 2024 17:19:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86count=E6=81=A2=E5=A4=8D=E4=B8=BA?= =?UTF-8?q?=E5=85=A8=E5=B1=80=E6=A0=87=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aio/code/durable_action/factory_test.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/aio/code/durable_action/factory_test.py b/aio/code/durable_action/factory_test.py index 23f77b8..c596ad5 100644 --- a/aio/code/durable_action/factory_test.py +++ b/aio/code/durable_action/factory_test.py @@ -11,6 +11,7 @@ from numpy import power from csv import writer tab_name = 'Durable Action' +count = 0 durable_data_current_xlsx = f'{dirname(__file__)}/../../assets/templates/durable/durable_data_current.xlsx' durable_data_current_max_xlsx = f'{dirname(__file__)}/../../assets/templates/durable/durable_data_current_max.xlsx' display_pdo_params = [ @@ -103,7 +104,7 @@ def execution(cmd, hr, w2t, **kwargs): return _response -def run_rl(path, config_file, data_all, count, hr, md, w2t): +def run_rl(path, config_file, data_all, hr, md, w2t): # 1. 关闭诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来,切手动模式并下电 _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False) md.trigger_estop() @@ -163,7 +164,7 @@ def run_rl(path, config_file, data_all, count, hr, md, w2t): _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False) sleep(1) # 保证所有数据均已返回 - get_durable_data(path, data_all, scenario_time, wait_time, count, rcs, hr, md, w2t) + get_durable_data(path, data_all, scenario_time, wait_time, rcs, hr, md, w2t) # 7. 继续运行 while True: @@ -175,10 +176,10 @@ def run_rl(path, config_file, data_all, count, hr, md, w2t): _response = execution('diagnosis.open', hr, w2t, open=False, display_open=False) sleep(2) # 保留数据并处理输出 - get_durable_data(path, data_all, scenario_time, wait_time, count, rcs, hr, md, w2t) + get_durable_data(path, data_all, scenario_time, wait_time, rcs, hr, md, w2t) -def get_durable_data(path, data, scenario_time, wait_time, count, rcs, hr, md, w2t): +def get_durable_data(path, data, scenario_time, wait_time, rcs, hr, md, w2t): _data_list = [] for _msg in hr.c_msg: if 'diagnosis.result' in _msg: @@ -270,6 +271,7 @@ def get_durable_data(path, data, scenario_time, wait_time, count, rcs, hr, md, w break else: sleep(1) + global count count += 1 w2t(f"[{this_time}] 当前次数:{count:09d} | 预计下次数据更新时间:{next_time}", 0, 0, '#008B8B', tab_name) break @@ -282,7 +284,6 @@ def get_durable_data(path, data, scenario_time, wait_time, count, rcs, hr, md, w def main(path, hr, md, w2t): - count = 0 durable_data_current = { 'time': list(range(1, 19)), 'axis1': [0 for _ in range(18)], @@ -305,7 +306,7 @@ def main(path, hr, md, w2t): data_dirs, data_files = traversal_files(path, w2t) config_file, prj_file = check_files(data_dirs, data_files, w2t) prj_to_xcore(prj_file) - run_rl(path, config_file, data_all, count, hr, md, w2t) + run_rl(path, config_file, data_all, hr, md, w2t) if __name__ == '__main__':