[modify]
v0.0.6(2024/05/23) 1. 为了调整多功能框架,aio.py文件将会作为入口程序存在,不实现具体功能,功能的实现将由具体的功能脚本实现,aio.py只负责条件调用 2. 新增了自动化处理电流数据(电机/过载)的功能
This commit is contained in:
parent
7123fa1147
commit
e11dc60438
21
rokae/aio/aio.py
Normal file
21
rokae/aio/aio.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import openpyxl
|
||||||
|
import brake
|
||||||
|
import current
|
||||||
|
|
||||||
|
try:
|
||||||
|
wb_conf = openpyxl.load_workbook('./configs.xlsx', read_only=True)
|
||||||
|
ws_conf = wb_conf['attention']
|
||||||
|
except Exception as Err:
|
||||||
|
msg = "无法在当前路径下找到或打开【configs.xlsx】文件,请确认!"
|
||||||
|
brake.warn_pause_exit(msg, 1, 2)
|
||||||
|
|
||||||
|
func_name = ws_conf['B2'].value
|
||||||
|
if func_name not in wb_conf.sheetnames[1:]:
|
||||||
|
msg = f"主功能选择错误,程序没有{func_name}的功能,请确认后重新输入...."
|
||||||
|
wb_conf.close()
|
||||||
|
brake.warn_pause_exit(msg, 1, 1)
|
||||||
|
else:
|
||||||
|
func_dict = {'brake': brake.main,
|
||||||
|
'current': current.main,
|
||||||
|
}
|
||||||
|
func_dict[func_name]()
|
@ -313,7 +313,7 @@ def execution(args):
|
|||||||
|
|
||||||
time_end = time.time()
|
time_end = time.time()
|
||||||
time_total = time_end - time_start
|
time_total = time_end - time_start
|
||||||
msg = f"数据处理时间:{time_total // 3600:02} h {time_total % 3600 // 60:02} min {time_total % 60:02} s"
|
msg = f"数据处理时间:{time_total // 3600:02} h {time_total % 3600 // 60:02} min {time_total % 60:02.0f} s"
|
||||||
warn_pause_exit(msg, 1, 0)
|
warn_pause_exit(msg, 1, 0)
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
103
rokae/aio/current.py
Normal file
103
rokae/aio/current.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
import openpyxl
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import pandas
|
||||||
|
|
||||||
|
|
||||||
|
def warn_pause_exit(msg, pause_num, exit_num):
|
||||||
|
# 功能:打印告警信息,并推出程序
|
||||||
|
# 参数:告警信息,暂停的次数,退出的值
|
||||||
|
# 返回值:-
|
||||||
|
print(msg + '\n')
|
||||||
|
for i in range(pause_num):
|
||||||
|
_ = input("Press ENTER to continue......\n")
|
||||||
|
sys.exit(exit_num)
|
||||||
|
|
||||||
|
|
||||||
|
def traversal_files(path):
|
||||||
|
# 功能:以列表的形式分别返回指定路径下的文件和文件夹,不包含子目录
|
||||||
|
# 参数:路径
|
||||||
|
# 返回值:路径下的文件夹列表 路径下的文件列表
|
||||||
|
if not os.path.exists(path):
|
||||||
|
msg = f'数据文件夹{path}不存在,请确认后重试......'
|
||||||
|
warn_pause_exit(msg, 1, 11)
|
||||||
|
else:
|
||||||
|
dirs = []
|
||||||
|
files = []
|
||||||
|
for item in os.scandir(path):
|
||||||
|
if item.is_dir():
|
||||||
|
dirs.append(item.path)
|
||||||
|
elif item.is_file():
|
||||||
|
files.append(item.path)
|
||||||
|
|
||||||
|
return dirs, files
|
||||||
|
|
||||||
|
|
||||||
|
def initialization():
|
||||||
|
try:
|
||||||
|
# read init configurations from config file
|
||||||
|
wb_conf = openpyxl.load_workbook('./configs.xlsx', read_only=True)
|
||||||
|
ws_conf = wb_conf['current']
|
||||||
|
except Exception as Err:
|
||||||
|
msg = "无法在当前路径下找到或打开【configs.xlsx】文件,请确认!"
|
||||||
|
warn_pause_exit(msg, 1, 2)
|
||||||
|
|
||||||
|
FUNC = ws_conf.cell(row=2, column=2).value
|
||||||
|
DATA_DIR = ws_conf.cell(row=3, column=2).value
|
||||||
|
AXIS = int(ws_conf.cell(row=4, column=2).value)
|
||||||
|
RC = ws_conf.cell(row=5, column=2).value.split(',')
|
||||||
|
COLUMN = int(ws_conf.cell(row=6, column=2).value)
|
||||||
|
wb_conf.close()
|
||||||
|
|
||||||
|
_, data_files = traversal_files(DATA_DIR)
|
||||||
|
for data_file in data_files:
|
||||||
|
if not data_file.endswith('.data'):
|
||||||
|
msg = f"所有文件必须以 .data 结尾,请检查后重新运行。"
|
||||||
|
warn_pause_exit(msg, 1, 1)
|
||||||
|
|
||||||
|
return data_files, FUNC, RC, COLUMN, AXIS
|
||||||
|
|
||||||
|
|
||||||
|
def current_max(*args):
|
||||||
|
data_files, FUNC, RC, COLUMN, AXIS = args
|
||||||
|
for data_file in data_files:
|
||||||
|
df = pandas.read_csv(data_file, sep='\t')
|
||||||
|
col = df.columns.values[COLUMN-1]
|
||||||
|
c_max = df[col].max()
|
||||||
|
print(f"{data_file}: {c_max/1000*RC[AXIS-1]:.3f}")
|
||||||
|
|
||||||
|
msg = f"数据处理完毕......"
|
||||||
|
warn_pause_exit(msg, 1, 0)
|
||||||
|
|
||||||
|
|
||||||
|
def current_avg(*args):
|
||||||
|
data_files, FUNC, RC, COLUMN, AXIS = args
|
||||||
|
for data_file in data_files:
|
||||||
|
df = pandas.read_csv(data_file, sep='\t')
|
||||||
|
col = df.columns.values[COLUMN-1]
|
||||||
|
c_std = df[col].std()
|
||||||
|
c_avg = df[col].mean()
|
||||||
|
|
||||||
|
axis = int(data_file.split('\\')[-1].split('_')[0].replace('j', ''))
|
||||||
|
print(f"{data_file}: {(abs(c_avg)+c_std)/1000*float(RC[axis-1]):.3f}")
|
||||||
|
|
||||||
|
msg = f"数据处理完毕......"
|
||||||
|
warn_pause_exit(msg, 1, 0)
|
||||||
|
|
||||||
|
|
||||||
|
def full_cycle(*args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
args = initialization()
|
||||||
|
if args[1] == 'max':
|
||||||
|
current_max(*args)
|
||||||
|
elif args[1] == 'avg':
|
||||||
|
current_avg(*args)
|
||||||
|
elif args[1] == 'cycle':
|
||||||
|
full_cycle(*args)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -6,8 +6,8 @@ VSVersionInfo(
|
|||||||
ffi=FixedFileInfo(
|
ffi=FixedFileInfo(
|
||||||
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
|
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
|
||||||
# Set not needed items to zero 0.
|
# Set not needed items to zero 0.
|
||||||
filevers=(0, 0, 5, 1),
|
filevers=(0, 0, 6, 0),
|
||||||
prodvers=(0, 0, 5, 1),
|
prodvers=(0, 0, 6, 0),
|
||||||
# Contains a bitmask that specifies the valid bits 'flags'r
|
# Contains a bitmask that specifies the valid bits 'flags'r
|
||||||
mask=0x3f,
|
mask=0x3f,
|
||||||
# Contains a bitmask that specifies the Boolean attributes of the file.
|
# Contains a bitmask that specifies the Boolean attributes of the file.
|
||||||
@ -31,12 +31,12 @@ VSVersionInfo(
|
|||||||
'040904b0',
|
'040904b0',
|
||||||
[StringStruct('CompanyName', 'Rokae - https://www.rokae.com/'),
|
[StringStruct('CompanyName', 'Rokae - https://www.rokae.com/'),
|
||||||
StringStruct('FileDescription', 'All in one automatic operating tool'),
|
StringStruct('FileDescription', 'All in one automatic operating tool'),
|
||||||
StringStruct('FileVersion', '0.0.5 (2024-05-20)'),
|
StringStruct('FileVersion', '0.0.6 (2024-05-20)'),
|
||||||
StringStruct('InternalName', 'AIO.exe'),
|
StringStruct('InternalName', 'AIO.exe'),
|
||||||
StringStruct('LegalCopyright', '© 2024-2024 Manford Fan'),
|
StringStruct('LegalCopyright', '© 2024-2024 Manford Fan'),
|
||||||
StringStruct('OriginalFilename', 'AIO.exe'),
|
StringStruct('OriginalFilename', 'AIO.exe'),
|
||||||
StringStruct('ProductName', 'AIO'),
|
StringStruct('ProductName', 'AIO'),
|
||||||
StringStruct('ProductVersion', '0.0.5 (2024-05-20)')])
|
StringStruct('ProductVersion', '0.0.6 (2024-05-23)')])
|
||||||
]),
|
]),
|
||||||
VarFileInfo([VarStruct('Translation', [1033, 1200])])
|
VarFileInfo([VarStruct('Translation', [1033, 1200])])
|
||||||
]
|
]
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
pip3 install --upgrade --force-reinstall numpy -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
|
pip3 install --upgrade --force-reinstall numpy -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
|
||||||
打包方法:pyinstaller.exe -F --version-file file_version_info.txt -i .\icon.ico .\aio.py
|
打包方法:pyinstaller.exe -F --version-file file_version_info.txt -i .\icon.ico .\aio.py
|
||||||
最好不用虚拟环境
|
最好不用虚拟环境
|
||||||
|
pyinstaller.exe -F --version-file file_version_info.txt -i .\icon.ico .\aio.py -p .\brake.py -p .\current.py
|
||||||
|
|
||||||
注意事项:
|
注意事项:
|
||||||
1. 数据文件存储存储规则
|
1. 数据文件存储存储规则
|
||||||
@ -102,10 +103,6 @@ v0.0.5(2024/05/23)
|
|||||||
6. 将initialazation中的预定义变量赋值调整到try...except...之外,更方便排查问题
|
6. 将initialazation中的预定义变量赋值调整到try...except...之外,更方便排查问题
|
||||||
7. 修改结束时间的格式,精确到秒
|
7. 修改结束时间的格式,精确到秒
|
||||||
|
|
||||||
|
v0.0.6(2024/05/23)
|
||||||
|
1. 为了调整多功能框架,aio.py文件将会作为入口程序存在,不实现具体功能,功能的实现将由具体的功能脚本实现,aio.py只负责条件调用
|
||||||
v0.x.x(2024/05/xx)
|
2. 新增了自动化处理电流数据(电机/过载)的功能
|
||||||
1. 修改configuration.xlsx变量顺序,同步调整代码,为了调整多功能框架,aio.py文件将会作为入口程序存在,不实现具体功能
|
|
||||||
2. 功能的实现将由具体的功能脚本实现,aio.py只负责条件调用
|
|
||||||
3. 使用pytinstaller打包多文件为exe可执行程序
|
|
||||||
4. 新增了自动化处理电机电流数据的功能
|
|
Loading…
x
Reference in New Issue
Block a user