LISHUZUOXUN_yangjiang/PureBackend/runaround_backend.py

46 lines
1.8 KiB
Python

# coding: gb2312
import traceback
from DeviceDefine.consensus import *
from Exercise3.run_around import Runaround
from LogRecord.log_recorder import GLOBAL_LOG
from PureBackend.base_driver import MODEL_MEDIAPIPE
from PureBackend.exam_driver import ExamDriver
from PureBackend.general import *
class RunaroundBackend(ExamDriver):
def __init__(self, master_mode=True, positioning=True, camera=True, model=MODEL_MEDIAPIPE, speaker=True,
multi_positioning_mode=True, device_type=UNKNOWN, pure_mode=False):
super().__init__(master_mode, positioning, camera, model, speaker, multi_positioning_mode, device_type, pure_mode)
if model == MODEL_MEDIAPIPE:
from Exercise3.run_around import Runaround
else:
from Exercise_mn.run_around import Runaround
self.runaround = Runaround
# 准备进行蛇形跑
def active_run_around(self, person_id, band_id):
if self.project:
self.project.kill()
if person_id:
info = self.manager.select_a_person(person_id)[0]
else:
if band_id:
raw_info = self.manager.select_a_person_from_band(band_id)
if not raw_info:
GLOBAL_LOG.write(f"准备进行蛇形跑发生错误: 该手环没有匹配的人员", need_print=True)
return False
info = raw_info[0]
else:
GLOBAL_LOG.write(f"准备进行蛇形跑发生错误: 参数缺失", need_print=True)
return False
try:
self.project = self.runaround(info, camera=self.camera)
self.exercise_tag = RUNAROUND
return True
except Exception as e:
GLOBAL_LOG.write(f"准备进行蛇形跑发生错误,{str(e)},错误来源:{traceback.format_exc()}")
return False