From 79797a3bdd1e674e081fd42c06c8261dbcc2272d Mon Sep 17 00:00:00 2001 From: gitea Date: Wed, 26 Jun 2024 21:38:21 +0800 Subject: [PATCH] =?UTF-8?q?20240626=209.=20[aio.py]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=86=E7=89=88=E6=9C=AC=2010.=20[current.py]=20max/avg?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=BB=93=E6=9D=9F=E4=B9=8B=E5=89=8D=E4=BC=9A?= =?UTF-8?q?=E5=B0=86=E7=BB=93=E6=9E=9C=E6=95=B0=E6=8D=AE=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E5=86=99=E5=85=A5=E6=BA=90=E6=96=87=E4=BB=B6=EF=BC=8Cavg?= =?UTF-8?q?=E7=AE=97=E6=B3=95=E6=9B=B4=E6=94=B9=E4=B8=BAaverage+3=C3=97std?= =?UTF-8?q?=2011.=20[wavelogger.py]=20=E7=AE=97=E6=B3=95=E6=9B=B4=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20average+3=C3=97std?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aio/README.md | 3 +++ aio/code/aio.py | 2 +- aio/code/automatic_test/btn_functions.py | 4 ---- aio/code/data_process/current.py | 14 ++++++++++++-- aio/code/data_process/wavelogger.py | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/aio/README.md b/aio/README.md index 8afb13f..d3f6ac9 100644 --- a/aio/README.md +++ b/aio/README.md @@ -304,3 +304,6 @@ v0.1.7.0(2024/06/26)-初步可用 6. [aio.py] 修改了在tabview_click函数中对于实例化openapi的动作,使每次切换标签都会重新实例化,也就是每次都会重新连接,修复显示不正确的问题 7. [openapi.py] 新增了socket关闭的函数,并增加msg_id为None的处理逻辑 8. [btn_functions.py] 完善了状态获取的功能,新增告警获取以及功能切换的逻辑 +9. [aio.py] 修改了版本 +10. [current.py] max/avg功能结束之前会将结果数据追加写入源文件,avg算法更改为average+3×std +11. [wavelogger.py] 算法更改为 average+3×std diff --git a/aio/code/aio.py b/aio/code/aio.py index 8640383..3795c23 100644 --- a/aio/code/aio.py +++ b/aio/code/aio.py @@ -99,7 +99,7 @@ class App(customtkinter.CTk): btns_func['log']['btn'].configure(command=lambda: self.thread_it(self.func_log_callback)) btns_func['end']['btn'].configure(command=lambda: self.thread_it(self.func_end_callback)) # create version info - self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.1.6.3\nDate: 06/18/2024", font=self.my_font, text_color="#4F4F4F") + self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.1.7.0\nDate: 06/26/2024", font=self.my_font, text_color="#4F4F4F") self.frame_func.rowconfigure(6, weight=1) self.label_version.grid(row=6, column=0, padx=20, pady=20, sticky='s') # ===================================================================== diff --git a/aio/code/automatic_test/btn_functions.py b/aio/code/automatic_test/btn_functions.py index 1a0398f..e6a6d51 100644 --- a/aio/code/automatic_test/btn_functions.py +++ b/aio/code/automatic_test/btn_functions.py @@ -1,10 +1,6 @@ import json -import socket -from os.path import dirname from sys import argv -current_path = dirname(__file__) - def validate_resp(_id, response, w2t): match _id: diff --git a/aio/code/data_process/current.py b/aio/code/data_process/current.py index 86343fd..7c2b820 100644 --- a/aio/code/data_process/current.py +++ b/aio/code/data_process/current.py @@ -6,7 +6,7 @@ from pandas import read_csv, concat, set_option from re import match from threading import Thread from time import sleep -from csv import reader +from csv import reader, writer class GetThreadResult(Thread): @@ -99,6 +99,11 @@ def current_max(data_files, rcs, trqh, w2t): current[axis].append(_) w2t(f"{data_file}: {_:.4f}") + with open(data_file, 'a+') as f_data: + csv_writer = writer(f_data) + csv_writer.writerow([''] * 4) + csv_writer.writerow([_]) + for axis, cur in current.items(): if not cur: continue @@ -127,10 +132,15 @@ def current_avg(data_files, rcs, trqh, w2t): c_avg = df[col].mean() scale = 1 if data_file.endswith('.csv') else 1000 - _ = (abs(c_avg)+c_std)/scale*rca + _ = (abs(c_avg)+c_std*3)/scale*rca current[axis].append(_) w2t(f"{data_file}: {_:.4f}") + with open(data_file, 'a+') as f_data: + csv_writer = writer(f_data) + csv_writer.writerow([''] * 4) + csv_writer.writerow([_]) + for axis, cur in current.items(): if not cur: continue diff --git a/aio/code/data_process/wavelogger.py b/aio/code/data_process/wavelogger.py index 4297e85..730d276 100644 --- a/aio/code/data_process/wavelogger.py +++ b/aio/code/data_process/wavelogger.py @@ -136,7 +136,7 @@ def single_file_proc(ws, data_file, df, low, high, cycle, w2t): _row_lt = find_point('forward', _step, 'c'+str(_row), data_file, 'lt', df, _row, w2t) _start = int(_row_gt + (_row_lt - _row_gt - 50) / 2) _end = _start + 50 - value = df.iloc[_start:_end, 2].mean() + df.iloc[_start:_end, 2].std() + value = df.iloc[_start:_end, 2].mean() + 3 * df.iloc[_start:_end, 2].std() _data[count].append(value) else: _row_gt = find_point('forward', _step, 'c'+str(_row), data_file, 'gt', df, _row, w2t)