转向从机型配置文件获取参数

This commit is contained in:
2025-01-14 14:14:33 +08:00
parent 137122947c
commit 0e67a2831c
25 changed files with 524877 additions and 203 deletions

View File

@@ -21,15 +21,16 @@ def traversal_files(_path, _w2t):
return dirs, files
def init_logdb(_conn, _cursor):
_conn = sqlite3.connect(":memory:", isolation_level=None, check_same_thread=False, cached_statements=4096)
_cursor = _conn.cursor()
_cursor.execute("PRAGMA journal_mode=wal")
_cursor.execute("PRAGMA wal_checkpoint=TRUNCATE")
_cursor.execute("PRAGMA synchronous=normal")
_cursor.execute("PRAGMA temp_store=memory")
_cursor.execute("PRAGMA mmap_size=30000000000")
_cursor.execute(
def init_logdb(conn, cursor):
conn = sqlite3.connect(":memory:", isolation_level=None, check_same_thread=False, cached_statements=2048)
cursor = conn.cursor()
cursor.execute("PRAGMA journal_mode=wal")
cursor.execute("PRAGMA wal_checkpoint=TRUNCATE")
cursor.execute("PRAGMA synchronous=normal")
cursor.execute("PRAGMA temp_store=memory")
cursor.execute("PRAGMA mmap_size=30000000000")
cursor.execute("PRAGMA cache_size=200000")
cursor.execute(
"""
create table if not exists logs(
id integer primary key autoincrement,
@@ -40,7 +41,7 @@ def init_logdb(_conn, _cursor):
)
"""
)
return _conn, _cursor
return conn, cursor
def db_lock(func):
@@ -61,7 +62,7 @@ def insert_logdb(_level, _module, _content):
global conn, cursor, lock
if "move.monitor" in _content:
return
data = [_level, _module, repr(_content)]
data = [_level, _module, _content]
cursor.execute("insert into logs (level, module, content) values (?, ?, ?)", data)
@@ -89,7 +90,6 @@ class GetThreadResult(threading.Thread):
def get_result(self):
threading.Thread.join(self) # 等待线程执行完毕
# noinspection PyBroadException
try:
return self.result
except Exception:
@@ -99,35 +99,18 @@ class GetThreadResult(threading.Thread):
# PREFIX = 'assets' # for pyinstaller packaging
PREFIX = '../assets' # for source code testing and debug
log_path = f"{PREFIX}/logs"
conn = None
cursor = None
levels = ["DEBUG", "INFO", "WARNING", "ERROR"]
db_state = "readwrite"
data_dp = {}
data_at = {}
w2t = None
running = False
stop = True
tl_prg = None
f_records = None
data_dp, data_at = {}, {}
conn, cursor, w2t, tl_prg, f_records, stop, running = None, None, None, None, None, True, False
ip_addr = "192.168.0.160"
ssh_port = 22
socket_port = 5050
xService_port = 6666
external_port = 8080
modbus_port = 502
upgrade_port = 4567
username = "luoshi"
password = "luoshi2019" # for real robot
# password = "forpqart" # for robot vm
ssh_port, socket_port, xService_port, external_port, modbus_port, upgrade_port = 22, 5050, 6666, 8080, 502, 4567
username, password = "luoshi", "luoshi2019"
interval = 0.5 # interval after actions being triggered, such as modbus/socket/external communication operations
RADIAN = 57.3 # 180 / 3.1415926
MAX_FRAME_SIZE = 1024
c_md = None
c_hr = None
c_ec = None
c_pd = None
c_md, c_hr, c_ec, c_pd = None, None, None, None
lock = threading.Lock()
conn, cursor = init_logdb(conn, cursor)