feat: 优化transfer_mpoint_val_to_ep_running_state

This commit is contained in:
caoqianming 2024-06-26 10:11:43 +08:00
parent 02d672a39d
commit 85bbdd6cd9
1 changed files with 5 additions and 6 deletions

View File

@ -46,12 +46,11 @@ def transfer_mpoint_val_to_ep_running_state(current_val, base_val: float, expr_s
matches = re.findall(pattern, expr_str) matches = re.findall(pattern, expr_str)
for match in matches: for match in matches:
if match == "self": if match == "self":
expr_str = expr_str.replace(f"${{{match}}}", str(current_val)) expr_str = expr_str.replace("{self}", str(current_val))
else: else:
mpoint_data = MpointCache(match).data
if mpoint_data:
match_val = 50 match_val = 50
if mpoint_data.get("gather_state", -2) == 0: # 测点正常采集 mpoint_data = MpointCache(match).data
if mpoint_data and mpoint_data.get("gather_state", -2) == 0: # 测点正常采集
match_val = mpoint_data["last_data"]["last_mrs"] match_val = mpoint_data["last_data"]["last_mrs"]
expr_str = expr_str.replace(f"{{{match}}}", str(match_val)) expr_str = expr_str.replace(f"{{{match}}}", str(match_val))
rval = eval(expr_str) rval = eval(expr_str)