diff --git a/.gitignore b/.gitignore index 9013072..a02c984 100644 --- a/.gitignore +++ b/.gitignore @@ -7,10 +7,8 @@ aio/venv aio/__pycache__/ aio/code/automatic_test/__pycache__/ aio/code/data_process/__pycache__/ -aio/assets/templates/c_msg.log* aio/code/durable_action/__pycache__/ aio/assets/templates/durable/ -aio/assets/templates/.__c_msg.lock aio/code/commons/__pycache__/ -aio/assets/templates/debug.log +aio/assets/templates/logs/ dial_gauge/results.xlsx diff --git a/aio/README.md b/aio/README.md index f245587..fd9b2d5 100644 --- a/aio/README.md +++ b/aio/README.md @@ -34,7 +34,7 @@ 打包时,只需要修改 clibs.py 中的 PREFIX 即可,调试时再修改回来 ``` -pyinstaller --noconfirm --onedir --windowed --optimize 2 --contents-directory . --upx-dir "D:/Syncthing/common/A_Program/upx-4.2.4-win64/" --add-data "C:/Users/Administrator/AppData/Local/Programs/Python/Python312/Lib/site-packages/customtkinter;customtkinter/" --add-data "D:/Syncthing/company/D-测试工作/X-自动化测试/01-AIO/rokae/aio/assets/templates:templates" --version-file ../assets/file_version_info.txt -i ../assets/icon.ico ../code/aio.py -p ../code/data_process/brake.py -p ../code/data_process/iso.py -p ../code/data_process/current.py -p ../code/data_process/wavelogger.py -p ../code/commons/openapi.py -p ../code/commons/clibs.py -p ../code/automatic_test/btn_functions.py -p ../code/automatic_test/do_current.py -p ../code/automatic_test/do_brake.py -p ../code/durable_action/factory_test.py +pyinstaller --noconfirm --onedir --windowed --optimize 2 --contents-directory . --upx-dir "D:/Syncthing/common/A_Program/upx-4.2.4-win64/" --add-data "C:/Users/Administrator/AppData/Local/Programs/Python/Python312/Lib/site-packages/customtkinter;customtkinter/" --add-data "D:/Syncthing/company/D-测试工作/X-自动化测试/01-AIO/rokae/aio/assets/templates:templates" --version-file ../assets/file_version_info.txt -i ../assets/templates/icon.ico ../code/aio.py -p ../code/data_process/brake.py -p ../code/data_process/iso.py -p ../code/data_process/current.py -p ../code/data_process/wavelogger.py -p ../code/commons/openapi.py -p ../code/commons/clibs.py -p ../code/automatic_test/btn_functions.py -p ../code/automatic_test/do_current.py -p ../code/automatic_test/do_brake.py -p ../code/durable_action/factory_test.py ``` --- @@ -275,7 +275,7 @@ v0.1.5.1(2024/06/12) 5. [requirements.txt] 新增必要库配置文件 v0.1.5.2(2024/06/13) -1. [brake.py/aio.py]: 将sto修改为estop +1. [brake.py/aio.py]: 将sto修改为estop 2. [brake.py] 修改了速度计算逻辑,新版本的vel列数据遵循如下规则,av = vel * 180 / pi,根据av再计算speed 3. [brake.py] 将threshold修改为常量50 4. [brake.py] 提高了输出提示语的明确性,删除了不必要的省略号 @@ -449,18 +449,18 @@ v0.1.7.6(2024/07/04) 3. [APIs: openapi.py] - 增加了modbus读取浮点数的功能 - 优化了get_from_id的逻辑 -4. [autotest.xml]: 新增了scenario_time只写寄存器 +4. [autotest.xml]: 新增了scenario_time只写寄存器 v0.1.8.0(2024/07/04) -1. [APIs: do_current.py]: 完成了堵转电流和惯量负载电机电流的采集和处理,至此,电机电流的自动化工作基本完成 +1. [APIs: do_current.py]: 完成了堵转电流和惯量负载电机电流的采集和处理,至此,电机电流的自动化工作基本完成 v0.1.8.1(2024/07/05) -1. [APIs: do_brake.py]: 完成了制动性能测试框架的搭建,可以顺利执行完整的测试程序,但是未实现急停和数据处理 -2. [APIs: aio.py]: 修改了do_brake主函数的参数 +1. [APIs: do_brake.py]: 完成了制动性能测试框架的搭建,可以顺利执行完整的测试程序,但是未实现急停和数据处理 +2. [APIs: aio.py]: 修改了do_brake主函数的参数 3. 增加工程文件target.zip v0.1.8.2(2024/07/08) -1. [APIs: do_brake.py]: 完成了制动性能测试逻辑,只不过制动信号传递生效延迟不可控,暂时pending +1. [APIs: do_brake.py]: 完成了制动性能测试逻辑,只不过制动信号传递生效延迟不可控,暂时pending 2. [APIs: do_current.py]: 修改曲线数据时序,主要是value data取反即可,解决了波形锯齿明细的问题 3. [APIs: openapi.py]: modbus新增了触发急停信号的寄存器 stop0_signal,并重写了解除急停,socket新增了register.set_value协议 @@ -591,8 +591,8 @@ v0.2.0.5(2024/07/31) - 保持电流,只取最后 15s - 优化 ssh 输入密码的部分 6. [t_change_ui: all the part]: 引入 commons 包,并定制了 logging 输出,后续持续优化 -7. [APIs: btn_functions.py]: 重写了告警输出函数,从日志中拿数据 -8. [APIs: aio.py]: 将日志框输出的内容,也保存至日志文件 +7. [APIs: btn_functions.py]: 重写了告警输出函数,从日志中拿数据 +8. [APIs: aio.py]: 将日志框输出的内容,也保存至日志文件 9. [APIs: do_brake.py] - 修改获取初始速度的逻辑,只获取configs文件中配置的时间内的速度 - 新增 configs 参数 single_brake,可针对特定条件做测试 @@ -617,4 +617,11 @@ v0.2.0.7(2024/08/16) 5. [t_change_ui: layout.xlsx]:修改了组件布局方式 -> 前两个修改点,修复的是网络提示的颜色不正确问题,因为日志将 textbox 中的内容也作为 debug 信息写入 hmi.log 了 \ No newline at end of file +> 前两个修改点,修复的是网络提示的颜色不正确问题,因为日志将 textbox 中的内容也作为 debug 信息写入 hmi.log 了 + +v0.2.0.8(2024/08/20) +1. [t_change_ui: clibs.py] + - 从外部拷贝 icon.ico 文件到 templates 目录 + - 在 assets 目录新建 logs 目录,存放日志文件,并增加了相应的逻辑保证正常执行 +2. [t_change_ui: aio.py]:增加 App 窗口图标代码 +3. [t_change_ui: openapi.py]:将重复输出的网络错误提示,从 textbox 中转移到 debug.log 日志文件中 diff --git a/aio/assets/file_version_info.txt b/aio/assets/file_version_info.txt index 5d84038..24d94f9 100644 --- a/aio/assets/file_version_info.txt +++ b/aio/assets/file_version_info.txt @@ -6,8 +6,8 @@ VSVersionInfo( ffi=FixedFileInfo( # filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4) # Set not needed items to zero 0. - filevers=(0, 2, 0, 7), - prodvers=(0, 2, 0, 7), + filevers=(0, 2, 0, 8), + prodvers=(0, 2, 0, 8), # Contains a bitmask that specifies the valid bits 'flags'r mask=0x3f, # Contains a bitmask that specifies the Boolean attributes of the file. @@ -31,12 +31,12 @@ VSVersionInfo( '040904b0', [StringStruct('CompanyName', 'Rokae - https://www.rokae.com/'), StringStruct('FileDescription', 'All in one automatic toolbox'), - StringStruct('FileVersion', '0.2.0.7 (2024-08-16)'), + StringStruct('FileVersion', '0.2.0.8 (2024-08-20)'), StringStruct('InternalName', 'AIO.exe'), StringStruct('LegalCopyright', '© 2024-2024 Manford Fan'), StringStruct('OriginalFilename', 'AIO.exe'), StringStruct('ProductName', 'AIO'), - StringStruct('ProductVersion', '0.2.0.7 (2024-08-16)')]) + StringStruct('ProductVersion', '0.2.0.8 (2024-08-20)')]) ]), VarFileInfo([VarStruct('Translation', [1033, 1200])]) ] diff --git a/aio/assets/icon.ico b/aio/assets/templates/icon.ico similarity index 100% rename from aio/assets/icon.ico rename to aio/assets/templates/icon.ico diff --git a/aio/assets/vers b/aio/assets/vers index 51d6c3b..b6884c7 100644 --- a/aio/assets/vers +++ b/aio/assets/vers @@ -1 +1 @@ -0.2.0.7 @ 08/16/2024 \ No newline at end of file +0.2.0.8 @ 08/20/2024 \ No newline at end of file diff --git a/aio/code/aio.py b/aio/code/aio.py index 639613b..0fd0f4d 100644 --- a/aio/code/aio.py +++ b/aio/code/aio.py @@ -70,7 +70,7 @@ class App(customtkinter.CTk): # ===================================================================== # configure window self.title("AIO - All in one automatic toolbox") - # self.iconbitmap('./icon.ico') + self.wm_iconbitmap(clibs.app_icon) self.geometry("1200x550+30+30") self.protocol("WM_DELETE_WINDOW", self.func_end_callback) self.config(bg='#E9E9E9') @@ -96,7 +96,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)) # 1.3 create version info - self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.2.0.7\nDate: 08/16/2024", font=self.my_font, text_color="#4F4F4F") + self.label_version = customtkinter.CTkLabel(self.frame_func, justify='left', text="Vers: 0.2.0.8\nDate: 08/20/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/commons/clibs.py b/aio/code/commons/clibs.py index d5919b6..c4b2a35 100644 --- a/aio/code/commons/clibs.py +++ b/aio/code/commons/clibs.py @@ -1,4 +1,4 @@ -from os import scandir +from os import scandir, mkdir from threading import Thread from time import sleep from os.path import exists @@ -17,8 +17,10 @@ setdefaulttimeout(TIMEOUT) tab_names = {'dp': 'Data Process', 'at': 'Automatic Test', 'da': 'Duration Action', 'op': 'openapi'} # PREFIX = '' # for pyinstaller packaging PREFIX = '../assets/' # for source code debug -log_data_hmi = f'{PREFIX}templates/c_msg.log' -log_data_debug = f'{PREFIX}templates/debug.log' +app_icon = f'{PREFIX}templates/icon.ico' +log_path = f'{PREFIX}templates/logs/' +log_data_hmi = f'{PREFIX}templates/logs/c_msg.log' +log_data_debug = f'{PREFIX}templates/logs/debug.log' heartbeat = f'{PREFIX}templates/heartbeat' durable_data_current_xlsx = f'{PREFIX}templates/durable/durable_data_current.xlsx' durable_data_current_max_xlsx = f'{PREFIX}templates/durable/durable_data_current_max.xlsx' @@ -41,6 +43,9 @@ durable_data_current_max = { 'axis6': [0 for _ in range(18)], } +if not exists(log_path): + mkdir(log_path) + # version:表示版本,该键值为从1开始的整数。该key必选,除此之外,其它key都是可选。 # formatters:日志格式化器,其value值为一个字典,该字典的每个键值对都代表一个Formatter,键值对中,key代表Formatter ID(自定义ID),value为字典,描述如何配置相应的Formatter实例。默认格式为 ‘%(message)s’ # filters:日志过滤器,其value值为一个字典,该字典的每个键值对都代表一个Filter,键值对中,key代表Filter ID(自定义ID),value为字典,描述如何配置相应的Filter实例。 diff --git a/aio/code/commons/openapi.py b/aio/code/commons/openapi.py index c0c67a1..fa38b66 100644 --- a/aio/code/commons/openapi.py +++ b/aio/code/commons/openapi.py @@ -203,7 +203,7 @@ class HmiRequest(object): self.c_xs.connect((clibs.ip_addr, 6666)) self.c_xs.setblocking(False) - self.w2t("Connection success", 0, 0, 'green', tab_name=self.tab_name) + logger.info("Connection success...") with open(clibs.heartbeat, "w", encoding='utf-8') as f_hb: f_hb.write('1') md = ModbusRequest(self.w2t) @@ -213,7 +213,7 @@ class HmiRequest(object): md.write_probe(False) md.write_axis(1) except Exception as Err: - self.w2t("Connection failed...", 0, 0, 'red', tab_name=self.tab_name) + logger.info("Connection failed...") with open(clibs.heartbeat, "w", encoding='utf-8') as f_hb: f_hb.write('0') @@ -255,7 +255,7 @@ class HmiRequest(object): with open(clibs.heartbeat, "w", encoding='utf-8') as f_hb: f_hb.write(_flag) if _flag == '0': - self.w2t(f"{_id} 心跳丢失,连接失败,重新连接中...", 0, 7, 'red', tab_name=self.tab_name) + logger.info(f"{_id} 心跳丢失,连接失败,重新连接中...") sleep(2) def msg_storage(self, response, flag=0): @@ -621,7 +621,8 @@ class HmiRequest(object): self.c.send(self.package(cmd)) sleep(0.5) except Exception as Err: - self.w2t(f"{cmd}: 请求发送失败...{Err}", 0, 0, 'red', tab_name=self.tab_name) + # self.w2t(f"{cmd}: 请求发送失败...{Err}", 0, 0, 'red', tab_name=self.tab_name) + logger.info(f"{cmd}: 请求发送失败...{Err}") return req['id']