修改MQTT通讯数据解析问题

This commit is contained in:
lixiaoyuan
2025-09-19 18:54:36 +08:00
parent 2ba4ab2781
commit 996cbac88c
27 changed files with 2743 additions and 1415 deletions

View File

@@ -1,8 +1,35 @@
{
"debug":0,
"launchdate": "2025-09-01",
"weburl": "http://127.0.0.1:19601/",
"database": {"host": "localhost", "port": 3306, "user": "root", "passwd": "123456", "dbname": "ess"},
"token":"",
"http": {"port": 19801},
"http": {"token":0, "port": 19801, "encryption":0, "encryptKey":""},
"mqtt": {"host":"mqtt://43.136.119.46:6203","username":"jsyhsec","password":"123456"},
"weburl": "http://127.0.0.1:19601/"
"topic": {
"EMS_YX": {"deviceType":101, "polling":0, "enabled": 1},
"EMS_YC": {"deviceType":101, "polling":0, "enabled": 1},
"EMS_YT": {"deviceType":101, "polling":0, "enabled": 1},
"PCS_YX": {"deviceType":102, "polling":1, "enabled": 1},
"PCS_YC": {"deviceType":102, "polling":1, "enabled": 1},
"PCU_YX": {"deviceType":103, "polling":0, "enabled": 1},
"PCU_YC": {"deviceType":103, "polling":0, "enabled": 1},
"BMS_YX": {"deviceType":104, "polling":0, "enabled": 1},
"BMS_YC": {"deviceType":104, "polling":0, "enabled": 1},
"BCU_YC": {"deviceType":105, "polling":1, "enabled": 1},
"BCU_YX": {"deviceType":105, "polling":1, "enabled": 1},
"MEM_YC": {"deviceType":3, "polling":0, "enabled": 1},
"TH_YC": {"deviceType":10, "polling":1, "enabled": 1},
"Fire40_YX": {"deviceType":7, "polling":1, "enabled": 1},
"Cooling_YC": {"deviceType":14, "polling":1, "enabled": 1},
"Cooling_YX": {"deviceType":14, "polling":1, "enabled": 1},
"Gateway_YX": {"deviceType":15, "polling":1, "enabled": 1},
"Gateway_YC": {"deviceType":15, "polling":1, "enabled": 1},
"Charger_YC": {"deviceType":106, "polling":0, "enabled": 1}
},
"view": {"latitude":0,"longitude":0,"altitude":0},
"video": {
"1":{"host":"", "port":9000, "user":"", "passwd":""}
},
"statistics": {"enabled": 1, "interval": 30}
}

View File

@@ -10,21 +10,21 @@ def read_sheet(wb, topic, sht_name):
sheet = wb[sht_name]
text = ""
for i in range(1, sheet.max_row):
for i in range(2, sheet.max_row+1):
# print(str(sheet.cell(i, 1).value))
addr = read_cell(sheet, i, 8)
name = read_cell(sheet,i, 2)
datatype = read_cell(sheet,i, 4)
unit = read_cell(sheet, i, 5)
is_alert = (read_cell(sheet, i, 7) == "告警")
remark = read_cell(sheet, i, 6)
remark = name + remark
if (len(addr) == 6):
if (len(addr) <= 6 and len(addr) >=2 and addr != "寄存器地址"):
if (len(unit)>0):
remark += '(' + unit + ')'
if (len(text)>0):
text += ',\n'
text += '\t\t\t{"key": "%s", "datatype": "%s", "remark": "%s"}' % (addr, datatype, remark.replace("\n", ""))
text += '\t\t\t{"key": "%s", "datatype": "%s", "alert": %d, "name":"%s", "remark": "%s"}' % (addr, datatype, is_alert, name, remark.replace("\n", ""))
if (len(text)>0):
@@ -53,37 +53,9 @@ text += ',\n' + read_sheet(wb, "TH_YC", "温湿度状态遥测")
text += ',\n' + read_sheet(wb, "Fire40_YX", "消防4.0遥信")
text += ',\n' + read_sheet(wb, "Cooling_YC", "冷机遥测")
text += ',\n' + read_sheet(wb, "Cooling_YX", "冷机遥信")
text += ',\n' + read_sheet(wb, "Gateway_YC", "网关遥测")
text += ',\n' + read_sheet(wb, "Gateway_YX", "网关遥信")
text += ',\n' + read_sheet(wb, "Charger_YC", "充电桩遥测")
with open('regaddrs.json', 'w', encoding='utf-8') as f:
f.write("{\n" + text + "\n}")
def read_sheet_alarm(wb, device_type, sht_name):
sheet = wb[sht_name]
text = ""
for i in range(1, sheet.max_row):
addr = read_cell(sheet, i, 8)
is_alarm = (read_cell(sheet, i, 7) == "告警")
if (len(addr) == 6 and is_alarm) :
name = read_cell(sheet,i, 2)
datatype = read_cell(sheet,i, 4)
unit = read_cell(sheet, i, 5)
remark = read_cell(sheet, i, 6)
remark = name + remark
if (len(unit)>0):
remark += '(' + unit + ')'
if (len(text)>0):
text += ',\n'
text += '\t\t\t{"key": "%s", "datatype": "%s", "remark": "%s"}' % (addr, datatype, remark.replace("\n", ""))
if (len(text)>0):
text = "\n" + text + "\n\t\t"
text = '\t"%s":{\n\t\t"addr":[%s]\n\t}' % (device_type, text)
return text;
text_err = ""
text_err = read_sheet_alarm(wb, 103, "PCU遥信")
text_err += ',\n' + read_sheet_alarm(wb, 104, "PCS遥信")
with open('regddrsErr.json', 'w', encoding='utf-8') as f:
f.write("{\n" + text_err + "\n}")
f.write("{\n" + text + "\n}")

View File

@@ -0,0 +1,890 @@
{
"EMS_YT":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "EMS工作模式0:无效1:本地控制模式, EMS不接受平台调控2:平台控制模式, EMS接收平台调控指令(-)"},
{"key": "0x0002", "datatype": "int16", "remark": "有功功率并网恒功率模式下交流侧功率值:<0: 充电功率0: 静置>0: 放电功率(kW)"},
{"key": "0x0003", "datatype": "uint16", "remark": "PCS开关机0: 关机1: 开机(-)"},
{"key": "0x0004", "datatype": "uint16", "remark": "主控对象储能遥控对象0无效1华云2轻舟"},
{"key": "0x0005", "datatype": "int16", "remark": "A相有功功率(1kW)"},
{"key": "0x0006", "datatype": "int16", "remark": "B相有功功率(1kW)"},
{"key": "0x0007", "datatype": "int16", "remark": "C相有功功率(1kW)"},
{"key": "0x0008", "datatype": "int16", "remark": "三相总有功功率(1kW)"},
{"key": "0x0009", "datatype": "int16", "remark": "A相无功功率(1kVar)"},
{"key": "0x000A", "datatype": "int16", "remark": "B相无功功率(1kVar)"},
{"key": "0x000B", "datatype": "int16", "remark": "C相无功功率(1kVar)"},
{"key": "0x000C", "datatype": "int16", "remark": "三相总无功功率(1kVar)"},
{"key": "0x000D", "datatype": "int16", "remark": "A相电流(0.01A)"},
{"key": "0x000E", "datatype": "int16", "remark": "B相电流(0.01A)"},
{"key": "0x000F", "datatype": "int16", "remark": "C相电流(0.01A)"},
{"key": "0x0010", "datatype": "uint16", "remark": "A相电压(1V)"},
{"key": "0x0011", "datatype": "uint16", "remark": "B相电压(1V)"},
{"key": "0x0012", "datatype": "uint16", "remark": "C相电压(1V)"},
{"key": "0x0013", "datatype": "int16", "remark": "A相交流功率因数(0.01)"},
{"key": "0x0014", "datatype": "int16", "remark": "B相交流功率因数(0.01)"},
{"key": "0x0015", "datatype": "int16", "remark": "C相交流功率因数(0.01)"},
{"key": "0x0016", "datatype": "int16", "remark": "A相视在功率(1kVA)"},
{"key": "0x0017", "datatype": "int16", "remark": "B相视在功率(1kVA)"},
{"key": "0x0018", "datatype": "int16", "remark": "C相视在功率(1kVA)"},
{"key": "0x0019", "datatype": "int16", "remark": "正向总有功总需量(1kW)"},
{"key": "0x001A", "datatype": "int16", "remark": "数据有效性0无效 1有效"},
{"key": "0x001B", "datatype": "uint16", "remark": "EMS工作模式0:无效1:本地控制模式, EMS不接受平台调控2:平台控制模式, EMS接收平台调控指令(-)"},
{"key": "0x001C", "datatype": "uint16", "remark": "有功功率并网恒功率模式下交流侧功率值:功率绝对值 没有正负(kW)"},
{"key": "0x001D", "datatype": "uint16", "remark": "充放电类型0: 关机1: 充电2:放电3:待机(-)"},
{"key": "0x001E", "datatype": "uint16", "remark": "最大SOC"},
{"key": "0x001F", "datatype": "uint16", "remark": "最小SOC"},
{"key": "0x0020", "datatype": "uint16", "remark": "自动并离网0手动1自动"},
{"key": "0x0021", "datatype": "uint16", "remark": "并网离网0并网1离网"}
]
},
"EMS_YX":{
"addr":[
{"key": "0x2001", "datatype": "uint16", "remark": "BMS(电池堆)通信状态0正常1故障"},
{"key": "0x2002", "datatype": "uint64", "remark": "BCU(电池簇)通信状态0正常1故障"},
{"key": "0x2006", "datatype": "uint16", "remark": "PCU(主控)通信状态0正常1故障"},
{"key": "0x2007", "datatype": "uint64", "remark": "PCS(模块)通信状态0正常1故障"},
{"key": "0x200B", "datatype": "uint16", "remark": "电表总接点通信状态0正常1故障"},
{"key": "0x200C", "datatype": "uint32", "remark": "电表通信状态0正常1故障"},
{"key": "0x200E", "datatype": "uint16", "remark": "消防通信状态0正常1故障"},
{"key": "0x200F", "datatype": "uint16", "remark": "UPS通信状态0正常1故障"},
{"key": "0x2010", "datatype": "uint16", "remark": "温湿度总接点通信状态0正常1故障"},
{"key": "0x2011", "datatype": "uint32", "remark": "温湿度通信状态0正常1故障"},
{"key": "0x2013", "datatype": "uint16", "remark": "空调总接点通信状态0正常1故障"},
{"key": "0x2014", "datatype": "uint32", "remark": "空调通信状态0正常1故障"},
{"key": "0x2016", "datatype": "uint16", "remark": "控制干接点(配电系统)状态0开路1闭合"},
{"key": "0x2017", "datatype": "uint16", "remark": "状态干接点(配电系统)状态0开路1闭合"},
{"key": "0x2018", "datatype": "uint16", "remark": "BCU总通信状态0正常 1告警 2故障"},
{"key": "0x2019", "datatype": "uint16", "remark": "PCU总通信状态0正常 1告警 2故障"},
{"key": "0x201A", "datatype": "uint16", "remark": "电表总通信状态0正常 1告警 2故障"},
{"key": "0x201B", "datatype": "uint16", "remark": "消防总通信状态0正常 1告警 2故障"},
{"key": "0x201C", "datatype": "uint16", "remark": "UPS总通信状态0正常 1告警 2故障"},
{"key": "0x201D", "datatype": "uint16", "remark": "温湿度总通信状态0正常 1告警 2故障"},
{"key": "0x201E", "datatype": "uint16", "remark": "空调总通信状态0正常 1告警 2故障"},
{"key": "0x201F", "datatype": "uint16", "remark": "EMU通信状态0正常 1告警 2故障"},
{"key": "0x2020", "datatype": "uint16", "remark": "冷机总通信状态0正常 1告警 2故障"},
{"key": "0x2021", "datatype": "uint16", "remark": "冷机总接点通信状态0正常1故障"},
{"key": "0x2022", "datatype": "uint16", "remark": "冷机通信状态0正常1故障"},
{"key": "0x207A", "datatype": "uint16", "remark": "判断总表的三相总有功 < -5.0fkW 充电 >5.0fkW放电 否则停机0:充电 1:放电 2:停机"}
]
},
"EMS_YC":{
"addr":[
{"key": "0x1001", "datatype": "uint16", "remark": "BMS(电池堆)个数1"},
{"key": "0x1002", "datatype": "uint16", "remark": "BCU通道个数1~2"},
{"key": "0x1003", "datatype": "uint16", "remark": "BCU(电池簇)个数1~40"},
{"key": "0x1004", "datatype": "uint16", "remark": "PCU(主控)个数1~4"},
{"key": "0x1005", "datatype": "uint16", "remark": "PCU通道个数1~4"},
{"key": "0x1006", "datatype": "uint16", "remark": "PCS(模块)个数1~40"},
{"key": "0x1007", "datatype": "uint16", "remark": "电表通道个数1"},
{"key": "0x1008", "datatype": "uint16", "remark": "电表个数1~10"},
{"key": "0x1009", "datatype": "uint16", "remark": "消防通道个数1~10"},
{"key": "0x100A", "datatype": "uint16", "remark": "消防个数1~10"},
{"key": "0x100B", "datatype": "uint16", "remark": "UPS通道个数1~10"},
{"key": "0x100C", "datatype": "uint16", "remark": "UPS个数1~10"},
{"key": "0x100D", "datatype": "uint16", "remark": "温湿度通道个数1"},
{"key": "0x100E", "datatype": "uint16", "remark": "温湿度个数1~10"},
{"key": "0x100F", "datatype": "uint16", "remark": "空调通道个数1"},
{"key": "0x1010", "datatype": "uint16", "remark": "空调个数1~10"},
{"key": "0x1011", "datatype": "uint16", "remark": "控制干接点(配电系统)个数16"},
{"key": "0x1012", "datatype": "uint16", "remark": "状态干接点(配电系统)个数16"},
{"key": "0x1072", "datatype": "uint32", "remark": "系统最大可充电功率(1KW)"},
{"key": "0x1074", "datatype": "uint32", "remark": "系统最大可放电功率(1KW)"},
{"key": "0x1076", "datatype": "uint32", "remark": "储能母线电压(0.1V)"},
{"key": "0x1078", "datatype": "int32", "remark": "储能母线电流(0.1A)"},
{"key": "0x107A", "datatype": "uint16", "remark": "储能系统SOC(0.1)"},
{"key": "0x107B", "datatype": "uint16", "remark": "储能系统SOH(0.1)"},
{"key": "0x107C", "datatype": "uint16", "remark": "电流变比"},
{"key": "0x107D", "datatype": "uint16", "remark": "电压变比"},
{"key": "0x107E", "datatype": "uint32", "remark": "A相电压(1V)"},
{"key": "0x1080", "datatype": "uint32", "remark": "B相电压(1V)"},
{"key": "0x1082", "datatype": "uint32", "remark": "C相电压(1V)"},
{"key": "0x1084", "datatype": "int32", "remark": "A相电流(1A)"},
{"key": "0x1086", "datatype": "int32", "remark": "B相电流(1A)"},
{"key": "0x1088", "datatype": "int32", "remark": "C相电流(1A)"},
{"key": "0x108A", "datatype": "uint32", "remark": "AB相电压(1V)"},
{"key": "0x108C", "datatype": "uint32", "remark": "BC相电压(1V)"},
{"key": "0x108E", "datatype": "uint32", "remark": "CA相电压(1V)"},
{"key": "0x1090", "datatype": "int32", "remark": "A相有功功率(1kW)"},
{"key": "0x1092", "datatype": "int32", "remark": "B相有功功率(1kW)"},
{"key": "0x1094", "datatype": "int32", "remark": "C相有功功率(1kW)"},
{"key": "0x1096", "datatype": "int32", "remark": "三相总有功功率(1kW)"},
{"key": "0x1098", "datatype": "int32", "remark": "当前控制功率(0.1kW)"},
{"key": "0x109A", "datatype": "uint32", "remark": "负荷率(0.01)"},
{"key": "0x109C", "datatype": "uint32", "remark": "三相不平衡度(0.01)"},
{"key": "0x109E", "datatype": "uint32", "remark": "功率因素比率(0.01)"},
{"key": "0x10A0", "datatype": "int32", "remark": "进线开关柜功率(1kW)"},
{"key": "0x10A2", "datatype": "int32", "remark": "用户关口表功率(1kW)"},
{"key": "0x1104", "datatype": "int32", "remark": "正向总有功总需量(1kW)"},
{"key": "0x1106", "datatype": "uint32", "remark": "尖段电价(1RMB)"},
{"key": "0x1108", "datatype": "uint32", "remark": "峰段电价(1RMB)"},
{"key": "0x110A", "datatype": "uint32", "remark": "平段电价(1RMB)"},
{"key": "0x110C", "datatype": "uint32", "remark": "谷段电价(1RMB)"},
{"key": "0x110E", "datatype": "uint32", "remark": "日充电电量(1kWh)"},
{"key": "0x1110", "datatype": "uint32", "remark": "日放电电量(1kWh)"},
{"key": "0x1112", "datatype": "uint32", "remark": "日充电费用(1RMB)"},
{"key": "0x1114", "datatype": "uint32", "remark": "日放电费用(1RMB)"},
{"key": "0x1116", "datatype": "int32", "remark": "日收益(1RMB)"},
{"key": "0x1118", "datatype": "uint32", "remark": "日正向尖有功电能(1kWh)"},
{"key": "0x111A", "datatype": "uint32", "remark": "日正向峰有功电能(1kWh)"},
{"key": "0x111C", "datatype": "uint32", "remark": "日正向平有功电能(1kWh)"},
{"key": "0x111E", "datatype": "uint32", "remark": "日正向谷有功电能(1kWh)"},
{"key": "0x1120", "datatype": "uint32", "remark": "日正向总有功电能(1kWh)"},
{"key": "0x1122", "datatype": "uint32", "remark": "日反向尖有功电能(1kWh)"},
{"key": "0x1124", "datatype": "uint32", "remark": "日反向峰有功电能(1kWh)"},
{"key": "0x1126", "datatype": "uint32", "remark": "日反向平有功电能(1kWh)"},
{"key": "0x1128", "datatype": "uint32", "remark": "日反向谷有功电能(1kWh)"},
{"key": "0x112A", "datatype": "uint32", "remark": "日反向总有功电能(1kWh)"},
{"key": "0x112C", "datatype": "uint32", "remark": "总充电电量(1kWh)"},
{"key": "0x112E", "datatype": "uint32", "remark": "总放电电量(1kWh)"},
{"key": "0x1130", "datatype": "uint32", "remark": "总充电费用(1RMB)"},
{"key": "0x1132", "datatype": "uint32", "remark": "总放电费用(1RMB)"},
{"key": "0x1134", "datatype": "int32", "remark": "总收益(1RMB)"},
{"key": "0x1136", "datatype": "uint32", "remark": "总正向尖有功电能(1kWh)"},
{"key": "0x1138", "datatype": "uint32", "remark": "总正向峰有功电能(1kWh)"},
{"key": "0x113A", "datatype": "uint32", "remark": "总正向平有功电能(1kWh)"},
{"key": "0x113C", "datatype": "uint32", "remark": "总正向谷有功电能(1kWh)"},
{"key": "0x113E", "datatype": "uint32", "remark": "总正向总有功电能(1kWh)"},
{"key": "0x1140", "datatype": "uint32", "remark": "总反向尖有功电能(1kWh)"},
{"key": "0x1142", "datatype": "uint32", "remark": "总反向峰有功电能(1kWh)"},
{"key": "0x1144", "datatype": "uint32", "remark": "总反向平有功电能(1kWh)"},
{"key": "0x1146", "datatype": "uint32", "remark": "总反向谷有功电能(1kWh)"},
{"key": "0x1148", "datatype": "uint32", "remark": "总反向总有功电能(1kWh)"},
{"key": "0x11AE", "datatype": "int16", "remark": "交流A相电压(1V)"},
{"key": "0x11AF", "datatype": "int16", "remark": "交流B相电压(1V)"},
{"key": "0x11B0", "datatype": "int16", "remark": "交流C相电压(1V)"},
{"key": "0x11B1", "datatype": "int16", "remark": "交流A相频率(1Hz)"},
{"key": "0x11B2", "datatype": "int16", "remark": "交流B相频率(1Hz)"},
{"key": "0x11B3", "datatype": "int16", "remark": "交流C相频率(1Hz)"},
{"key": "0x11B4", "datatype": "int32", "remark": "总直流功率(1kW)"},
{"key": "0x11B6", "datatype": "uint32", "remark": "总直流电压(0.1V)"},
{"key": "0x11B8", "datatype": "int32", "remark": "总直流电流(0.1A)"},
{"key": "0x121B", "datatype": "int16", "remark": "储能系统温度(0.1℃)"},
{"key": "0x121C", "datatype": "uint16", "remark": "储能充放电时段hh(时)"},
{"key": "0x121D", "datatype": "uint16", "remark": "储能充放电时段mm(分)"},
{"key": "0x121E", "datatype": "uint16", "remark": "储能充放电时段ss(秒)"}
]
},
"PCU_YC":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "所属通道号1~4"},
{"key": "0x0002", "datatype": "uint32", "remark": "充电功率最大许可(1KW)"},
{"key": "0x0004", "datatype": "uint32", "remark": "放电功率最大许可(1KW)"},
{"key": "0x0006", "datatype": "uint32", "remark": "交流日总充电量(1KWh)"},
{"key": "0x0008", "datatype": "uint32", "remark": "交流日总放电量(1KWh)"},
{"key": "0x000A", "datatype": "uint32", "remark": "交流总充电量(1KWh)"},
{"key": "0x000C", "datatype": "uint32", "remark": "交流总放电量(1KWh)"},
{"key": "0x000E", "datatype": "int16", "remark": "有功功率期望值(1KW)"},
{"key": "0x000F", "datatype": "int16", "remark": "无功功率期望值(1kVar)"},
{"key": "0x0010", "datatype": "int16", "remark": "PCS侧线电压VAB(1v)"},
{"key": "0x0011", "datatype": "int16", "remark": "PCS侧线电压VBC(1v)"},
{"key": "0x0012", "datatype": "int16", "remark": "PCS侧线电压VCA(1v)"},
{"key": "0x0013", "datatype": "int16", "remark": "PCS侧线A相电压(1v)"},
{"key": "0x0014", "datatype": "int16", "remark": "PCS侧线B相电压(1v)"},
{"key": "0x0015", "datatype": "int16", "remark": "PCS侧线C相电压(1v)"},
{"key": "0x0016", "datatype": "int16", "remark": "PCS侧A相频率(1Hz)"},
{"key": "0x0017", "datatype": "int16", "remark": "PCS侧B相频率(1Hz)"},
{"key": "0x0018", "datatype": "int16", "remark": "PCS侧C相频率(1Hz)"},
{"key": "0x0019", "datatype": "int16", "remark": "PCS侧功率因数A(1)"},
{"key": "0x001A", "datatype": "int16", "remark": "PCS侧功率因数B(1)"},
{"key": "0x001B", "datatype": "int16", "remark": "PCS侧功率因数C(1)"},
{"key": "0x001C", "datatype": "int16", "remark": "PCS侧相电流A(1A)"},
{"key": "0x001D", "datatype": "int16", "remark": "PCS侧相电流B(1A)"},
{"key": "0x001E", "datatype": "int16", "remark": "PCS侧相电流C(1A)"},
{"key": "0x001F", "datatype": "int16", "remark": "PCS侧有功功率A(1kW)"},
{"key": "0x0020", "datatype": "int16", "remark": "PCS侧有功功率B(1kW)"},
{"key": "0x0021", "datatype": "int16", "remark": "PCS侧有功功率C(1kW)"},
{"key": "0x0022", "datatype": "int16", "remark": "PCS侧无功功率A(1kVar)"},
{"key": "0x0023", "datatype": "int16", "remark": "PCS侧无功功率B(1kVar)"},
{"key": "0x0024", "datatype": "int16", "remark": "PCS侧无功功率C(1kVar)"},
{"key": "0x0025", "datatype": "int16", "remark": "PCS侧视在功率A(1kVar)"},
{"key": "0x0026", "datatype": "int16", "remark": "PCS侧视在功率B(1kVar)"},
{"key": "0x0027", "datatype": "int16", "remark": "PCS侧视在功率C(1kVar)"},
{"key": "0x0028", "datatype": "int16", "remark": "PCS侧三相总有功功率(1kW)"},
{"key": "0x0029", "datatype": "int16", "remark": "PCS侧三相总无功功率(1kVar)"},
{"key": "0x002A", "datatype": "int16", "remark": "PCS侧三相总视在功率(1kVA)"},
{"key": "0x002B", "datatype": "int16", "remark": "PCS侧三相总功率因数(1)"},
{"key": "0x002C", "datatype": "int16", "remark": "PCU模块温度(1℃)"},
{"key": "0x002D", "datatype": "int16", "remark": "外部温度NTC1(1℃)"},
{"key": "0x002E", "datatype": "int16", "remark": "外部温度NTC2(1℃)"},
{"key": "0x002F", "datatype": "int16", "remark": "外部温度NTC3(1℃)"},
{"key": "0x0030", "datatype": "int16", "remark": "台区负载侧A相电流(1A)"},
{"key": "0x0031", "datatype": "int16", "remark": "台区负载侧B相电流(1A)"},
{"key": "0x0032", "datatype": "int16", "remark": "台区负载侧C相电流(1A)"},
{"key": "0x0033", "datatype": "int16", "remark": "台区负载侧A相有功功率(1kW)"},
{"key": "0x0034", "datatype": "int16", "remark": "台区负载侧B相有功功率(1kW)"},
{"key": "0x0035", "datatype": "int16", "remark": "台区负载侧C相有功功率(1kW)"},
{"key": "0x0036", "datatype": "int16", "remark": "台区负载侧总有功功率(1kW)"},
{"key": "0x0037", "datatype": "int16", "remark": "台区负载侧A相无功功率(1kVar)"},
{"key": "0x0038", "datatype": "int16", "remark": "台区负载侧B相无功功率(1kVar)"},
{"key": "0x0039", "datatype": "int16", "remark": "台区负载侧C相无功功率(1kVar)"},
{"key": "0x003A", "datatype": "int16", "remark": "台区负载侧总无功功率(1kVar)"},
{"key": "0x003B", "datatype": "int16", "remark": "台区负载侧A相视在功率(1kVA)"},
{"key": "0x003C", "datatype": "int16", "remark": "台区负载侧B相视在功率(1kVA)"},
{"key": "0x003D", "datatype": "int16", "remark": "台区负载侧C相视在功率(1kVA)"},
{"key": "0x003E", "datatype": "int16", "remark": "台区负载侧总视在功率(1kVA)"},
{"key": "0x003F", "datatype": "int16", "remark": "台区负载侧A相功率因数(1)"},
{"key": "0x0040", "datatype": "int16", "remark": "台区负载侧B相功率因数(1)"},
{"key": "0x0041", "datatype": "int16", "remark": "台区负载侧C相功率因数(1)"},
{"key": "0x0042", "datatype": "int16", "remark": "台区负载侧总功率因数(1)"},
{"key": "0x0043", "datatype": "int16", "remark": "负载侧线电压AB(1V)"},
{"key": "0x0044", "datatype": "int16", "remark": "负载侧线电压BC(1V)"},
{"key": "0x0045", "datatype": "int16", "remark": "负载侧线电压CA(1V)"},
{"key": "0x0046", "datatype": "int16", "remark": "负载侧相电压AN(1V)"},
{"key": "0x0047", "datatype": "int16", "remark": "负载侧相电压BN(1V)"},
{"key": "0x0048", "datatype": "int16", "remark": "负载侧相电压CN(1V)"},
{"key": "0x0049", "datatype": "int16", "remark": "负载侧A功率因素(1)"},
{"key": "0x004A", "datatype": "int16", "remark": "负载侧B功率因素(1)"},
{"key": "0x004B", "datatype": "int16", "remark": "负载侧C功率因素(1)"},
{"key": "0x004C", "datatype": "int16", "remark": "负载侧A视在功率(1kVA)"},
{"key": "0x004D", "datatype": "int16", "remark": "负载侧B视在功率(1kVA)"}
]
},
"PCU_YX":{
"addr":[
{"key": "0x1001", "datatype": "uint16", "remark": "所属通道号1~4"},
{"key": "0x1002", "datatype": "uint16", "remark": "故障状态1故障0正常"},
{"key": "0x1003", "datatype": "uint16", "remark": "告警状态1告警0正常"},
{"key": "0x1004", "datatype": "uint16", "remark": "设备在线1在线0无效"},
{"key": "0x1005", "datatype": "uint16", "remark": "本地远程1本地0远程"},
{"key": "0x1006", "datatype": "uint16", "remark": "启停状态1开机0关机"},
{"key": "0x1007", "datatype": "uint16", "remark": "电网状态1离网0并网"},
{"key": "0x1008", "datatype": "uint16", "remark": "模块状态1开机0待机"},
{"key": "0x1009", "datatype": "uint16", "remark": "EPO急停1故障0正常"},
{"key": "0x100A", "datatype": "uint16", "remark": "防雷器异常1告警0正常"},
{"key": "0x100B", "datatype": "uint16", "remark": "负载电压反序1故障0正常"},
{"key": "0x100C", "datatype": "uint16", "remark": "市电电压反序1故障0正常"},
{"key": "0x100D", "datatype": "uint16", "remark": "输出相反序1故障0正常"},
{"key": "0x100E", "datatype": "uint16", "remark": "过载告警1告警0正常"},
{"key": "0x100F", "datatype": "uint16", "remark": "过载超时1故障0正常"},
{"key": "0x1010", "datatype": "uint16", "remark": "交流过流保护1故障0正常"},
{"key": "0x1011", "datatype": "uint16", "remark": "逆变电压异常1故障0正常"},
{"key": "0x1012", "datatype": "uint16", "remark": "内部串口异常1故障0正常"},
{"key": "0x1013", "datatype": "uint16", "remark": "485通信故障1故障0正常"},
{"key": "0x1014", "datatype": "uint16", "remark": "CAN通信故障1故障0正常"},
{"key": "0x1015", "datatype": "uint16", "remark": "E2PROM故障1故障0正常"},
{"key": "0x1016", "datatype": "uint16", "remark": "电网过压1故障0正常"},
{"key": "0x1017", "datatype": "uint16", "remark": "电网欠压1故障0正常"},
{"key": "0x1018", "datatype": "uint16", "remark": "电网过频1故障0正常"},
{"key": "0x1019", "datatype": "uint16", "remark": "电网欠频1故障0正常"},
{"key": "0x101A", "datatype": "uint16", "remark": "电网快检综合异常1故障0正常"},
{"key": "0x101B", "datatype": "uint16", "remark": "电网幅值快检异常1故障0正常"},
{"key": "0x101C", "datatype": "uint16", "remark": "电网拖尾异常1故障0正常"},
{"key": "0x101D", "datatype": "uint16", "remark": "消防输入信号NO1闭合0断开"},
{"key": "0x101E", "datatype": "uint16", "remark": "急停按钮信号NC1急停0正常"},
{"key": "0x101F", "datatype": "uint16", "remark": "避雷器NC1故障0正常"},
{"key": "0x1020", "datatype": "uint16", "remark": "避雷器断路器NC1故障0正常"},
{"key": "0x1021", "datatype": "uint16", "remark": "PCS总断路器NC1闭合0断开"},
{"key": "0x1022", "datatype": "uint16", "remark": "电操状态NO1闭合0断开"},
{"key": "0x1023", "datatype": "uint16", "remark": "远程关机NO1开机0无效"},
{"key": "0x1024", "datatype": "uint16", "remark": "远程开机NO1开机0无效"},
{"key": "0x1025", "datatype": "uint16", "remark": "BA故障信号NO1故障0正常"},
{"key": "0x1026", "datatype": "uint16", "remark": "PCS_01状态1在线0掉线"},
{"key": "0x1027", "datatype": "uint16", "remark": "PCS_02状态1在线0掉线"},
{"key": "0x1028", "datatype": "uint16", "remark": "PCS_03状态1在线0掉线"},
{"key": "0x1029", "datatype": "uint16", "remark": "PCS_04状态1在线0掉线"},
{"key": "0x102A", "datatype": "uint16", "remark": "PCS_05状态1在线0掉线"},
{"key": "0x102B", "datatype": "uint16", "remark": "PCS_06状态1在线0掉线"},
{"key": "0x102C", "datatype": "uint16", "remark": "PCS_07状态1在线0掉线"},
{"key": "0x102D", "datatype": "uint16", "remark": "PCS_09状态1在线0掉线"},
{"key": "0x102E", "datatype": "uint16", "remark": "PCS_10状态1在线0掉线"},
{"key": "0x102F", "datatype": "uint16", "remark": "PCS_01下发设置1故障0正常"},
{"key": "0x1030", "datatype": "uint16", "remark": "PCS_02下发设置1故障0正常"},
{"key": "0x1031", "datatype": "uint16", "remark": "PCS_03下发设置1故障0正常"},
{"key": "0x1032", "datatype": "uint16", "remark": "PCS_04下发设置1故障0正常"},
{"key": "0x1033", "datatype": "uint16", "remark": "PCS_05下发设置1故障0正常"},
{"key": "0x1034", "datatype": "uint16", "remark": "PCS_06下发设置1故障0正常"},
{"key": "0x1035", "datatype": "uint16", "remark": "PCS_07下发设置1故障0正常"},
{"key": "0x1036", "datatype": "uint16", "remark": "PCS_08下发设置1故障0正常"},
{"key": "0x1037", "datatype": "uint16", "remark": "PCS_09下发设置1故障0正常"},
{"key": "0x1038", "datatype": "uint16", "remark": "PCS_10下发设置1:故障0正常"},
{"key": "0x1039", "datatype": "uint16", "remark": "内部DSP通信故障1:故障0正常"},
{"key": "0x103A", "datatype": "uint16", "remark": "BMS CAN通信故障1:故障0正常"}
]
},
"PCS_YC":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "所属主控号1~4"},
{"key": "0x0002", "datatype": "uint16", "remark": "所属PCS号1~40"},
{"key": "0x0003", "datatype": "uint32", "remark": "总充电量(1kWh)"},
{"key": "0x0005", "datatype": "uint32", "remark": "总放电量(1kWh)"},
{"key": "0x0007", "datatype": "int16", "remark": "散热器温度(1℃)"},
{"key": "0x0008", "datatype": "int16", "remark": "内部温度(1℃)"},
{"key": "0x0009", "datatype": "int16", "remark": "最大允许充电功率(0.1kW)"},
{"key": "0x000A", "datatype": "int16", "remark": "最大允许放电功率(0.1kW)"},
{"key": "0x000B", "datatype": "int16", "remark": "有功功率期望(1kWh)"},
{"key": "0x000C", "datatype": "int16", "remark": "无功功率期望(1kVar)"},
{"key": "0x000D", "datatype": "int16", "remark": "AB线电压(1V)"},
{"key": "0x000E", "datatype": "int16", "remark": "BC线电压(1V)"},
{"key": "0x000F", "datatype": "int16", "remark": "CA线电压(1V)"},
{"key": "0x0010", "datatype": "int16", "remark": "A相电压(1V)"},
{"key": "0x0011", "datatype": "int16", "remark": "B相电压(1V)"},
{"key": "0x0012", "datatype": "int16", "remark": "C相电压(1V)"},
{"key": "0x0013", "datatype": "int16", "remark": "A相频率(1Hz)"},
{"key": "0x0014", "datatype": "int16", "remark": "B相频率(1Hz)"},
{"key": "0x0015", "datatype": "int16", "remark": "C相频率(1Hz)"},
{"key": "0x0016", "datatype": "int16", "remark": "A相功率因数(1)"},
{"key": "0x0017", "datatype": "int16", "remark": "B相功率因数(1)"},
{"key": "0x0018", "datatype": "int16", "remark": "C相功率因数(1)"},
{"key": "0x0019", "datatype": "int16", "remark": "A相电流(1A)"},
{"key": "0x001A", "datatype": "int16", "remark": "B相电流(1A)"},
{"key": "0x001B", "datatype": "int16", "remark": "C相电流(1A)"},
{"key": "0x001C", "datatype": "int16", "remark": "A相有功功率(1kW)"},
{"key": "0x001D", "datatype": "int16", "remark": "B相有功功率(1kW)"},
{"key": "0x001E", "datatype": "int16", "remark": "C相有功功率(1kW)"},
{"key": "0x001F", "datatype": "int16", "remark": "A相无功功率(1kVar)"},
{"key": "0x0020", "datatype": "int16", "remark": "B相无功功率(1kVar)"},
{"key": "0x0021", "datatype": "int16", "remark": "C相无功功率(1kVar)"},
{"key": "0x0022", "datatype": "int16", "remark": "A相视在功率(1kVA)"},
{"key": "0x0023", "datatype": "int16", "remark": "B相视在功率(1kVA)"},
{"key": "0x0024", "datatype": "int16", "remark": "C相视在功率(1kVA)"},
{"key": "0x0025", "datatype": "int16", "remark": "三相总有功功率(1kW)"},
{"key": "0x0026", "datatype": "int16", "remark": "三相总无功功率(1kVar)"},
{"key": "0x0027", "datatype": "int16", "remark": "三相总视在功率(1kVA)"},
{"key": "0x0028", "datatype": "int16", "remark": "三相总功率因数(1)"},
{"key": "0x0029", "datatype": "int16", "remark": "直流功率(1kW)"},
{"key": "0x002A", "datatype": "int16", "remark": "直流电压(1V)"},
{"key": "0x002B", "datatype": "int16", "remark": "直流电流(1A)"},
{"key": "0x002C", "datatype": "int16", "remark": "充电功率(1kW)"},
{"key": "0x002D", "datatype": "int16", "remark": "放电功率(1kW)"},
{"key": "0x002E", "datatype": "int16", "remark": "PF值(1)"},
{"key": "0x002F", "datatype": "int16", "remark": "UV线/U相电网计量线电压(1V)"},
{"key": "0x0030", "datatype": "int16", "remark": "VW线/V相电网计量线电压(1V)"},
{"key": "0x0031", "datatype": "int16", "remark": "WU线/W相电网计量线电压(1V)"},
{"key": "0x0032", "datatype": "int16", "remark": "U相电网计量电流(1A)"},
{"key": "0x0033", "datatype": "int16", "remark": "V相电网计量电流(1A)"},
{"key": "0x0034", "datatype": "int16", "remark": "W相电网计量电流(1A)"},
{"key": "0x0035", "datatype": "int16", "remark": "正母线电压(1V)"},
{"key": "0x0036", "datatype": "int16", "remark": "可用功率(1kVA)"},
{"key": "0x0037", "datatype": "int16", "remark": "负母线电压(1V)"},
{"key": "0x0038", "datatype": "int16", "remark": "A相IGBT温度(1℃)"},
{"key": "0x0039", "datatype": "int16", "remark": "B相IGBT温度(1℃)"},
{"key": "0x003A", "datatype": "int16", "remark": "C相IGBT温度(1℃)"},
{"key": "0x003B", "datatype": "int16", "remark": "逆变侧AB线电压(1V)"},
{"key": "0x003C", "datatype": "int16", "remark": "逆变侧BC线电压(1V)"},
{"key": "0x003D", "datatype": "int16", "remark": "逆变侧CA线电压(1V)"},
{"key": "0x003E", "datatype": "int16", "remark": "逆变侧A相电压(1V)"},
{"key": "0x003F", "datatype": "int16", "remark": "逆变侧B相电压(1V)"},
{"key": "0x0040", "datatype": "int16", "remark": "逆变侧C相电压(1V)"},
{"key": "0x0041", "datatype": "int16", "remark": "逆变侧A相电流(1A)"},
{"key": "0x0042", "datatype": "int16", "remark": "逆变侧B相电流(1A)"},
{"key": "0x0043", "datatype": "int16", "remark": "逆变侧C相电流(1A)"},
{"key": "0x0044", "datatype": "int16", "remark": "逆变侧A相电流直流分量(1A)"},
{"key": "0x0045", "datatype": "int16", "remark": "逆变侧B相电流直流分量(1A)"},
{"key": "0x0046", "datatype": "int16", "remark": "逆变侧C相电流直流分量(1A)"},
{"key": "0x0047", "datatype": "int16", "remark": "离网频率(1Hz)"},
{"key": "0x0048", "datatype": "int16", "remark": "A相负载量(1)"},
{"key": "0x0049", "datatype": "int16", "remark": "B相负载量(1)"},
{"key": "0x004A", "datatype": "int16", "remark": "C相负载量(1)"},
{"key": "0x004B", "datatype": "int16", "remark": "总负载量(1)"},
{"key": "0x004C", "datatype": "int16", "remark": "逆变侧AB线电压直流分量(1A)"},
{"key": "0x004D", "datatype": "int16", "remark": "逆变侧BC线电压直流分量(1A)"},
{"key": "0x004E", "datatype": "int16", "remark": "逆变侧CA线电压直流分量(1A)"},
{"key": "0x004F", "datatype": "int16", "remark": "在线数量"}
]
},
"PCS_YX":{
"addr":[
{"key": "0x1001", "datatype": "uint16", "remark": "所属主控号1~4"},
{"key": "0x1002", "datatype": "uint16", "remark": "所属PCS号1~40"},
{"key": "0x1003", "datatype": "uint16", "remark": "故障状态1故障0正常"},
{"key": "0x1004", "datatype": "uint16", "remark": "告警状态1告警0正常"},
{"key": "0x1005", "datatype": "uint16", "remark": "设备在线1在线0无效"},
{"key": "0x1006", "datatype": "uint16", "remark": "禁止充电1禁止0无效"},
{"key": "0x1007", "datatype": "uint16", "remark": "禁止放电1禁止0无效"},
{"key": "0x1008", "datatype": "uint16", "remark": "运行状态1开机0关机"},
{"key": "0x1009", "datatype": "uint16", "remark": "充放状态0待机,1充电,2放电,3搁置"},
{"key": "0x100A", "datatype": "uint16", "remark": "电网状态1离网0并网"},
{"key": "0x100B", "datatype": "uint16", "remark": "逆变供电0禁止1使能"},
{"key": "0x100C", "datatype": "uint16", "remark": "缓启动完成0禁止1使能"},
{"key": "0x100D", "datatype": "uint16", "remark": "主机标志0禁止1使能"},
{"key": "0x100E", "datatype": "uint16", "remark": "并离网状态0并网, 1离网"},
{"key": "0x100F", "datatype": "uint16", "remark": "同步请求标志0无效1动作"},
{"key": "0x1010", "datatype": "uint16", "remark": "绝缘故障1:故障0正常"},
{"key": "0x1011", "datatype": "uint16", "remark": "漏电保护1:故障0正常"},
{"key": "0x1012", "datatype": "uint16", "remark": "直流过压1:故障0正常"},
{"key": "0x1013", "datatype": "uint16", "remark": "市电幅值异常1:故障0正常"},
{"key": "0x1014", "datatype": "uint16", "remark": "市电相序异常1:故障0正常"},
{"key": "0x1015", "datatype": "uint16", "remark": "温度开关异常1:故障0正常"},
{"key": "0x1016", "datatype": "uint16", "remark": "市电频率异常1:故障0正常"},
{"key": "0x1017", "datatype": "uint16", "remark": "IGBT过温1:故障0正常"},
{"key": "0x1018", "datatype": "uint16", "remark": "交流接地故障1:故障0正常"},
{"key": "0x1019", "datatype": "uint16", "remark": "逆变过流异常1:故障0正常"},
{"key": "0x101A", "datatype": "uint16", "remark": "直流缓起故障1:故障0正常"},
{"key": "0x101B", "datatype": "uint16", "remark": "直流主继电器故障1:故障0正常"},
{"key": "0x101C", "datatype": "uint16", "remark": "风机异常1:故障0正常"},
{"key": "0x101D", "datatype": "uint16", "remark": "主接触器异常1:故障0正常"},
{"key": "0x101E", "datatype": "uint16", "remark": "均浮充切换超时1:故障0正常"},
{"key": "0x101F", "datatype": "uint16", "remark": "硬件故障1:故障0正常"},
{"key": "0x1020", "datatype": "uint16", "remark": "机内过温1:故障0正常"},
{"key": "0x1021", "datatype": "uint16", "remark": "软启动故障1:故障0正常"},
{"key": "0x1022", "datatype": "uint16", "remark": "触摸屏通讯故障1:故障0正常"},
{"key": "0x1023", "datatype": "uint16", "remark": "防雷器故障1:故障0正常"},
{"key": "0x1024", "datatype": "uint16", "remark": "急停故障1:故障0正常"},
{"key": "0x1025", "datatype": "uint16", "remark": "BMS系统故障1:故障0正常"},
{"key": "0x1026", "datatype": "uint16", "remark": "BMS通讯故障1:故障0正常"},
{"key": "0x1027", "datatype": "uint16", "remark": "BMS干接点通讯故障1:故障0正常"},
{"key": "0x1028", "datatype": "uint16", "remark": "远程通讯故障1:故障0正常"},
{"key": "0x1029", "datatype": "uint16", "remark": "门禁告警1:故障0正常"},
{"key": "0x102A", "datatype": "uint16", "remark": "锁相异常1:故障0正常"},
{"key": "0x102B", "datatype": "uint16", "remark": "IGBT过温告警1:故障0正常"},
{"key": "0x102C", "datatype": "uint16", "remark": "硬件过流保护1:故障0正常"},
{"key": "0x102D", "datatype": "uint16", "remark": "驱动故障1:故障0正常"},
{"key": "0x102E", "datatype": "uint16", "remark": "ID冲突1:故障0正常"},
{"key": "0x102F", "datatype": "uint16", "remark": "电池过压1:故障0正常"},
{"key": "0x1030", "datatype": "uint16", "remark": "电池欠压1:故障0正常"},
{"key": "0x1031", "datatype": "uint16", "remark": "直流过流保护1:故障0正常"},
{"key": "0x1032", "datatype": "uint16", "remark": "输出电压异常1:故障0正常"},
{"key": "0x1033", "datatype": "uint16", "remark": "离网输出电压不符合1:故障0正常"},
{"key": "0x1034", "datatype": "uint16", "remark": "输出过载保护1:故障0正常"},
{"key": "0x1035", "datatype": "uint16", "remark": "输出短路保护1:故障0正常"},
{"key": "0x1036", "datatype": "uint16", "remark": "并机通信异常1:故障0正常"},
{"key": "0x1037", "datatype": "uint16", "remark": "电池保险异常1:故障0正常"},
{"key": "0x1038", "datatype": "uint16", "remark": "电池重载低压1:故障0正常"},
{"key": "0x1039", "datatype": "uint16", "remark": "电池低压告警1:故障0正常"},
{"key": "0x103A", "datatype": "uint16", "remark": "一拖二压差过大1:故障0正常"},
{"key": "0x103B", "datatype": "uint16", "remark": "电池反接故障1:故障0正常"},
{"key": "0x103C", "datatype": "uint16", "remark": "电池电压异常1:故障0正常"},
{"key": "0x103D", "datatype": "uint16", "remark": "过载告警1:故障0正常"},
{"key": "0x103E", "datatype": "uint16", "remark": "外部接触器异常1:故障0正常"},
{"key": "0x103F", "datatype": "uint16", "remark": "IGBT温度传感器异常1:故障0正常"},
{"key": "0x1040", "datatype": "uint16", "remark": "整机温度传感器异常1:故障0正常"},
{"key": "0x1041", "datatype": "uint16", "remark": "市电CT异常1:故障0正常"},
{"key": "0x1042", "datatype": "uint16", "remark": "逆变电流三相不平衡1:故障0正常"},
{"key": "0x1043", "datatype": "uint16", "remark": "逆变电流直流分量异常1:故障0正常"},
{"key": "0x1044", "datatype": "uint16", "remark": "母线不平衡1:故障0正常"},
{"key": "0x1045", "datatype": "uint16", "remark": "逆变电压直流分量异常1:故障0正常"},
{"key": "0x1046", "datatype": "uint16", "remark": "主接触器控制异常1:故障0正常"},
{"key": "0x1047", "datatype": "uint16", "remark": "逆变电压控制异常1:故障0正常"},
{"key": "0x1048", "datatype": "uint16", "remark": "直流霍尔异常1:故障0正常"},
{"key": "0x1049", "datatype": "uint16", "remark": "电池单体过压1:故障0正常"},
{"key": "0x104A", "datatype": "uint16", "remark": "电池单体欠压1:故障0正常"},
{"key": "0x104B", "datatype": "uint16", "remark": "电网过压1:故障0正常"},
{"key": "0x104C", "datatype": "uint16", "remark": "电网欠压1:故障0正常"},
{"key": "0x104D", "datatype": "uint16", "remark": "电网过频1:故障0正常"},
{"key": "0x104E", "datatype": "uint16", "remark": "电网欠频1:故障0正常"},
{"key": "0x104F", "datatype": "uint16", "remark": "市电不平衡1:故障0正常"},
{"key": "0x1050", "datatype": "uint16", "remark": "参数设置不匹配1:故障0正常"},
{"key": "0x1051", "datatype": "uint16", "remark": "SPI通信异常1:故障0正常"},
{"key": "0x1052", "datatype": "uint16", "remark": "SCI通信异常1:故障0正常"},
{"key": "0x1053", "datatype": "uint16", "remark": "IIC通信异常1:故障0正常"},
{"key": "0x1054", "datatype": "uint16", "remark": "Xintf通信异常1:故障0正常"},
{"key": "0x1055", "datatype": "uint16", "remark": "零偏校准异常1:故障0正常"},
{"key": "0x1056", "datatype": "uint16", "remark": "烟雾告警1:故障0正常"},
{"key": "0x1057", "datatype": "uint16", "remark": "无电池组故障1异常0正常"},
{"key": "0x1058", "datatype": "uint16", "remark": "环温降频1异常0正常"},
{"key": "0x1059", "datatype": "uint16", "remark": "交流过载1异常0正常"},
{"key": "0x105A", "datatype": "uint16", "remark": "采样异常1异常0正常"},
{"key": "0x105B", "datatype": "uint16", "remark": "24V辅源故障1异常0正常"},
{"key": "0x105C", "datatype": "uint16", "remark": "直流欠压异常1异常0正常"},
{"key": "0x105D", "datatype": "uint16", "remark": "散热器过温1异常0正常"},
{"key": "0x105E", "datatype": "uint16", "remark": "CAN配置故障1异常0正常"},
{"key": "0x105F", "datatype": "uint16", "remark": "3.3V辅源故障1异常0正常"},
{"key": "0x1060", "datatype": "uint16", "remark": "环境过温1异常0正常"},
{"key": "0x1061", "datatype": "uint16", "remark": "A相IGBT逆变过流1异常0正常"},
{"key": "0x1062", "datatype": "uint16", "remark": "B相IGBT逆变过流1异常0正常"}
]
},
"BMS_YC":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "SOC(0.1)"},
{"key": "0x0002", "datatype": "uint16", "remark": "SOH(0.1)"},
{"key": "0x0003", "datatype": "uint32", "remark": "电压(0.1V)"},
{"key": "0x0005", "datatype": "int32", "remark": "电流(0.1A)"},
{"key": "0x0007", "datatype": "uint32", "remark": "可充电量(1kWh)"},
{"key": "0x0009", "datatype": "uint32", "remark": "可放电量(1kWh)"},
{"key": "0x000B", "datatype": "uint32", "remark": "单次可充电量(1kWh)"},
{"key": "0x000D", "datatype": "uint32", "remark": "单次可放电量(1kWh)"},
{"key": "0x000F", "datatype": "int32", "remark": "堆功率(1kW)"},
{"key": "0x0011", "datatype": "uint32", "remark": "充电量累加(1kWh)"},
{"key": "0x0013", "datatype": "uint32", "remark": "放电量累加(1kWh)"},
{"key": "0x0015", "datatype": "uint16", "remark": "簇最大SOC(0.1)"},
{"key": "0x0016", "datatype": "uint16", "remark": "簇最小SOC(0.1)"},
{"key": "0x0017", "datatype": "uint16", "remark": "簇最大SOC号"},
{"key": "0x0018", "datatype": "uint16", "remark": "簇最小SOC号"},
{"key": "0x0019", "datatype": "uint16", "remark": "簇SOC差值(0.1)"},
{"key": "0x001A", "datatype": "uint16", "remark": "簇最大电压(0.1V)"},
{"key": "0x001B", "datatype": "uint16", "remark": "簇最小电压(0.1V)"},
{"key": "0x001C", "datatype": "uint16", "remark": "簇最大电压号"},
{"key": "0x001D", "datatype": "uint16", "remark": "簇最小电压号"},
{"key": "0x001E", "datatype": "uint16", "remark": "簇电压差值(0.1V)"},
{"key": "0x001F", "datatype": "uint16", "remark": "单体最大电压簇号"},
{"key": "0x0020", "datatype": "uint16", "remark": "单体最大电压节号"},
{"key": "0x0021", "datatype": "uint16", "remark": "单体最大电压(mV)"},
{"key": "0x0022", "datatype": "uint16", "remark": "单体最小电压簇号"},
{"key": "0x0023", "datatype": "uint16", "remark": "单体最小电压节号"},
{"key": "0x0024", "datatype": "uint16", "remark": "单体最小电压(mV)"},
{"key": "0x0025", "datatype": "uint16", "remark": "单体平均电压(mV)"},
{"key": "0x0026", "datatype": "uint16", "remark": "单体电压差(mV)"},
{"key": "0x0027", "datatype": "uint16", "remark": "单体最大温度簇号"},
{"key": "0x0028", "datatype": "uint16", "remark": "单体最大温度节号"},
{"key": "0x0029", "datatype": "int16", "remark": "单体最大温度(0.1℃)"},
{"key": "0x002A", "datatype": "uint16", "remark": "单体最小温度簇号"},
{"key": "0x002B", "datatype": "uint16", "remark": "单体最小温度节号"},
{"key": "0x002C", "datatype": "int16", "remark": "单体最小温度(0.1℃)"},
{"key": "0x002D", "datatype": "int16", "remark": "单体平均温度(0.1℃)"},
{"key": "0x002E", "datatype": "int16", "remark": "单体温度差(0.1℃)"},
{"key": "0x002F", "datatype": "uint16", "remark": "最大内阻簇号"},
{"key": "0x0030", "datatype": "uint16", "remark": "最大内阻节号"},
{"key": "0x0031", "datatype": "uint16", "remark": "最大内阻(mΩ)"},
{"key": "0x0032", "datatype": "uint16", "remark": "最小内阻簇号"},
{"key": "0x0033", "datatype": "uint16", "remark": "最小内阻节号"},
{"key": "0x0034", "datatype": "uint16", "remark": "最小内阻(mΩ)"},
{"key": "0x0035", "datatype": "uint16", "remark": "单体平均内阻(mΩ)"},
{"key": "0x0036", "datatype": "uint16", "remark": "单体内阻差(mΩ)"},
{"key": "0x0037", "datatype": "uint16", "remark": "单体最大SOH簇号"},
{"key": "0x0038", "datatype": "uint16", "remark": "单体最大SOH节号"},
{"key": "0x0039", "datatype": "uint16", "remark": "单体最大SOH(0.001)"},
{"key": "0x003A", "datatype": "uint16", "remark": "单体最小SOH簇号"},
{"key": "0x003B", "datatype": "uint16", "remark": "单体最小SOH节号"},
{"key": "0x003C", "datatype": "uint16", "remark": "单体最小SOH(0.001)"},
{"key": "0x003D", "datatype": "uint16", "remark": "单体最大SOc簇号"},
{"key": "0x003E", "datatype": "uint16", "remark": "单体最大SOc节号"},
{"key": "0x0040", "datatype": "uint16", "remark": "单体最大Soc(0.001)"},
{"key": "0x0041", "datatype": "uint16", "remark": "单体最小SOc簇号"},
{"key": "0x0042", "datatype": "uint16", "remark": "单体最小SOc节号"},
{"key": "0x0043", "datatype": "uint16", "remark": "单体最小SOc(0.001)"},
{"key": "0x0043", "datatype": "uint32", "remark": "系统剩余最大可充电功率(1KW)"},
{"key": "0x0045", "datatype": "uint32", "remark": "系统剩余最大可放电功率(1KW)"},
{"key": "0x0047", "datatype": "uint16", "remark": "可充电状态"},
{"key": "0x0048", "datatype": "uint16", "remark": "可放电状态"},
{"key": "0x0049", "datatype": "uint16", "remark": "运行状态"}
]
},
"BCU_YC":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "所属通道号1~4"},
{"key": "0x0002", "datatype": "uint16", "remark": "所属BCU号1~40"},
{"key": "0x0003", "datatype": "uint32", "remark": "簇电压(0.1V)"},
{"key": "0x0005", "datatype": "int32", "remark": "簇电流(0.1A)"},
{"key": "0x0007", "datatype": "int32", "remark": "簇温度(0.1℃)"},
{"key": "0x0009", "datatype": "uint32", "remark": "簇电阻(1mΩ)"},
{"key": "0x000B", "datatype": "uint16", "remark": "簇SOC(0.1)"},
{"key": "0x000C", "datatype": "uint16", "remark": "簇SOH(0.1)"},
{"key": "0x000D", "datatype": "uint32", "remark": "簇正绝缘电阻(1kΩ)"},
{"key": "0x000F", "datatype": "uint32", "remark": "簇负绝缘电阻(1kΩ)"},
{"key": "0x0011", "datatype": "int32", "remark": "簇允许最大充电电流(0.1A)"},
{"key": "0x0013", "datatype": "int32", "remark": "簇允许最大放电电流(0.1A)"},
{"key": "0x0015", "datatype": "uint32", "remark": "簇允许最大充电功率(1kW)"},
{"key": "0x0017", "datatype": "uint32", "remark": "簇允许最大放电功率(1kW)"},
{"key": "0x0019", "datatype": "uint32", "remark": "簇可充容量(0.1Ah)"},
{"key": "0x001B", "datatype": "uint32", "remark": "簇可放容量(0.1Ah)"},
{"key": "0x001D", "datatype": "uint32", "remark": "簇单次累计充容量(0.1Ah)"},
{"key": "0x001F", "datatype": "uint32", "remark": "簇单次累计放容量(0.1Ah)"},
{"key": "0x0021", "datatype": "uint32", "remark": "簇总累计充容量(0.1Ah)"},
{"key": "0x0023", "datatype": "uint32", "remark": "簇总累计放容量(0.1Ah)"},
{"key": "0x0025", "datatype": "uint32", "remark": "簇可充电量(1kWh)"},
{"key": "0x0027", "datatype": "uint32", "remark": "簇可放电量(1kWh)"},
{"key": "0x0029", "datatype": "uint32", "remark": "簇单次充电量(1kWh)"},
{"key": "0x002B", "datatype": "uint32", "remark": "簇单次放电量(1kWh)"},
{"key": "0x002D", "datatype": "uint32", "remark": "簇累计充电量(1kWh)"},
{"key": "0x002F", "datatype": "uint32", "remark": "簇累计放电量(1kWh)"},
{"key": "0x0031", "datatype": "uint32", "remark": "pack累计簇总压(0.1V)"},
{"key": "0x0033", "datatype": "uint32", "remark": "簇与pack压差(0.1V)"},
{"key": "0x0035", "datatype": "uint32", "remark": "簇与PCS压差(0.1V)"},
{"key": "0x0037", "datatype": "uint16", "remark": "簇中BMU个数"},
{"key": "0x0038", "datatype": "uint16", "remark": "簇中BMU中单体个数"},
{"key": "0x0039", "datatype": "uint16", "remark": "簇中BMU中温度个数"},
{"key": "0x003A", "datatype": "uint16", "remark": "簇中单体个数"},
{"key": "0x003B", "datatype": "uint16", "remark": "簇中温度个数"},
{"key": "0x003C", "datatype": "uint16", "remark": "单体最高SOC节号"},
{"key": "0x003D", "datatype": "uint16", "remark": "单体最高SOC(0.1)"},
{"key": "0x003E", "datatype": "uint16", "remark": "单体最低SOC节号"},
{"key": "0x003F", "datatype": "uint16", "remark": "单体最低SOC(0.1)"},
{"key": "0x0040", "datatype": "uint16", "remark": "单体最高SOH节号"},
{"key": "0x0041", "datatype": "uint16", "remark": "单体最高SOH(0.1)"},
{"key": "0x0042", "datatype": "uint16", "remark": "单体最低SOH节号"},
{"key": "0x0043", "datatype": "uint16", "remark": "单体最低SOH(0.1)"},
{"key": "0x0044", "datatype": "uint16", "remark": "单体最高电压节号"},
{"key": "0x0045", "datatype": "uint16", "remark": "单体最高电压(mV)"},
{"key": "0x0046", "datatype": "uint16", "remark": "单体最低电压节号"},
{"key": "0x0047", "datatype": "uint16", "remark": "单体最低电压(mV)"},
{"key": "0x0048", "datatype": "uint16", "remark": "单体电压差(mV)"},
{"key": "0x0049", "datatype": "uint16", "remark": "单体平均电压(mV)"},
{"key": "0x004A", "datatype": "uint16", "remark": "单体最高温度节号"},
{"key": "0x004B", "datatype": "int16", "remark": "单体最高温度(0.1℃)"},
{"key": "0x004C", "datatype": "uint16", "remark": "单体最低温度节号"},
{"key": "0x004D", "datatype": "int16", "remark": "单体最低温度(0.1℃)"},
{"key": "0x004E", "datatype": "int16", "remark": "单体温度差(0.1℃)"},
{"key": "0x004F", "datatype": "int16", "remark": "单体平均温度(0.1℃)"},
{"key": "0x0050", "datatype": "uint16", "remark": "单体最高内阻节号"},
{"key": "0x0051", "datatype": "uint16", "remark": "单体最高内阻(mΩ)"},
{"key": "0x0052", "datatype": "uint16", "remark": "单体最低内阻节号"},
{"key": "0x0053", "datatype": "uint16", "remark": "单体最低内阻(mΩ)"},
{"key": "0x0054", "datatype": "uint16", "remark": "单体内阻差(mΩ)"},
{"key": "0x0055", "datatype": "uint16", "remark": "单体平均内阻(mΩ)"}
]
},
"BCU_YX":{
"addr":[
{"key": "0xA001", "datatype": "uint16", "remark": "所属通道号1~4"},
{"key": "0xA002", "datatype": "uint16", "remark": "所属BCU号1~40"},
{"key": "0xA003", "datatype": "uint16", "remark": "蓄电池充放电状态0x11开路0x22待机0x33充电0x44放电"},
{"key": "0xA004", "datatype": "uint16", "remark": "电池组运行状态0x11跳机 0x22待机 0x33放空 0x44充满 0x55预警 0x66正常"},
{"key": "0xA005", "datatype": "uint16", "remark": "簇DO1状态1断开 2闭合"},
{"key": "0xA006", "datatype": "uint16", "remark": "簇DO2状态1断开 2闭合"},
{"key": "0xA007", "datatype": "uint16", "remark": "继电器总正0:断开 1闭合 2粘连"},
{"key": "0xA008", "datatype": "uint16", "remark": "继电器总负0:断开 1闭合 2粘连"},
{"key": "0xA009", "datatype": "uint16", "remark": "继电器预充0:断开 1闭合 2粘连"},
{"key": "0xA00A", "datatype": "uint16", "remark": "继电器bmu供电0:断开 1闭合 2粘连"},
{"key": "0xA00B", "datatype": "uint16", "remark": "整簇总电压过高告警0正常 1告警"},
{"key": "0xA00C", "datatype": "uint16", "remark": "整簇总电压过低告警0正常 1告警"},
{"key": "0xA00D", "datatype": "uint16", "remark": "整簇中单体电压过高告警0正常 1告警"},
{"key": "0xA00E", "datatype": "uint16", "remark": "整簇中单体电压过低告警0正常 1告警"},
{"key": "0xA00F", "datatype": "uint16", "remark": "整簇中单体电压偏差过大告警0正常 1告警"},
{"key": "0xA010", "datatype": "uint16", "remark": "整簇中单体温度偏差过大告警0正常 1告警"},
{"key": "0xA011", "datatype": "uint16", "remark": "整簇中单体温度过高告警0正常 1告警"},
{"key": "0xA012", "datatype": "uint16", "remark": "整簇中单体温度过低告警0正常 1告警"},
{"key": "0xA013", "datatype": "uint16", "remark": "整簇总充电电流过高告警0正常 1告警"},
{"key": "0xA014", "datatype": "uint16", "remark": "整簇总放电电流过高告警0正常 1告警"},
{"key": "0xA015", "datatype": "uint16", "remark": "整簇总SOC过高告警0正常 1告警"},
{"key": "0xA016", "datatype": "uint16", "remark": "整簇总SOC过低告警0正常 1告警"},
{"key": "0xA017", "datatype": "uint16", "remark": "高压盒主正接触器粘连告警0正常 1告警"},
{"key": "0xA018", "datatype": "uint16", "remark": "高压盒主正接触器不能吸合告警0正常 1告警"},
{"key": "0xA019", "datatype": "uint16", "remark": "高压盒主负接触器粘连告警0正常 1告警"},
{"key": "0xA01A", "datatype": "uint16", "remark": "高压盒主负接触器不能吸合告警0正常 1告警"},
{"key": "0xA01B", "datatype": "uint16", "remark": "高压盒预充接触器粘连告警0正常 1告警"},
{"key": "0xA01C", "datatype": "uint16", "remark": "高压盒预充接触器不能吸合告警0正常 1告警"},
{"key": "0xA01D", "datatype": "uint16", "remark": "预充失败告警0正常 1告警"},
{"key": "0xA01E", "datatype": "uint16", "remark": "BCU电压检测模块出现问题告警0正常 1告警"},
{"key": "0xA01F", "datatype": "uint16", "remark": "BCU温度检测模块出现问题告警0正常 1告警"},
{"key": "0xA020", "datatype": "uint16", "remark": "BCU电流检测模块出现问题告警0正常 1告警"},
{"key": "0xA021", "datatype": "uint16", "remark": "BCU绝缘检测模块出现问题告警0正常 1告警"},
{"key": "0xA022", "datatype": "uint16", "remark": "高压盒内总压检测模块出现问题告警0正常 1告警"},
{"key": "0xA023", "datatype": "uint16", "remark": "高压盒外总压检测模块出现问题告警0正常 1告警"},
{"key": "0xA024", "datatype": "uint16", "remark": "PCS-CAN通信故障告警0正常 1告警"},
{"key": "0xA025", "datatype": "uint16", "remark": "高压盒供电电压过高告警0正常 1告警"},
{"key": "0xA026", "datatype": "uint16", "remark": "绝缘正极故障告警0正常 1告警"},
{"key": "0xA027", "datatype": "uint16", "remark": "绝缘负极故障告警0正常 1告警"},
{"key": "0xA028", "datatype": "uint16", "remark": "绝缘中间侧故障告警0正常 1告警"},
{"key": "0xA029", "datatype": "uint16", "remark": "绝缘故障告警0正常 1告警"},
{"key": "0xA02A", "datatype": "uint16", "remark": "BMU中电压采样线开路告警0正常 1告警"},
{"key": "0xA02B", "datatype": "uint16", "remark": "BMU中NTC采样线短开路告警0正常 1告警"},
{"key": "0xA02C", "datatype": "uint16", "remark": "BMU中采样芯片故障告警0正常 1告警"},
{"key": "0xA02D", "datatype": "uint16", "remark": "BMU中电池温度升高过快告警0正常 1告警"},
{"key": "0xA02E", "datatype": "uint16", "remark": "BMU中电池内部短路告警0正常 1告警"},
{"key": "0xA02F", "datatype": "uint16", "remark": "BMU充电均衡模块出现故障告警0正常 1告警"},
{"key": "0xA030", "datatype": "uint16", "remark": "BMU放电均衡模块出现故障告警0正常 1告警"},
{"key": "0xA031", "datatype": "uint16", "remark": "BMU通信故障告警0正常 1告警"},
{"key": "0xA032", "datatype": "uint16", "remark": "单体内阻过大告警0正常 1告警"},
{"key": "0xA033", "datatype": "uint16", "remark": "单体内阻过小告警0正常 1告警"},
{"key": "0xA034", "datatype": "uint16", "remark": "单体内阻阻差过大告警0正常 1告警"},
{"key": "0xA035", "datatype": "uint16", "remark": "簇内阻过大告警0正常 1告警"},
{"key": "0xA036", "datatype": "uint16", "remark": "簇内阻过小告警0正常 1告警"},
{"key": "0xA037", "datatype": "uint16", "remark": "SOC初始化无效告警0正常 1告警"},
{"key": "0xA038", "datatype": "uint16", "remark": "充电时soc降低故障告警0正常 1告警"},
{"key": "0xA039", "datatype": "uint16", "remark": "放电时soc升高告警0正常 1告警"},
{"key": "0xA03A", "datatype": "uint16", "remark": "静止时SOC跳变告警0正常 1告警"},
{"key": "0xA03B", "datatype": "uint16", "remark": "整簇总电压过高保护0正常 1保护"},
{"key": "0xA03C", "datatype": "uint16", "remark": "整簇总电压过低保护0正常 1保护"},
{"key": "0xA03D", "datatype": "uint16", "remark": "整簇中单体电压过高保护0正常 1保护"},
{"key": "0xA03E", "datatype": "uint16", "remark": "整簇中单体电压过低保护0正常 1保护"},
{"key": "0xA03F", "datatype": "uint16", "remark": "整簇中单体电压偏差过大保护0正常 1保护"},
{"key": "0xA040", "datatype": "uint16", "remark": "整簇中单体温度偏差过大保护0正常 1保护"},
{"key": "0xA041", "datatype": "uint16", "remark": "整簇中单体温度过高保护0正常 1保护"},
{"key": "0xA042", "datatype": "uint16", "remark": "整簇中单体温度过低保护0正常 1保护"},
{"key": "0xA043", "datatype": "uint16", "remark": "整簇总充电电流过高保护0正常 1保护"},
{"key": "0xA044", "datatype": "uint16", "remark": "整簇总放电电流过高保护0正常 1保护"},
{"key": "0xA045", "datatype": "uint16", "remark": "整簇总SOC过高保护0正常 1保护"},
{"key": "0xA046", "datatype": "uint16", "remark": "整簇总SOC过低保护0正常 1保护"},
{"key": "0xA047", "datatype": "uint16", "remark": "高压盒主正接触器粘连保护0正常 1保护"},
{"key": "0xA048", "datatype": "uint16", "remark": "高压盒主正接触器不能吸合保护0正常 1保护"},
{"key": "0xA049", "datatype": "uint16", "remark": "高压盒主负接触器粘连保护0正常 1保护"},
{"key": "0xA04A", "datatype": "uint16", "remark": "高压盒主负接触器不能吸合保护0正常 1保护"},
{"key": "0xA04B", "datatype": "uint16", "remark": "高压盒预充接触器粘连保护0正常 1保护"},
{"key": "0xA04C", "datatype": "uint16", "remark": "高压盒预充接触器不能吸合保护0正常 1保护"},
{"key": "0xA04D", "datatype": "uint16", "remark": "预充失败保护0正常 1保护"},
{"key": "0xA04E", "datatype": "uint16", "remark": "BCU电压检测模块出现问题保护0正常 1保护"},
{"key": "0xA04F", "datatype": "uint16", "remark": "BCU温度检测模块出现问题保护0正常 1保护"},
{"key": "0xA050", "datatype": "uint16", "remark": "BCU电流检测模块出现问题保护0正常 1保护"},
{"key": "0xA051", "datatype": "uint16", "remark": "BCU绝缘检测模块出现问题保护0正常 1保护"},
{"key": "0xA052", "datatype": "uint16", "remark": "高压盒内总压检测模块出现问题保护0正常 1保护"},
{"key": "0xA053", "datatype": "uint16", "remark": "高压盒外总压检测模块出现问题保护0正常 1保护"},
{"key": "0xA054", "datatype": "uint16", "remark": "PCS-CAN通信故障保护0正常 1保护"},
{"key": "0xA055", "datatype": "uint16", "remark": "高压盒供电电压过高保护0正常 1保护"},
{"key": "0xA056", "datatype": "uint16", "remark": "绝缘正极故障保护0正常 1保护"},
{"key": "0xA057", "datatype": "uint16", "remark": "绝缘负极故障保护0正常 1保护"},
{"key": "0xA058", "datatype": "uint16", "remark": "绝缘中间侧故障保护0正常 1保护"},
{"key": "0xA059", "datatype": "uint16", "remark": "绝缘故障保护0正常 1保护"},
{"key": "0xA05A", "datatype": "uint16", "remark": "BMU中电压采样线开路保护0正常 1保护"},
{"key": "0xA05B", "datatype": "uint16", "remark": "BMU中NTC采样线短开路保护0正常 1保护"},
{"key": "0xA05C", "datatype": "uint16", "remark": "BMU中采样芯片故障保护0正常 1保护"},
{"key": "0xA05D", "datatype": "uint16", "remark": "BMU中电池温度升高过快保护0正常 1保护"},
{"key": "0xA05E", "datatype": "uint16", "remark": "BMU中电池内部短路保护0正常 1保护"},
{"key": "0xA05F", "datatype": "uint16", "remark": "BMU充电均衡模块出现故障保护0正常 1保护"},
{"key": "0xA060", "datatype": "uint16", "remark": "BMU放电均衡模块出现故障保护0正常 1保护"},
{"key": "0xA061", "datatype": "uint16", "remark": "BMU通信故障保护0正常 1保护"},
{"key": "0xA062", "datatype": "uint16", "remark": "单体内阻过大保护0正常 1保护"},
{"key": "0xA063", "datatype": "uint16", "remark": "单体内阻过小保护0正常 1保护"},
{"key": "0xA064", "datatype": "uint16", "remark": "单体内阻阻差过大保护0正常 1保护"},
{"key": "0xA065", "datatype": "uint16", "remark": "簇内阻过大保护0正常 1保护"},
{"key": "0xA066", "datatype": "uint16", "remark": "簇内阻过小保护0正常 1保护"},
{"key": "0xA067", "datatype": "uint16", "remark": "SOC初始化无效保护0正常 1保护"},
{"key": "0xA068", "datatype": "uint16", "remark": "充电时soc降低故障保护0正常 1保护"},
{"key": "0xA069", "datatype": "uint16", "remark": "放电时soc升高保护0正常 1保护"},
{"key": "0xA06A", "datatype": "uint16", "remark": "静止时SOC跳变保护0正常 1保护"}
]
},
"MEM_YC":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "所属通道号1"},
{"key": "0x0008", "datatype": "uint16", "remark": "电表类型0储能站总表1逆变前侧电表2逆变后侧电表3配电柜电表4并网口电表"},
{"key": "0x0009", "datatype": "uint16", "remark": "电流变比"},
{"key": "0x000A", "datatype": "uint16", "remark": "电压变比"},
{"key": "0x000B", "datatype": "uint32", "remark": "A相电压(1V)"},
{"key": "0x000D", "datatype": "uint32", "remark": "B相电压(1V)"},
{"key": "0x000F", "datatype": "uint32", "remark": "C相电压(1V)"},
{"key": "0x0011", "datatype": "int32", "remark": "A相电流(1A)"},
{"key": "0x0013", "datatype": "int32", "remark": "B相电流(1A)"},
{"key": "0x0015", "datatype": "int32", "remark": "C相电流(1A)"},
{"key": "0x0017", "datatype": "uint32", "remark": "AB相电压(1V)"},
{"key": "0x0019", "datatype": "uint32", "remark": "BC相电压(1V)"},
{"key": "0x001B", "datatype": "uint32", "remark": "CA相电压(1V)"},
{"key": "0x001D", "datatype": "int32", "remark": "A相有功(1kW)"},
{"key": "0x001F", "datatype": "int32", "remark": "B相有功(1kW)"},
{"key": "0x0021", "datatype": "int32", "remark": "C相有功(1kW)"},
{"key": "0x0023", "datatype": "int32", "remark": "三相总有功(1kW)"},
{"key": "0x0025", "datatype": "int32", "remark": "正向总有功总需量(1kW)"},
{"key": "0x0027", "datatype": "uint32", "remark": "尖段电价(1RMB)"},
{"key": "0x0029", "datatype": "uint32", "remark": "峰段电价(1RMB)"},
{"key": "0x002B", "datatype": "uint32", "remark": "平段电价(1RMB)"},
{"key": "0x002D", "datatype": "uint32", "remark": "谷段电价(1RMB)"},
{"key": "0x002F", "datatype": "uint32", "remark": "日充电电量(1kWh)"},
{"key": "0x0031", "datatype": "uint32", "remark": "日放电电量(1kWh)"},
{"key": "0x0033", "datatype": "uint32", "remark": "日充电费用(1RMB)"},
{"key": "0x0035", "datatype": "uint32", "remark": "日放电费用(1RMB)"},
{"key": "0x0037", "datatype": "int32", "remark": "日收益(1RMB)"},
{"key": "0x0039", "datatype": "uint32", "remark": "日正向尖有功电能(1kWh)"},
{"key": "0x003B", "datatype": "uint32", "remark": "日正向峰有功电能(1kWh)"},
{"key": "0x003D", "datatype": "uint32", "remark": "日正向平有功电能(1kWh)"},
{"key": "0x003F", "datatype": "uint32", "remark": "日正向谷有功电能(1kWh)"},
{"key": "0x0041", "datatype": "uint32", "remark": "日正向总有功电能(1kWh)"},
{"key": "0x0043", "datatype": "uint32", "remark": "日反向尖有功电能(1kWh)"},
{"key": "0x0045", "datatype": "uint32", "remark": "日反向峰有功电能(1kWh)"},
{"key": "0x0047", "datatype": "uint32", "remark": "日反向平有功电能(1kWh)"},
{"key": "0x0049", "datatype": "uint32", "remark": "日反向谷有功电能(1kWh)"},
{"key": "0x004B", "datatype": "uint32", "remark": "日反向总有功电能(1kWh)"},
{"key": "0x004D", "datatype": "uint32", "remark": "总充电电量(1kWh)"},
{"key": "0x004F", "datatype": "uint32", "remark": "总放电电量(1kWh)"},
{"key": "0x0051", "datatype": "uint32", "remark": "总充电费用(1RMB)"},
{"key": "0x0053", "datatype": "uint32", "remark": "总放电费用(1RMB)"},
{"key": "0x0055", "datatype": "int32", "remark": "总收益(1RMB)"},
{"key": "0x0057", "datatype": "uint32", "remark": "总正向尖有功电能(1kWh)"},
{"key": "0x0059", "datatype": "uint32", "remark": "总正向峰有功电能(1kWh)"},
{"key": "0x005B", "datatype": "uint32", "remark": "总正向平有功电能(1kWh)"},
{"key": "0x005D", "datatype": "uint32", "remark": "总正向谷有功电能(1kWh)"},
{"key": "0x005F", "datatype": "uint32", "remark": "总正向总有功电能(1kWh)"},
{"key": "0x0061", "datatype": "uint32", "remark": "总反向尖有功电能(1kWh)"},
{"key": "0x0063", "datatype": "uint32", "remark": "总反向峰有功电能(1kWh)"},
{"key": "0x0065", "datatype": "uint32", "remark": "总反向平有功电能(1kWh)"},
{"key": "0x0067", "datatype": "uint32", "remark": "总反向谷有功电能(1kWh)"},
{"key": "0x0069", "datatype": "uint32", "remark": "总反向总有功电能(1kWh)"}
]
},
"TH_YC":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "所属通道号1"},
{"key": "0x0002", "datatype": "uint16", "remark": "所属温湿度号1~10"},
{"key": "0x0003", "datatype": "int16", "remark": "温度(0.1℃)"},
{"key": "0x0004", "datatype": "int16", "remark": "湿度(0.1℃)"}
]
},
"Fire40_YX":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "所属通道号1~10"},
{"key": "0x0002", "datatype": "uint16", "remark": "主控数量1"},
{"key": "0x0003", "datatype": "uint16", "remark": "主控ID1"},
{"key": "0x0004", "datatype": "uint16", "remark": "主控状态0正常 1预警 2火警"},
{"key": "0x0005", "datatype": "uint32", "remark": "主控硬件版本"},
{"key": "0x0007", "datatype": "uint32", "remark": "主控软件版本"},
{"key": "0x0009", "datatype": "uint16", "remark": "主电状态0使用市电 1使用备电"},
{"key": "0x000A", "datatype": "uint32", "remark": "备电电流(0.1A)"},
{"key": "0x000C", "datatype": "uint32", "remark": "备电电压(0.1V)"},
{"key": "0x000E", "datatype": "uint32", "remark": "可用容量(0.01Ah)"},
{"key": "0x0010", "datatype": "uint32", "remark": "可充放容量(0.01Ah)"},
{"key": "0x0012", "datatype": "uint16", "remark": "警铃是否使用"},
{"key": "0x0013", "datatype": "uint16", "remark": "警铃状态0无效 1掉线 2正常 3启动"},
{"key": "0x0014", "datatype": "uint16", "remark": "瓶头阀是否使用"},
{"key": "0x0015", "datatype": "uint16", "remark": "瓶头阀状态0无效 1掉线 2正常 3启动"},
{"key": "0x0016", "datatype": "uint16", "remark": "手报是否使用"},
{"key": "0x0017", "datatype": "uint16", "remark": "手报状态0无效 1掉线 2正常 3启动"},
{"key": "0x0018", "datatype": "uint16", "remark": "簇控制器数量"},
{"key": "0x0019", "datatype": "uint16", "remark": "复合探测器总数量"},
{"key": "0x001A", "datatype": "uint16", "remark": "烟雾探测器总数量"},
{"key": "0x001B", "datatype": "uint16", "remark": "压力探测器总数量"},
{"key": "0x001C", "datatype": "uint16", "remark": "吸气式探测器总数量"},
{"key": "0x001D", "datatype": "uint16", "remark": "PACK探测器总数量"},
{"key": "0x001E", "datatype": "uint16", "remark": "电池总数量"}
]
},
"Cooling_YC":{
"addr":[
{"key": "0x0001", "datatype": "uint16", "remark": "所属通道号1"},
{"key": "0x0002", "datatype": "uint16", "remark": "所属冷机号1~10"},
{"key": "0x0003", "datatype": "int16", "remark": "制冷点(0.1℃)"},
{"key": "0x0004", "datatype": "int16", "remark": "制冷偏差(0.1℃)"},
{"key": "0x0005", "datatype": "int16", "remark": "高温告警值(0.1℃)"},
{"key": "0x0006", "datatype": "int16", "remark": "低温告警值(0.1℃)"},
{"key": "0x0007", "datatype": "int16", "remark": "制热点(0.1℃)"},
{"key": "0x0008", "datatype": "int16", "remark": "制热偏差(0.1℃)"},
{"key": "0x0009", "datatype": "int16", "remark": "电芯温度(0.1℃)"},
{"key": "0x000A", "datatype": "int16", "remark": "环境湿度(0.1℃)"},
{"key": "0x000B", "datatype": "int16", "remark": "吸气温度(0.1℃)"},
{"key": "0x000C", "datatype": "int16", "remark": "排气温度(0.1℃)"},
{"key": "0x000D", "datatype": "int16", "remark": "进水温度/供液温度(0.1℃)"},
{"key": "0x000E", "datatype": "int16", "remark": "出水温度/回液温度(0.1℃)"},
{"key": "0x000F", "datatype": "int16", "remark": "进水压力/供液压力(0.1)"},
{"key": "0x0010", "datatype": "int16", "remark": "出水压力/回液压力(0.1)"},
{"key": "0x0011", "datatype": "int16", "remark": "高压压力(0.1)"},
{"key": "0x0012", "datatype": "int16", "remark": "低压压力(0.1)"},
{"key": "0x0013", "datatype": "int16", "remark": "循环水泵转速"},
{"key": "0x0014", "datatype": "int16", "remark": "压缩机频率"},
{"key": "0x0015", "datatype": "int16", "remark": "室外风机转速"}
]
},
"Cooling_YX":{
"addr":[
{"key": "0x1001", "datatype": "uint16", "remark": "所属通道号1"},
{"key": "0x1002", "datatype": "uint16", "remark": "所属冷机号1~10"},
{"key": "0x1003", "datatype": "uint16", "remark": "开关0关机1开机"},
{"key": "0x1004", "datatype": "uint16", "remark": "采样模式(0-出水温度 1-电芯温度)"},
{"key": "0x1005", "datatype": "uint16", "remark": "制冷状态0关闭,1启动"},
{"key": "0x1006", "datatype": "uint16", "remark": "制热状态0关闭,1启动"},
{"key": "0x1007", "datatype": "uint16", "remark": "高温告警0正常1告警"},
{"key": "0x1008", "datatype": "uint16", "remark": "低温告警0正常1告警"},
{"key": "0x1009", "datatype": "uint16", "remark": "高压告警0正常1告警"},
{"key": "0x100A", "datatype": "uint16", "remark": "低压告警0正常1告警"},
{"key": "0x100B", "datatype": "uint16", "remark": "进水温度传感器0正常1告警"},
{"key": "0x100C", "datatype": "uint16", "remark": "出水温度传感器0正常1告警"},
{"key": "0x100D", "datatype": "uint16", "remark": "进水压力传感器0正常1告警"},
{"key": "0x100E", "datatype": "uint16", "remark": "出水压力传感器0正常1告警"}
]
},
"Gateway_YC":{
"addr":[
{"key": "40001", "datatype": "uint16", "remark": "模式"},
{"key": "40002", "datatype": "uint16", "remark": "峰谷时间段"},
{"key": "40021", "datatype": "uint16", "remark": "自定时间段"},
{"key": "40038", "datatype": "uint16", "remark": "其他参数"}
]
},
"Charger_YC":{
"addr":[
{"key": "11", "datatype": "uint16", "remark": "枪1:状态"},
{"key": "12", "datatype": "uint16", "remark": "枪1:需求电压"},
{"key": "13", "datatype": "uint16", "remark": "枪1:需求电流"},
{"key": "14", "datatype": "uint16", "remark": "枪1:需求功率"},
{"key": "15", "datatype": "uint16", "remark": "枪1:输出电压"},
{"key": "16", "datatype": "uint16", "remark": "枪1:输出电流"},
{"key": "17", "datatype": "uint16", "remark": "枪1:输出功率"},
{"key": "18", "datatype": "uint16", "remark": "枪1:功率限值"},
{"key": "21", "datatype": "uint16", "remark": "枪2:状态"},
{"key": "22", "datatype": "uint16", "remark": "枪2:需求电压"},
{"key": "23", "datatype": "uint16", "remark": "枪2:需求电流"},
{"key": "24", "datatype": "uint16", "remark": "枪2:需求功率"},
{"key": "25", "datatype": "uint16", "remark": "枪2:输出电压"},
{"key": "26", "datatype": "uint16", "remark": "枪2:输出电流"},
{"key": "27", "datatype": "uint16", "remark": "枪2:输出功率"},
{"key": "28", "datatype": "uint16", "remark": "枪2:功率限值"}
]
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -7,69 +7,100 @@
["B相电压", "0x1080", "0.0", " V", "1"],
["B相电流", "0x1086", "0.0", " A"],
["C相电压", "0x1082", "0.0", " V", "1"],
["C相电流", "0x1088", "0.0", " A"]
["C相电流", "0x1088", "0.0", " A"],
["总有功功率", "0x1096", "0.0", " kW"]
],
"addrCurve": ["0x107E", "0x1084", "0x1096"]
},
"PCS":{
"deviceType":102,
"addrYC":[
["充放状态", "0x1009", "--", ""],
["电网状态", "0x100A", "--", ""],
["总充电量", "0x0003", "0.0", " kWh"],
["总放电量", "0x0005", "0.0", " kWh"],
["A相电压", "0x0010", "0.0", " V", "1"],
["A相电流", "0x0019", "0.0", " A"],
["B相电压", "0x0011", "0.0", " V", "1"],
["B相电流", "0x001A", "0.0", " A"],
["C相电压", "0x0011", "0.0", " V", "1"],
["C相电流", "0x001B", "0.0", " A"]
["C相电流", "0x001B", "0.0", " A"],
["总有功功率", "0x0025", "0.0", " kW"]
],
"addrCurve": ["0x0010", "0x0019", "0x0025"]
},
"PCU":{
"deviceType":103,
"addrYC":[
["电网状态", "0x1007", "--", ""],
["模块状态", "0x1008", "--", ""],
["日充电量", "0x0006", "0.0", " kWh"],
["日放电量", "0x0008", "0.0", " kWh"],
["总充电量", "0x000A", "0.0", " kWh"],
["总放电量", "0x000C", "0.0", " kWh"],
["A相电压", "0x0013", "0.0", " V", "1"],
["A相电流", "0x001C", "0.0", " A"],
["B相电压", "0x0014", "0.0", " V", "1"],
["B相电流", "0x001D", "0.0", " A"],
["C相电压", "0x0015", "0.0", " V", "1"],
["C相电流", "0x001E", "0.0", " A"]
["C相电流", "0x001E", "0.0", " A"],
["总有功功率", "0x0028", "0.0", " kW"]
],
"addrCurve": ["0x0013", "0x001C", "0x0028"]
},
"BMS":{
"deviceType":104,
"addrYC":[
["充放状态", "0x004A", "--", ""],
["堆功率", "0x000F", "0.0", " kW"],
["SOC", "0x0001", "0", " %", "0.1"],
["SOH", "0x0002", "0", " %", "0.1"],
["电压", "0x0003", "0.0", " V", "0.1"],
["电流", "0x0005", "0.0", " A", "0.1"],
["单体最电压", "0x0021", "0.0", " V", "0.1"],
["单体最电压", "0x0021", "0.0", " V", "0.1"],
["单体最小电压", "0x0024", "0.0", " V", "0.1"],
["单体最大温度", "0x0029", "0.0", " ℃", "0.1"],
["单体最小温度", "0x002C", "0.0", " ℃", "0.1"]
["单体最小温度", "0x002C", "0.0", " ℃", "0.1"]
],
"addrCurve": ["0x0003", "0x0005", ""]
},
"BCU":{
"deviceType":105,
"addrYC":[
["充放状态", "0xA003", "--", ""],
["运行状态", "0xA004", "--", ""],
["簇可充容量", "0x0019", "0.0", " Ah", "0.1"],
["簇可放容量", "0x001B", "0.0", " Ah", "0.1"],
["簇SOC", "0x000B", "0", " %", "0.1"],
["簇SOH", "0x000C", "0", " %", "0.1"],
["簇电压", "0x0003", "0.0", " V", "0.1"],
["簇电流", "0x0005", "0", " A", "0.1"],
["簇温度", "0x0007", "0.0", " ℃", "0.1"],
["簇电阻", "0x0009", "0.0", " Ω"],
["簇SOC", "0x000B", "0", " %", "0.1"],
["簇SOH", "0x000C", "0", " %", "0.1"]
["簇电阻", "0x0009", "0.0", " Ω"]
],
"addrCurve": ["0x0003", "0x0005", ""]
},
"MEM":{
"deviceType":3,
"addrYC":[
["日充电电量", "0x002F", "0", " kWh"],
["日放电电量", "0x0031", "0", " kWh"],
["总充电电量", "0x004D", "0", " kWh"],
["总放电电量", "0x004F", "0", " kWh"],
["日充电费用", "0x0033", "0", " 元"],
["日放电费用", "0x0035", "0", " 元"],
["总充电费用", "0x0051", "0", " 元"],
["总放电费用", "0x0053", "0", " 元"],
["日收益", "0x0037", "0", " 元"],
["总收益", "0x0055", "0", " 元"],
["A相电压", "0x000B", "0.0", " V"],
["A相电流", "0x000D", "0.0", " A"],
["B相电压", "0x000F", "0.0", " V"],
["B相电流", "0x0011", "0.0", " A"],
["C相电压", "0x0013", "0.0", " V"],
["C相电流", "0x0015", "0.0", " A"]
["C相电流", "0x0015", "0.0", " A"],
["总有功总需量", "0x0025", "0.0", " kW"]
],
"addrCurve": ["0x000B","0x0011","0x0023"]
},
@@ -96,14 +127,15 @@
"Charger": {
"deviceType":106,
"addrYC":[
["需求电压", "31071", "0.0", " V"],
["需求电", "31073", "0.0", " A"],
["需求功率", "31075", "0.0", " kW"],
["功率限值", "31077", "0.0", " kW"],
["输出电压", "31079", "0.0", " V"],
["输出电流", "31081", "0.0", " A"],
["输出功率", "31083", "0.0", " kW"]
["工作状态", "11", "空闲", ""],
["需求电", "12", "0.0", " V", "0.1"],
["需求电流", "13", "0.0", " A", "0.01"],
["需求功率", "14", "0.0", " kW", "0.1"],
["输出电压", "15", "0.0", " V", "0.1"],
["输出电流", "16", "0.0", " A", "0.01"],
["输出功率", "17", "0.0", " kW", "0.1"],
["功率限值", "18", "0.0", " kW", "0.1"]
],
"addrCurve": ["31079", "31081", "31083"]
"addrCurve": ["15", "16", "17"]
}
}

View File

@@ -16,6 +16,11 @@ void Application::init()
{
// 初始化系统配置,读取配置文件
Config::init("assets/config/app.json");
if (Config::option.debug)
{
spdlog::set_level(spdlog::level::debug); // 设置全局日志等级为 debug
spdlog::debug("[app] spdlog debug enable.");
}
// MQTT 数据结构
REGAddr::load("assets/config/regaddrs.json");
@@ -77,8 +82,8 @@ void Application::runThreadMain()
if (!this->isInit) { continue; }
}
static TimeTick ttMqtt(1); // 检查 场站的 MQTT 连接
if (ttMqtt.elapse(20))
static TimeTick ttMqtt; // 检查 场站的 MQTT 连接
if (ttMqtt.elapse(30))
{
auto& optionMqtt = Config::option.mqtt;
if (!optionMqtt.host.empty())
@@ -86,22 +91,21 @@ void Application::runThreadMain()
for (auto& item : appdata.mapStation)
{
auto& station = item.second;
if (station && station->isOpen)
if (station)
{
// 该函数检查连接状态,若已经连接,则无操作;若未连接,则进行连接操作
item.second->initMqtt();
// 召测
item.second->polling();
if (station->isOpen)
{
// 该函数检查连接状态,若已经连接,则无操作;若未连接,则进行连接操作
item.second->initMqtt();
// 召测
item.second->polling();
}
// 检查设备的在线状态
station->checkDevice();
}
}
}
}
static TimeTick ttData(1); // 检查数据
if (ttData.elapse(20))
{
//appdata.initFromDB();
}
}
}
@@ -110,20 +114,14 @@ void Application::runThreadStat()
int nCachePos = 0;
while (!isQuit)
{
int64_t tTime = Utils::time();
int64_t tDate = Utils::date();
int64_t delta = tTime-tDate;
int n = delta / 600;
int offset = delta % 600;
bool flagStore = (delta >=0 && delta < 86400 && offset <= 10 && n != nCachePos);
if (flagStore)
static TimeTick ttStat(1);
if(ttStat.elapse(10))
{
nCachePos = n;
std::string dt = Utils::dateStr(tDate);
// // 设备历史数据(电压、电流、功率),存储到 history_day
// 设备历史数据(电压、电流、功率),存储到 history_day
// 统计数据,存储到 stat_day
for (auto item: appdata.mapStation)
{
item.second->writeRuntimeData(dt, nCachePos);
item.second->writeStatistic();
}
}
else
@@ -131,12 +129,6 @@ void Application::runThreadStat()
//spdlog::info("保存历史数据倒计时: {}", 600 - offset);
}
// 统计计算,存储到 stat_station
for (auto& station : appdata.mapStation)
{
}
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}

View File

@@ -5,6 +5,7 @@
#include "common/JsonN.h"
#include "common/Spdlogger.h"
#include "AppData.h"
#include "protocol/MqttEntity.h"
AppOption Config::option;
@@ -19,49 +20,106 @@ bool Config::init(std::string filename)
}
spdlog::info("[config] load config file success, filename={}", filename);
JSON::read(jsonroot, "debug", option.debug);
JSON::read(jsonroot, "weburl", option.webSrvUrl);
JSON::read(jsonroot, "launchdate", option.lunchDate);
if (jsonroot.contains("database"))
{
njson json = jsonroot.at("database");
njson& json = jsonroot.at("database");
JSON::read(json, "host", option.database.host);
JSON::read(json, "port", option.database.port);
JSON::read(json, "user", option.database.user);
JSON::read(json, "passwd", option.database.passwd);
JSON::read(json, "dbname", option.database.dbname);
spdlog::info("[config] parse database success. host={}", option.database.host);
}
else
{
spdlog::info("[config] parse database failed: not found.");
spdlog::error("[config] parse database failed: not found.");
}
if (jsonroot.contains("http"))
{
njson json = jsonroot.at("http");
std:string token;
JSON::read(json, "token", token);
option.http.useToken = !token.empty();
njson& json = jsonroot.at("http");
JSON::read(json, "token", option.http.useToken);
JSON::read(json, "port", option.http.port);
JSON::read(json, "encryption", option.http.encryption);
JSON::read(json, "encryptKey", option.http.encryptKey);
}
else
{
spdlog::info("[config] parse http failed: not found.");
spdlog::error("[config] parse http failed: not found.");
}
if (jsonroot.contains("mqtt"))
{
njson json = jsonroot.at("mqtt");
njson& json = jsonroot.at("mqtt");
JSON::read(json, "host", option.mqtt.host);
JSON::read(json, "username", option.mqtt.username);
JSON::read(json, "password", option.mqtt.password);
}
else
{
spdlog::info("[config] parse mqtt failed: not found.");
spdlog::error("[config] parse mqtt failed: not found.");
}
JSON::read(jsonroot, "weburl", option.webSrvUrl);
JSON::read(jsonroot, "launchdate", option.lunchDate);
if (jsonroot.contains("view"))
{
njson& json = jsonroot["view"];
JSON::read(json, "latitude", option.view.latitude);
JSON::read(json, "longitude", option.view.longitude);
JSON::read(json, "altitude", option.view.altitude);
}
else
{
spdlog::error("[config] parse view failed: not found.");
}
if (jsonroot.contains("video"))
{
njson& json = jsonroot["video"];
for (auto& item: json.items())
{
auto& key = item.key();
auto& jsonItem = item.value();
auto& itemVideo = option.mapVideo[key];
JSON::read(jsonItem, "host", itemVideo.host);
JSON::read(jsonItem, "port", itemVideo.port);
JSON::read(jsonItem, "user", itemVideo.user);
JSON::read(jsonItem, "passwd", itemVideo.passwd);
}
}
else
{
spdlog::error("[config] parse video failed: not found.");
}
if (jsonroot.contains("topic"))
{
njson& json = jsonroot["topic"];
for (auto& item: json.items())
{
auto& key = item.key();
auto& jsonItem = item.value();
auto& info = MqttClient::s_mapTopicInfo[key];
info.name = key;
JSON::read(jsonItem, "deviceType", info.deviceType);
JSON::read(jsonItem, "polling", info.polling);
JSON::read(jsonItem, "enabled", info.enabled);
}
}
return true;
}
AppOption::VideoInfo* Config::getVideoInfo(std::string name)
{
auto iter = option.mapVideo.find(name);
if (iter!=option.mapVideo.end())
{
return &(iter->second);
}
return nullptr;
}

View File

@@ -1,23 +1,27 @@
#pragma once
#include <map>
#include <string>
struct DatabaseOption
{
std::string host;
int port;
std::string user;
std::string passwd;
std::string dbname;
};
struct AppOption
{
DatabaseOption database;
int debug {0};
std::string webSrvUrl;
std::string lunchDate;
struct {
bool useToken {true};
std::string host;
int port;
std::string user;
std::string passwd;
std::string dbname;
} database;
struct {
int useToken {1};
int port {0};
int encryption {1};
std::string encryptKey;
} http;
struct {
@@ -26,8 +30,20 @@ struct AppOption
std::string password;
} mqtt;
std::string webSrvUrl;
std::string lunchDate;
struct {
float latitude {0};
float longitude {0};
float altitude {0};
} view;
struct VideoInfo {
std::string host;
int port;
std::string user;
std::string passwd;
};
std::map<std::string, VideoInfo> mapVideo;
};
@@ -36,6 +52,7 @@ class Config
public:
static bool init(std::string filename);
static AppOption::VideoInfo* getVideoInfo(std::string name);
static AppOption option;
};

View File

@@ -34,16 +34,14 @@ void REGAddr::load(std::string filename)
for (auto& item : jsonaddrs)
{
std::string addr = item["key"];
mapItem[addr] = RegAddrUnit(addr, item["datatype"], item["remark"]);
std::string datatype = JSON::read<std::string>(item, "datatype");
std::string remark = JSON::read<std::string>(item, "remark");
std::string name = JSON::read<std::string>(item, "name");
int alert = JSON::read<int>(item, "alert");
mapItem[addr] = RegAddrUnit(addr, datatype, alert, name, remark);
}
}
}
//for (auto& item: s_mapReg["EMS_YC"])
//{
// auto& unit = item.second;
// spdlog::info("[{}]={}, {}", unit.key, unit.datatype, unit.remark);
//}
}
std::map<std::string, RegAddrUnit>* REGAddr::getRegMap(std::string name)

View File

@@ -2,21 +2,57 @@
#include <map>
#include <string>
enum class EAlertType
{
SYS = 1, // 系统告警
USER = 2, // 用户告警
DEVICE = 3, // 设备告警
};
enum class EDeviceType
{
//1 变压器 0
//2 配电柜 0
//3 电表 1
//4 门禁 0
//5 空调 0
//6 照明 0
//7 消防 0
//8 光照监测设备 0
//9 风速监测设备 0
//10 温湿度监测设备 0
//11 烟感监测设备 0
//12 水浸传感器 0
//13 视频监控 4
//14 冷机 0
//15 网关 0
//100 储能预制舱 1
EMS = 101,//101 EMS 1
PCS = 102, //102 PCS 1
PCU = 103, //103 PCU 1
BMS = 104, //104 BMS 1
BCU = 105, //105 BCU 1
//106 充电桩 2
//107 充电枪 2
//108 集中器 2
//109 光伏板 3
//110 风力发电机 3
};
struct RegAddrUnit
{
std::string key;
std::string datatype;
int bytes {0};
std::string name;
std::string remark;
int ratio {1};
int alert {0};
RegAddrUnit() {}
RegAddrUnit(std::string key, std::string datatype, std::string remark)
: key(key), datatype(datatype), remark(remark)
RegAddrUnit(std::string key, std::string datatype, int alert, std::string name, std::string remark)
: key(key), datatype(datatype), alert(alert), name(name), remark(remark)
{
if (datatype == "uint16" || datatype == "int16") { bytes = 1; }
else if (datatype == "uint32" || datatype == "int32") { bytes = 2; }
}
};

View File

@@ -4,7 +4,7 @@
#include "common/Utils.h"
#include "protocol/CommEntity.h"
#include "common/JsonN.h"
#include "app/DataStruct.h"
#include <unordered_set>
std::map<int, std::vector<DeviceParamAddr>> Device::s_mapDeviceAddrParam;
@@ -76,6 +76,13 @@ void Device::loadParamAddr(std::string filename)
}
}
static const int BCU_UNIT_SIZE = 256;
Device::Device()
{
vecBCUUnit = std::vector<std::vector<float>>(BCU_UNIT_SIZE, std::vector<float>(5, 0.0f));
}
void Device::setFields(Fields& fields)
{
fields.get("station_id", this->stationId);
@@ -256,6 +263,9 @@ void Device::storeDB(int npos)
void Device::setParam(std::string k, int v)
{
this->ts = Utils::time();
online = 1;
float ratio = 1.0;
auto iter = mapMyParams.find(k);
if (iter != mapMyParams.end())
@@ -264,40 +274,62 @@ void Device::setParam(std::string k, int v)
//spdlog::info("[device] set param: {} {}={}, ratio={}", iter->second->name, k, v, ratio);
}
if (type == 106) // 充电桩2号枪特殊数据格式
{
if (k=="22") { ratio = 0.1; }
else if (k=="23") { ratio = 0.01; }
else if (k== "24") { ratio = 0.1; }
else if (k== "25") { ratio = 0.1; }
else if (k== "26") { ratio = 0.01; }
else if (k== "27") { ratio = 0.1; }
else if (k== "28") { ratio = 0.1; }
}
int precision = (ratio != 1.0f) ? 1 : 0;
mapParams[k] = Utils::toStr(v*ratio, precision);
std::string valStr = Utils::toStr(v*ratio, precision);
if (type == 106) // 充电桩状态,特殊数据格式
{
if (k=="11" || k == "21") {
valStr = (valStr == "1" ? "充电" : "空闲");
}
}
mapParams[k] = valStr;
if (type == 3 ) // 电表
{
if (k == "") this->err = v;
{
running = 1;
}
else if (type == 101) // EMS
{
running = 1;
}
else if (type == 102) // PCS
{
if (k == "0x1003") err = v; // 故障状态 R uint16 1故障0正常 0 0x1003
if (k == "0x1005") online = v; // 设备在线 R uint16 1在线0无效 1 0x1005
if (k == "0x1009") running = (v==1 || v==2); //充放状态 R uint16 0待机, 1充电, 2放电, 3搁置 0 0x1009
if (k == "0x1003") err = v; // 故障状态 R uint16 1故障0正常 0 0x1003
else if (k == "0x1005") online = v; // 设备在线 R uint16 1在线0无效 1 0x1005
else if (k == "0x1009") running = (v==1 || v==2); //充放状态 R uint16 0待机, 1充电, 2放电, 3搁置 0 0x1009
}
else if (type == 103) // PCU
{
if (k == "0x1002") err = v; //故障状态 R uint16 1故障0正常 0 0x1002
if (k == "0x1004") online = v; //设备在线 R uint16 1在线0无效 1 0x1004
if (k == "0x1006") running = v; //启停状态 R uint16 1开机0关机 1 0x1006
if (k == "0x1002") err = v; //故障状态 R uint16 1故障0正常 0 0x1002
else if (k == "0x1004") online = v; //设备在线 R uint16 1在线0无效 1 0x1004
else if (k == "0x1006") running = v; //启停状态 R uint16 1开机0关机 1 0x1006
}
else if (type == 104) // BMS
{
if (k == "0x004A") { err = (v==1); online = 1; } //运行状态 R uint16 0 运行状态 0-正常 1-告警 2-保护 0x004A
if (k == "0x004B") running = (v==1 || v==2); //充放电状态 R uint16 0 0-待机 1-充电 2-放电 0x004B
if (k == "0x004A") { err = (v==1); } //运行状态 R uint16 0 运行状态 0-正常 1-告警 2-保护 0x004A
else if (k == "0x004B") running = (v==1 || v==2); //充放电状态 R uint16 0 0-待机 1-充电 2-放电 0x004B
}
else if (type == 105) // BCU
else if (type == int(EDeviceType::BCU)) // BCU
{
if (k == "0xA003") running = (v==0x33 || v==0x44); //蓄电池充放电状态 R uint16 "0x11开路,0x22待机,0x33充电,0x44放电" 34 0xA003
if (k == "0xA004") err = (v==0x55); online=1; //电池组运行状态 R uint16 "0x11跳机,0x22待机,0x33放空,0x44充满,0x55预警,0x66正常" 102 0xA004
if (k == "0xA003") { running = (v==0x33 || v==0x44); } //蓄电池充放电状态 R uint16 "0x11开路,0x22待机,0x33充电,0x44放电" 34 0xA003
else if (k == "0xA004") { err = (v==0x55); } //电池组运行状态 R uint16 "0x11跳机,0x22待机,0x33放空,0x44充满,0x55预警,0x66正常" 102 0xA004
}
else if (type == 106) // 充电桩
{
if (k == "21") {
running = (mapParams["11"] == "充电" || mapParams["21"] == "充电"); // 充电状态: 0空闲1充电
}
}
else if (type == 109) // 光伏板
{
@@ -329,13 +361,69 @@ void Device::getRuntimeParams(std::vector<std::pair<std::string, std::string>>&
// 106 充电桩
// 109 光伏板
auto& vecAddr = s_mapDeviceAddrParam[this->type];
for (auto& itemAddr: vecAddr)
for (auto& item: vecAddr)
{
std::string v;
v = getParam(itemAddr.addr, itemAddr.defaultVal) + itemAddr.unit;
std::string v = getParam(item.addr, item.defaultVal);
if (type == int(EDeviceType::BCU) )
{
if (item.addr == "0xA003") //"0x11开路0x22待机0x33充电0x44放电"
{
if (v == "17") v = "开路";
else if (v == "34") v = "待机";
else if (v == "51") v = "充电";
else if (v == "68") v = "放电";
}
else if (item.addr == "0xA004") //"0x11跳机 0x22待机0x33放空0x44充满0x55预警0x66正常"
{
if (v == "17") v = "跳机";
else if (v == "34") v = "待机";
else if (v == "51") v = "放空";
else if (v == "68") v = "充满";
else if (v == "85") v = "预警";
else if (v == "102") v = "正常";
}
}
else if (type == int(EDeviceType::BMS))
{
if (item.addr == "0x004A") // 0-待机 1-充电 2-放电
{
if (v == "0") v = "待机";
else if (v == "1") v = "充电";
else if (v == "2") v = "放电";
}
}
else if (type == int(EDeviceType::PCU))
{
if (item.addr == "0x1007") // 电网状态 R uint16 1离网0并网 0x1007
{
if (v == "0") v = "并网";
else if (v == "1") v = "离网";
}
if (item.addr == "0x1008") // 模块状态 R uint16 1开机0待机 0x1008
{
if (v == "0") v = "开机";
else if (v == "1") v = "待机";
}
}
else if (type == int(EDeviceType::PCS))
{
if (item.addr == "0x1009") //充放状态 R uint16 0待机, 1充电, 2放电, 3搁置 0x1009
{
if (v == "0") v = "待机";
else if (v == "1") v = "充电";
else if (v == "2") v = "放电";
else if (v == "3") v = "搁置";
}
else if (item.addr == "0x100A") //电网状态 R uint16 1离网0并网 0x100A
{
if (v == "0") v = "并网";
else if (v == "1") v = "离网";
}
}
//if (this->online) { }
//else { v = "--"; }
params.push_back({itemAddr.name, v});
params.push_back({item.name, v + item.unit});
}
}
@@ -343,12 +431,39 @@ void Device::getRuntimeParams1(std::vector<std::pair<std::string, std::string>>&
{
if (type == 106)
{
params.push_back({"需求电压", getParam("31072", "0.0") + " V"});
params.push_back({"需求电", getParam("31074", "0.0") + " A"});
params.push_back({"需求功率", getParam("31076", "0.0") + " kW"});
params.push_back({"功率限值", getParam("31078", "0.0") + " kW"});
params.push_back({"输出电压", getParam("31080", "0.0") + " V"});
params.push_back({"输出电流", getParam("31082", "0.0") + " A"});
params.push_back({"输出功率", getParam("31084", "0.0") + " kW"});
params.push_back({"工作状态", getParam("21", "空闲")});
params.push_back({"需求电", getParam("22", "0.0") + " V"});
params.push_back({"需求电流", getParam("23", "0.0") + " A"});
params.push_back({"需求功率", getParam("24", "0.0") + " kW"});
params.push_back({"输出电压", getParam("25", "0.0") + " V"});
params.push_back({"输出电流", getParam("26", "0.0") + " A"});
params.push_back({"输出功率", getParam("27", "0.0") + " kW"});
params.push_back({"功率限值", getParam("28", "0.0") + " kW"});
}
}
void Device::setBCUUnit(std::string k, int pos, int v, int count)
{
//单体SOC R uint16[1000] 0.1 0x0056~0x043D
//单体SOH R uint16[1000] 0.1 0x043E~0x0825
//单体电压 R uint16[1000] mV 0x0826~0x0C0D
//单体温度 R int16[1000] 0.01℃ 0x0C0E~0x0FF5
//单体内阻 R uint16[1000] mΩ 0x0FF6~0x13DD
if (pos < BCU_UNIT_SIZE)
{
auto& bcuUnit = vecBCUUnit[pos];
if (pos == 0)
{
bcuCount = count;
for (int i = count; i<BCU_UNIT_SIZE; ++i)
{
std::fill(vecBCUUnit[i].begin(), vecBCUUnit[i].end(), 0.0f);
}
}
if (k == "0x0056") { bcuUnit[0] = float(v) * 0.1f; }
else if (k == "0x043E") { bcuUnit[1] = float(v) * 0.1f; }
else if (k == "0x0826") { bcuUnit[2] = float(v) * 0.001f; }
else if (k == "0x0C0E") { bcuUnit[3] = float(v); } // * 0.01f
else if (k == "0x0FF6") { bcuUnit[4] = float(v); }
}
}

View File

@@ -11,6 +11,7 @@
class CommEntity;
// 需要在前端展示的设备参数
struct DeviceParamAddr
{
std::string name;
@@ -35,6 +36,8 @@ public:
static std::shared_ptr<Device> create(Fields& fields);
static void loadParamAddr(std::string filename);
Device();
void setFields(Fields& fields);
int startComm();
@@ -55,6 +58,8 @@ public:
void getRuntimeParams(std::vector<std::pair<std::string, std::string>>& params);
void getRuntimeParams1(std::vector<std::pair<std::string, std::string>>& params);
void setBCUUnit(std::string k, int pos, int v, int count);
public:
static std::map<int, std::vector<DeviceParamAddr>> s_mapDeviceAddrParam;
static std::map<int, std::vector<std::string>> s_mapDeviceAddrCurve;
@@ -73,6 +78,8 @@ public:
int online = 0;
int running = 0;
int64_t ts {0};
//std::map<std::string, std::string> mapAttrs;
Fields attrs;
@@ -87,5 +94,7 @@ public:
std::map<std::string, DeviceParamAddr*> mapMyParams;
std::vector<std::vector<float>> vecBCUUnit;
int bcuCount {0};
};

View File

@@ -99,13 +99,13 @@ void SysPolicy::parseJsonPeriods(njson& jsonroot)
{
auto& jsonP = item["charge_time"];
vecPeriods1[i].push_back({jsonP[0], ""}); // 第一/二次充电开始
vecPeriods1[i].push_back({jsonP[1], ""}); // 第一/二次充电结束
vecPeriods1[i].push_back({jsonP[1], ""}); // 第一/二次充电结束
}
if (item.contains("discharge_time") && item["discharge_time"].size() >= 2)
{
auto& jsonP = item["discharge_time"];
vecPeriods1[i].push_back({jsonP[0], ""}); // 第一/二次放电开始
vecPeriods1[i].push_back({jsonP[1], ""}); // 第一/二次放电结束
vecPeriods1[i].push_back({jsonP[1], ""}); // 第一/二次放电结束
}
}
}
@@ -123,9 +123,8 @@ static void PeriodsTimeStrToInt(std::string str, int& h, int& m)
void SysPolicy::getGatewayJsonPeriods(njson& json)
{
if (type == 1 || type == 5)
if (type == 1)
{
// std::vector<std::vector<std::pair<std::string, std::string>>>
for (auto& itemMonth: vecPeriods1)
{
njson jsonArrayMonth = njson::array();
@@ -143,4 +142,22 @@ void SysPolicy::getGatewayJsonPeriods(njson& json)
json.push_back(jsonArrayMonth);
}
}
else if (type == 5)
{
if (vecPeriods1.size()>0)
{
for (auto& item: vecPeriods1[0])
{
int h = 0; int m = 0;
PeriodsTimeStrToInt(item.first, h, m);
int p = 1;
if (item.second == "") p = 1;
else if (item.second == "") p = 2;
else if (item.second == "") p = 3;
else if (item.second == "") p = 4;
else p = 0;
json.push_back({h, m, p});
}
}
}
}

View File

@@ -8,24 +8,12 @@
#include "protocol/MqttEntity.h"
#include "common/JsonN.h"
#include "app/Config.h"
#include "common/Snowflake.h"
#include "app/DataStruct.h"
Station::Station() : stationId(0)
{
mqttCli = std::make_shared<MqttClient>();
// 测试,设置默认值
for (int i = 1; i<=5; i++) {
auto& unit = mapCoolingUnit[i];
unit.powerOn = 1;
unit.mode = i%2;
}
for (int i = 1; i<=5; i++) {
auto& unit = mapAircUnit[i];
unit.powerOn = 1;
unit.temp = Utils::random(20, 40);
unit.hum = Utils::random(20, 80);
}
}
void Station::setFields(Fields& fields)
@@ -33,12 +21,12 @@ void Station::setFields(Fields& fields)
this->stationId = fields.get<int>(DMStation::STATION_ID);
this->name = fields.value(DMStation::NAME);
this->capacity = fields.get<double>(DMStation::CAPACITY);
this->workModeId = fields.get<int>(DMStation::WORK_MODE);
this->workMode = fields.get<int>(DMStation::WORK_MODE);
this->code = fields.value(DMStation::CODE);
this->status = fields.get<int>(DMStation::STATUS);
this->operationDate = fields.value(DMStation::OPERATION_DATE);
this->isOpen = fields.get<int>(DMStation::STATUS);
this->launchDate = fields.value("operation_date");
this->policy.setFields(fields);
}
@@ -134,7 +122,7 @@ void Station::getDeviceByCategory(int category, std::vector<std::shared_ptr<Devi
void Station::setWorkMode(int modeId)
{
this->workModeId = modeId;
this->workMode = modeId;
std::string sql = SQL(SQL::TYPE::update).table(DMStation::TABLENAME)
.update(DMStation::WORK_MODE, std::to_string(modeId))
.where(DMStation::STATION_ID + "=" + std::to_string(stationId)).str();
@@ -157,71 +145,6 @@ void Station::setPolicy(int policyId)
}
}
static std::string MapValueToJson(int npos, std::map<int, double>& mapV)
{
njson jsonarray = njson::array();
for (int i = 0; i<=npos; i++)
{
jsonarray.push_back(mapV[i]);
}
return jsonarray.dump();
}
void Station::writeRuntimeData(std::string dt, int npos)
{
auto dao = DaoEntity::create("history_day");
for (auto iter = mapDevice.begin(); iter!=mapDevice.end(); ++iter)
{
auto device = iter->second;
if (device->cache(npos))
{
Fields fields;
fields.set("dt", dt);
fields.set("station_id", this->stationId);
fields.set("device_id", device->deviceId);
fields.set("datatype", 1);
fields.set("value", MapValueToJson(npos, device->mapCacheVoltage));
DAO::insertRuntimeData(dao, fields);
fields.set("datatype", 2);
fields.set("value", MapValueToJson(npos, device->mapCacheCurrent));
DAO::insertRuntimeData(dao, fields);
fields.set("datatype", 3);
fields.set("value", MapValueToJson(npos, device->mapCachePower));
DAO::insertRuntimeData(dao, fields);
spdlog::info("[device] write runtime date to database, deviceId={}", device->deviceId);
}
}
}
void Station::writeStatistic(std::string dt)
{
Fields fields;
fields.set("storage_elect_in", statData.totalElectIn);
fields.set("storage_elect_out", statData.totalElectOut);
//fields.set("storage_num_in", statData.totalElectIn);
//fields.set("storage_num_out", 0);
//fields.set("storage_num_err", 0);
//fields.set("storage_t_in", 0);
//fields.set("storage_t_out", 0);
//fields.set("storage_usage", 0);
//fields.set("solar_elect_gen", 0);
//fields.set("solar_elect_grid", 0);
//fields.set("solar_num_err", 0);
//fields.set("solar_t", 0);
//fields.set("solar_usage", 0);
//fields.set("charge_elect", 0);
//fields.set("charge_num", 0);
//fields.set("charge_num_err", 0);
//fields.set("charge_t", 0);
//fields.set("charge_usage", 0);
fields.set("income_elect", statData.totalIncome);
//fields.set("income_charge", 0);
//fields.set("usage_rate", 0);
}
void Station::initMqtt()
{
if (status!=0 && mqttCli)
@@ -249,7 +172,7 @@ void Station::setGarewayWorkMode()
njson json;
json["ts"] = Utils::time();
json["no"] = 1; // 设备编号
json["40001"] = this->workModeId;
json["40001"] = this->workMode;
if (policy.type == 1)
{
@@ -267,31 +190,75 @@ void Station::setGarewayWorkMode()
mqttCli->publish("Gateway_YT", text);
}
void Station::setRuntimeData(string addr, int val)
void Station::checkDevice()
{
if (addr == "0x110E") { statData.dayElectIn = val; } //日充电电量 R uint32 1kWh 0 0x110E
else if (addr == "0x1110") { statData.dayElectOut = val; } //日放电电量 R uint32 1kWh 0 0x1110
else if (addr == "0x1112") { statData.dayIncomeIn = val; } //日充电费用 R uint32 1RMB 0 0x1112
else if (addr == "0x1114") { statData.dayIncomeOut = val; } //日放电费用 R uint32 1RMB 0 0x1114
else if (addr == "0x1116") { statData.dayIncome = val; } //日收益 R int32 1RMB 0 0x1116
else if (addr == "0x112C") { statData.totalElectIn = val; } //总充电电量 R uint32 1kWh 6659(0x112D) 0x112C
else if (addr == "0x112E") { statData.totalElectOut = val; } //总放电电量 R uint32 1kWh 4925(0x112F) 0x112E
else if (addr == "0x1130") { statData.totalIncomeIn = val; } //总充电费用 R uint32 1RMB 6605(0x1131) 0x1130
else if (addr == "0x1132") { statData.totalIncomeOut = val; } //总放电费用 R uint32 1RMB 4949(0x1133) 0x1132
else if (addr == "0x1134") { statData.totalIncome = val; } //总收益 R int32 1RMB -1 0x1134
for (auto& item: mapDevice)
{
auto& device = item.second;
if (device)
{
if (Utils::time() - device->ts > 60*6)
{
device->online = 0;
}
}
}
}
void Station::setTHData(int deviceNo, string addr, int val)
void Station::readAlert(std::shared_ptr<Device> device, int v, std::string text)
{
Fields fields;
fields.set("log_id", Snowflake::instance().getIdStr());
if (device) { fields.set("device_id", device->deviceId); }
fields.set("type", int(EAlertType::DEVICE));
fields.set("context", text + ":故障(" + std::to_string(v) + ")");
fields.set("status", 1);
auto dao = DaoEntity::create("log_alert");
dao->insertFields(fields);
}
void Station::readRuntimeData(int deviceNo, string addr, int val)
{
if (deviceNo == 1)
{
if (addr == "0x000B") { this->voltage = val; } // A相电压 R uint32 1V 0x000B
if (addr == "0x0011") { this->current = val; } // A相电流 R int32 1A 0x0011
if (addr == "0x0011") { this->power = val; } // 三相总有功 R int32 1kW 0x0023
}
else if (deviceNo == 2)
{
statData.ts = Utils::time();
if (addr == "0x002F") { statData.dayElectIn = val; } //日充电电量 R uint32 1kWh 0x002F
else if (addr == "0x0031") { statData.dayElectOut = val; } //日放电电量 R uint32 1kWh 0x0031
else if (addr == "0x0033") { statData.dayFeeIn = val; } //日充电费用 R uint32 1RMB 0x0033
else if (addr == "0x0035") { statData.dayFeeOut = val; } //日放电费用 R uint32 1RMB 0x0035
else if (addr == "0x0037") { statData.dayIncome = val; } //日收益 R int32 1RMB 0x0037
else if (addr == "0x004D") { statData.totalElectIn = val; } //总充电电量 R uint32 1kWh 0x004D
else if (addr == "0x004F") { statData.totalElectOut = val; } //总放电电量 R uint32 1kWh 0x004F
else if (addr == "0x0051") { statData.totalFeeIn = val; } //总充电费用 R uint32 1RMB 0x0051
else if (addr == "0x0053") { statData.totalFeeOut = val; } //总放电费用 R uint32 1RMB 0x0053
else if (addr == "0x0055") { statData.totalIncome = val; } //总收益 R int32 1RMB 0x0055
}
}
void Station::readTHData(int deviceNo, string addr, int val)
{
auto& unit = mapTempHumUnit[deviceNo];
if (addr == "0x0001") { ; } //所属通道号 R uint16 1 0x0001
else if (addr == "0x0002") { ; } //所属温湿度号 R uint16 1~10 0x0002
else if (addr == "0x0003") { unit.temp = float(val) * 0.1; } //温度 R int16 0.1℃ 0x0003
else if (addr == "0x0004") { unit.hum = float(val) * 0.1; } //湿度 R int16 0.1℃ 0x0004
else if (addr == "0x0003") //温度 R int16 0.1℃ 0x0003
{
unit.temp = float(val) * 0.1;
if (deviceNo == 1) temperature = unit.temp;
}
else if (addr == "0x0004") //湿度 R int16 0.1℃ 0x0004
{
unit.hum = float(val) * 0.1;
if (deviceNo == 1) humidity = unit.hum;
}
}
void Station::setFire40Data(int deviceNo, string addr, int val)
void Station::readFire40Data(int deviceNo, string addr, int val)
{
auto& unit = mapFire40Unit[deviceNo];
@@ -322,14 +289,14 @@ void Station::setFire40Data(int deviceNo, string addr, int val)
}
void Station::setCoolingData(int deviceNo, string addr, int val)
void Station::readCoolingData(int deviceNo, string addr, int val)
{
auto& unit = mapCoolingUnit[deviceNo];
if (addr == "0x1001") { ; } //所属通道号 R uint16 1 0x1001
else if (addr == "0x1002") { ; }// 所属冷机号 R uint16 1~10 0x1002
else if (addr == "0x1003") { unit.powerOn = val; }// 开关 R uint16 0关机1开机 0x1003
else if (addr == "0x1004") { ; }// 采样模式 R uint16 0-出水温度 1-电芯温度 0x1004
else if (addr == "0x1003") { coolingStatus = unit.powerOn = val; }// 开关 R uint16 0关机1开机 0x1003
else if (addr == "0x1004") { unit.mode = val; }// 采样模式 R uint16 0-出水温度 1-电芯温度 0x1004
else if (addr == "0x1005") { unit.cooling = val; }// 制冷状态 R uint16 0关闭, 1启动 0x1005
else if (addr == "0x1006") { unit.heating = val; }// 制热状态 R uint16 0关闭, 1启动 0x1006
else if (addr == "0x1007") { unit.highTemp = val; }// 高温告警 R uint16 0正常1告警 0x1007
@@ -340,4 +307,135 @@ void Station::setCoolingData(int deviceNo, string addr, int val)
else if (addr == "0x100C") { ; }// 出水温度传感器 R uint16 0正常1告警 0x100C
else if (addr == "0x100D") { ; }// 进水压力传感器 R uint16 0正常1告警 0x100D
else if (addr == "0x100E") { ; }// 出水压力传感器 R uint16 0正常1告警 0x100E
}
}
void Station::readGatewayMode(int mode)
{
if (mode != this->workMode)
{
//this->setGarewayWorkMode();
}
}
void Station::readGatewayStatus(int cdzStatus, int emuStatus)
{
//充电桩 1在线0离线
if (cdzStatus >= 0)
{
if (cdzStatus != this->cdzStatus)
{
std::string text = "场站[" + name + "(" + std::to_string(stationId) + ")]充电桩状态变化:" + (cdzStatus>0 ? "在线" : "离线");
if (this->cdzStatus < 0) { text = "系统启动," + text; }
DAO::insertSystemLogDevice(stationId, 0, text, cdzStatus);
this->cdzStatus = cdzStatus;
}
}
//储能 1在线0离线
if (emuStatus >= 0)
{
if (emuStatus != this->emuStatus)
{
std::string text = "场站[" + name + "(" + std::to_string(stationId) + ")]储能EMU状态变化" + (emuStatus>0 ? "在线" : "离线");
if (this->emuStatus < 0) { text = "系统启动," + text; }
DAO::insertSystemLogDevice(stationId, 0, text, emuStatus);
this->emuStatus = emuStatus;
}
}
}
static std::string MapValueToJson(int npos, std::map<int, double>& mapV)
{
njson jsonarray = njson::array();
for (int i = 0; i<=npos; i++)
{
jsonarray.push_back(mapV[i]);
}
return jsonarray.dump();
}
void Station::writeStatistic()
{
auto dao = DaoEntity::create("history_day");
std::string dt = Utils::dateStr();
int64_t tTime = Utils::time();
int64_t tDate = Utils::date();
int npos = (tTime-tDate) / 600;
for (auto iter = mapDevice.begin(); iter!=mapDevice.end(); ++iter)
{
auto device = iter->second;
if (device->cache(npos))
{
Fields fields;
fields.set("dt", dt);
fields.set("station_id", this->stationId);
fields.set("device_id", device->deviceId);
fields.set("datatype", 1);
fields.set("value", MapValueToJson(npos, device->mapCacheVoltage));
DAO::insertRuntimeData(dao, fields);
fields.set("datatype", 2);
fields.set("value", MapValueToJson(npos, device->mapCacheCurrent));
DAO::insertRuntimeData(dao, fields);
fields.set("datatype", 3);
fields.set("value", MapValueToJson(npos, device->mapCachePower));
DAO::insertRuntimeData(dao, fields);
//spdlog::info("[device] write runtime date to database, deviceId={}", device->deviceId);
}
}
if (statData.ts != 0)
{
Fields fields;
fields.set("dt", Utils::dateStr(statData.ts));
fields.set("station_id", this->stationId);
fields.set("category", 1);
fields.set("device_id", 0);
fields.set("elect_in", statData.dayElectIn);
fields.set("elect_out", statData.dayElectOut);
fields.set("fee_in", statData.dayFeeIn);
fields.set("fee_out", statData.dayFeeOut);
fields.set("income", statData.dayIncome);
//fields.set("num_in", "");
//fields.set("num_out", "");
//fields.set("num_err", "");
//fields.set("t_in", "");
//fields.set("t_out", "");
//fields.set("usage_rate", "");
fields.set("elect_in_total", statData.totalElectIn);
fields.set("elect_out_total", statData.totalElectOut);
fields.set("fee_in_total", statData.totalFeeIn);
fields.set("fee_out_total", statData.totalFeeOut);
fields.set("income_total", statData.totalIncome);
dao->setTableName("stat_storage");
std::vector<std::string> vecKeys = {
"elect_in", "elect_out", "num_in", "num_out", "num_err", "t_in", "t_out", "usage_rate", "fee_in", "fee_out",
"elect_in_total", "elect_out_total", "fee_in_total", "fee_out_total", "income_total"
};
dao->duplicateUpdate(fields, vecKeys);
{
Fields fields;
fields.set("dt", Utils::dateStr(statData.ts));
fields.set("station_id", this->stationId);
fields.set("device_id", 0);
fields.set("storage_elect_in", statData.dayElectIn);
fields.set("storage_elect_out", statData.dayElectOut);
fields.set("income_elect", statData.dayIncome);
DAO::insertStatStation(dao, fields);
}
{
Fields fields;
fields.set("station_id", this->stationId);
fields.set("elect_in", statData.dayElectIn);
fields.set("elect_out", statData.dayElectOut);
fields.set("income", statData.dayIncome);
dao->setTableName("stat_total");
dao->duplicateUpdate(fields, {"elect_in", "elect_out", "income"});
}
}
}

View File

@@ -109,17 +109,20 @@ public:
void setWorkMode(int modeId);
void setPolicy(int policyId);
void writeRuntimeData(std::string dt, int npos);
void writeStatistic(std::string dt);
void initMqtt();
void polling();
void setGarewayWorkMode();
void checkDevice();
void setRuntimeData(string addr, int val);
void setTHData(int deviceNo, string addr, int val);
void setFire40Data(int deviceNo, string addr, int val);
void setCoolingData(int deviceNo, string addr, int val);
void readAlert(std::shared_ptr<Device> device, int v, std::string text);
void readRuntimeData(int deviceNo, string addr, int val);
void readTHData(int deviceNo, string addr, int val);
void readFire40Data(int deviceNo, string addr, int val);
void readCoolingData(int deviceNo, string addr, int val);
void readGatewayMode(int mode);
void readGatewayStatus(int cdzStatus, int emuStatus);
void writeStatistic();
public:
int stationId {};
@@ -129,14 +132,13 @@ public:
int status {0};
std::string operationDate;
SysPolicy policy;
std::string launchDate {};
bool isConnected {false};
int workModeId {}; // 运行模式
int workMode {}; // 运行模式
int runPolicyId {}; // 运行策略
///////////////////////////////////////////////////////////////////////////////////////////////
/// === 系统统计 ===
// 累计发电量单位kWh
@@ -185,6 +187,12 @@ public:
double temperature {};
// 湿度
double humidity {};
int aircStatus {0};
int coolingStatus {0};
double voltage {0};
double current {0};
double power {0};
double powerFactor {0};
///////////////////////////////////////////////////////////////////////////////////////////////
/// === 设备信息 ===
@@ -207,25 +215,25 @@ public:
struct {
int64_t ts;
int64_t ts {0};
double totalElectIn; //总充电电量 R uint32 1kWh 6659(0x112D) 0x112C
double totalElectOut; //总放电电量 R uint32 1kWh 4925(0x112F) 0x112E
double totalIncomeIn; //总充电费用 R uint32 1RMB 6605(0x1131) 0x1130
double totalIncomeOut; //总放电费用 R uint32 1RMB 4949(0x1133) 0x1132
double totalIncome; //总收益 R int32 1RMB -1 0x1134
float totalElectIn {0.0}; //总充电电量 R uint32 1kWh 6659(0x112D) 0x112C
float totalElectOut {0.0}; //总放电电量 R uint32 1kWh 4925(0x112F) 0x112E
float totalFeeIn {0.0}; //总充电费用 R uint32 1RMB 6605(0x1131) 0x1130
float totalFeeOut {0.0}; //总放电费用 R uint32 1RMB 4949(0x1133) 0x1132
float totalIncome {0.0}; //总收益 R int32 1RMB -1 0x1134
//储能充放电时段hh R uint16 时 336 0x01 0x121C
//储能充放电时段mm R uint16 分 0 0x01 0x121D
//储能充放电时段ss R uint16 秒 0 0x01 0x121E
double totalDurationIn;
double totalDurationOut;
float totalDurationIn {0.0};
float totalDurationOut {0.0};
double dayElectIn; // 日充电电量 R uint32 1kWh 0 0x110E
double dayElectOut; // 日放电电量 R uint32 1kWh 0 0x1110
double dayIncomeIn; // 日充电费用 R uint32 1RMB 0 0x1112
double dayIncomeOut; // 日放电费用 R uint32 1RMB 0 0x1114
double dayIncome; // 日收益 R int32 1RMB 0 0x1116
float dayElectIn {0.0}; // 日充电电量 R uint32 1kWh 0 0x110E
float dayElectOut {0.0}; // 日放电电量 R uint32 1kWh 0 0x1110
float dayFeeIn {0.0}; // 日充电费用 R uint32 1RMB 0 0x1112
float dayFeeOut {0.0}; // 日放电费用 R uint32 1RMB 0 0x1114
float dayIncome {0.0}; // 日收益 R int32 1RMB 0 0x1116
} statData;
@@ -233,4 +241,7 @@ public:
struct {
} runtimeData;
int cdzStatus {-1};
int emuStatus {-1};
};

View File

@@ -21,7 +21,7 @@ void Spdlogger::init(spdlog::level::level_enum log_level, std::string filename)
// 创建控制台接收器
auto consoleSink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
consoleSink->set_level(spdlog::level::info); // 设置控制台日志等级
//consoleSink->set_level(log_level); // 设置控制台日志等级
//consoleSink->set_pattern("[%T] [%^%l%$] %v"); // 设置日志格式
// 创建文件接收器
@@ -31,7 +31,7 @@ void Spdlogger::init(spdlog::level::level_enum log_level, std::string filename)
// 每日文件sink可选每天生成新文件
auto dailySink = std::make_shared<spdlog::sinks::daily_file_sink_mt>("logs/ess.log", 0, 0);
dailySink->set_level(spdlog::level::debug);
//dailySink->set_level(log_level);
//dailySink->set_pattern("[%Y-%m-%d %H:%M:%S.%e] [%l] %v");
// 创建一个多重接收器的 logger
@@ -40,8 +40,8 @@ void Spdlogger::init(spdlog::level::level_enum log_level, std::string filename)
// 设置全局 logger
spdlog::set_default_logger(logger);
spdlog::set_level(spdlog::level::debug); // 设置全局日志等级为 debug
spdlog::flush_on(spdlog::level::info); // 开启日志刷新
spdlog::set_level(log_level); // 设置全局日志等级为 debug
spdlog::flush_on(log_level); // 开启日志刷新
}
void Spdlogger::drop()

View File

@@ -524,13 +524,14 @@ Errcode DAO::insertSystemLogUser(std::string token, std::string content, int sta
fields.set("user_account", user.account);
return DAO::insertSystemLog(fields);
}
Errcode DAO::insertSystemLogDevice(std::string deviceId, std::string content, int status)
Errcode DAO::insertSystemLogDevice(int stationId, int deviceId, std::string content, int status)
{
Fields fields;
fields.set("station_id", stationId);
fields.set("device_id", deviceId);
fields.set("type", 3);
fields.set("content", content);
fields.set("status", status);
fields.set("device_id", deviceId);
return DAO::insertSystemLog(fields);
}
@@ -576,7 +577,6 @@ Errcode DAO::queryStatStationGroup(std::shared_ptr<DaoEntity> dao, string statio
if (!sqlCondition.empty()) { sqlCondition = " WHERE " + sqlCondition; }
std::string sql = R"(SELECT dt,
SUM(ss.storage_elect_in) storage_elect_in,
SUM(storage_elect_in) storage_elect_in,
SUM(storage_elect_out) storage_elect_out,
SUM(storage_num_in) storage_num_in,
@@ -592,7 +592,7 @@ Errcode DAO::queryStatStationGroup(std::shared_ptr<DaoEntity> dao, string statio
AVG(charge_usage) charge_usage,
SUM(income_elect) income_elect,
SUM(income_charge) income_charge
FROM stat_station ss)" + sqlCondition + "GROUP by dt;";
FROM stat_day)" + sqlCondition + " GROUP by dt;";
return DAO::exec(dao, sql, result);
}
@@ -621,7 +621,7 @@ Errcode DAO::queryStatStationList(PageInfo& pageInfo, Fields& params, vector<Fie
if (!sqlCondition.empty()) { sqlCondition = " WHERE " + sqlCondition; }
std::string sqlFields = "ss.*, d.name device_name, ddt.name device_type";
std::string sqlFrom = R"(FROM stat_station ss
std::string sqlFrom = R"(FROM stat_day ss
LEFT JOIN device d ON d.device_id = ss.device_id
LEFT JOIN def_device_type ddt ON ddt.device_type_id = d.`type`)" + sqlCondition;
@@ -643,7 +643,8 @@ Errcode DAO::queryPolicyTypeDef(std::shared_ptr<DaoEntity> dao, vector<Fields>&
Errcode DAO::insertStatStation(std::shared_ptr<DaoEntity> dao, Fields& fields)
{
// 根据主键dt、station_id、category写入或更新数据
if (!dao) { dao = DaoEntity::create("stat_station"); }
if (!dao) { dao = DaoEntity::create("stat_day"); }
else { dao->setTableName("stat_day"); }
std::vector<std::string> vecKeys = {
"storage_elect_in",
"storage_elect_out",

View File

@@ -103,7 +103,7 @@ public:
static Errcode insertSystemLogSys(std::string content, int status);
static Errcode insertSystemLogUser(std::string token, std::string content, int status);
static Errcode insertSystemLogDevice(std::string deviceId, std::string content, int status);
static Errcode insertSystemLogDevice(int stationId, int deviceId, std::string content, int status);
static Errcode queryAlertLogList(PageInfo& pageInfo, vector<Fields>& result);
static Errcode insertAlertLog(Fields& params);

View File

@@ -44,13 +44,13 @@ std::shared_ptr<DaoEntity> DaoEntity::create(string tb_name)
return std::make_shared<DaoEntity>(tb_name);
}
bool DaoEntity::execOnce(string sql)
int DaoEntity::execOnce(string sql)
{
auto db = make_shared<MysqlClient>(DaoEntity::option);
return db->exec(sql);
}
bool DaoEntity::execOnce(string sql, vector<Fields>& result)
int DaoEntity::execOnce(string sql, vector<Fields>& result)
{
auto db = make_shared<MysqlClient>(DaoEntity::option);
return db->exec(sql, result);
@@ -129,21 +129,18 @@ int DaoEntity::duplicateUpdate(Fields& fields, const vector<string>& keys)
string val;
for (auto& item : fields.map())
{
if (!key.empty())
{
key += ","; val += ",";
}
if (!key.empty()) { key += ","; val += ","; }
key += (item.first);
val += ("'" + item.second + "'");
}
string str;
for (auto& k : keys)
{
if (!str.empty())
if (fields.contains(k))
{
str += ",";
if (!str.empty()) { str += ","; }
str += (k + "='" + fields.value(k) + "'");
}
str += (k + "='" + fields.value(k) + "'");
}
string sql = "INSERT INTO " + tableName + "(" + key + ") VALUES (" + val + ") ON duplicate KEY UPDATE " + str;
return this->db->exec(sql);

View File

@@ -18,14 +18,14 @@ public:
* 执行sql语句
* @param: sql 要执行的完整 sql 语句
*/
static bool execOnce(string sql);
static int execOnce(string sql);
/**
* 执行sql语句返回结果数据集
* @param: sql 要执行的完整 sql 语句
* @param: result 返回的结果数据集
*/
static bool execOnce(string sql, vector<Fields>& result);
static int execOnce(string sql, vector<Fields>& result);
/**
* 设置数据库表名称

View File

@@ -169,7 +169,7 @@ namespace DMLogAlert
namespace DMStatStation
{
const string TABLENAME = "stat_station";
const string TABLENAME = "stat_day";
const string DT = "dt";
const string STATION_ID = "station_id";
const string STORAGE_ELECT_IN = "storage_elect_in";

View File

@@ -124,14 +124,15 @@ int main(int argc, char** argv)
// 设置控制台输入为 UTF-8 编码(如果需要输入中文)
SetConsoleCP(CP_UTF8);
// 初始化日志
Spdlogger::init(spdlog::level::debug, "");
Spdlogger::init(spdlog::level::info, "");
spdlog::info("[main] start ... ======================================================================");
qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--ignore-gpu-blacklist --enable-gpu-rasterization --enable-native-gpu-memory-buffers --num-raster-threads=4");
// 运行后台服务
Application::instance().init();
while (1) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); };
// 启动 PV 服务主线程

View File

@@ -128,6 +128,8 @@ public:
static std::map<std::string, HandlerOptions> g_mapHttpHandlerGet =
{
{"/queryBaseinfo", HandlerOptions(&HttpEntity::logqueryBaseinfoin, {})},
{"/login", HandlerOptions(&HttpEntity::login, {DMUser::ACCOUNT, DMUser::PASSWD})},
{"/queryUserList", HandlerOptions(&HttpEntity::queryUserList, {})},
{"/deleteUser", HandlerOptions(&HttpEntity::deleteUser, { DMUser::USER_ID})},
@@ -155,8 +157,8 @@ static std::map<std::string, HandlerOptions> g_mapHttpHandlerGet =
{"/queryPolicyList", HandlerOptions(&HttpEntity::queryPolicyList, {})},
{"/deletePolicy", HandlerOptions(&HttpEntity::deletePolicy, { DMPolicy::POLICY_ID})},
{"/queryPolicyByType", HandlerOptions(&HttpEntity::queryPolicyByType, {"type"})},
{"/querySystemLogList", HandlerOptions(&HttpEntity::querySystemLogList, {})},
@@ -280,6 +282,7 @@ void HttpEntity::runHandler(std::string name, const HandlerOptions& handler, con
jsonresp["errmsg"] = ErrcodeStr(errcode) + (errmsg.empty() ? "" : (":"+errmsg));
resp.set_content(jsonresp.dump(), "text/plain; charset=utf-8");
resp.status = 200;
spdlog::info("[http] request: {}, response: {}.", name, int(errcode));
}
void HttpEntity::registGet(std::string name, void (HttpEntity::* func)(const httplib::Request& req, httplib::Response& resp))
@@ -287,6 +290,18 @@ void HttpEntity::registGet(std::string name, void (HttpEntity::* func)(const htt
this->httpsvr.Get(name, std::bind(func, this, std::placeholders::_1, std::placeholders::_2));
}
Errcode HttpEntity::logqueryBaseinfoin(const httplib::Request& req, njson& json, std::string& errmsg)
{
json["data"] = {
{"encryption", Config::option.http.encryption},
{"encryptKey", Config::option.http.encryptKey},
{"latitude", Config::option.view.latitude},
{"longitude", Config::option.view.longitude},
{"altitude", Config::option.view.altitude}
};
return Errcode::OK;
}
Errcode HttpEntity::login(const httplib::Request& req, njson& json, std::string& errmsg)
{
std::string userId;
@@ -602,12 +617,13 @@ Errcode HttpEntity::insertStation(const httplib::Request& req, njson& json, std:
Errcode HttpEntity::updateStation(const httplib::Request& req, njson& json, std::string& errmsg)
{
Fields params;
GetRequestParam(req, {"station_id", "name", "address", "lon", "lat", "tel", "capacity", "status", "work_mode", "policy_id"}, params);
GetRequestParam(req, {"station_id", "name", "address", "lon", "lat", "tel", "capacity", "status", "work_mode", "policy_id", "operation_date"}, params);
std::string stationId = params.value("station_id");
params.check("capacity", "", "0.0");
params.check("lon", "", "0.0");
params.check("lat", "", "0.0");
params.check("status", "", "1");
params.check("policy_id", "", "NULL");
Errcode err = DAO::updateStationById(params);
if (err == Errcode::OK)
{
@@ -621,16 +637,11 @@ Errcode HttpEntity::updateStation(const httplib::Request& req, njson& json, std:
}
else
{
if (result.size() > 0)
auto station = Application::data().getStation(Utils::toInt(stationId));
if (result.size() > 0 && station)
{
auto station = Application::data().getStation(Utils::toInt(stationId));
if (station)
{
station->setFields(result[0]);
station->setGarewayWorkMode();
}
station->setFields(result[0]);
}
}
}
return err;
@@ -681,6 +692,15 @@ Errcode HttpEntity::queryStationOverview(const httplib::Request& req, njson& jso
njson jsonCharge = njson::parse(R"({"category":2, "count":0, "power":0.0})");
njson jsonSolar = njson::parse(R"({"category":3, "count":0, "power":0.0})");
njson jsonSecurity = njson::parse(R"({"category":4, "count":0, "power":0.0})");
auto videoInfo = Config::getVideoInfo(stationId);
if (videoInfo)
{
jsonSecurity["host"] = videoInfo->host;
jsonSecurity["port"] = videoInfo->port;
jsonSecurity["user"] = videoInfo->user;
jsonSecurity["passwd"] = videoInfo->passwd;
}
for (auto& fields : result)
{
int category = fields.get<int>("category");
@@ -743,17 +763,21 @@ Errcode HttpEntity::queryStationInfo(const httplib::Request& req, njson& json, s
}
Errcode HttpEntity::queryStationData(const httplib::Request& req, njson& json, std::string& errmsg)
{
// 温度, 电压、电流、功率、功率因数、
std::string stationId = req.get_param_value("station_id");
auto station = Application::data().getStation(Utils::toInt(stationId));
njson jsondata;
jsondata["voltage"] = Utils::toStr(200.32);
jsondata["current"] = Utils::toStr(20.56);
jsondata["power"] = Utils::toStr(200.32);
jsondata["powerFactor"] = Utils::toStr(1);
jsondata["envTemp"] = Utils::toStr(200.32);
jsondata["envhum"] = Utils::toStr(200.32);
jsondata["aircStatus"] = Utils::toStr(1);
jsondata["coolingStatus"] = Utils::toStr(0);
if (station)
{
// 温度, 电压、电流、功率、功率因数、
jsondata["voltage"] = Utils::toStr(station->voltage, 0);
jsondata["current"] = Utils::toStr(station->current, 0);
jsondata["power"] = Utils::toStr(station->power, 0);
jsondata["powerFactor"] = Utils::toStr(station->powerFactor, 0);
jsondata["envTemp"] = Utils::toStr(station->temperature, 0);
jsondata["envhum"] = Utils::toStr(station->humidity, 0);
jsondata["aircStatus"] = station->aircStatus;
jsondata["coolingStatus"] = station->coolingStatus;
}
json["data"] = jsondata;
return Errcode::OK;
}
@@ -899,10 +923,28 @@ Errcode HttpEntity::queryDevicCharts(const httplib::Request& req, njson& json, s
Errcode HttpEntity::queryDeviceBCUDetail(const httplib::Request& req, njson& json, std::string& errmsg)
{
Fields params;
GetRequestParam(req, {"station_id", "device_id"}, params);
if (!params.contains("station_id")) { errmsg = "缺少参数[station_id]"; return Errcode::ERR_PARAM; }
if (!params.contains("device_id")) { errmsg = "缺少参数[device_id]"; return Errcode::ERR_PARAM; }
int stationId = params.get<int>("station_id");
int deviceId = params.get<int>("device_id");
auto device = Application::data().getDevice(stationId, deviceId);
njson jsondata = njson::array();
for (int i = 0; i<=100; ++i)
if (device)
{
jsondata.push_back({{"SOC", "1"}, {"SOH", "1"}, {"V", "1"}, {"T", "1"}, {"R_i", "1"}});
for (int i = 0; i<=device->bcuCount && i<device->vecBCUUnit.size(); ++i)
{
auto& row = device->vecBCUUnit[i];
std::string soc = Utils::toStr(row[0], 1);
std::string soh = Utils::toStr(row[1], 1);
std::string u = Utils::toStr(row[2], 0);
std::string t = Utils::toStr(row[3], 2);
std::string r_i = Utils::toStr(row[4], 0);
jsondata.push_back({{"SOC", soc}, {"SOH", soh}, {"V", u}, {"T", t}, {"R_i", r_i}});
}
}
json["data"] = jsondata;
return Errcode::OK;
@@ -937,6 +979,14 @@ Errcode HttpEntity::deletePolicy(const httplib::Request& req, njson& json, std::
GetRequestParam(req, {"policy_id"}, params);
return DAO::deletePolicyById(params.value("policy_id"));
};
Errcode HttpEntity::queryPolicyByType(const httplib::Request& req, njson& json, std::string& errmsg)
{
std::string type = req.get_param_value("type");
std::string sql = "SELECT policy_id, `type`, name from policy WHERE `type`='" + type + "';";
std::vector<Fields> result;
int ret = DaoEntity::execOnce(sql, result);
return Errcode(ret);
}
Errcode HttpEntity::querySystemLogList(const httplib::Request& req, njson& json, std::string& errmsg)
{
@@ -1048,7 +1098,7 @@ Errcode HttpEntity::queryStatStationGroup(const httplib::Request& req, njson& js
auto dao = DaoEntity::create("");
std::string sql = R"(SELECT s.station_id, s.name station_name, ss.income_elect, ss.income_charge, ss.storage_usage FROM station s LEFT JOIN
(SELECT station_id, SUM(income_elect ) income_elect , SUM(income_charge) income_charge, avg(storage_usage) storage_usage FROM stat_station GROUP BY station_id) AS ss
(SELECT station_id, SUM(income_elect ) income_elect , SUM(income_charge) income_charge, avg(storage_usage) storage_usage FROM stat_day GROUP BY station_id) AS ss
ON ss.station_id = s.station_id)";
std::vector<Fields> vecStations;
auto err = dao->exec(sql, vecStations);
@@ -1106,9 +1156,9 @@ static std::string VerifyStatSqlCondition(Fields& params)
return sqlCondition;
}
static std::string GetRequestStatParams(const httplib::Request& req)
static std::string GetRequestStatParams(const httplib::Request& req, Fields& params)
{
Fields params;
GetRequestParam(req, {"station_id", "category", "start_date", "end_date"}, params);
VerifyRequstParamsStatDate(params);
return VerifyStatSqlCondition(params);
@@ -1116,8 +1166,9 @@ static std::string GetRequestStatParams(const httplib::Request& req)
Errcode HttpEntity::queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg)
{
std::string sqlCondition = GetRequestStatParams(req);
std::string sql = R"(SELECT SUM(ss.storage_elect_in) storage_elect_in,
Fields params;
std::string sqlCondition = GetRequestStatParams(req, params);
std::string sql = R"(SELECT
SUM(storage_elect_in) storage_elect_in,
SUM(storage_elect_out) storage_elect_out,
SUM(storage_num_in) storage_num_in,
@@ -1133,14 +1184,24 @@ Errcode HttpEntity::queryStatTotal(const httplib::Request& req, njson& json, std
AVG(charge_usage) charge_usage,
SUM(income_elect) income_elect,
SUM(income_charge) income_charge
FROM stat_station ss)" + sqlCondition + ";";
FROM stat_day ss)" + sqlCondition + ";";
std::string stationId = params.value("station_id");
njson jsondata;
auto station = Application::data().getStation(Utils::toInt(stationId));
if (station)
{
jsondata["launch_date"] = station->launchDate;
}
std::vector<Fields> result;
DaoEntity::execOnce(sql, result);
if (result.size() > 0)
{
auto& fields = result[0];
njson jsondata;
// jsondata["launch_date"] = "2025-09-01"; //场站上线日期
// jsondata["station_id"] = station_id;
jsondata["storage_elect_in"] = fields.value("storage_elect_in"); //储能充电电量kWh精度0.001
@@ -1170,16 +1231,63 @@ Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, s
std::string category = params.value("category");
std::string startDate = params.value("start_date");
std::string endDate = params.value("end_date");
if (endDate.empty())
{
int64_t t = Utils::time();
endDate = Utils::dateStr(t);
startDate = Utils::dateStr(t - 86400*7);
}
std::vector<Fields> result;
auto err = DAO::queryStatStationGroup(NULL, stationId, category, startDate, endDate, result);
json["data"] = FieldsToJsonArray(result);
if (!startDate.empty() && !endDate.empty())
{
int64_t t0 = Utils::time(startDate + " 00:00:00");
int64_t t1 = Utils::time(endDate + " 00:00:00");
int i = 0;
njson jsondata = njson::array();
for (int64_t t = t0; t<=t1; t += 86400)
{
njson jsonrow;
std::string dt = Utils::dateStr(t);
Fields* fields = NULL;
if (i<result.size() && result[i].value("dt") == dt)
{
fields = &(result[i]);
i++;
}
jsonrow["dt"] = dt.substr(5);
jsonrow["storage_elect_in"] = fields ? fields->value("storage_elect_in") : "0";
jsonrow["storage_elect_out"] = fields ? fields->value("storage_elect_out") : "0";
jsonrow["storage_num_in"] = fields ? fields->value("storage_num_in") : "0";
jsonrow["storage_num_out"] = fields ? fields->value("storage_num_out") : "0";
jsonrow["storage_num_err"] = fields ? fields->value("storage_num_err") : "0";
jsonrow["solar_elect_gen"] = fields ? fields->value("solar_elect_gen") : "0";
jsonrow["solar_elect_grid"] = fields ? fields->value("solar_elect_grid") : "0";
jsonrow["solar_num_err"] = fields ? fields->value("solar_num_err") : "0";
jsonrow["storage_usage"] = fields ? fields->value("storage_usage") : "0";
jsonrow["charge_elect"] = fields ? fields->value("charge_elect") : "0";
jsonrow["charge_num"] = fields ? fields->value("charge_num") : "0";
jsonrow["charge_num_err"] = fields ? fields->value("charge_num_err") : "0";
jsonrow["charge_usage"] = fields ? fields->value("charge_usage") : "0";
jsonrow["income_elect"] = fields ? fields->value("income_elect") : "0";
jsonrow["income_charge"] = fields ? fields->value("income_charge") : "0";
jsondata.push_back(jsonrow);
}
json["data"] = jsondata;
}
else
{
json["data"] = FieldsToJsonArray(result);
}
return err;
}
//Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, std::string& errmsg)
//{
// std::string sqlCondition = GetRequestStatParams(req);
// std::string sql = R"(SELECT ss.*, d.name device_name, ddt.name device_type FROM stat_station ss
// std::string sql = R"(SELECT ss.*, d.name device_name, ddt.name device_type FROM stat_day ss
// LEFT JOIN device d ON d.device_id = ss.device_id
// LEFT JOIN def_device_type ddt ON ddt.device_type_id = d.`type`)" + sqlCondition + ";";
//
@@ -1200,7 +1308,8 @@ Errcode HttpEntity::queryStatDetailList(const httplib::Request& req, njson& json
std::vector<Fields> result;
auto err = DAO::queryStatStationList(pageinfo, params, result);
json["data"] = FieldsToJsonArray(result);
//json["data"] = FieldsToJsonArray(result);
HttpHelper::setPagination(pageinfo, result, json);
return err;
}
@@ -1286,40 +1395,38 @@ Errcode HttpEntity::queryEnvironment(const httplib::Request& req, njson& json, s
auto& unit = iter->second;
njson node;
node["pos"] = "#" + std::to_string(iter->first);
node["temp"] = unit.temp;
node["hum"] = unit.hum;
node["temp"] = Utils::toStr(unit.temp);
node["hum"] = Utils::toStr(unit.hum);
nodearray.push_back(node);
}
jsondata["temp_hum"] = nodearray;
}
{ //空调
auto& mapAircUnit = station->mapAircUnit;
AircUnit unitTmp;
AircUnit* unit = (mapAircUnit.size() > 0) ? &(mapAircUnit[0]) : &unitTmp;
njson nodearray = njson::array();
if (unit)
for (auto& item: mapAircUnit)
{
nodearray.push_back({{"pos", "开关"}, {"status", unit->powerOn == 0 ? "关机" : "开机"}});
nodearray.push_back({{"pos", "启动制冷指令"}, {"status", unit->cooling == 0 ? "启动" : "关闭"}});
nodearray.push_back({{"pos", "启动送风指令"}, {"status", unit->airSupply == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "启动待机指令"}, {"status", unit->standby == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "启动加热指令"}, {"status", unit->heating == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "传感器故障"}, {"status", unit->sensorAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "高低电压告警"}, {"status", unit->voltageAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "高低告警"}, {"status", unit->tempAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "高低告警"}, {"status", unit->pressureAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "缩机告警"}, {"status", unit->compressorAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "当前温度"}, {"status", std::to_string(unit->temp) + ""}});
nodearray.push_back({{"pos", "当前湿"}, {"status", std::to_string(unit->hum) + "%"}});
auto& unit = item.second;
nodearray.push_back({{"pos", "开关"}, {"status", unit.powerOn == 0 ? "关机" : "开机"}});
nodearray.push_back({{"pos", "启动制冷指令"}, {"status", unit.cooling == 0 ? "启动" : "关闭"}});
nodearray.push_back({{"pos", "启动送风指令"}, {"status", unit.airSupply == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "启动待机指令"}, {"status", unit.standby == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "启动加热指令"}, {"status", unit.heating == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "传感器故障"}, {"status", unit.sensorAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "高低电压告警"}, {"status", unit.voltageAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "高低告警"}, {"status", unit.tempAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "高低压告警"}, {"status", unit.pressureAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "压缩机告警"}, {"status", unit.compressorAlarm == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "当前"}, {"status", std::to_string(unit.temp) + ""}});
nodearray.push_back({{"pos", "当前湿度"}, {"status", std::to_string(unit.hum) + "%"}});
break;
}
jsondata["airc"] = nodearray;
}
{ // 消防
static std::map<int, std::string> mapFireStatusDef = { {0, "正常"}, {1,"预警"}, {2,"火警"} };
std::map<int, string> mapStatusDef = {{0, "无效"}, {1, "掉线"}, {2, "正常"}, {3, "启动"}};
auto& mapFire40Unit = station->mapFire40Unit;
njson nodearray = njson::array();
for (auto iter = mapFire40Unit.begin(); iter!=mapFire40Unit.end(); ++iter)
@@ -1338,20 +1445,19 @@ Errcode HttpEntity::queryEnvironment(const httplib::Request& req, njson& json, s
}
{ // 冷机
auto& mapCoolingUnit = station->mapCoolingUnit;
CoolingUnit unitTmp;
CoolingUnit* unit = (mapCoolingUnit.size() > 0) ? &(mapCoolingUnit[0]) : &unitTmp;
njson nodearray = njson::array();
if (unit)
for (auto& item: mapCoolingUnit)
{
auto& unit = item.second;
njson node;
nodearray.push_back({{"pos", "开关"}, {"status", unit->powerOn == 0 ? "关机" : "开机"}});
nodearray.push_back({{"pos", "采样模式"}, {"status", unit->mode == 0 ? "出水温度" : "电芯温度"}});
nodearray.push_back({{"pos", "制冷状态"}, {"status", unit->cooling == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "制热状态"}, {"status", unit->heating == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "高温告警"}, {"status", unit->highTemp == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "低温告警"}, {"status", unit->lowTemp == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "高压告警"}, {"status", unit->highPressure == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "低压告警"}, {"status", unit->lowPressure == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "开关"}, {"status", unit.powerOn == 0 ? "关机" : "开机"}});
nodearray.push_back({{"pos", "采样模式"}, {"status", unit.mode == 0 ? "出水温度" : "电芯温度"}});
nodearray.push_back({{"pos", "制冷状态"}, {"status", unit.cooling == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "制热状态"}, {"status", unit.heating == 0 ? "关闭" : "启动"}});
nodearray.push_back({{"pos", "高温告警"}, {"status", unit.highTemp == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "低温告警"}, {"status", unit.lowTemp == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "高压告警"}, {"status", unit.highPressure == 0 ? "正常" : "告警"}});
nodearray.push_back({{"pos", "低压告警"}, {"status", unit.lowPressure == 0 ? "正常" : "告警"}});
}
jsondata["cooling"] = nodearray;
}

View File

@@ -29,6 +29,7 @@ public:
//void onGet(const httplib::Request& req, httplib::Response& resp);
Errcode logqueryBaseinfoin(const httplib::Request& req, njson& json, std::string& errmsg);
Errcode login(const httplib::Request& req, njson& json, std::string& errmsg);
Errcode queryUserList(const httplib::Request& req, njson& json, std::string& errmsg);
@@ -70,6 +71,7 @@ public:
Errcode insertPolicy(const httplib::Request& req, njson& json, std::string& errmsg);
Errcode updatePolicy(const httplib::Request& req, njson& json, std::string& errmsg);
Errcode deletePolicy(const httplib::Request& req, njson& json, std::string& errmsg);
Errcode queryPolicyByType(const httplib::Request& req, njson& json, std::string& errmsg);
Errcode querySystemLogList(const httplib::Request& req, njson& json, std::string& errmsg);
//Errcode insertSystemLog(const httplib::Request& req, httplib::Response& resp, NJsonNode& json);

View File

@@ -9,6 +9,20 @@
#define TIMEOUT 10000L
bool MqttClient::load(std::string filename)
{
njson jsonroot;
bool ret = JSON::load(filename, jsonroot);
if (!ret)
{
spdlog::error("[mqtt] load config file failed, filename={}", filename);
return false;
}
return true;
}
std::map<std::string, TopicInfo> MqttClient::s_mapTopicInfo;
int MqttClient::init(string addr, string clientId, string username, string password)
{
@@ -24,26 +38,6 @@ int MqttClient::init(string addr, string clientId, string username, string passw
this->addr = addr;
this->clientId = clientId;
//this->mapTopicInfo["EMS_YX"] = TopicInfo("EMS_YX", 101);
this->mapTopicInfo["EMS_YC"] = TopicInfo("EMS_YC", 101);
//this->mapTopicInfo["EMS_YT"] = TopicInfo("EMS_YT", 101);
//this->mapTopicInfo["PCS_YX"] = TopicInfo("PCS_YX", 102, 1);
//this->mapTopicInfo["PCS_YC"] = TopicInfo("PCS_YC", 102, 1);
//this->mapTopicInfo["PCU_YX"] = TopicInfo("PCU_YX", 103);
//this->mapTopicInfo["PCU_YC"] = TopicInfo("PCU_YC", 103);
//this->mapTopicInfo["BMS_YX"] = TopicInfo("BMS_YX", 104); // BMS没有遥信
//this->mapTopicInfo["BMS_YC"] = TopicInfo("BMS_YC", 104);
//this->mapTopicInfo["BCU_YX"] = TopicInfo("BCU_YX", 105, 1);
//this->mapTopicInfo["BCU_YC"] = TopicInfo("BCU_YC", 105, 1);
//this->mapTopicInfo["MEM_YC"] = TopicInfo("MEM_YC", 3, 1);
//this->mapTopicInfo["TH_YC"] = TopicInfo("TH_YC", 10, 1);
//this->mapTopicInfo["Fire40_YX"] = TopicInfo("Fire40_YX", 7, 1);
this->mapTopicInfo["Cooling_YC"] = TopicInfo("Cooling_YC", 14, 1);
this->mapTopicInfo["Cooling_YX"] = TopicInfo("Cooling_YX", 14, 1);
//this->mapTopicInfo["Gateway_YX"] = TopicInfo("Gateway_YX", 15, 1);
//this->mapTopicInfo["Gateway_YC"] = TopicInfo("Gateway_YC", 15, 1);
//this->mapTopicInfo["Charger_YC"] = TopicInfo("Charger_YC", 106, 1);
MQTTAsync_connectOptions option = MQTTAsync_connectOptions_initializer;
MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
int rc {0};
@@ -135,18 +129,21 @@ void MqttClient::subscribe()
MQTTAsync_responseOptions options = MQTTAsync_responseOptions_initializer;
options.onSuccess = funcSuccess;
options.onFailure = funcFailure;
for (auto& item: mapTopicInfo)
for (auto& item: MqttClient::s_mapTopicInfo)
{
std::string topic = "up/json/" + clientId + "/" + item.first;
options.context = (void*)&item.first;
int rc = MQTTAsync_subscribe(client, topic.data(), qos, &options);
if (rc != MQTTASYNC_SUCCESS)
if (item.second.enabled)
{
spdlog::error("[mqtt] subscribe [{},{}] failed, err={}", topic, qos, rc);
}
else
{
spdlog::info("[mqtt] subscribe [{},{}] ", topic, qos);
std::string topic = "up/json/" + clientId + "/" + item.first;
options.context = (void*)&item.first;
int rc = MQTTAsync_subscribe(client, topic.data(), qos, &options);
if (rc != MQTTASYNC_SUCCESS)
{
spdlog::error("[mqtt] subscribe [{},{}] failed, err={}", topic, qos, rc);
}
else
{
spdlog::info("[mqtt] subscribe [{},{}] ", topic, qos);
}
}
}
}
@@ -199,10 +196,10 @@ int MqttClient::polling()
return 0;
}
for (auto& item: mapTopicInfo)
for (auto& item: MqttClient::s_mapTopicInfo)
{
auto& topicInfo = item.second;
if (topicInfo.polling)
if (topicInfo.polling && topicInfo.enabled)
{
std::vector<std::shared_ptr<Device>> vecDevice;
station->getDeviceByType(topicInfo.deviceType, vecDevice);
@@ -268,96 +265,6 @@ void MqttClient::onConnectFaiure(MQTTAsync_failureData* resp)
this->destory();
}
void MqttClient::ParseArrivedMessage(njson& json, string clientId, string command, std::shared_ptr<Station> station)
{
std::string stationNo = clientId;
auto mapRegPtr = REGAddr::getRegMap(command);
if (!mapRegPtr)
{
spdlog::error("[mqtt] get register add info error, clientId={}, stationId={}, command={}", clientId, stationNo, command);
return;
}
auto iterTopic = mapTopicInfo.find(command);
if (iterTopic == mapTopicInfo.end())
{
spdlog::error("[mqtt] get topic info error, clientId={}, stationId={}, command={}", clientId, stationNo, command);
return;
}
TopicInfo& topicInfo = iterTopic->second;
int deviceNo = -1;
JSON::read(json, "no", deviceNo);
auto device = station->getDeviceByType(topicInfo.deviceType, Utils::toStr(deviceNo));
if (!device)
{
return;
}
for (auto& item: json.items())
{
std::string key = item.key();
if (key != "ts" && key != "no")
{
auto data = json.at(key);
if (data.is_array())
{
std::string addrText;
auto iter = mapRegPtr->find(key);
for (int i = 0; i<data.size(); ++i)
{
if (iter != mapRegPtr->end())
{
auto addr = iter->first;
int val = data[i];
device->setParam(addr, val);
spdlog::info("[mqtt] read [{}]={},{}", addr, val, iter->second.remark);
if (command == "EMS_YC" && addr == "0x110C")
{
int a = 30;
a = 100;
}
if (command == "EMS_YC")
{
station->setRuntimeData(addr, val);
}
else if (command == "Fire40_YX")
{
station->setFire40Data(deviceNo, addr, val);
}
else if (command == "TH_YC")
{
station->setTHData(deviceNo, addr, val);
}
else if (command == "Cooling_YX" || command == "Cooling_YC")
{
station->setCoolingData(deviceNo, addr, val);
}
else if (command == "Gateway_YX")
{
//if (key == "CDZ") "CDZ": 1, //充电桩 1在线0离线
//else if (key == "EMU") //储能 1在线0离线
}
++iter;
}
}
}
else if (data.is_number())
{
device->setParam(key, data.get<int>());
}
else if (data.is_string())
{
device->setParam(key, Utils::toInt(data.get<std::string>()));
}
}
}
}
int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* msg)
{
std::string topicStr = topic;
@@ -394,7 +301,7 @@ int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* m
{
std::string key = item.key();
auto& val = item.value();
if (key == "40001") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "模式"); }
if (key == "40001") { station->readGatewayMode(val.get<int>()); }
else if (key == "40002") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "峰谷时间段"); }
else if (key == "40021") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "自定时间段"); }
else if (key == "40038") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "其他参数"); }
@@ -402,17 +309,15 @@ int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* m
}
else if (command == "Gateway_YX")
{
for (auto& item: json.items())
{
std::string key = item.key();
auto& val = item.value();
if (key == "cdz") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "充电桩通讯状态"); }
else if (key == "emu") { spdlog::info("[mqtt] read register addr: [{}]={}, {}", key, val.dump(), "充电桩通讯状态"); }
}
int cdzStatus = -1;
int emuStatus = -1;
JSON::read(json, "cdz", cdzStatus);
JSON::read(json, "emu", cdzStatus);
station->readGatewayStatus(cdzStatus, emuStatus);
}
else
{
ParseArrivedMessage(json, clientId, command, station);
ParseArrivedMessage(json, command, station);
}
// 必须释放消息内存!
@@ -422,117 +327,135 @@ int MqttClient::onMessageArrived(char* topic, int topicLen, MQTTAsync_message* m
}
string MQTT::pack(std::string name)
void MqttClient::ParseArrivedMessage(njson& json, string command, std::shared_ptr<Station> station)
{
njson json;
json["ts"] = Utils::time();
json["no"] = 1;
std::string stationNo = clientId;
if (name == "EMS_YC")
auto iterTopic = MqttClient::s_mapTopicInfo.find(command);
if (iterTopic == MqttClient::s_mapTopicInfo.end())
{
//A相电压 R uint32 1V 0x107E
//B相电压 R uint32 1V 0x1080
//C相电压 R uint32 1V 0x1082
//A相电流 R int32 1A 0x1084
//B相电流 R int32 1A 0x1086
//C相电流 R int32 1A 0x1088
//储能系统SOC R uint16 0.1 0x107A
//储能系统SOH R uint16 0.1 0x107B
json["addr"] = {"0x107A", "0x107B", "0x107E", "0x1080", "0x1082", "0x1084", "0x1086", "0x1088"};
spdlog::error("[mqtt] get topic info error, clientId={}, stationId={}, command={}", clientId, stationNo, command);
return;
}
else if (name == "PCS_YC")
TopicInfo& topicInfo = iterTopic->second;
int deviceNo = -1;
JSON::read(json, "no", deviceNo);
auto device = station->getDeviceByType(topicInfo.deviceType, Utils::toStr(deviceNo));
if (!device)
{
//总充电量 R uint32 1kWh 0x0003
//总放电量 R uint32 1kWh 0x0005
//A相电压 R int16 1V 0x0010
//B相电压 R int16 1V 0x0011
//C相电压 R int16 1V 0x0012
//A相电流 R int16 1A 0x0019
//B相电流 R int16 1A 0x001A
//C相电流 R int16 1A 0x001B
//三相总有功功率 R int16 1kW 0x0025
//三相总无功功率 R int16 1kVar 0x0026
//三相总视在功率 R int16 1kVA 0x0027
//三相总功率因数 R int16 1 0x0028
//充电功率 R int16 1kW 0x002C
//放电功率 R int16 1kW 0x002D
json["addr"] = {"0x0003", "0x0005", "0x0010", "0x0011", "0x0012", "0x0019", "0x001A", "0x001B", "0x0025", "0x0026", "0x0027", "0x0028", "0x002C", "0x002D"};
spdlog::error("[mqtt] get device info error, clientId={}, stationId={}, command={}", clientId, stationNo, command);
return;
}
else if (name == "PCU_YC")
auto mapRegPtr = REGAddr::getRegMap(command);
if (!mapRegPtr)
{
//PCS侧线A相电压 R int16 1v 0x0013
//PCS侧线B相电压 R int16 1v 0x0014
//PCS侧线C相电压 R int16 1v 0x0015
//PCS侧功率因数A R int16 1 0x0019
//PCS侧功率因数B R int16 1 0x001A
//PCS侧功率因数C R int16 1 0x001B
//PCS侧相电流A R int16 1A 0x001C
//PCS侧相电流B R int16 1A 0x001D
//PCS侧相电流C R int16 1A 0x001E
//PCS侧三相总有功功率 R int16 1kW 0x0028
//PCS侧三相总无功功率 R int16 1kVar 0x0029
//PCS侧三相总视在功率 R int16 1kVA 0x002A
//PCS侧三相总功率因数 R int16 1 0x002B
json["addr"] = {"0x0013", "0x0014", "0x0015", "0x1080", "0x1082", "0x1084", "0x1086", "0x1088"};
spdlog::error("[mqtt] get register add info error, clientId={}, stationId={}, command={}", clientId, stationNo, command);
return;
}
else if (name == "BMS_YC")
for (auto& item: json.items())
{
//SOC R uint16 0.1 0x0001
//SOH R uint16 0.1 0x0002
//电压 R uint32 0.1V 0x0003
//电流 R int32 0.1A 0x0005
//可充电量 R uint32 1kWh 0x0007
//可放电量 R uint32 1kWh 0x0009
//可充电状态 R uint16 1可充电0不可充电 0x0047
//可放电状态 R uint16 1可放电0不可放电 0x0048
//运行状态 R uint16 运行状态 0-正常 1-告警 2-保护 0x0049
//充放电状态 R uint16 0-待机 1-充电 2-放电 0x004A
std::string key = item.key();
if (key == "ts" || key == "no")
{
continue;
}
auto data = json[key];
if (data.is_array())
{
int dataSize = data.size();
if (command == "Charger_YC")
{
if (key == "1") key = "11";
else if (key == "2") key = "21";
}
std::string addrText;
auto iter = mapRegPtr->find(key);
for (int i = 0; i<dataSize; ++i)
{
int val = data[i];
json["addr"] = {"0x0001", "0x0002", "0x0003", "0x0005", "0x0007", "0x0009", "0x0047", "0x0048", "0x0049", "0x004A"};
if (command == "BCU_YC" && (key == "0x0056" || key == "0x043E" || key == "0x0826" || key == "0x0C0E" || key == "0x0FF6"))
{
device->setBCUUnit(key, i, val, dataSize);
}
else
{
if (iter != mapRegPtr->end())
{
auto addr = iter->first;
auto& regUnit = iter->second;
if (regUnit.alert && val>=0)
{
station->readAlert(device, val, "[" + command + "]" + regUnit.name + "(" + addr + ")");
}
device->setParam(addr, val);
spdlog::debug("[mqtt] read [{}]={}, {}{}", addr, val, regUnit.name, regUnit.remark);
if (command == "MEM_YC") { station->readRuntimeData(deviceNo, addr, val); }
else if (command == "Fire40_YX") { station->readFire40Data(deviceNo, addr, val); }
else if (command == "TH_YC") { station->readTHData(deviceNo, addr, val); }
else if (command == "Cooling_YX" || command == "Cooling_YC") { station->readCoolingData(deviceNo, addr, val); }
else if (command == "Gateway_YX")
{
//if (key == "CDZ") "CDZ": 1, //充电桩 1在线0离线
//else if (key == "EMU") //储能 1在线0离线
}
++iter;
}
}
}
}
else if (data.is_number())
{
device->setParam(key, data.get<int>());
}
else if (data.is_string())
{
device->setParam(key, Utils::toInt(data.get<std::string>()));
}
}
}
std::vector<std::string> KEY_CHARGER_1 = {"31071", "31073", "31075", "31077", "31079", "31081", "31083"};
std::vector<std::string> KEY_CHARGER_2 = {"31072", "31074", "31076", "31078", "31080", "31082", "31084"};
void MqttClient::ParseMessageCharge(njson& json, string command, std::shared_ptr<Station> station, std::shared_ptr<Device> device)
{
if (json.contains("1"))
{
auto& jsondata = json["1"];
if (jsondata.is_array())
{
for (int i = 0; i<jsondata.size(); i++)
{
if (i<KEY_CHARGER_1.size())
{
auto& addr = KEY_CHARGER_1[i];
auto val = jsondata[i].get<int>();
device->setParam(addr, val);
spdlog::info("[mqtt] read: 枪1 [{}]={}", addr, val);
}
}
}
}
if (json.contains("2"))
{
auto& jsondata = json["2"];
if (jsondata.is_array())
{
for (int i = 0; i<jsondata.size(); i++)
{
if (i<KEY_CHARGER_2.size())
{
auto& addr = KEY_CHARGER_2[i];
auto val = jsondata[i].get<int>();
device->setParam(addr, val);
spdlog::info("[mqtt] read: 枪2 [{}]={}", addr, val);
}
}
}
}
else if (name == "BCU_YC")
{
//电表类型 R uint16 "0储能站总表 1逆变前侧电表 2逆变后侧电表 3配电柜电表 4并网口电表" 0x0008
//A相电压 R uint32 1V 0x000B
//B相电压 R uint32 1V 0x000D
//C相电压 R uint32 1V 0x000F
//A相电流 R int32 1A 0x0011
//B相电流 R int32 1A 0x0013
//C相电流 R int32 1A 0x0015
//尖段电价 R uint32 1RMB 0x0027
//峰段电价 R uint32 1RMB 0x0029
//平段电价 R uint32 1RMB 0x002B
//谷段电价 R uint32 1RMB 0x002D
//日充电电量 R uint32 1kWh 0x002F
//日放电电量 R uint32 1kWh 0x0031
//日充电费用 R uint32 1RMB 0x0033
//日放电费用 R uint32 1RMB 0x0035
//日收益 R int32 1RMB 0x0037
//总充电电量 R uint32 1kWh 0x004D
//总放电电量 R uint32 1kWh 0x004F
//总充电费用 R uint32 1RMB 0x0051
//总放电费用 R uint32 1RMB 0x0053
//总收益 R int32 1RMB 0x0055
}
else if (name == "TH_YC")
{
//所属通道号 R uint16 1 0x0001
//所属温湿度号 R uint16 1~10 0x0002
//温度 R int16 0.1℃ 0x0003
//湿度 R int16 0.1℃ 0x0004
}
return json.dump();
}

View File

@@ -7,13 +7,14 @@
#include "common/JsonN.h"
class Station;
class Device;
struct TopicInfo
{
std::string name;
int deviceType {0};
int polling {0}; // 召测
int enabled {1};
TopicInfo() {};
TopicInfo(std::string name, int deviceType, int polling=0)
:name(name), deviceType(deviceType), polling(polling)
@@ -25,6 +26,8 @@ using namespace std;
class MqttClient
{
public:
static bool load(std::string filename);
int init(string addr, string clientId, string username, string password);
void destory();
@@ -39,7 +42,8 @@ public:
void onConnectFaiure(MQTTAsync_failureData* resp);
int onMessageArrived(char* topic, int len, MQTTAsync_message* msg);
void ParseArrivedMessage(njson& json, string clientId, string command, std::shared_ptr<Station> station);
void ParseArrivedMessage(njson& json, string command, std::shared_ptr<Station> station);
void ParseMessageCharge(njson& json, string command, std::shared_ptr<Station> station, std::shared_ptr<Device> device);
public:
// MQTT clientId (使用station 的 code)
@@ -51,7 +55,7 @@ public:
bool isConnected {false};
bool isSubscribed {false};
std::map<std::string, TopicInfo> mapTopicInfo;
static std::map<std::string, TopicInfo> s_mapTopicInfo;
};
@@ -71,12 +75,3 @@ public:
#define TOPIC_PCS_YC "up/json/预制舱01/PCS_YC"
#define TOPIC_PCS_YC "up/json/预制舱01/PCS_YC"
class MQTT
{
public:
public:
static string pack(std::string name);
};