将count恢复为全局标量
This commit is contained in:
parent
2f782c9693
commit
8b49d3b6e4
@ -11,6 +11,7 @@ from numpy import power
|
|||||||
from csv import writer
|
from csv import writer
|
||||||
|
|
||||||
tab_name = 'Durable Action'
|
tab_name = 'Durable Action'
|
||||||
|
count = 0
|
||||||
durable_data_current_xlsx = f'{dirname(__file__)}/../../assets/templates/durable/durable_data_current.xlsx'
|
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'
|
durable_data_current_max_xlsx = f'{dirname(__file__)}/../../assets/templates/durable/durable_data_current_max.xlsx'
|
||||||
display_pdo_params = [
|
display_pdo_params = [
|
||||||
@ -103,7 +104,7 @@ def execution(cmd, hr, w2t, **kwargs):
|
|||||||
return _response
|
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. 关闭诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来,切手动模式并下电
|
# 1. 关闭诊断曲线,触发软急停,并解除,目的是让可能正在运行着的机器停下来,切手动模式并下电
|
||||||
_response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
|
_response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
|
||||||
md.trigger_estop()
|
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)
|
_response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
|
||||||
sleep(1) # 保证所有数据均已返回
|
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. 继续运行
|
# 7. 继续运行
|
||||||
while True:
|
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)
|
_response = execution('diagnosis.open', hr, w2t, open=False, display_open=False)
|
||||||
sleep(2)
|
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 = []
|
_data_list = []
|
||||||
for _msg in hr.c_msg:
|
for _msg in hr.c_msg:
|
||||||
if 'diagnosis.result' in _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
|
break
|
||||||
else:
|
else:
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
global count
|
||||||
count += 1
|
count += 1
|
||||||
w2t(f"[{this_time}] 当前次数:{count:09d} | 预计下次数据更新时间:{next_time}", 0, 0, '#008B8B', tab_name)
|
w2t(f"[{this_time}] 当前次数:{count:09d} | 预计下次数据更新时间:{next_time}", 0, 0, '#008B8B', tab_name)
|
||||||
break
|
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):
|
def main(path, hr, md, w2t):
|
||||||
count = 0
|
|
||||||
durable_data_current = {
|
durable_data_current = {
|
||||||
'time': list(range(1, 19)),
|
'time': list(range(1, 19)),
|
||||||
'axis1': [0 for _ in range(18)],
|
'axis1': [0 for _ in range(18)],
|
||||||
@ -305,7 +306,7 @@ def main(path, hr, md, w2t):
|
|||||||
data_dirs, data_files = traversal_files(path, w2t)
|
data_dirs, data_files = traversal_files(path, w2t)
|
||||||
config_file, prj_file = check_files(data_dirs, data_files, w2t)
|
config_file, prj_file = check_files(data_dirs, data_files, w2t)
|
||||||
prj_to_xcore(prj_file)
|
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__':
|
if __name__ == '__main__':
|
||||||
|
Reference in New Issue
Block a user