LISHUZUOXUN_yangjiang/PureBackend/healthy_backend.py

38 lines
1.3 KiB
Python

# coding: gb2312
# 代码编写人:曾忠和
from DeviceDefine.consensus import UNKNOWN
from PureBackend.base_driver import MODEL_MEDIAPIPE
from PureBackend.standard_manager import StandardManager
MAX_HR = "max_hr"
MIN_BO = "min_bo"
HR = "hr"
BO = "bo"
class HealthyBackend(StandardManager):
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)
# 手环状态监控
self.hr_bo_record = {MAX_HR: 0, MIN_BO: 100, HR: 0, BO: 100}
def reset_hr_bo_record(self):
self.hr_bo_record = {MAX_HR: 0, MIN_BO: 100, HR: 0, BO: 100}
def update_hr_bo_record(self, tag_mes):
if tag_mes[HR] != 0:
self.hr_bo_record[HR] = tag_mes[HR]
if self.hr_bo_record[MAX_HR] < tag_mes[HR]:
self.hr_bo_record[MAX_HR] = tag_mes[HR]
if tag_mes[BO] != 0:
self.hr_bo_record[BO] = tag_mes[BO]
if self.hr_bo_record[MIN_BO] > tag_mes[BO]:
self.hr_bo_record[MIN_BO] = tag_mes[BO]
def return_hr_bo_record(self):
return self.hr_bo_record