修改配置文件,调整寄存器地址定义格式

This commit is contained in:
lixiaoyuan
2025-09-08 19:35:10 +08:00
parent e2995eff92
commit 5c94e2098a
3 changed files with 63 additions and 869 deletions

View File

@@ -36,41 +36,42 @@ def parse_from_file(filename):
if len(data) > 0:
data += ",\n"
data += ("\t\t" + json.dumps(item, ensure_ascii=False))
data += ("\t\t\t" + json.dumps(item, ensure_ascii=False))
return data
addritems = {}
addritems["EMSYT"] = "EMS遥调.txt"
addritems["BCUYX"] = "BCU电池簇遥信.txt"
addritems["BCUYC"] = "BCU电池簇遥测.txt"
addritems["BMSYC"] = "BMS电池堆遥测.txt"
addritems["EMSYX"] = "EMS遥信.txt"
addritems["EMSYC"] = "EMS遥测.txt"
addritems["EMSYT"] = "EMS遥调.txt"
addritems["PCSYX"] = "PCS遥信.txt"
addritems["PCSYC"] = "PCS遥测.txt"
addritems["PCUYX"] = "PCU遥信.txt"
addritems["PCUYC"] = "PCU遥测.txt"
addritems["MEMYC"] = "多功能电表遥测.txt"
addritems["THYC"] = "温湿度状态遥测.txt"
addritems["Fire40YX"] = "消防4.0遥信.txt"
addritems["CoolingYX"] = "冷机遥信.txt"
addritems["CoolingYC"] = "冷机遥测.txt"
addritems["EMS_YT"] = ["EMS遥调.txt", 1]
addritems["BCU_YX"] = ["BCU电池簇遥信.txt", 1]
addritems["BCU_YC"] = ["BCU电池簇遥测.txt", 1]
addritems["BMS_YC"] = ["BMS电池堆遥测.txt", 1]
addritems["EMS_YX"] = ["EMS遥信.txt", 1]
addritems["EMS_YC"] = ["EMS遥测.txt", 1]
addritems["EMS_YT"] = ["EMS遥调.txt", 1]
addritems["PCS_YX"] = ["PCS遥信.txt", 1]
addritems["PCS_YC"] = ["PCS遥测.txt", 1]
addritems["PCU_YX"] = ["PCU遥信.txt", 1]
addritems["PCU_YC"] = ["PCU遥测.txt", 1]
addritems["MEM_YC"] = ["多功能电表遥测.txt", 1]
addritems["TH_YC"] = ["温湿度状态遥测.txt", 1]
addritems["Fire40_YX"] = ["消防4.0遥信.txt", 1]
addritems["Cooling_YX"] = ["冷机遥信.txt", 1]
addritems["Cooling_YC"] = ["冷机遥测.txt", 1]
with open('registeraddr.json', 'w', encoding='utf-8') as f:
f.write("{")
count = 0
index = 0
for key in addritems:
filename = addritems[key]
filename = addritems[key][0]
count = addritems[key][1]
print("parse: ", key, filename)
data = parse_from_file(filename)
if len(data) > 0:
data = "\n" + data + "\n\t"
if count != 0:
if index != 0:
f.write(",")
f.write("\n\t\"" + key + "\": [" + data + "]")
count+=1
f.write("\n\t\"" + key + "\": {\n\t\t\"count\":" + str(count) + ",\n\t\t\"addr\":[" + data + "\t]\n\t}")
index+=1
f.write("\n}")