diff --git a/bin/Release/assets/config-online/app.json b/bin/Release/assets/config-online/app.json index c8b072b..856a462 100644 --- a/bin/Release/assets/config-online/app.json +++ b/bin/Release/assets/config-online/app.json @@ -6,7 +6,7 @@ "exportpath": "D:/Programs/openresty-1.27.1.1-win64/zdownload", "database": {"host": "localhost", "port": 3306, "user": "root", "passwd": "jsyh@2025", "dbname": "ess"}, "http": {"token":0, "port": 19800, "encryption":0, "encryptKey":""}, - "mqtt": {"host":"mqtt://118.195.161.113:8883","username":"admin","password":"jsyh@2025", "interval": 120}, + "mqtt": {"host":"mqtt://118.195.161.113:8883","username":"admin","password":"jsyh@2025", "interval": 300}, "topic": { "EMS_YX": {"deviceType":101, "polling":0, "enabled": 1}, "EMS_YC": {"deviceType":101, "polling":0, "enabled": 1}, @@ -26,6 +26,7 @@ "Cooling_YX": {"deviceType":14, "polling":1, "enabled": 1}, "Gateway_YX": {"deviceType":15, "polling":1, "enabled": 1}, "Gateway_YC": {"deviceType":15, "polling":1, "enabled": 1}, + "Gateway_YT": {"deviceType":15, "polling":0, "enabled": 1}, "Charger_YC": {"deviceType":106, "polling":0, "enabled": 1} }, "view": {"latitude":0,"longitude":0,"altitude":0}, diff --git a/bin/Release/assets/config-online/regaddrs.json b/bin/Release/assets/config-online/regaddrs.json index 375213f..513eb9e 100644 --- a/bin/Release/assets/config-online/regaddrs.json +++ b/bin/Release/assets/config-online/regaddrs.json @@ -278,29 +278,31 @@ {"key": "0x1022", "datatype": "uint16", "alert": 0, "name":"电操状态NO", "remark": "1闭合,0断开"}, {"key": "0x1023", "datatype": "uint16", "alert": 0, "name":"远程关机NO", "remark": "1开机,0无效"}, {"key": "0x1024", "datatype": "uint16", "alert": 0, "name":"远程开机NO", "remark": "1开机,0无效"}, - {"key": "0x1025", "datatype": "uint16", "alert": 0, "name":"BA故障信号NO", "remark": "1故障,0正常"}, - {"key": "0x1026", "datatype": "uint16", "alert": 0, "name":"PCS_01状态", "remark": "1在线,0掉线"}, - {"key": "0x1027", "datatype": "uint16", "alert": 0, "name":"PCS_02状态", "remark": "1在线,0掉线"}, - {"key": "0x1028", "datatype": "uint16", "alert": 0, "name":"PCS_03状态", "remark": "1在线,0掉线"}, - {"key": "0x1029", "datatype": "uint16", "alert": 0, "name":"PCS_04状态", "remark": "1在线,0掉线"}, - {"key": "0x102A", "datatype": "uint16", "alert": 0, "name":"PCS_05状态", "remark": "1在线,0掉线"}, - {"key": "0x102B", "datatype": "uint16", "alert": 0, "name":"PCS_06状态", "remark": "1在线,0掉线"}, - {"key": "0x102C", "datatype": "uint16", "alert": 0, "name":"PCS_07状态", "remark": "1在线,0掉线"}, - {"key": "0x102D", "datatype": "uint16", "alert": 0, "name":"PCS_09状态", "remark": "1在线,0掉线"}, - {"key": "0x102E", "datatype": "uint16", "alert": 0, "name":"PCS_10状态", "remark": "1在线,0掉线"}, - {"key": "0x102F", "datatype": "uint16", "alert": 1, "name":"PCS_01下发设置", "remark": "1故障,0正常"}, - {"key": "0x1030", "datatype": "uint16", "alert": 1, "name":"PCS_02下发设置", "remark": "1故障,0正常"}, - {"key": "0x1031", "datatype": "uint16", "alert": 1, "name":"PCS_03下发设置", "remark": "1故障,0正常"}, - {"key": "0x1032", "datatype": "uint16", "alert": 1, "name":"PCS_04下发设置", "remark": "1故障,0正常"}, - {"key": "0x1033", "datatype": "uint16", "alert": 1, "name":"PCS_05下发设置", "remark": "1故障,0正常"}, - {"key": "0x1034", "datatype": "uint16", "alert": 1, "name":"PCS_06下发设置", "remark": "1故障,0正常"}, - {"key": "0x1035", "datatype": "uint16", "alert": 1, "name":"PCS_07下发设置", "remark": "1故障,0正常"}, - {"key": "0x1036", "datatype": "uint16", "alert": 1, "name":"PCS_08下发设置", "remark": "1故障,0正常"}, - {"key": "0x1037", "datatype": "uint16", "alert": 1, "name":"PCS_09下发设置", "remark": "1故障,0正常"}, - {"key": "0x1038", "datatype": "uint16", "alert": 1, "name":"PCS_10下发设置", "remark": "1:故障,0正常"}, - {"key": "0x1039", "datatype": "uint16", "alert": 1, "name":"内部DSP通信故障", "remark": "1:故障,0正常"}, - {"key": "0x103A", "datatype": "uint16", "alert": 1, "name":"BMS CAN通信故障", "remark": "1:故障,0正常"}, - {"key": "0x103B", "datatype": "uint16", "alert": 1, "name":"下发设置失败", "remark": "1:故障,0正常"} + {"key": "0x1025", "datatype": "uint16", "alert": 1, "name":"BA故障信号NO", "remark": "1故障,0正常"}, + {"key": "0x1026", "datatype": "uint16", "alert": 1, "name":"PCS_01状态", "remark": "1在线,0掉线"}, + {"key": "0x1027", "datatype": "uint16", "alert": 1, "name":"PCS_02状态", "remark": "1在线,0掉线"}, + {"key": "0x1028", "datatype": "uint16", "alert": 1, "name":"PCS_03状态", "remark": "1在线,0掉线"}, + {"key": "0x1029", "datatype": "uint16", "alert": 1, "name":"PCS_04状态", "remark": "1在线,0掉线"}, + {"key": "0x102A", "datatype": "uint16", "alert": 1, "name":"PCS_05状态", "remark": "1在线,0掉线"}, + {"key": "0x102B", "datatype": "uint16", "alert": 1, "name":"PCS_06状态", "remark": "1在线,0掉线"}, + {"key": "0x102C", "datatype": "uint16", "alert": 1, "name":"PCS_07状态", "remark": "1在线,0掉线"}, + {"key": "0x102D", "datatype": "uint16", "alert": 1, "name":"PCS_08状态", "remark": "1在线,0掉线"}, + {"key": "0x102E", "datatype": "uint16", "alert": 1, "name":"PCS_09状态", "remark": "1在线,0掉线"}, + {"key": "0x102F", "datatype": "uint16", "alert": 1, "name":"PCS_10状态", "remark": "1在线,0掉线"}, + {"key": "0x1030", "datatype": "uint16", "alert": 1, "name":"PCS_01下发设置", "remark": "1故障,0正常"}, + {"key": "0x1031", "datatype": "uint16", "alert": 1, "name":"PCS_02下发设置", "remark": "1故障,0正常"}, + {"key": "0x1032", "datatype": "uint16", "alert": 1, "name":"PCS_03下发设置", "remark": "1故障,0正常"}, + {"key": "0x1033", "datatype": "uint16", "alert": 1, "name":"PCS_04下发设置", "remark": "1故障,0正常"}, + {"key": "0x1034", "datatype": "uint16", "alert": 1, "name":"PCS_05下发设置", "remark": "1故障,0正常"}, + {"key": "0x1035", "datatype": "uint16", "alert": 1, "name":"PCS_06下发设置", "remark": "1故障,0正常"}, + {"key": "0x1036", "datatype": "uint16", "alert": 1, "name":"PCS_07下发设置", "remark": "1故障,0正常"}, + {"key": "0x1037", "datatype": "uint16", "alert": 1, "name":"PCS_08下发设置", "remark": "1故障,0正常"}, + {"key": "0x1038", "datatype": "uint16", "alert": 1, "name":"PCS_09下发设置", "remark": "1故障,0正常"}, + {"key": "0x1039", "datatype": "uint16", "alert": 1, "name":"PCS_10下发设置", "remark": "1:故障,0正常"}, + {"key": "0x103A", "datatype": "uint16", "alert": 1, "name":"内部DSP通信故障", "remark": "1:故障,0正常"}, + {"key": "0x103B", "datatype": "uint16", "alert": 1, "name":"BMS CAN通信故障", "remark": "1:故障,0正常"}, + {"key": "0x103C", "datatype": "uint16", "alert": 1, "name":"下发设置失败", "remark": "1:故障,0正常"}, + {"key": "0x103D", "datatype": "uint16", "alert": 0, "name":"手动/自动并离网状态", "remark": "1:自动,0手动"} ] }, "PCS_YC":{ diff --git a/bin/Release/assets/config-online/regaddrsShow.json b/bin/Release/assets/config-online/regaddrsShow.json index 586322e..fff2e0a 100644 --- a/bin/Release/assets/config-online/regaddrsShow.json +++ b/bin/Release/assets/config-online/regaddrsShow.json @@ -2,6 +2,15 @@ "EMS":{ "deviceType":101, "addrYC":[ + ["BCU总通信状态", "0x2018", "--", ""], + ["PCU总通信状态", "0x2019", "--", ""], + ["电表总通信状态", "0x201A", "--", ""], + ["消防总通信状态", "0x201B", "--", ""], + ["UPS总通信状态", "0x201C", "--", ""], + ["温湿度总通信状态", "0x201D", "--", ""], + ["空调总通信状态", "0x201E", "--", ""], + ["EMU通信状态", "0x201F", "--", ""], + ["冷机总通信状态", "0x2020", "--", ""], ["A相电压", "0x107E", "0.0", " V", "1"], ["A相电流", "0x1084", "0.0", " A"], ["B相电压", "0x1080", "0.0", " V", "1"], @@ -11,7 +20,18 @@ ["总有功功率", "0x1096", "0.0", " kW"] ], - "addrCurve": ["0x107E", "0x1084", "0x1096"] + "addrCurve": ["0x107E", "0x1084", "0x1096"], + "valstr": { + "0x2018": {"0":"正常", "1":"告警", "2":"故障"}, + "0x2019": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201A": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201B": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201C": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201D": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201E": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201F": {"0":"正常", "1":"告警", "2":"故障"}, + "0x2020": {"0":"正常", "1":"告警", "2":"故障"} + } }, "PCS":{ "deviceType":102, @@ -24,17 +44,21 @@ ["B相电流", "0x001A", "0.0", " A"], ["C相电压", "0x0011", "0.0", " V", "1"], ["C相电流", "0x001B", "0.0", " A"], + ["期望有功功率", "0x000B", "0.0", " kW"], ["总有功功率", "0x0025", "0.0", " kW"] ], - "addrCurve": ["0x0010", "0x0019", "0x0025"] + "addrCurve": ["0x0010", "0x0019", "0x0025"], + "valstr": { + "0x1009": {"0":"待机","1":"充电","2":"放电","3":"搁置"}, + "0x100A": {"1":"离网","0":"并网"} + } }, "PCU":{ "deviceType":103, "addrYC":[ ["电网状态", "0x1007", "--", ""], ["启停状态", "0x1006", "--", ""], - ["有功功率期望值","0x000E", "0.0", " KW"], - ["无功功率期望值","0x000F", "0.0", " kVar"], + ["手动/自动状态", "0x103D", "--", ""], ["A相电压", "0x0013", "0.0", " V", "1"], ["A相电流", "0x001C", "0.0", " A"], ["B相电压", "0x0014", "0.0", " V", "1"], @@ -43,7 +67,12 @@ ["C相电流", "0x001E", "0.0", " A"], ["总有功功率", "0x0028", "0.0", " kW"] ], - "addrCurve": ["0x0013", "0x001C", "0x0028"] + "addrCurve": ["0x0013", "0x001C", "0x0028"], + "valstr": { + "0x1007": {"1":"离网","0":"并网"}, + "0x1006": {"1":"开机","0":"关机"}, + "0x103D": {"1":"自动","0":"手动"} + } }, "BMS":{ "deviceType":104, @@ -54,28 +83,36 @@ ["SOH", "0x0002", "0", " %", "0.1"], ["电压", "0x0003", "0.0", " V", "0.1"], ["电流", "0x0005", "0.0", " A", "0.1"], - ["单体最电压", "0x0021", "0.0", " V", "0.1"], - ["单体最小电压", "0x0024", "0.0", " V", "0.1"], + ["单体最大电压", "0x0021", "0.0", " V", "0.001"], + ["单体最小电压", "0x0024", "0.0", " V", "0.001"], ["单体最大温度", "0x0029", "0.0", " ℃", "0.1"], ["单体最小温度", "0x002C", "0.0", " ℃", "0.1"] ], - "addrCurve": ["0x0003", "0x0005", ""] + "addrCurve": ["0x0003", "0x0005", ""], + "valstr": { + "0x004A": {"0":"待机","1":"充电","2":"放电"} + } }, "BCU":{ "deviceType":105, "addrYC":[ ["充放状态", "0xA003", "--", ""], ["运行状态", "0xA004", "--", ""], - ["簇可充容量", "0x0019", "0.0", " Ah", "0.1"], - ["簇可放容量", "0x001B", "0.0", " Ah", "0.1"], + ["簇可充电量", "0x0025", "0.0", " kWh", "1"], + ["簇可放电量", "0x0027", "0.0", " kWh", "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", " Ω"] + ["单体最高电压", "0x0045", "0", " V", "0.001"], + ["单体最低电压", "0x0047", "0", " V", "0.001"], + ["单体平均电压", "0x0049", "0", " V", "0.001"] ], - "addrCurve": ["0x0003", "0x0005", ""] + "addrCurve": ["0x0003", "0x0005", ""], + "valstr": { + "0xA003": {"17":"开路","34":"待机","51":"充电","68":"放电"}, + "0xA004": {"17":"跳机","34":"待机","51":"放空","68":"充满","85":"预警","102":"正常"} + } }, "MEM":{ "deviceType":3, @@ -116,6 +153,7 @@ ["B相电流", "0x0013", "0.0", " A"], ["C相电压", "0x000F", "0.0", " V"], ["C相电流", "0x0015", "0.0", " A"], + ["三相总有功","0x0023", "0.0", " kW"], ["总有功总需量", "0x0025", "0.0", " kW"] ], "addrCurve": ["0x000B","0x0011","0x0023"] diff --git a/bin/Release/assets/config-online/regaddrsShow.json.bakup20251110 b/bin/Release/assets/config-online/regaddrsShow.json.bakup20251110 new file mode 100644 index 0000000..25962b6 --- /dev/null +++ b/bin/Release/assets/config-online/regaddrsShow.json.bakup20251110 @@ -0,0 +1,193 @@ +{ + "EMS":{ + "deviceType":101, + "addrYC":[ + ["BCU总通信状态", "0x2018", "--", ""], + ["PCU总通信状态", "0x2019", "--", ""], + ["电表总通信状态", "0x201A", "--", ""], + ["消防总通信状态", "0x201B", "--", ""], + ["UPS总通信状态", "0x201C", "--", ""], + ["温湿度总通信状态", "0x201D", "--", ""], + ["空调总通信状态", "0x201E", "--", ""], + ["EMU通信状态", "0x201F", "--", ""], + ["冷机总通信状态", "0x2020", "--", ""], + ["A相电压", "0x107E", "0.0", " V", "1"], + ["A相电流", "0x1084", "0.0", " A"], + ["B相电压", "0x1080", "0.0", " V", "1"], + ["B相电流", "0x1086", "0.0", " A"], + ["C相电压", "0x1082", "0.0", " V", "1"], + ["C相电流", "0x1088", "0.0", " A"], + ["总有功功率", "0x1096", "0.0", " kW"] + + ], + "addrCurve": ["0x107E", "0x1084", "0x1096"], + "valstr": { + "0x2018": {"0":"正常", "1":"告警", "2":"故障"}, + "0x2019": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201A": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201B": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201C": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201D": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201E": {"0":"正常", "1":"告警", "2":"故障"}, + "0x201F": {"0":"正常", "1":"告警", "2":"故障"}, + "0x2020": {"0":"正常", "1":"告警", "2":"故障"} + } + }, + "PCS":{ + "deviceType":102, + "addrYC":[ + ["充放状态", "0x1009", "--", ""], + ["电网状态", "0x100A", "--", ""], + ["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"], + ["总有功功率", "0x0025", "0.0", " kW"] + ], + "addrCurve": ["0x0010", "0x0019", "0x0025"], + "valstr": { + "0x1009": {"0":"待机","1":"充电","2":"放电","3":"搁置"}, + "0x100A": {"1":"离网","0":"并网"} + } + }, + "PCU":{ + "deviceType":103, + "addrYC":[ + ["电网状态", "0x1007", "--", ""], + ["启停状态", "0x1006", "--", ""], + ["手动/自动状态", "0x103D", "--", ""], + ["有功功率期望值","0x000E", "0.0", " KW"], + ["无功功率期望值","0x000F", "0.0", " kVar"], + ["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"], + ["总有功功率", "0x0028", "0.0", " kW"] + ], + "addrCurve": ["0x0013", "0x001C", "0x0028"], + "valstr": { + "0x1007": {"1":"离网","0":"并网"}, + "0x1006": {"1":"开机","0":"关机"}, + "0x103D": {"1":"自动","0":"手动"} + } + }, + "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.001"], + ["单体最小电压", "0x0024", "0.0", " V", "0.001"], + ["单体最大温度", "0x0029", "0.0", " ℃", "0.1"], + ["单体最小温度", "0x002C", "0.0", " ℃", "0.1"] + ], + "addrCurve": ["0x0003", "0x0005", ""], + "valstr": { + "0x004A": {"0":"待机","1":"充电","2":"放电"} + } + }, + "BCU":{ + "deviceType":105, + "addrYC":[ + ["充放状态", "0xA003", "--", ""], + ["运行状态", "0xA004", "--", ""], + ["簇可充电量", "0x0025", "0.0", " kWh", "1"], + ["簇可放电量", "0x0027", "0.0", " kWh", "1"], + ["簇SOC", "0x000B", "0", " %", "0.1"], + ["簇SOH", "0x000C", "0", " %", "0.1"], + ["簇电压", "0x0003", "0.0", " V", "0.1"], + ["簇电流", "0x0005", "0", " A", "0.1"] + ], + "addrCurve": ["0x0003", "0x0005", ""], + "valstr": { + "0xA003": {"17":"开路","34":"待机","51":"充电","68":"放电"}, + "0xA004": {"17":"跳机","34":"待机","51":"放空","68":"充满","85":"预警","102":"正常"} + } + }, + "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", " 元"], + ["日正向尖电能", "0x0039", "0", " kWh"], + ["日正向峰电能", "0x003B", "0", " kWh"], + ["日正向平电能", "0x003D", "0", " kWh"], + ["日正向谷电能", "0x003F", "0", " kWh"], + ["日正向总电能", "0x0041", "0", " kWh"], + ["日反向尖电能", "0x0043", "0", " kWh"], + ["日反向峰电能", "0x0045", "0", " kWh"], + ["日反向平电能", "0x0047", "0", " kWh"], + ["日反向谷电能", "0x0049", "0", " kWh"], + ["日反向总电能", "0x004B", "0", " kWh"], + ["总正向尖电能", "0x0057", "0", " kWh"], + ["总正向峰电能", "0x0059", "0", " kWh"], + ["总正向平电能", "0x005B", "0", " kWh"], + ["总正向谷电能", "0x005D", "0", " kWh"], + ["总正向总电能", "0x005F", "0", " kWh"], + ["总反向尖电能", "0x0061", "0", " kWh"], + ["总反向峰电能", "0x0063", "0", " kWh"], + ["总反向平电能", "0x0065", "0", " kWh"], + ["总反向谷电能", "0x0067", "0", " kWh"], + ["总反向总电能", "0x0069", "0", " kWh"], + ["A相电压", "0x000B", "0.0", " V"], + ["A相电流", "0x0011", "0.0", " A"], + ["B相电压", "0x000D", "0.0", " V"], + ["B相电流", "0x0013", "0.0", " A"], + ["C相电压", "0x000F", "0.0", " V"], + ["C相电流", "0x0015", "0.0", " A"], + ["三相总有功","0x0023", "0.0", " kW"], + ["总有功总需量", "0x0025", "0.0", " kW"] + ], + "addrCurve": ["0x000B","0x0011","0x0023"] + }, + "TH": { + "deviceType":10, + "addrYC":[ + ["温度", "0x0003", "0.0", " ℃", "0.1"], + ["湿度", "0x0004", "0.0", " %", "0.1"] + ] + }, + "Cooling": { + "deviceType":14, + "addrYC":[ + ["开关", "0x1003", "0", "", "1"], + ["采样模式", "0x1004", "0", "", "1"], + ["制冷状态", "0x1005", "0", "", "1"], + ["制热状态", "0x1006", "0", "", "1"], + ["高温告警", "0x1007", "0", "", "1"], + ["低温告警", "0x1008", "0", "", "1"], + ["高压告警", "0x1009", "0", "", "1"], + ["低压告警", "0x100A", "0", "", "1"] + ] + }, + "Charger": { + "deviceType":106, + "addrYC":[ + ["工作状态", "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": ["15", "16", "17"] + } +} \ No newline at end of file diff --git a/bin/Release/assets/config/regaddrsShow-online.json b/bin/Release/assets/config/regaddrsShow-online.json index 25962b6..e8f834f 100644 --- a/bin/Release/assets/config/regaddrsShow-online.json +++ b/bin/Release/assets/config/regaddrsShow-online.json @@ -48,7 +48,7 @@ ], "addrCurve": ["0x0010", "0x0019", "0x0025"], "valstr": { - "0x1009": {"0":"待机","1":"充电","2":"放电","3":"搁置"}, + "0x1009": {"0":"待机","1":"充电","2":"放电","3":"空闲"}, "0x100A": {"1":"离网","0":"并网"} } }, diff --git a/bin/Release/assets/config/regaddrsShow.json b/bin/Release/assets/config/regaddrsShow.json index edef5e8..83ad000 100644 --- a/bin/Release/assets/config/regaddrsShow.json +++ b/bin/Release/assets/config/regaddrsShow.json @@ -49,7 +49,7 @@ ], "addrCurve": ["0x0010", "0x0019", "0x0025"], "valstr": { - "0x1009": {"0":"待机","1":"充电","2":"放电","3":"搁置"}, + "0x1009": {"0":"待机","1":"充电","2":"放电","3":"空闲"}, "0x100A": {"1":"离网","0":"并网"} } }, diff --git a/src/app/Constant.cpp b/src/app/Constant.cpp index 3b134c3..cc060e3 100644 --- a/src/app/Constant.cpp +++ b/src/app/Constant.cpp @@ -1,6 +1,6 @@ #include "Constant.h" -namespace CONST +namespace CONSTS { const std::string VAR; } diff --git a/src/app/Constant.h b/src/app/Constant.h index 544f0b6..8d2c662 100644 --- a/src/app/Constant.h +++ b/src/app/Constant.h @@ -1,11 +1,11 @@ -#ifndef _CONSTANTS_H_ -#define _CONSTANTS_H_ +#ifndef _MYCONSTS_H_ +#define _MYCONSTS_H_ #include -namespace CONST +namespace CONSTS { extern const std::string VAR; } -#endif // !_CONSTANTS_H_ +#endif // !_MYCONSTS_H_ diff --git a/src/app/DataStruct.h b/src/app/DataStruct.h index f5a0777..51c541c 100644 --- a/src/app/DataStruct.h +++ b/src/app/DataStruct.h @@ -12,9 +12,10 @@ enum class EAlertType enum class EDeviceType { + NUL = 0, //1 变压器 0 //2 配电柜 0 - //3 电表 1 + E_METER = 3, //3 电表 1 //4 门禁 0 //5 空调 0 //6 照明 0 diff --git a/src/app/Device.cpp b/src/app/Device.cpp index 9136814..e473ea4 100644 --- a/src/app/Device.cpp +++ b/src/app/Device.cpp @@ -28,6 +28,9 @@ std::shared_ptr Device::create(Fields& fields) static const int BCU_UNIT_SIZE = 256; Device::Device() { + cacheU = vector(144, 0); + cacheI = vector(144, 0); + cacheP = vector(144, 0); vecBCUUnit = std::vector>(BCU_UNIT_SIZE, std::vector(5, 0.0f)); } @@ -104,54 +107,54 @@ int Device::startComm() return 0; } -void Device::getCacheVoltage(std::vector& vec) -{ - vec.resize(mapCacheVoltage.size()); - int i = 0; - for (auto iter = mapCacheVoltage.begin(); iter != mapCacheVoltage.end(); ++iter) - { - vec[i] = Utils::toStr(iter->second); - i++; - } -} -void Device::getCacheCurrent(std::vector& vec) -{ - vec.resize(mapCacheCurrent.size()); - int i = 0; - for (auto iter = mapCacheCurrent.begin(); iter != mapCacheCurrent.end(); ++iter) - { - vec[i] = Utils::toStr(iter->second); - i++; - } -} -void Device::getCachePower(std::vector& vec) -{ - vec.resize(mapCachePower.size()); - int i = 0; - for (auto iter = mapCachePower.begin(); iter != mapCachePower.end(); ++iter) - { - vec[i] = Utils::toStr(iter->second); - i++; - } -} +//void Device::getCacheVoltage(std::vector& vec) +//{ +// vec.resize(mapCacheVoltage.size()); +// int i = 0; +// for (auto iter = mapCacheVoltage.begin(); iter != mapCacheVoltage.end(); ++iter) +// { +// vec[i] = Utils::toStr(iter->second); +// i++; +// } +//} +//void Device::getCacheCurrent(std::vector& vec) +//{ +// vec.resize(mapCacheCurrent.size()); +// int i = 0; +// for (auto iter = mapCacheCurrent.begin(); iter != mapCacheCurrent.end(); ++iter) +// { +// vec[i] = Utils::toStr(iter->second); +// i++; +// } +//} +//void Device::getCachePower(std::vector& vec) +//{ +// vec.resize(mapCachePower.size()); +// int i = 0; +// for (auto iter = mapCachePower.begin(); iter != mapCachePower.end(); ++iter) +// { +// vec[i] = Utils::toStr(iter->second); +// i++; +// } +//} void Device::setCache(int datatype, std::vector& vd) { - std::map* mapptr = NULL; - if (datatype == 1) { mapptr = &mapCacheVoltage; } - else if (datatype == 2) { mapptr = &mapCacheCurrent; } - else if (datatype == 3) { mapptr = &mapCachePower; } + std::vector* vecptr = NULL; + if (datatype == 1) { vecptr = &cacheU; } + else if (datatype == 2) { vecptr = &cacheI; } + else if (datatype == 3) { vecptr = &cacheP; } - if (mapptr) + if (vecptr) { const int step = 600; const int N = 86400/step; int64_t tsSeconds = Utils::timeDaySeconds(); int npos = tsSeconds / step; - for (int i = 0; isize(); ++i) { - if (i < vd.size()) { (*mapptr)[i] = vd[i]; } - else if (i <= npos) { (*mapptr)[i] = 0; } + if (i < vd.size()) { (*vecptr)[i] = vd[i]; } + else if (i <= npos) { (*vecptr)[i] = 0; } } } } @@ -164,9 +167,9 @@ bool Device::cache(int npos) } if (npos == 0) { - mapCacheVoltage.clear(); - mapCacheCurrent.clear(); - mapCachePower.clear(); + std::fill(cacheU.begin(), cacheU.end(), 0); + std::fill(cacheI.begin(), cacheI.end(), 0); + std::fill(cacheP.begin(), cacheP.end(), 0); } std::string addrV; @@ -186,9 +189,9 @@ bool Device::cache(int npos) int U = Utils::toInt(this->getParam(addrV, "0")); int I = Utils::toInt(this->getParam(addrI, "0")); int P = addrP.empty() ? U*I*0.001 : Utils::toInt(this->getParam(addrP, "0")); - mapCacheVoltage[npos] = U; - mapCacheCurrent[npos] = I; - mapCachePower[npos] = P; + cacheU[npos] = U; + cacheI[npos] = I; + cacheP[npos] = P; return true; } diff --git a/src/app/Device.h b/src/app/Device.h index ba640ea..5799a8e 100644 --- a/src/app/Device.h +++ b/src/app/Device.h @@ -23,9 +23,9 @@ public: int startComm(); - void getCacheVoltage(std::vector& vec); - void getCacheCurrent(std::vector& vec); - void getCachePower(std::vector& vec); + //void getCacheVoltage(std::vector& vec); + //void getCacheCurrent(std::vector& vec); + //void getCachePower(std::vector& vec); // int datatype: 1: 电压,2:电流,3:功率 void setCache(int datatype, std::vector& vec); @@ -49,7 +49,7 @@ public: int type = {0}; std::string name; std::string code; - int category; + int category = 0; bool isOpen = false; std::string attrsJson = ""; int sortNo {0}; @@ -67,9 +67,13 @@ public: std::shared_ptr commEntity; int64_t tsDataDate {}; - std::map mapCacheVoltage; - std::map mapCacheCurrent; - std::map mapCachePower; + //std::map mapCacheVoltage; + //std::map mapCacheCurrent; + //std::map mapCachePower; + + std::vector cacheU; + std::vector cacheI; + std::vector cacheP; // 参数值(保存从设备读取的参数值) std::map mapParams; diff --git a/src/app/Station.cpp b/src/app/Station.cpp index d944b28..dfda645 100644 --- a/src/app/Station.cpp +++ b/src/app/Station.cpp @@ -18,6 +18,18 @@ Station::Station() : stationId(0) predictStorageIn = vector(144, 0); predictStorageOut = vector(144, 0); predictCharge = vector(144, 0); + + storage.U = vector(144, 0); + storage.I = vector(144, 0); + storage.P = vector(144, 0); + + charge.U = vector(144, 0); + charge.I = vector(144, 0); + charge.P = vector(144, 0); + + pv.U = vector(144, 0); + pv.I = vector(144, 0); + pv.P = vector(144, 0); } void Station::setFields(Fields& fields) @@ -214,13 +226,13 @@ void Station::setGarewayParams() string Station::getGatewayMode() { - // 0:手动,1:峰谷套利,2:配网增容,3:应急供电,4:并网保电,5:自定时段 + // 0:手动,1:峰谷套利,2:配网增容,3:应急供电,4:并网保电,5:运营支撑 if (gatewayParam.mode == 0) { return "手动"; } else if (gatewayParam.mode == 1) { return "峰谷套利"; } else if (gatewayParam.mode == 2) { return "配网增容"; } else if (gatewayParam.mode == 3) { return "应急供电"; } else if (gatewayParam.mode == 4) { return "并网保电"; } - else if (gatewayParam.mode == 5) { return "自定时段"; } + else if (gatewayParam.mode == 5) { return "运营支撑"; } else { return "--"; }; } @@ -236,7 +248,11 @@ static map mapPeriodOper = string Station::getGatewayParam() { stringstream ss; - std::string str1 = "峰谷套利时段:
"; + std::string str1 = std::format("运行模式:{}
储能EMY状态:{}
充电桩状态:{}

", + getGatewayMode(), + this->emuStatus == 1 ? "在线" : (this->emuStatus == 0 ? "离线" : "--"), + this->cdzStatus == 1 ? "在线" : (this->cdzStatus == 0 ? "离线" : "--")); + str1 += "峰谷套利时段:
"; { njson json; if (JSON::parse(gatewayParam.param1, json)) @@ -346,18 +362,24 @@ void Station::readAlert(std::shared_ptr device, std::string addr, int v, } } -void Station::readRuntimeData(int deviceNo, string addr, int val) +void Station::readEnergyData(int deviceNo, string addr, int val) { - if (deviceNo == 1) + 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 == "0x0023") { this->power = val; } // 三相总有功 R int32 1kW 0x0023 + if (addr == "0x000B") { this->grid.voltage = val; } // A相电压 R uint32 1V 0x000B + if (addr == "0x0011") { this->grid.current = val; } // A相电流 R int32 1A 0x0011 + if (addr == "0x0023") { this->grid.power = val; } // 三相总有功 R int32 1kW 0x0023 + // 功率因数 ?? 电表没有功率因数数据 } - else if (deviceNo == 2) + else if (deviceNo == 2) // 储能电表 { statData.ts = Utils::time(); - if (addr == "0x002F") { statData.dayElectIn = val; } //日充电电量 R uint32 1kWh 0x002F + + if (addr == "0x000B") { this->storage.voltage = val; } // A相电压 R uint32 1V 0x000B + else if (addr == "0x0011") { this->storage.current = val; } // A相电流 R int32 1A 0x0011 + else if (addr == "0x0023") { this->storage.power = val; } // 三相总有功 R int32 1kW 0x0023 + // 功率因数 ?? 电表没有功率因数数据 + else 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 @@ -392,7 +414,29 @@ void Station::readRuntimeData(int deviceNo, string addr, int val) else if (addr == "0x0069") { statData.totalElectOut_Total = val; } //总反向总有功电能 R uint32 1kWh 0x0069 } } +// 充电桩 +void Station::readChargeData(int deviceNo, string addr, int val) +{ + if (addr == "11") { charge.connector1.isCharge = val; } //枪1:状态 R uint16 11 + //枪1 : 需求电压 R uint16 12 + //枪1 : 需求电流 R uint16 13 + //枪1 : 需求功率 R uint16 14 + else if (addr == "15") { charge.connector1.voltage = val * 0.1; } //枪1 : 输出电压 R uint16 15 + else if (addr == "16") { charge.connector1.current = val * 0.01; } //枪1 : 输出电流 R uint16 16 + else if (addr == "17") { charge.connector1.power = val * 0.1; } //枪1 : 输出功率 R uint16 17 + //枪1 : 功率限值 R uint16 18 + else if (addr == "21") { charge.connector2.isCharge = val; } //枪2 : 状态 R uint16 21 + //枪2 : 需求电压 R uint16 22 + //枪2 : 需求电流 R uint16 23 + //枪2 : 需求功率 R uint16 24 + else if (addr == "25") { charge.connector2.voltage = val * 0.1; } //枪2 : 输出电压 R uint16 25 + else if (addr == "26") { charge.connector2.current = val * 0.01; } //枪2 : 输出电流 R uint16 26 + else if (addr == "27") { charge.connector2.power = val * 0.1; } //枪2 : 输出功率 R uint16 27 + //枪2 : 功率限值 R uint16 28 + bool isCharge = (charge.connector1.isCharge || charge.connector2.isCharge); + charge.status = isCharge ? 2 : 1; +} void Station::readTHData(int deviceNo, string addr, int val) { auto& unit = mapTempHumUnit[deviceNo]; @@ -507,6 +551,11 @@ void Station::readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus) device->ts = Utils::time(); } + if (cdzStatus == 0) charge.status = 0; + else if (charge.status == 0) charge.status = 1; + if (emuStatus == 0) storage.status = 0; + else if (storage.status == 0) storage.status = 1; + //充电桩 1:在线,0:离线 if (cdzStatus >= 0) { @@ -565,24 +614,51 @@ void Station::cache() int npos = tDaySeconds / 600; int offset = tDaySeconds % 600; bool save = false; - if (offset >= (600-180) && npos + 1 < 144) - { - npos += 1; - save = true; - } - else if (offset <= 180 && posCache < npos) + if (posCache != npos && offset <= 180) // 超过时间点3分钟内没有存储,进行兼容处理 { + if (npos == 0) + { + std::fill(storage.U.begin(), storage.U.end(), 0); + std::fill(storage.I.begin(), storage.I.end(), 0); + std::fill(storage.P.begin(), storage.P.end(), 0); + std::fill(charge.U.begin(), charge.U.end(), 0); + std::fill(charge.I.begin(), charge.I.end(), 0); + std::fill(charge.P.begin(), charge.P.end(), 0); + std::fill(pv.U.begin(), pv.U.end(), 0); + std::fill(pv.I.begin(), pv.I.end(), 0); + std::fill(pv.P.begin(), pv.P.end(), 0); + } save = true; posCache = npos; } - if (save) + if (save && npos < storage.U.size()) { - mapCacheElectIn[npos] = Utils::random(100, 800); // dayElectIn - mapCacheElectOut[npos] = Utils::random(100, 800); // dayElectOut - mapCacheElectCharger[npos] = Utils::random(100, 800); // 暂无数据源 + storage.U[npos] = storage.voltage; + storage.I[npos] = storage.current; + storage.P[npos] = storage.power; + + charge.U[npos] = charge.connector1.voltage; + charge.I[npos] = charge.connector1.current; + charge.P[npos] = charge.connector1.power; + + //pv.U[npos]; + //pv.I[npos]; + //pv.P[npos]; } } +static njson VectorToJsonArray(vector& vec, int n) +{ + //int v = Utils::random(40, 50); + njson jsonArray = njson::array(); + for (int i = 0; i <= n && i < vec.size(); ++i) + { + jsonArray.push_back(int(vec[i])); + //jsonArray.push_back(v + Utils::random(1, 6) -3); + } + return jsonArray; +} + void Station::writeStatistic() { auto dao = DaoEntity::create("history_day"); @@ -603,15 +679,15 @@ void Station::writeStatistic() fields.set("station_id", this->stationId); fields.set("device_id", device->deviceId); fields.set("datatype", 1); - fields.set("value", MapValueToJson(npos, device->mapCacheVoltage)); + fields.set("value", VectorToJsonArray(device->cacheU, npos)); DAO::insertRuntimeData(dao, fields); fields.set("datatype", 2); - fields.set("value", MapValueToJson(npos, device->mapCacheCurrent)); + fields.set("value", VectorToJsonArray(device->cacheI, npos)); DAO::insertRuntimeData(dao, fields); fields.set("datatype", 3); - fields.set("value", MapValueToJson(npos, device->mapCachePower)); + fields.set("value", VectorToJsonArray(device->cacheP, npos)); DAO::insertRuntimeData(dao, fields); //spdlog::info("[device] write runtime date to database, deviceId={}", device->deviceId); } @@ -802,4 +878,10 @@ void Station::predict() // predictStorageOut[i] = v2 >= 0 ? v2 : 0; // predictCharge[i] = v3 >= 0 ? v3 : 0; //} +} + + + +void Station::writeDeviceData() +{ } \ No newline at end of file diff --git a/src/app/Station.h b/src/app/Station.h index 70f3310..d491f4e 100644 --- a/src/app/Station.h +++ b/src/app/Station.h @@ -119,13 +119,16 @@ public: string getGatewayParam(); void readAlert(std::shared_ptr device, std::string addr, int v, std::string text); - void readRuntimeData(int deviceNo, string addr, int val); + void readEnergyData(int deviceNo, string addr, int val); + void readChargeData(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 deviceNo, int mode, string p1, string p2, string p3); void readGatewayStatus(int deviceNo, int cdzStatus, int emuStatus); + void readTDData(int deviceNo); + void setCache(int datatype, std::vector& vd); void cache(); int posCache {0}; @@ -135,6 +138,8 @@ public: void predict(); + void writeDeviceData(); + public: int stationId {}; std::string name; @@ -147,7 +152,6 @@ public: int err = 0; int online = 0; int running = 0; - bool isConnected {false}; int workMode {}; // 运行模式 @@ -172,6 +176,83 @@ public: int overload {}; // 防过载回差 40059(1KW 10-300) } gatewayParam; + int cdzStatus{ -1 }; // 充电桩 1:在线,0:离线 + int emuStatus{ -1 }; // 储能 1:在线,0:离线 + int pvStatus{ -1 }; + + /////////////////////////////////////////////////////////////////////////////////////////////// + /// === 储能相关数据 === + struct { + int ts; // 数据更新时间戳(通讯) + int num = 1; // 储能设备的数量(储能仓的个数) + + int status = 0; // 储能设备状态: 0:离线,1:空闲,2:充电,3:放电,9:故障 + + int voltage = 0; + int current = 0; + int power = 0; + float powerFactor = 0; + + vector U; // 电压曲线(144个点位) + vector I; // 电流曲线(144个点位) + vector P; // 功率曲线(144个点位) + + } storage; + + /////////////////////////////////////////////////////////////////////////////////////////////// + /// === 充电相关数据 === + struct { + int ts; // 数据更新时间戳(通讯) + int num = 1; // 充电设备的数量 + int status = 0; // 充电设备状态: 0:离线,1:空闲,2:充电,9:故障 + + struct { + int isCharge = 0; + int voltage = 0; + int current = 0; + int power = 0; + int powerLimit = 0; + } connector1; + + struct { + int isCharge = 0; + int voltage = 0; + int current = 0; + int power = 0; + int powerLimit = 0; + } connector2; + + vector U; // 电压曲线(144个点位) + vector I; // 电流曲线(144个点位) + vector P; // 功率曲线(144个点位) + } charge; + + /////////////////////////////////////////////////////////////////////////////////////////////// + /// === 光伏相关数据 === + struct { + int ts; // 数据更新时间戳(通讯) + int status = 0; // 充电设备状态: 0:离线,1:空闲,2:发电,9:故障 + int voltage = 0; + int current = 0; + int power = 0; + vector U; // 电压曲线(144个点位) + vector I; // 电流曲线(144个点位) + vector P; // 功率曲线(144个点位) + } pv; + + /////////////////////////////////////////////////////////////////////////////////////////////// + /// === 电网相关数据 === + struct { + int status = 0; // 充电设备状态: 0:离线,1:空闲,2:发电,9:故障 + + int voltage = 0; + int current = 0; + int power = 0; + float powerFactor = 0; + //vector U; // 电压曲线(144个点位) + //vector I; // 电流曲线(144个点位) + vector P; // 功率曲线(144个点位) + } grid; /////////////////////////////////////////////////////////////////////////////////////////////// /// === 系统统计 === // 累计发电量,单位:kWh @@ -202,10 +283,10 @@ public: double humidity {}; int aircStatus {0}; int coolingStatus {0}; - double voltage {0}; - double current {0}; - double power {0}; - double powerFactor {0}; + //double voltage {0}; + //double current {0}; + //double power {0}; + //double powerFactor {0}; /////////////////////////////////////////////////////////////////////////////////////////////// /// === 设备信息 === @@ -272,12 +353,8 @@ public: } runtimeData; - int cdzStatus {-1}; // 充电桩 1:在线,0:离线 - int emuStatus {-1}; // 储能 1:在线,0:离线 - std::map mapAlertCache; - /////////////////////////////////////////////////////////////////////////////////////////////// /// 说明:从电表中读取对应数据:每间隔600秒(10分钟)缓存一个点位,存储到数据库,用于绘制一天的电曲线 // 储能充电量缓存,key:位置索引(0->144),val:电量 diff --git a/src/common/Fields.h b/src/common/Fields.h index c7c8222..af72ced 100644 --- a/src/common/Fields.h +++ b/src/common/Fields.h @@ -26,7 +26,7 @@ public: { stringstream ss; ss.precision(precision); - ss << val; + ss << std::fixed << val; mapFields[key] = ss.str(); } diff --git a/src/database/Dao.cpp b/src/database/Dao.cpp index 06ba061..c2acd20 100644 --- a/src/database/Dao.cpp +++ b/src/database/Dao.cpp @@ -443,6 +443,11 @@ Errcode DAO::queryDeviceList(PageInfo& pageInfo, vector& result) std::string sqlFrom = "FROM device d LEFT JOIN station s ON d.station_id =s.station_id"; return QueryPagination("d.*, s.name station_name", sqlFrom, pageInfo, result); } +Errcode DAO::queryDeviceListByStation(PageInfo& pageInfo, string stationId, vector& result) +{ + std::string sqlFrom = "FROM device d LEFT JOIN station s ON d.station_id =s.station_id WHERE d.station_id='" + stationId + "'"; + return QueryPagination("d.*, s.name station_name", sqlFrom, pageInfo, result); +} // 查询设备类型定义 Errcode DAO::queryDeviceTypeDef(std::shared_ptr dao, vector& result) diff --git a/src/database/Dao.h b/src/database/Dao.h index bd8abd5..749e304 100644 --- a/src/database/Dao.h +++ b/src/database/Dao.h @@ -74,6 +74,8 @@ public: // 查询设备信息列表(分页) static Errcode queryDeviceList(PageInfo& pageInfo, vector& result); + // 查询设备信息列表(分页) + static Errcode queryDeviceListByStation(PageInfo& pageInfo, string stationId, vector& result); // 查询设备信息列表 static Errcode queryDeviceList(std::shared_ptr dao, vector& result, bool sort=false); // 查询设备类型定义 @@ -112,16 +114,10 @@ public: /////////////////////////////////////////////////////////////////////////////////////////////// // === 统计数据管理 === static Errcode queryStatDataList(std::shared_ptr dao, std::string startDate, std::string endDate, vector& result); - static Errcode queryStatStationGroup(std::shared_ptr dao, string stationId, string category, string startDate, string endDate, vector& result); - static Errcode queryStatStationList(PageInfo& pageInfo, Fields& params, vector& result); - static Errcode queryWorkModeDef(std::shared_ptr dao, vector& result); - static Errcode queryPolicyTypeDef(std::shared_ptr dao, vector& result); - - static Errcode insertStatDay(std::shared_ptr dao, Fields& fields); diff --git a/src/main.cpp b/src/main.cpp index 392034e..a984f9c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -177,7 +177,6 @@ int main(int argc, char** argv) //OpensslSM2_test(); //SM2_test(); - // 初始化日志 Spdlogger::init(spdlog::level::info, ""); spdlog::info("[main] start ... ======================================================================"); @@ -192,7 +191,7 @@ int main(int argc, char** argv) QApplication qapp(argc, argv); QString fontFile = QCoreApplication::applicationDirPath() + "/assets/fonts/优设标题黑.ttf"; QFontDatabase::addApplicationFont(fontFile); - QFont font("微软雅黑", 10, 600); + QFont font("Cascadia Code, Microsoft YaHei", 10, 600); QApplication::setFont(font); MainApp mainApp; return qapp.exec(); diff --git a/src/protocol/HttpEntity.cpp b/src/protocol/HttpEntity.cpp index cf503bf..046e575 100644 --- a/src/protocol/HttpEntity.cpp +++ b/src/protocol/HttpEntity.cpp @@ -159,7 +159,10 @@ static std::map g_mapHttpHandlerGet = {"/queryStationData", HandlerOptions(&HttpEntity::queryStationData, { DMStation::STATION_ID})}, {"/queryStationOverview", HandlerOptions(&HttpEntity::queryStationOverview, {DMStation::STATION_ID})}, - + {"/queryStationTodayU", HandlerOptions(&HttpEntity::queryStationTodayU, {DMStation::STATION_ID, "category"})}, + {"/queryStationTodayI", HandlerOptions(&HttpEntity::queryStationTodayI, {DMStation::STATION_ID, "category"})}, + {"/queryStationTodayP", HandlerOptions(&HttpEntity::queryStationTodayP, {DMStation::STATION_ID, "category"})}, + {"/queryDeviceList", HandlerOptions(&HttpEntity::queryDeviceList, {})}, {"/deleteDevice", HandlerOptions(&HttpEntity::deleteDevice, { DMDevice::DEVICE_ID})}, {"/queryDevicTypeDef", HandlerOptions(&HttpEntity::queryDevicTypeDef, {})}, @@ -823,28 +826,120 @@ Errcode HttpEntity::queryStationData(const httplib::Request& req, njson& json, s njson jsondata; 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; + /// 储能:电压、电流、功率、功率因数 + { + njson json = njson::object(); + json["U"] = Utils::toStr(station->storage.voltage); + json["I"] = Utils::toStr(station->storage.current); + json["P"] = Utils::toStr(station->storage.power); + //json["PF"] = Utils::toStr(station->storage.powerFactor, 1); + jsondata["storage"] = json; + } + /// 充电:电压、电流、功率、功率因数 + { + njson json = njson::object(); + json["U"] = Utils::toStr(station->charge.connector1.voltage); + json["I"] = Utils::toStr(station->charge.connector1.current); + json["P"] = Utils::toStr(station->charge.connector1.power); + jsondata["charge"] = json; + } + /// 光伏 + { + njson json = njson::object(); + json["P"] = Utils::toStr(station->pv.power); + jsondata["pv"] = json; + } + /// 电网 + { + njson json = njson::object(); + json["U"] = Utils::toStr(station->grid.voltage); + json["I"] = Utils::toStr(station->grid.current); + json["P"] = Utils::toStr(station->grid.power); + //json["PF"] = Utils::toStr(station->grid.powerFactor, 1); + jsondata["grid"] = json; + } + + /// 环境:温度、湿度 + { + njson json = njson::object(); + json["envTemp"] = Utils::toStr(station->temperature, 0); + json["envhum"] = Utils::toStr(station->humidity, 0); + json["aircStatus"] = station->aircStatus; + json["coolingStatus"] = station->coolingStatus; + jsondata["env"] = json; + } } json["data"] = jsondata; return Errcode::OK; } +static njson VectorToJsonArray(vector& vec, int n) +{ + njson jsonArray = njson::array(); + for (int i = 0; i <= n && i < vec.size(); ++i) + { + jsonArray.push_back(int(vec[i])); + } + return jsonArray; +} + +// 获取场站今日电压曲线数据,category: 1:储能,2:充电,3:光伏 +Errcode HttpEntity::queryStationTodayU(const httplib::Request& req, njson& json, std::string& errmsg) +{ + std::string stationId = req.get_param_value("station_id"); + std::string catogray = req.get_param_value("category"); + njson jsondata; + + auto station = Application::data().getStation(Utils::toInt(stationId)); + if (station) + { + int n = Utils::timeDaySeconds() / 600; + if (catogray == "1") + { + auto device = station->getDeviceByType(int(EDeviceType::E_METER), "2"); + if (device) { + jsondata["U"] = VectorToJsonArray(device->cacheU, n); + jsondata["I"] = VectorToJsonArray(device->cacheI, n); + jsondata["P"] = VectorToJsonArray(device->cacheP, n); + } + } + else if (catogray == "2") + { + auto device = station->getDeviceByType(int(EDeviceType::CHARGER), "1"); + if (device) { + jsondata["U"] = VectorToJsonArray(device->cacheU, n); + jsondata["I"] = VectorToJsonArray(device->cacheI, n); + jsondata["P"] = VectorToJsonArray(device->cacheP, n); + } + } + else if (catogray == "3") + { + } + } + json["data"] = jsondata; + return Errcode::OK; +} + +// 获取场站今日电流曲线数据,category: 1:储能,2:充电,3:光伏 +Errcode HttpEntity::queryStationTodayI(const httplib::Request& req, njson& json, std::string& errmsg) +{ + return Errcode::OK; +} + +// 获取场站今日功率曲线数据,category: 1:储能,2:充电,3:光伏 +Errcode HttpEntity::queryStationTodayP(const httplib::Request& req, njson& json, std::string& errmsg) +{ + return Errcode::OK; +} + Errcode HttpEntity::queryDeviceList(const httplib::Request& req, njson& json, std::string& errmsg) { PageInfo pageinfo; pageinfo.index = Utils::toInt(req.get_param_value("page")); pageinfo.size = Utils::toInt(req.get_param_value("page_size")); - + string stationId = req.get_param_value("station_id"); std::vector result; - auto err = DAO::queryDeviceList(pageinfo, result); + auto err = DAO::queryDeviceListByStation(pageinfo, stationId, result); HttpHelper::setPagination(pageinfo, result, json); return err; }; @@ -983,14 +1078,20 @@ Errcode HttpEntity::queryDevicCharts(const httplib::Request& req, njson& json, s int deviceId = params.get("device_id"); auto device = Application::data().getDevice(stationId, deviceId); - std::vector vecV, vecI, vecP; + int npos = Utils::timeDaySeconds() / 600; + std::vector vecU(npos, 0); + std::vector vecI(npos, 0); + std::vector vecP(npos, 0); if (device) { - device->getCacheVoltage(vecV); - device->getCacheCurrent(vecI); - device->getCachePower(vecP); + for (size_t i = 0; i < npos; ++i) + { + if (i < device->cacheU.size()) vecU[i] = int(device->cacheU[i]); + if (i < device->cacheI.size()) vecI[i] = int(device->cacheI[i]); + if (i < device->cacheP.size()) vecP[i] = int(device->cacheP[i]); + } } - json["data"] = {{"V", vecV}, {"I", vecI}, {"P", vecP}}; + json["data"] = {{"V", vecU}, {"I", vecI}, {"P", vecP}}; return Errcode::OK; } @@ -1141,45 +1242,220 @@ Errcode HttpEntity::queryPredictionDetail(const httplib::Request& req, njson& js return Errcode::OK; } +static void VerifyRequstParamsStatDate(Fields& params) +{ + if (!params.contains("end_date")) + { + if (!params.contains("start_date")) + { + params.set("end_date", Utils::dateStr()); + params.set("start_date", Utils::dateStr(Utils::date() - 86400 * 7)); + } + else + { + params.set("end_date", Utils::dateStr(Utils::time(params.value("start_date") + " 00:00:00") + 86400 * 7)); + } + } +} +static std::string VerifyStatSqlCondition(Fields& params) +{ + std::string stationId = params.value("station_id"); + std::string category = params.value("category"); + std::string dtStart = params.value("start_date"); + std::string dtEnd = params.value("end_date"); + + std::string sqlCondition; + if (!dtStart.empty() && dtEnd.empty()) + { + sqlCondition += "dt BETWEEN '" + dtStart + "' AND '" + dtEnd + "'"; + } + if (!stationId.empty()) + { + if (!sqlCondition.empty()) sqlCondition += " AND "; + sqlCondition += "ss.station_id='" + stationId + "'"; + } + if (!category.empty() && category != "0") + { + //if (!sqlCondition.empty()) sqlCondition += " AND "; + //sqlCondition += "ss.category='" + category + "'";; + } + if (!sqlCondition.empty()) { sqlCondition = " WHERE " + sqlCondition; } + return sqlCondition; +} +static std::string GetRequestStatParams(const httplib::Request& req, Fields& params) +{ + + GetRequestParams(req, { "station_id", "category", "start_date", "end_date" }, params); + VerifyRequstParamsStatDate(params); + return VerifyStatSqlCondition(params); +} + +static string GetStationStatusStr(int status) +{ + if (status == 1) return "空闲"; + else if (status == 2) return "充电"; + else if (status == 2) return "放电"; + else if (status == 9) return "故障"; + else return "离线"; +} + +Errcode HttpEntity::queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg) +{ + Fields params; + std::string sqlCondition = GetRequestStatParams(req, params); + + njson jsondata; + std::string launchDate; + float incomeTotal{}; + int storageDeviceNum = 0; + int chargeDeviceNum = 0; + int solarDeviceNum = 0; + int capacityTotal{}; + + bool isQueryStation = params.contains("station_id"); + if (isQueryStation) + { + std::string stationId = params.value("station_id"); + auto station = Application::data().getStation(Utils::toInt(stationId)); + if (station) + { + launchDate = station->launchDate; + storageDeviceNum = 1; //: 储能设备数量 + chargeDeviceNum = station->getDeviceCount(2); //: 光伏设备数量 + solarDeviceNum = station->getDeviceCount(3); //: 光伏设备数量 + capacityTotal = station->capacity; // : 储能总容量(kWh),精度0.001 + jsondata["storage_status"] = GetStationStatusStr(station->storage.status); + jsondata["charge_status"] = GetStationStatusStr(station->charge.status); + jsondata["pv_status"] = "离线"; + } + } + else + { + auto& appdata = Application::data(); + launchDate = appdata.launchDate; //: 系统上线启用日期,格式:yyyy-mm-dd + for (auto& item : appdata.mapStation) + { + auto& station = item.second; + storageDeviceNum += 1; + chargeDeviceNum += station->getDeviceCount(2); + solarDeviceNum += station->getDeviceCount(3); + capacityTotal += station->capacity; + } + } + + jsondata["launch_date"] = launchDate; // 场站上线启用日期,格式:yyyy-mm-dd + jsondata["storage_device_num"] = storageDeviceNum; //: 储能设备数量 + jsondata["charge_device_num"] = chargeDeviceNum; //: 储能设备数量 + jsondata["income_total"] = incomeTotal; // : 累计收益(元),精度0.01 + jsondata["solar_device_num"] = solarDeviceNum; //: 光伏设备数量 + jsondata["capacity_total"] = capacityTotal; // : 储能总容量(kWh),精度0.001 + + + + // 从 stat_total 表中查询日期最新的一条数据 + std::vector result; + std::string sql = std::format("SELECT st.* FROM stat_total st INNER JOIN " + "(SELECT station_id, MAX(dt) max_dt FROM stat_total ss {} GROUP BY station_id) tmp " + "ON st.station_id = tmp.station_id AND st.dt = tmp.max_dt; ", sqlCondition); + DaoEntity::execOnce(sql, result); + + int eIn = 0; + int eOut = 0; + int tIn = 0; + int tOut = 0; + int nErr = 0; + int eGen = 0; + int eGrid = 0; + int eCharge = 0; + int income = 0; + int incomeCharge = 0; + for (int i=0; i("E_in"); + eOut = fields.get("E_out"); + tIn = fields.get("t_in"); + tOut = fields.get("t_out"); + eGen = fields.get("E_gen"); + eGrid = fields.get("E_grid"); + eCharge = fields.get("E_charge"); + income = fields.get("income"); + } + } + else + { + eIn += fields.get("E_in"); + eOut += fields.get("E_out"); + tIn += fields.get("t_in"); + tOut += fields.get("t_out"); + eGen += fields.get("E_gen"); + eGrid = fields.get("E_grid"); + eCharge += fields.get("E_charge"); + income += fields.get("income"); + } + } + + jsondata["storage_elect_in"] = eIn; //储能充电电量(kWh),精度:0.001 + jsondata["storage_elect_out"] = eOut; //储能放电电量(kWh),精度:0.001 + jsondata["storage_num_in"] = tIn; //储能设备充电次数 + jsondata["storage_num_out"] = tOut; //储能设备放电次数 + //jsondata["storage_num_err"] = fields.value("n_err"); //储能设备故障次数 + jsondata["solar_elect_gen"] = eGen; //光伏发电电量(kWh),精度:0.001 + jsondata["solar_elect_grid"] = eGrid; //光伏入网电量(kWh),精度:0.001 + //jsondata["solar_num_err"] = fields.value("n_err_solor"); //光伏设备故障次数 + jsondata["charge_elect"] = eCharge; //充电设备充电电量(kWh),精度:0.001 + //jsondata["charge_num"] = fields.value("n_charge"); //充电设备充电次数 + //jsondata["charge_num_err"] = fields.value("n_err_charge"); //充电设备故障次数 + jsondata["income_elect"] = income; //发电收益(元),精度:0.01 + //jsondata["income_charge"] = fields.value("income_charge"); //充电收益(元),精度:0.01 + //jsondata["usage_rate"] = 0; //Utils::toStr(float(fields.get("storage_usage") + fields.get("storage_usage")) * 0.5f, 0); + json["data"] = jsondata; + + return Errcode::OK; +} + + Errcode HttpEntity::queryStatSystem(const httplib::Request& req, njson& json, std::string& errmsg) { auto& appdata = Application::data(); - float incomeTotal {}; - float station_num = appdata.getStationCount(); - float solarDeviceNum {}; - float capacityTotal {}; - float electGenTotal {}; - float electGridTotal {}; - float electStorageIn {}; - float electStorageOut {}; + float income = 0.0; + int nStation = 0; + int nSolar {}; + int capacity {}; + int eGen {}; + int eGrid {}; + int eIn {}; + int eOut {}; for (auto& item : appdata.mapStation) { auto& station = item.second; - solarDeviceNum += station->getDeviceCount(3); - capacityTotal += station->capacity; - electGenTotal += station->electGenTotal; - electGridTotal += station->electGridTotal; - electStorageIn += station->electStorageIn; - electStorageOut += station->electStorageOut; + nStation += 1; + nSolar += station->getDeviceCount(3); + capacity += station->capacity; + eGen += station->electGenTotal; + eGrid += station->electGridTotal; + eIn += station->statData.totalElectIn; + eOut += station->statData.totalElectOut; } - float income = 0.0; - njson jsondata; jsondata["launch_date"] = appdata.launchDate; //: 系统上线启用日期,格式:yyyy-mm-dd - jsondata["income_total"] = incomeTotal; // : 累计收益(元),精度0.01 - jsondata["station_num"] = station_num; // : 能源站数量 - jsondata["storage_device_num"] = station_num; //: 储能设备数量 - jsondata["solar_device_num"] = solarDeviceNum; //: 光伏设备数量 - jsondata["capacity_total"] = capacityTotal; // : 储能总容量(kWh),精度0.001 - jsondata["solar_elect_gen"] = electGenTotal; // : 发电总电量(kWh),精度0.001 - jsondata["solar_elect_grid"] = electGridTotal; // : 入网种电量(kWh),精度0.001 - jsondata["storage_elect_in"] = electStorageIn; // : 储能充电总电量(kWh),精度0.001 - jsondata["storage_elect_out"] = electStorageOut; // : 储能放电总电量(kWh),精度0.001 + jsondata["income_total"] = income; // : 累计收益(元),精度0.01 + jsondata["storage_device_num"] = nStation; //: 储能设备数量 + jsondata["solar_device_num"] = nSolar; //: 光伏设备数量 + jsondata["capacity_total"] = capacity; // : 储能总容量(kWh),精度0.001 + jsondata["solar_elect_gen"] = eGen; // : 发电总电量(kWh),精度0.001 + jsondata["solar_elect_grid"] = eGrid; // : 入网总电量(kWh),精度0.001 + jsondata["storage_elect_in"] = eIn; // : 储能充电总电量(kWh),精度0.001 + jsondata["storage_elect_out"] = eOut; // : 储能放电总电量(kWh),精度0.001 // 总览页面:累计收益 - std::string sql = "SELECT * FROM stat_total st INNER JOIN " + std::string sql = "SELECT st.* FROM stat_total st INNER JOIN " "(SELECT station_id, MAX(dt) max_dt FROM stat_total GROUP BY station_id) tmp " "ON st.station_id = tmp.station_id AND st.dt = tmp.max_dt; "; std::vector result; @@ -1216,119 +1492,7 @@ Errcode HttpEntity::queryStatStationGroup(const httplib::Request& req, njson& js return Errcode(err); } -static void VerifyRequstParamsStatDate(Fields& params) -{ - if (!params.contains("end_date")) - { - if (!params.contains("start_date")) - { - params.set("end_date", Utils::dateStr()); - params.set("start_date", Utils::dateStr(Utils::date() - 86400*7)); - } - else - { - params.set("end_date", Utils::dateStr(Utils::time(params.value("start_date") +" 00:00:00") + 86400*7)); - } - } -} -static std::string VerifyStatSqlCondition(Fields& params) -{ - std::string stationId = params.value("station_id"); - std::string category = params.value("category"); - std::string dtStart = params.value("start_date"); - std::string dtEnd = params.value("end_date"); - - std::string sqlCondition; - if (!dtStart.empty() && dtEnd.empty()) - { - sqlCondition += "dt BETWEEN '" + dtStart + "' AND '" + dtEnd + "'"; - } - if (!stationId.empty()) - { - if (!sqlCondition.empty()) sqlCondition += " AND "; - sqlCondition += "ss.station_id='" + stationId + "'"; - } - if (!category.empty() && category != "0") - { - //if (!sqlCondition.empty()) sqlCondition += " AND "; - //sqlCondition += "ss.category='" + category + "'";; - } - if (!sqlCondition.empty()) { sqlCondition = " WHERE " + sqlCondition; } - return sqlCondition; -} - -static std::string GetRequestStatParams(const httplib::Request& req, Fields& params) -{ - - GetRequestParams(req, {"station_id", "category", "start_date", "end_date"}, params); - VerifyRequstParamsStatDate(params); - return VerifyStatSqlCondition(params); -} - -Errcode HttpEntity::queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg) -{ - 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, - // SUM(storage_num_out) storage_num_out, - // SUM(storage_num_err) storage_num_err, - // SUM(solar_elect_gen) solar_elect_gen, - // SUM(solar_elect_grid) solar_elect_grid, - // SUM(solar_num_err) solar_num_err, - // AVG(storage_usage) storage_usage, - // SUM(charge_elect) charge_elect, - // SUM(charge_num) charge_num, - // SUM(charge_num_err) charge_num_err, - // AVG(charge_usage) charge_usage, - // SUM(income_elect) income_elect, - // SUM(income_charge) income_charge - // 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; - } - - auto& appdata = Application::data(); - std::vector result; - std::string sql = std::format("SELECT * FROM stat_total st INNER JOIN " - "(SELECT station_id, MAX(dt) max_dt FROM stat_total ss {} GROUP BY station_id) tmp " - "ON st.station_id = tmp.station_id AND st.dt = tmp.max_dt; ", sqlCondition); - DaoEntity::execOnce(sql, result); - if (result.size() > 0) - { - auto& fields = result[0]; - - //jsondata["launch_date"] = appdata.launchDate; //: 系统上线启用日期,格式:yyyy-mm-dd - // jsondata["station_id"] = station_id; - jsondata["storage_elect_in"] = fields.value("E_in"); //储能充电电量(kWh),精度:0.001 - jsondata["storage_elect_out"] = fields.value("E_out"); //储能放电电量(kWh),精度:0.001 - jsondata["storage_num_in"] = fields.value("t_in"); //储能设备充电次数 - jsondata["storage_num_out"] = fields.value("t_out"); //储能设备放电次数 - jsondata["storage_num_err"] = fields.value("n_err"); //储能设备故障次数 - jsondata["solar_elect_gen"] = fields.value("E_gen"); //光伏发电电量(kWh),精度:0.001 - jsondata["solar_elect_grid"] = fields.value("E_grid"); //光伏入网电量(kWh),精度:0.001 - jsondata["solar_num_err"] = fields.value("n_err_solor"); //光伏设备故障次数 - jsondata["charge_elect"] = fields.value("E_charge"); //充电设备充电电量(kWh),精度:0.001 - jsondata["charge_num"] = fields.value("n_charge"); //充电设备充电次数 - jsondata["charge_num_err"] = fields.value("n_err_charge"); //充电设备故障次数 - jsondata["income_elect"] = fields.value("income"); //发电收益(元),精度:0.01 - jsondata["income_charge"] = fields.value("income_charge"); //充电收益(元),精度:0.01 - jsondata["usage_rate"] = 0; //Utils::toStr(float(fields.get("storage_usage") + fields.get("storage_usage")) * 0.5f, 0); - json["data"] = jsondata; - } - - return Errcode::OK; -} Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, std::string& errmsg) { Fields params; @@ -1362,6 +1526,7 @@ Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, s njson jsondata = njson::array(); for (int64_t t = t0; t<=t1; t += 86400) { + i++; njson jsonrow; std::string dt = Utils::dateStr(t); Fields* fields = NULL; @@ -1369,21 +1534,21 @@ Errcode HttpEntity::queryStatDayList(const httplib::Request& req, njson& json, s if (iter != mapTemp.end()) { fields = iter->second; } jsonrow["dt"] = dt.substr(5); - jsonrow["storage_elect_in"] = fields ? fields->value("storage_elect_in") : "0"; + 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"; + 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; diff --git a/src/protocol/HttpEntity.h b/src/protocol/HttpEntity.h index c09fb1f..9cd9796 100644 --- a/src/protocol/HttpEntity.h +++ b/src/protocol/HttpEntity.h @@ -55,9 +55,24 @@ public: Errcode deleteStation(const httplib::Request& req, njson& json, std::string& errmsg); Errcode queryStationOverview(const httplib::Request& req, njson& json, std::string& errmsg); + + /// 查询场站信息 + // @param: station_id + // @return: object Errcode queryStationInfo(const httplib::Request& req, njson& json, std::string& errmsg); + + /// 查询场站信息 + // @param: station_id + // @return: object Errcode queryStationData(const httplib::Request& req, njson& json, std::string& errmsg); + // 获取场站今日电压曲线数据,category: 1:储能,2:充电,3:光伏 + Errcode queryStationTodayU(const httplib::Request& req, njson& json, std::string& errmsg); + // 获取场站今日电流曲线数据,category: 1:储能,2:充电,3:光伏 + Errcode queryStationTodayI(const httplib::Request& req, njson& json, std::string& errmsg); + // 获取场站今日功率曲线数据,category: 1:储能,2:充电,3:光伏 + Errcode queryStationTodayP(const httplib::Request& req, njson& json, std::string& errmsg); + Errcode queryDeviceList(const httplib::Request& req, njson& json, std::string& errmsg); Errcode insertDevice(const httplib::Request& req, njson& json, std::string& errmsg); Errcode updateDevice(const httplib::Request& req, njson& json, std::string& errmsg); @@ -83,12 +98,14 @@ public: Errcode queryPredictionDetail(const httplib::Request& req, njson& json, std::string& errmsg); - // 系统总览所有场站统计 (总览页 运行状况) - Errcode queryStatSystem(const httplib::Request& req, njson& json, std::string& errmsg); - Errcode queryStatStationGroup(const httplib::Request& req, njson& json, std::string& errmsg); - - // 一个场站的累计统计 + /// 总览: 查询累计统计信息 + // @param: station_id 可选,无该参数时查询所有场站累计数据 Errcode queryStatTotal(const httplib::Request& req, njson& json, std::string& errmsg); + + // 总览: 所有场站统计 (总览页 运行状况) + Errcode queryStatSystem(const httplib::Request& req, njson& json, std::string& errmsg); + + Errcode queryStatStationGroup(const httplib::Request& req, njson& json, std::string& errmsg); // 场站按类别按天统计 Errcode queryStatDayList(const httplib::Request& req, njson& json, std::string& errmsg); diff --git a/src/protocol/MqttEntity.cpp b/src/protocol/MqttEntity.cpp index 51e3160..410cef9 100644 --- a/src/protocol/MqttEntity.cpp +++ b/src/protocol/MqttEntity.cpp @@ -408,7 +408,8 @@ void MqttClient::ParseArrivedMessage(njson& json, string command, std::shared_pt } device->setParam(addr, val); - if (command == "MEM_YC") { station->readRuntimeData(deviceNo, addr, val); } + if (command == "MEM_YC") { station->readEnergyData(deviceNo, addr, val); } + else if (command == "Charger_YC") { station->readChargeData(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); } diff --git a/src/qt/MainApp.cpp b/src/qt/MainApp.cpp index 34bb9c0..526bced 100644 --- a/src/qt/MainApp.cpp +++ b/src/qt/MainApp.cpp @@ -18,7 +18,7 @@ MainApp::MainApp() this->setAutoFillBackground(true); this->setPalette(palette); this->setStyleSheet("color: white;"); - this->setFixedSize(1440, 900); + this->setFixedSize(1600, 900); this->show(); this->setAttribute(Qt::WA_StyledBackground, true); // 启用样式表背景绘制 @@ -43,6 +43,7 @@ QPushButton* MainApp::addMenuItem(int index, string itemName) { auto itemBtn = new QPushButton(itemName.c_str()); itemBtn->setStyleSheet(QSS_BTN_MENU.c_str()); + //itemBtn->setFont(QFont("微软雅黑", 16, 600)); mapMenuBtn[itemName] = itemBtn; QObject::connect(itemBtn, &QPushButton::clicked, this, [=]() { this->setActiveMenu(itemName); }); diff --git a/src/qt/MyQUI.cpp b/src/qt/MyQUI.cpp index 6271563..eee4371 100644 --- a/src/qt/MyQUI.cpp +++ b/src/qt/MyQUI.cpp @@ -40,8 +40,9 @@ static const std::string QSS_TABLE = "QTableWidget {" " background-color: transparent;" // 背景色 " gridline-color: #C0C0C0;" // 网格线颜色 -" border: 1px solid gray;" // 边框 -" color: white;" // 文字颜色 +" border: 1px solid gray;" // 边框 +" color: white;" // 文字颜色 +" outline: 2px solid #409EFF;" // 选中焦点轮廓 "}" // 表头样式 "QHeaderView { background-color: rgba(150,150,150,50);}" @@ -60,7 +61,6 @@ static const std::string QSS_TABLE = "QTableWidget::item:selected {" " background-color: rgba(184, 214, 255, 50);" // 选中背景色 " color: rgb(220,220,220);" // 选中文字颜色 -" outline: none; " "}"; static const std::string QSS_BTN_COMBOX = @@ -128,7 +128,7 @@ std::shared_ptr MyQUI::TableWidget(QWidget* parent, int x, int y, table->setSelectionMode(QAbstractItemView::SingleSelection); // 设置为单选模式 table->setSelectionBehavior(QAbstractItemView::SelectRows); // 设置为整行选中 table->horizontalHeader()->setFixedHeight(50); - table->horizontalHeader()->setDefaultSectionSize(60); + table->horizontalHeader()->setDefaultSectionSize(50); // 设置默认行宽 return table; } diff --git a/src/qt/widgets/QWHome.cpp b/src/qt/widgets/QWHome.cpp index 7cf10d9..5e7542d 100644 --- a/src/qt/widgets/QWHome.cpp +++ b/src/qt/widgets/QWHome.cpp @@ -14,8 +14,6 @@ QWHome::QWHome(QWidget* parent) : MyWidget(parent) this->setObjectName("home"); this->setStyleSheet("#home { background-color:rgba(100,100,100,50); }"); - - int x = 10, y = 0; { //this->groupSys = MyQUI::GroupBox(this, x, y, 1190, 120, "系统"); @@ -47,29 +45,29 @@ QWHome::QWHome(QWidget* parent) : MyWidget(parent) this->addPair("db-n", pw, 20, 20, "数据库名: ", Config::option.database.dbname); this->addPair("db-h", pw, 20, 50, "主机地址: ", Config::option.database.host); this->addPair("db-u", pw, 20, 80, "用 户 名: ", Config::option.database.user); - - QStringList headerTextList; - headerTextList << "ID" << "站名" << "编号" << "状态" << "MQTT状态" << "召测(秒)" - << "日充电\n电量" << "日放电\n电量" << "总充电\n电量" << "总放电\n电量" - << "日充电\n费用" << "日放电\n费用" << "总充电\n费用" << "总放电\n费用" - << "日收益" << "总收益" << "--"; - - table = MyQUI::TableWidget(this, 10, y += 210, 1190, 265); - // 设置为水平表头 - table->setColumnCount(headerTextList.size()); - table->setHorizontalHeaderLabels(headerTextList); - table->setColumnWidth(0, 50); - table->setColumnWidth(1, 120); - table->setColumnWidth(2, 50); - table->setColumnWidth(4, 80); } + QStringList headerTextList; + headerTextList << "ID" << "站名" << "编号" << "状态" << "MQTT状态" << "召测(秒)" + << "日充电\n电量" << "日放电\n电量" << "总充电\n电量" << "总放电\n电量" + << "日充电\n费用" << "日放电\n费用" << "总充电\n费用" << "总放电\n费用" + << "日收益" << "总收益" << "--"; + table = MyQUI::TableWidget(this, 10, y += 210, 1350, 265); + // 设置为水平表头 + table->setColumnCount(headerTextList.size()); + table->setHorizontalHeaderLabels(headerTextList); + table->setColumnWidth(0, 40); + table->setColumnWidth(1, 120); + table->setColumnWidth(2, 40); + table->setColumnWidth(4, 80); + table->setColumnWidth(5, 70); + logFilter = MyQUI::PairLine(this, 10, y += 280, "日志过滤: ", "", false); btnLogClean = MyQUI::Button(this, 400, y-1, 80, 28, "清除"); QObject::connect(btnLogClean.get(), &QPushButton::clicked, this, &QWHome::slotBtnClearLog); texteditLog = std::make_shared(this); - texteditLog->setGeometry(10, y += 35, 1190, 280); + texteditLog->setGeometry(10, y += 35, 1350, 340); texteditLog->setStyleSheet("background-color: transparent; border: 1px solid gray; font-weight: 400;"); texteditLog->setReadOnly(true); texteditLog->document()->setMaximumBlockCount(1000); diff --git a/src/qt/widgets/QWMonitor.cpp b/src/qt/widgets/QWMonitor.cpp index 4908c8f..3c5e486 100644 --- a/src/qt/widgets/QWMonitor.cpp +++ b/src/qt/widgets/QWMonitor.cpp @@ -39,7 +39,7 @@ QWMonitor::QWMonitor(QWidget* parent) : MyWidget(parent) } QStringList headerTextList; - headerTextList << "ID" << "类型ID" << "类型名称" << "设备名称" << "编号" << "状态" << "通讯\n状态" << "工作\n状态" << "故障\n状态"; + headerTextList << "ID" << "类型ID" << "类型名称" << "设备名称" << "编号" << "状态" << "通讯\n状态" << "工作\n状态" << "故障\n状态" << "--"; table = MyQUI::TableWidget(this, 10, y += 50, 700, 800); // 设置为水平表头 @@ -73,7 +73,7 @@ QWMonitor::QWMonitor(QWidget* parent) : MyWidget(parent) uiReg.scroll->setWidgetResizable(true); std::string QSS_LISTVIEW = - "QListView { background-color: transparent; color: white; }" + "QListView { background-color: transparent; color: white; outline: 1px solid #409EFF;}" "QListView::item { background-color: transparent; border-bottom: 0px solid gray; padding: 0px; height: 20px; }"; uiReg.listReg = new QListWidget(groupStation.get()); diff --git a/src/qt/widgets/QWStatistics.cpp b/src/qt/widgets/QWStatistics.cpp index d74bfa7..1dbde54 100644 --- a/src/qt/widgets/QWStatistics.cpp +++ b/src/qt/widgets/QWStatistics.cpp @@ -24,17 +24,17 @@ QWStatistics::QWStatistics(QWidget* parent) : MyWidget(parent) headerTextList << "日期" << "日充电\n电量" << "日放电\n电量" << "日充电\n电量(尖)" << "日充电\n电量(峰)" << "日充电\n电量(平)" << "日充电\n电量(谷)" << "日放电\n电量(尖)" << "日放电\n电量(峰)" << "日放电\n电量(平)" << "日放电\n电量(谷)" - << "日充电\n费用" << "日放电\n费用" << "日收益" ; + << "日充电\n费用" << "日放电\n费用" << "日收益" << "--"; //<< "总充电\n电量" << "总放电\n电量" //<< "总充电\n电量(尖)" << "总充电\n电量(峰)" << "总充电\n电量(平)" << "总充电\n电量(谷)" //<< "总放电\n电量(尖)" << "总放电\n电量(峰)" << "总放电\n电量(平)" << "总放电\n电量(谷)"; - table = MyQUI::TableWidget(this, 10, 50, 1190, 800); + table = MyQUI::TableWidget(this, 10, 50, 1350, 800); table->horizontalHeader()->setDefaultSectionSize(80); // 设置为水平表头 table->setColumnCount(headerTextList.size()); table->setHorizontalHeaderLabels(headerTextList); - table->setColumnWidth(0, 120); + table->setColumnWidth(0, 100); btnRefresh = make_shared("刷新", this); btnRefresh->setGeometry(220, 10, 60, 30); diff --git a/src/qt/widgets/QWSysmgr.cpp b/src/qt/widgets/QWSysmgr.cpp index bb51b1e..c4b39dc 100644 --- a/src/qt/widgets/QWSysmgr.cpp +++ b/src/qt/widgets/QWSysmgr.cpp @@ -283,7 +283,7 @@ QWSysmgr::QWSysmgr(QWidget* parent) : MyWidget(parent) QStringList headerTextList; //headerTextList << "ID" << "类型ID" << "类型名称" << "设备名称" << "编号" << "状态" << "通讯\n状态" << "工作\n状态" << "故障\n状态"; - table = MyQUI::TableWidget(this, 10, y += 100, 1190, 740); + table = MyQUI::TableWidget(this, 10, y += 100, 1350, 740); // 设置为水平表头 table->setColumnCount(headerTextList.size()); table->setHorizontalHeaderLabels(headerTextList); diff --git a/web/public/config/columnList.js b/web/public/config/columnList.js index b0930ba..6da1869 100644 --- a/web/public/config/columnList.js +++ b/web/public/config/columnList.js @@ -218,18 +218,18 @@ export const columnList = [ dataIndex: 'operation_date', key: 'operation_date' }, - { - title: '场站运行模式', - dataIndex: 'work_mode', - key: 'work_mode', - scopedSlots: { customRender: 'work_mode' } - }, - { - title: '场站运行策略', - dataIndex: 'policy_id', - key: 'policy_id', - scopedSlots: { customRender: 'policy_id' } - }, + // { + // title: '场站运行模式', + // dataIndex: 'work_mode', + // key: 'work_mode', + // scopedSlots: { customRender: 'work_mode' } + // }, + // { + // title: '场站运行策略', + // dataIndex: 'policy_id', + // key: 'policy_id', + // scopedSlots: { customRender: 'policy_id' } + // }, { title: '操作', dataIndex: 'operate', diff --git a/web/src/App.vue b/web/src/App.vue index c385198..cd2c2f4 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -18,6 +18,24 @@ const locale = ref(zhCN) \ No newline at end of file diff --git a/web/src/components/Home/Modal.vue b/web/src/components/Home/Modal.vue index 5d74a4b..06c697c 100644 --- a/web/src/components/Home/Modal.vue +++ b/web/src/components/Home/Modal.vue @@ -1,27 +1,25 @@