diff --git a/aio/assets/templates/durable/durable_data_current.xlsx b/aio/assets/templates/durable/durable_data_current.xlsx index 0cb184a..7a7f763 100644 Binary files a/aio/assets/templates/durable/durable_data_current.xlsx and b/aio/assets/templates/durable/durable_data_current.xlsx differ diff --git a/aio/assets/templates/durable/durable_data_current_max.xlsx b/aio/assets/templates/durable/durable_data_current_max.xlsx index f408976..a9e1e5f 100644 Binary files a/aio/assets/templates/durable/durable_data_current_max.xlsx and b/aio/assets/templates/durable/durable_data_current_max.xlsx differ diff --git a/aio/code/durable_action/factory_test.py b/aio/code/durable_action/factory_test.py index cb6e157..3dc30e6 100644 --- a/aio/code/durable_action/factory_test.py +++ b/aio/code/durable_action/factory_test.py @@ -7,6 +7,7 @@ from time import sleep, time, strftime, localtime from pandas import DataFrame from openpyxl import load_workbook from math import sqrt +from numpy import power tab_name = 'Durable Action' count = 0 @@ -215,7 +216,6 @@ def get_durable_data(path, data, scenario_time, wait_time, rcs, hr, w2t): # f_obj.write(f"{_}\n") _d2d_trq = {0: [], 1: [], 2: [], 3: [], 4: [], 5: []} - _d2d_trq_max = {0: [], 1: [], 2: [], 3: [], 4: [], 5: []} for line in _data_list: for item in line['data']: @@ -225,14 +225,24 @@ def get_durable_data(path, data, scenario_time, wait_time, rcs, hr, w2t): _d2d_trq[i].extend(item['value']) if len(_d2d_trq[0]) / 1000 > scenario_time + 1: + this_time = strftime("%Y-%m-%d %H:%M:%S", localtime(time())) + next_time = strftime("%Y-%m-%d %H:%M:%S", localtime(time()+wait_time+10+scenario_time)).split()[-1] _df = DataFrame(_d2d_trq) for i in range(6): - _ = sqrt(100*_df[i].apply(lambda x: (rcs[i]*x/10000)**2).sum()/len(_df[i])) + try: + _ = sqrt(_df[i].apply(lambda x: power((rcs[i]*x/1000), 2)).sum()/len(_df[i])) + except: + _df.to_excel(path+"\\err_data.xlsx") + w2t(f"{i}calculate error", 0, 11, 'red', tab_name) del data[0][f"axis{i + 1}"][0] data[0][f"axis{i + 1}"].append(_) + del data[0]['time'][0] + data[0]['time'].append(next_time) _ = rcs[i] * _df[i].abs().max() / 1000 del data[1][f"axis{i + 1}"][0] data[1][f"axis{i + 1}"].append(_) + del data[1]['time'][0] + data[1]['time'].append(this_time.split()[-1]) _df_1 = DataFrame(data[0]) _df_2 = DataFrame(data[1]) @@ -247,13 +257,11 @@ def get_durable_data(path, data, scenario_time, wait_time, rcs, hr, w2t): sleep(1) global count count += 1 - this_time = strftime("%Y-%m-%d %H:%M:%S", localtime(time())) - next_time = strftime("%Y-%m-%d %H:%M:%S", localtime(time()+wait_time+10+scenario_time)).split()[-1] w2t(f"[{this_time}] 当前次数:{count:09d} | 预计下次数据更新时间:{next_time}", 0, 0, '#008B8B', tab_name) break else: with open(f'{path}\\device_servo_trq_feedback_0.txt', 'w', encoding='utf-8') as f_obj: - for _ in _d2d_trq['device_servo_trq_feedback_0']: + for _ in _d2d_trq[0]: f_obj.write(f"{_}\n") w2t("采集的数据时间长度不够,需要确认。", 0, 2, 'red', tab_name)