完成了电流->转矩的转变,基本完成
This commit is contained in:
@@ -66,42 +66,12 @@ def insert_logdb(_level, _module, _content):
|
||||
cursor.execute("insert into logs (level, module, content) values (?, ?, ?)", data)
|
||||
|
||||
|
||||
def insert_logdb_multi(data):
|
||||
if db_state == "readwrite":
|
||||
global conn, cursor, lock
|
||||
# data = [_level, _module, repr(_content)]
|
||||
# cursor.execute("insert into logs (level, module, content) values (?, ?, ?)", data)
|
||||
try:
|
||||
lock.acquire(True)
|
||||
cursor.executemany("insert into logs (level, module, content) values (?, ?, ?)", data)
|
||||
finally:
|
||||
lock.release()
|
||||
|
||||
|
||||
class GetThreadResult(threading.Thread):
|
||||
def __init__(self, func, args=()):
|
||||
super(GetThreadResult, self).__init__()
|
||||
self.func = func
|
||||
self.args = args
|
||||
self.result = None
|
||||
|
||||
def run(self):
|
||||
self.result = self.func(*self.args)
|
||||
|
||||
def get_result(self):
|
||||
threading.Thread.join(self) # 等待线程执行完毕
|
||||
try:
|
||||
return self.result
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
# PREFIX = 'assets' # for pyinstaller packaging
|
||||
PREFIX = '../assets' # for source code testing and debug
|
||||
log_path = f"{PREFIX}/logs"
|
||||
levels = ["DEBUG", "INFO", "WARNING", "ERROR"]
|
||||
db_state = "readwrite"
|
||||
data_dp, data_at = {}, {}
|
||||
data_dp, data_at, data_dd = {}, {}, {}
|
||||
conn, cursor, w2t, tl_prg, f_records, stop, running = None, None, None, None, None, True, False
|
||||
|
||||
ip_addr = "192.168.0.160"
|
||||
|
||||
Reference in New Issue
Block a user