Commit 2989168c authored by ZZH's avatar ZZH

add sta map info 2026-4-27 16:26

parent 111596bd
This diff is collapsed.
......@@ -66,13 +66,13 @@ class Meter3rdForward:
try:
msg_str = payload.decode("utf-8")
data = json.loads(msg_str)
cid = data.get("fId")
if cid:
self.d_last_msg[cid] = msg_str
fId = data.get("fId")
if fId:
self.d_last_msg[fId] = msg_str
except Exception as e:
logger.error(f"Decode msg:{payload} error: {e}")
async def parse_and_forward(self, cid, raw_payload):
async def parse_and_forward(self, fid, raw_payload):
""" 重新封装消息,推送至EMQX """
try:
d_pyds = {}
......@@ -81,9 +81,9 @@ class Meter3rdForward:
for item in data["items"]:
try:
scada_id = item["n"]
if scada_id in SCADA_FIELDS_MAP[cid].keys():
tmp = SCADA_FIELDS_MAP[cid][scada_id]
mid = tmp["sid"]
if scada_id in SCADA_FIELDS_MAP[fid].keys():
tmp = SCADA_FIELDS_MAP[fid][scada_id]
cid, mid = tmp["cid"], tmp["sid"]
tag = {tmp["field"]: item["v"]}
if mid in d_pyds:
d_pyds[mid]["images"][0]["tags"].update(tag)
......@@ -112,9 +112,9 @@ class Meter3rdForward:
cur_batch = dict(self.d_last_msg)
self.d_last_msg.clear()
for cid, raw_msg in cur_batch.items():
if cid in SCADA_FIELDS_MAP:
await self.parse_and_forward(cid, raw_msg)
for fid, raw_msg in cur_batch.items():
if fid in SCADA_FIELDS_MAP:
await self.parse_and_forward(fid, raw_msg)
except Exception as e:
logger.error(f"Processing loop error: {e}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment