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: ...@@ -66,13 +66,13 @@ class Meter3rdForward:
try: try:
msg_str = payload.decode("utf-8") msg_str = payload.decode("utf-8")
data = json.loads(msg_str) data = json.loads(msg_str)
cid = data.get("fId") fId = data.get("fId")
if cid: if fId:
self.d_last_msg[cid] = msg_str self.d_last_msg[fId] = msg_str
except Exception as e: except Exception as e:
logger.error(f"Decode msg:{payload} error: {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 """ """ 重新封装消息,推送至EMQX """
try: try:
d_pyds = {} d_pyds = {}
...@@ -81,9 +81,9 @@ class Meter3rdForward: ...@@ -81,9 +81,9 @@ class Meter3rdForward:
for item in data["items"]: for item in data["items"]:
try: try:
scada_id = item["n"] scada_id = item["n"]
if scada_id in SCADA_FIELDS_MAP[cid].keys(): if scada_id in SCADA_FIELDS_MAP[fid].keys():
tmp = SCADA_FIELDS_MAP[cid][scada_id] tmp = SCADA_FIELDS_MAP[fid][scada_id]
mid = tmp["sid"] cid, mid = tmp["cid"], tmp["sid"]
tag = {tmp["field"]: item["v"]} tag = {tmp["field"]: item["v"]}
if mid in d_pyds: if mid in d_pyds:
d_pyds[mid]["images"][0]["tags"].update(tag) d_pyds[mid]["images"][0]["tags"].update(tag)
...@@ -112,9 +112,9 @@ class Meter3rdForward: ...@@ -112,9 +112,9 @@ class Meter3rdForward:
cur_batch = dict(self.d_last_msg) cur_batch = dict(self.d_last_msg)
self.d_last_msg.clear() self.d_last_msg.clear()
for cid, raw_msg in cur_batch.items(): for fid, raw_msg in cur_batch.items():
if cid in SCADA_FIELDS_MAP: if fid in SCADA_FIELDS_MAP:
await self.parse_and_forward(cid, raw_msg) await self.parse_and_forward(fid, raw_msg)
except Exception as e: except Exception as e:
logger.error(f"Processing loop error: {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