init commit
This commit is contained in:
62
code/common/clibs.py
Normal file
62
code/common/clibs.py
Normal file
@ -0,0 +1,62 @@
|
||||
import os
|
||||
import os.path
|
||||
import threading
|
||||
|
||||
|
||||
def traversal_files(dir_path, signal):
|
||||
# 功能:以列表的形式分别返回指定路径下的文件和文件夹,不包含子目录
|
||||
# 参数:路径/信号/游标/功能编号
|
||||
# 返回值:路径下的文件夹列表 路径下的文件列表
|
||||
global cursor, tb_name
|
||||
|
||||
if not os.path.exists(dir_path):
|
||||
logger("ERROR", "clibs", f"数据文件夹{dir_path}不存在,请确认后重试......", "red", signal=signal)
|
||||
else:
|
||||
dirs, files = [], []
|
||||
for item in os.scandir(dir_path):
|
||||
if item.is_dir():
|
||||
dirs.append(item.path.replace("\\", "/"))
|
||||
elif item.is_file():
|
||||
files.append(item.path.replace("\\", "/"))
|
||||
|
||||
return dirs, files
|
||||
|
||||
|
||||
def db_lock(func):
|
||||
def wrapper(*args, **kwargs):
|
||||
try:
|
||||
lock.acquire(True)
|
||||
ret = func(*args, **kwargs)
|
||||
finally:
|
||||
lock.release()
|
||||
return ret
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@db_lock
|
||||
def logger(level, module, content, color="black", flag="both", signal=""):
|
||||
global cursor, tb_name
|
||||
if flag == "signal":
|
||||
signal.emit(content, color)
|
||||
elif flag == "cursor":
|
||||
cursor.execute(f"INSERT INTO {tb_name} (level, module, content) VALUES (%s, %s, %s)", (level, module, content))
|
||||
elif flag == "both":
|
||||
signal.emit(content, color)
|
||||
cursor.execute(f"INSERT INTO {tb_name} (level, module, content) VALUES (%s, %s, %s)", (level, module, content))
|
||||
|
||||
|
||||
# PREFIX = "assets" # for pyinstaller packaging
|
||||
PREFIX = "../assets" # for source code testing and debug
|
||||
lock = threading.Lock()
|
||||
|
||||
running = [0, 0, 0, 0, 0, 0, 0] # 制动数据/转矩数据/激光数据/精度数据/制动自动化/转矩自动化/耐久数据采集
|
||||
functions = ["制动数据处理", "转矩数据处理", "激光数据处理", "精度数据处理", "制动自动化测试", "转矩自动化测试", "耐久数据采集"]
|
||||
|
||||
log_name = ""
|
||||
ip_addr, ssh_port, socket_port, xService_port, external_port, modbus_port, upgrade_port = "", 22, 5050, 6666, 8080, 502, 4567
|
||||
username, password = "luoshi", "123456"
|
||||
INTERVAL, RADIAN, MAX_FRAME_SIZE, MAX_LOG_NUMBER = 0.5, 57.3, 1024, 10
|
||||
c_md, c_hr, c_ec, c_pd, cursor, tb_name = None, None, None, None, None, ""
|
||||
status = {"mysql": 0, "hmi": 0, "md": 0, "ec": 0}
|
||||
c_joint_vel, c_servo_trq, c_sensor_trq, c_estimate_trans_trq, c_safety_estop = 1, 2, 3, 4, 3 # 各个指标所在列
|
2577
code/common/openapi.py
Normal file
2577
code/common/openapi.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user