增加ini 人脸超时限制
This commit is contained in:
@ -68,7 +68,7 @@ def save_user(user_id: int, user_name: str) -> bool:
|
||||
return True
|
||||
|
||||
class UserManageDialog(QDialog):
|
||||
def __init__(self, parent, send_func):
|
||||
def __init__(self, parent=None, send_func=None):
|
||||
super().__init__(parent)
|
||||
self.send_func = send_func
|
||||
uic.loadUi(users_ui_file_path, self)
|
||||
@ -91,7 +91,7 @@ class UserManageDialog(QDialog):
|
||||
def delete_selected(self):
|
||||
row = self.table.currentRow()
|
||||
if row < 0:
|
||||
QMessageBox.warning(self, "提示", "请选择要删除的用户")
|
||||
QMessageBox.warning(self, "提示", "删除选择用户")
|
||||
return
|
||||
uid = self.table.item(row, 0).text()
|
||||
uname = self.table.item(row, 1).text()
|
||||
|
||||
@ -87,6 +87,8 @@ CMD_NAMES = {
|
||||
CMD_GET_VERSION: "获取版本信息",
|
||||
CMD_INIT_ENCRYPTION: "初始化加密",
|
||||
CMD_ENROLL_WITH_PHOTO: "照片录入注册",
|
||||
CMD_FACE_VIEW: "人脸框显示切换",
|
||||
CMD_UVC_VIEW: "视频模式切换",
|
||||
}
|
||||
|
||||
# 结果码名称映射(结果码 -> 中文名称)
|
||||
@ -218,7 +220,7 @@ def build_led_control(state: int) -> bytes:
|
||||
|
||||
#pd_rightaway: int,验证成功后是否立即断电(0=不立即断电,1=立即断电),仅保留低8位有效(通过&0xFF确保)
|
||||
#timeout: int,验证超时时间(单位:秒),范围通常为1-255秒,仅保留低8位有效(通过&0xFF确保)
|
||||
def build_verify(pd_rightaway: int = 0, timeout: int = 10) -> bytes:
|
||||
def build_verify(pd_rightaway, timeout: int = 10) -> bytes:
|
||||
data = struct.pack("BB", pd_rightaway & 0xFF, timeout & 0xFF)
|
||||
return pack_frame(CMD_VERIFY, data)
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -149,7 +149,8 @@ class system_parameter :
|
||||
default_config = {
|
||||
'screen_blanking_time': '360',
|
||||
'system_password': '2008',
|
||||
'language': 'zh_CN'
|
||||
'language': 'zh_CN',
|
||||
"facerecognition_timeout": '10',
|
||||
}
|
||||
|
||||
# 如果配置文件存在,加载配置
|
||||
@ -161,6 +162,7 @@ class system_parameter :
|
||||
self.screen_blanking_time = system_param.get('blanking_time', default_config['screen_blanking_time'])
|
||||
self.system_password = system_param.get('password', default_config['system_password'])
|
||||
self.language = system_param.get('language', default_config['language'])
|
||||
self.facerecognition_timeout = system_param.get('facerecognition_timeout', default_config['facerecognition_timeout'])
|
||||
except (configparser.Error, KeyError) as e:
|
||||
# 处理读取配置文件时的错误
|
||||
print(f"读取配置错误: {e}。使用默认设置。")
|
||||
@ -174,6 +176,7 @@ class system_parameter :
|
||||
self.screen_blanking_time = default_config['screen_blanking_time']
|
||||
self.system_password = default_config['system_password']
|
||||
self.language = default_config['language']
|
||||
self.facerecognition_timeout = default_config['facerecognition_timeout']
|
||||
|
||||
def write_to_ini(self):
|
||||
"""将默认配置写入ini文件。"""
|
||||
@ -181,7 +184,8 @@ class system_parameter :
|
||||
config['SystemParam'] = {
|
||||
'blanking_time': self.screen_blanking_time,
|
||||
'password': self.system_password,
|
||||
'language': self.language
|
||||
'language': self.language,
|
||||
'facerecognition_timeout': self.facerecognition_timeout
|
||||
}
|
||||
with open("system_parameter.ini", 'w') as configfile:
|
||||
config.write(configfile)
|
||||
@ -208,12 +212,21 @@ class system_parameter :
|
||||
def get_system_language(self):
|
||||
return self.language
|
||||
|
||||
def set_verify_timeout(self, timeout):
|
||||
self.facerecognition_timeout = timeout
|
||||
self.write_to_ini()
|
||||
|
||||
def get_verify_timeout(self):
|
||||
return int(self.facerecognition_timeout)
|
||||
|
||||
# 向文件存储系统信息
|
||||
def write_to_ini(self):
|
||||
system_param = configparser.ConfigParser()
|
||||
system_param['SystemParam'] = {'language': self.language,
|
||||
'blanking_time': self.screen_blanking_time,
|
||||
'password': self.system_password}
|
||||
'password': self.system_password,
|
||||
'facerecognition_timeout': self.facerecognition_timeout}
|
||||
|
||||
with open('system_parameter.ini', 'w') as f:
|
||||
system_param.write(f)
|
||||
|
||||
Reference in New Issue
Block a user