|
@@ -870,12 +870,48 @@ static void handle_pcs_set(struct mg_connection* c,struct mg_str body)
|
870
|
870
|
}
|
871
|
871
|
}
|
872
|
872
|
|
|
873
|
+static void handle_bms_set(struct mg_connection* c,struct mg_str body)
|
|
874
|
+{
|
|
875
|
+ long cmd;
|
|
876
|
+ long param;
|
|
877
|
+ bool ok = true;
|
|
878
|
+ struct chan485_t* ch = &APPL.chan485[2];
|
|
879
|
+ struct Settings_t* set = &APPL.Set.s;
|
|
880
|
+ cmd = mg_json_get_long(body,"$.cmd",-1);
|
|
881
|
+ param = mg_json_get_long(body,"$.param",-1);
|
|
882
|
+ if(cmd == -1 || param == -1)
|
|
883
|
+ {
|
|
884
|
+ ok = false;
|
|
885
|
+ }
|
|
886
|
+ else
|
|
887
|
+ {
|
|
888
|
+ switch(cmd)
|
|
889
|
+ {
|
|
890
|
+ case BMS_CMD_RESET:
|
|
891
|
+ ch->Cmd = CMD_485_BMS_RESET;
|
|
892
|
+ break;
|
|
893
|
+
|
|
894
|
+ default:
|
|
895
|
+ syslog(LOG_INFO,"%s, unknown cmd : %ld",__func__,cmd);
|
|
896
|
+ break;
|
|
897
|
+ }
|
|
898
|
+ }
|
|
899
|
+ if(ok)
|
|
900
|
+ {
|
|
901
|
+ mg_http_reply(c,200,s_json_header,"true\n");
|
|
902
|
+ }
|
|
903
|
+ else
|
|
904
|
+ {
|
|
905
|
+ mg_http_reply(c,200,s_json_header,"false\n");
|
|
906
|
+ }
|
|
907
|
+}
|
|
908
|
+
|
873
|
909
|
static void handle_ac_set(struct mg_connection* c,struct mg_str body)
|
874
|
910
|
{
|
875
|
911
|
long cmd;
|
876
|
912
|
long param;
|
877
|
913
|
bool ok = true;
|
878
|
|
- struct chan485_t* ch = &APPL.chan485[4];
|
|
914
|
+ struct chan485_t* ch = &APPL.chan485[3];
|
879
|
915
|
struct Envicool5kW_t* ac = &APPL.Envicool5kW;
|
880
|
916
|
struct Settings_t* set = &APPL.Set.s;
|
881
|
917
|
cmd = mg_json_get_long(body,"$.cmd",-1);
|
|
@@ -911,6 +947,7 @@ static void handle_ac_set(struct mg_connection* c,struct mg_str body)
|
911
|
947
|
// 英维克5kW立式 请求设定模式
|
912
|
948
|
// 0:停机模式;1;制冷:2:加热;3:自循环;
|
913
|
949
|
case AC_CMD_MODESET:
|
|
950
|
+ ch->Cmd = CMD_485_AC_SET_MODESET;
|
914
|
951
|
set->SetMode = param;
|
915
|
952
|
break;
|
916
|
953
|
|
|
@@ -920,9 +957,9 @@ static void handle_ac_set(struct mg_connection* c,struct mg_str body)
|
920
|
957
|
// ch->CmdParam = param;
|
921
|
958
|
// break;
|
922
|
959
|
// 英维克5kW立式 设定温度
|
923
|
|
- case AC_CMD_SET_TEMP:
|
924
|
|
- set->SetTemp = param;
|
925
|
|
- break;
|
|
960
|
+ // case AC_CMD_SET_TEMP:
|
|
961
|
+ // set->SetTemp = param;
|
|
962
|
+ // break;
|
926
|
963
|
|
927
|
964
|
// // 同飞5kW LCI-50C-01SZ-1227 水温目标控制温度
|
928
|
965
|
// // 0 出水水温控制 1 回水水温控制
|
|
@@ -1122,7 +1159,7 @@ static void handle_ctl_get(struct mg_connection* c)
|
1122
|
1159
|
%m:%m,%m:%f,%m:%f,%m:%f,%m:%f,\
|
1123
|
1160
|
%m:%f,%m:%f,%m:%f,\
|
1124
|
1161
|
%m:%f,%m:%f,%m:%f,%m:%f,%m:%f,%m:%f,\
|
1125
|
|
-%m:%m,%m:%d,%m:%d,%m:%f,%m:%f,\
|
|
1162
|
+%m:%m,%m:%f,%m:%f,%m:%f,%m:%f,\
|
1126
|
1163
|
%m:%m,%m:%m,%m:%m,\
|
1127
|
1164
|
%m:%m,%m:%m,\
|
1128
|
1165
|
%m:%m,%m:%m}\n",
|
|
@@ -1222,34 +1259,67 @@ static void handle_pcs_get(struct mg_connection* c)
|
1222
|
1259
|
/*8*/MG_ESC("交流电容故障字"),MG_ESC(p->szAcCapFault),MG_ESC("系统故障字"),MG_ESC(p->szSysFault),MG_ESC("开关故障字"),MG_ESC(p->szOnOffFault),MG_ESC("其他故障字"),MG_ESC(p->szOtherFault));
|
1223
|
1260
|
}
|
1224
|
1261
|
|
1225
|
|
-static void handle_bms_get(struct mg_connection* c)
|
|
1262
|
+// static void handle_bms_get(struct mg_connection* c)
|
|
1263
|
+// {
|
|
1264
|
+// struct NanRuiBms_t* bms = &APPL.NanRuiBms;
|
|
1265
|
+// mg_http_reply(c,200,s_json_header,
|
|
1266
|
+// "{"
|
|
1267
|
+// "%m:%m,%m:%f,%m:%f,%m:%f,%m:%f,%m:%m," // 1
|
|
1268
|
+// "%m:%f,%m:%f," // 2
|
|
1269
|
+// "%m:%f,%m:%f,%m:%f," // 3
|
|
1270
|
+// "%m:%f,%m:%f,%m:%f," // 4
|
|
1271
|
+// "%m:%f,%m:%f," // 5
|
|
1272
|
+// "%m:%m," // 6
|
|
1273
|
+// "%m:%d,%m:%d,%m:%d,%m:%d," // 7
|
|
1274
|
+// "%m:%f,%m:%f," // 8
|
|
1275
|
+// "%m:%m,%m:%lld," // 9
|
|
1276
|
+// "%m:%d,%m:%d,%m:%d,%m:%d," // 10
|
|
1277
|
+// "%m:%m,%m:%m,%m:%m" // 11
|
|
1278
|
+// "}\n",
|
|
1279
|
+// /*1*/MG_ESC("通信状态"),MG_ESC(bms->szCommState),MG_ESC("总电压"),bms->BatV,MG_ESC("总电流"),bms->BatI,MG_ESC("SOC"),bms->Soc,MG_ESC("SOH"),bms->Soh,MG_ESC("电池状态"),MG_ESC(bms->szBatState),
|
|
1280
|
+// /*2*/MG_ESC("绝缘电阻R+"),bms->PosRes,MG_ESC("绝缘电阻R-"),bms->NegRes,
|
|
1281
|
+// /*3*/MG_ESC("最高电芯电压"),bms->MaxCellV,MG_ESC("平均电芯电压"),bms->AvgCellV,MG_ESC("最低电芯电压"),bms->MinCellV,
|
|
1282
|
+// /*4*/MG_ESC("最高电芯温度"),bms->MaxCellT,MG_ESC("平均电芯温度"),bms->AvgCellT,MG_ESC("最低电芯温度"),bms->MinCellT,
|
|
1283
|
+// /*5*/MG_ESC("压差"),bms->CellVDiff,MG_ESC("温差"),bms->CellTDiff,
|
|
1284
|
+// /*6*/MG_ESC("高压状态"),MG_ESC(bms->szHvState),
|
|
1285
|
+// /*7*/MG_ESC("最高温度位置"),bms->MaxCellTIdx,MG_ESC("最低温度位置"),bms->MinCellTIdx,MG_ESC("最高电压位置"),bms->MaxCellVIdx,MG_ESC("最低电压位置"),bms->MinCellVIdx,
|
|
1286
|
+// /*8*/MG_ESC("最大可充电流"),bms->MaxChgCurr,MG_ESC("最大可放电流"),bms->MaxDhgCurr,
|
|
1287
|
+// /*9*/MG_ESC("数据更新时间"),MG_ESC(bms->szLastUpdate),MG_ESC("通信失败次数"),bms->CommFailTotalCnt,
|
|
1288
|
+// /*10*/MG_ESC("工作状态"),bms->WorkState,MG_ESC("电池自检"),bms->BatSelfSupervise,MG_ESC("系统状态"),bms->SysState,MG_ESC("上电条件"),bms->HvOnCondition,
|
|
1289
|
+// /*11*/MG_ESC("动作元件状态"),MG_ESC(bms->szActionCompStatus),MG_ESC("装置自检状态"),MG_ESC(bms->szSelfCheckStatus),MG_ESC("遥信变位状态"),MG_ESC(bms->szRemoteSignal)
|
|
1290
|
+// );
|
|
1291
|
+// }
|
|
1292
|
+
|
|
1293
|
+ static void handle_bms_get(struct mg_connection* c)
|
1226
|
1294
|
{
|
1227
|
1295
|
struct NanRuiBms_t* bms = &APPL.NanRuiBms;
|
1228
|
1296
|
mg_http_reply(c,200,s_json_header,
|
1229
|
1297
|
"{"
|
1230
|
|
- "%m:%m,%m:%f,%m:%f,%m:%f,%m:%f,%m:%m," // 1
|
1231
|
|
- "%m:%f,%m:%f," // 2
|
|
1298
|
+ "%m:%m,%m:%f,%m:%f,%m:%f,%m:%f," // 1
|
|
1299
|
+ "%m:%f,%m:%f,%m:%f,%m:%f,%m:%f," // 2
|
1232
|
1300
|
"%m:%f,%m:%f,%m:%f," // 3
|
1233
|
1301
|
"%m:%f,%m:%f,%m:%f," // 4
|
1234
|
1302
|
"%m:%f,%m:%f," // 5
|
1235
|
|
- "%m:%m," // 6
|
|
1303
|
+ "%m:%d,%m:%f," // 6
|
1236
|
1304
|
"%m:%d,%m:%d,%m:%d,%m:%d," // 7
|
1237
|
1305
|
"%m:%f,%m:%f," // 8
|
1238
|
|
- "%m:%m,%m:%lld," // 9
|
1239
|
|
- "%m:%d,%m:%d,%m:%d,%m:%d," // 10
|
1240
|
|
- "%m:%m,%m:%m,%m:%m" // 11
|
|
1306
|
+ "%m:%f,%m:%d," //9
|
|
1307
|
+ "%m:%m,%m:%lld," // 10
|
|
1308
|
+ "%m:%m,%m:%m,%m:%m,%m:%d," // 11
|
|
1309
|
+ "%m:%m,%m:%m,%m:%m" // 12
|
1241
|
1310
|
"}\n",
|
1242
|
|
- /*1*/MG_ESC("通信状态"),MG_ESC(bms->szCommState),MG_ESC("总电压"),bms->BatV,MG_ESC("总电流"),bms->BatI,MG_ESC("SOC"),bms->Soc,MG_ESC("SOH"),bms->Soh,MG_ESC("电池状态"),MG_ESC(bms->szBatState),
|
1243
|
|
- /*2*/MG_ESC("绝缘电阻R+"),bms->PosRes,MG_ESC("绝缘电阻R-"),bms->NegRes,
|
|
1311
|
+ /*1*/MG_ESC("通信状态"),MG_ESC(bms->szCommState),MG_ESC("总电压"),bms->BatV,MG_ESC("总电流"),bms->BatI,MG_ESC("SOC"),bms->Soc,MG_ESC("SOH"),bms->Soh,
|
|
1312
|
+ /*2*/MG_ESC("绝缘电阻R+"),bms->PosRes,MG_ESC("绝缘电阻R-"),bms->NegRes,MG_ESC("簇功率"),bms->BatPower,MG_ESC("可充电量"),bms->ChgableAmount,MG_ESC("可放电量"),bms->DhgableAmount,
|
1244
|
1313
|
/*3*/MG_ESC("最高电芯电压"),bms->MaxCellV,MG_ESC("平均电芯电压"),bms->AvgCellV,MG_ESC("最低电芯电压"),bms->MinCellV,
|
1245
|
1314
|
/*4*/MG_ESC("最高电芯温度"),bms->MaxCellT,MG_ESC("平均电芯温度"),bms->AvgCellT,MG_ESC("最低电芯温度"),bms->MinCellT,
|
1246
|
1315
|
/*5*/MG_ESC("压差"),bms->CellVDiff,MG_ESC("温差"),bms->CellTDiff,
|
1247
|
|
- /*6*/MG_ESC("高压状态"),MG_ESC(bms->szHvState),
|
|
1316
|
+ /*6*/MG_ESC("电池容量"),bms->BatCapacity,MG_ESC("母线总电压"),bms->BusV,
|
1248
|
1317
|
/*7*/MG_ESC("最高温度位置"),bms->MaxCellTIdx,MG_ESC("最低温度位置"),bms->MinCellTIdx,MG_ESC("最高电压位置"),bms->MaxCellVIdx,MG_ESC("最低电压位置"),bms->MinCellVIdx,
|
1249
|
1318
|
/*8*/MG_ESC("最大可充电流"),bms->MaxChgCurr,MG_ESC("最大可放电流"),bms->MaxDhgCurr,
|
1250
|
|
- /*9*/MG_ESC("数据更新时间"),MG_ESC(bms->szLastUpdate),MG_ESC("通信失败次数"),bms->CommFailTotalCnt,
|
1251
|
|
- /*10*/MG_ESC("工作状态"),bms->WorkState,MG_ESC("电池自检"),bms->BatSelfSupervise,MG_ESC("系统状态"),bms->SysState,MG_ESC("上电条件"),bms->HvOnCondition,
|
1252
|
|
- /*11*/MG_ESC("动作元件状态"),MG_ESC(bms->szActionCompStatus),MG_ESC("装置自检状态"),MG_ESC(bms->szSelfCheckStatus),MG_ESC("遥信变位状态"),MG_ESC(bms->szRemoteSignal)
|
|
1319
|
+ /*9*/MG_ESC("模组最高电压"),bms->MaxCellVMod,MG_ESC("模组最高电压编号"),bms->MaxCellVModIdx,
|
|
1320
|
+ /*10*/MG_ESC("数据更新时间"),MG_ESC(bms->szLastUpdate),MG_ESC("通信失败次数"),bms->CommFailTotalCnt,
|
|
1321
|
+ /*11*/MG_ESC("工作状态"),MG_ESC(bms->szWorkState),MG_ESC("电池自检"),MG_ESC(bms->szBatSelfSupervise),MG_ESC("系统状态"),MG_ESC(bms->szSysState),MG_ESC("上电条件"),bms->HvOnCondition,
|
|
1322
|
+ /*12*/MG_ESC("动作元件状态"),MG_ESC(bms->szActionCompStatus),MG_ESC("装置自检状态"),MG_ESC(bms->szSelfCheckStatus),MG_ESC("遥信变位状态"),MG_ESC(bms->szRemoteSignal)
|
1253
|
1323
|
);
|
1254
|
1324
|
}
|
1255
|
1325
|
|
|
@@ -1259,17 +1329,16 @@ static void handle_ac_get(struct mg_connection* c)
|
1259
|
1329
|
struct Settings_t* set = &APPL.Set.s;
|
1260
|
1330
|
mg_http_reply(c, 200, s_json_header, "{\
|
1261
|
1331
|
%m:%m,%m:%m,%m:%m,%m:%m,\
|
1262
|
|
-%m:%d,%m:%d,%m:%d,\
|
1263
|
|
-%m:%.2lf,%m:%.2lf,\
|
|
1332
|
+%m:%f,%m:%f,%m:%f,\
|
|
1333
|
+%m:%f,%m:%f,\
|
1264
|
1334
|
%m:%m,%m:%d,%m:%d,%m:%d,%m:%d,\
|
1265
|
|
-%m:%m,%m:%m,%m:%d,%m:%d,%m:%m,%m:%m,\
|
|
1335
|
+%m:%m,%m:%m,%m:%d,%m:%d,%m:%m,%m:%m,%m:%m,\
|
1266
|
1336
|
%m:%m,%m:%m,%m:%m}\n",
|
1267
|
1337
|
/*1*/MG_ESC("通信状态"), MG_ESC(ac->szCommState),MG_ESC("数据更新时间"), MG_ESC(ac->szLastUpdate1), MG_ESC("工作模式"),MG_ESC(ac->szWorkMode), MG_ESC("控制模式"),MG_ESC(ac->szCtlMode),
|
1268
|
1338
|
/*2*/MG_ESC("出水温度"),ac->OutWaterTemp, MG_ESC("回水温度"),ac->InWaterTemp, MG_ESC("环境温度"),ac->EnvTemp,
|
1269
|
1339
|
/*3*/MG_ESC("回水压力"),ac->InWaterPre, MG_ESC("出水压力"),ac->OutWaterPre,
|
1270
|
1340
|
/*4*/MG_ESC("供回水控制目标"),MG_ESC(ac->szWaterTempTargetCtlTemp),MG_ESC("制冷温度设定"),ac->watercool,MG_ESC("制冷回差"),ac->watercoolgap,MG_ESC("加热温度设定"),ac->waterhot,MG_ESC("加热回差"),ac->waterhotgap,
|
1271
|
|
-/*5*/MG_ESC("水泵档位"),MG_ESC(ac->szPumpShift),MG_ESC("压缩机档位"),MG_ESC(ac->szPumpShift),MG_ESC("水泵转速"),ac->PumpRpm,MG_ESC("心跳"),ac->Heartbeat,MG_ESC("压缩机状态"),MG_ESC(ac->szCmpState),MG_ESC("运行时间"),MG_ESC(ac->szRunTime),
|
1272
|
|
-// /*5*/MG_ESC("水泵转速"),ac->PumpRpm,MG_ESC("心跳"),ac->Heartbeat,MG_ESC("压缩机状态"),MG_ESC(ac->szCmpState),MG_ESC("运行时间"),MG_ESC(ac->szRunTime),
|
|
1341
|
+/*5*/MG_ESC("水泵档位"),MG_ESC(ac->szPumpShift),MG_ESC("压缩机档位"),MG_ESC(ac->szCmpShift),MG_ESC("水泵转速"),ac->PumpRpm,MG_ESC("心跳"),ac->Heartbeat,MG_ESC("水泵状态"),MG_ESC(ac->szPumpState),MG_ESC("压缩机状态"),MG_ESC(ac->szCmpState),MG_ESC("运行时间"),MG_ESC(ac->szRunTime),
|
1273
|
1342
|
/*6*/MG_ESC("液压水温故障"),MG_ESC(ac->szErrMsg1),MG_ESC("变频器故障"),MG_ESC(ac->szErrMsg2),MG_ESC("当前告警最高等级"),MG_ESC(ac->szErrMsg3));
|
1274
|
1343
|
}
|
1275
|
1344
|
|
|
@@ -1329,9 +1398,9 @@ static void handle_env_get(struct mg_connection* c)
|
1329
|
1398
|
struct Dehumi_t* dh = &APPL.Dehumi;
|
1330
|
1399
|
struct Co_t* co = &APPL.Co;
|
1331
|
1400
|
mg_http_reply(c,200,s_json_header,"{\
|
1332
|
|
-%m:{%m:%m,%m:%lf,%m:%lf,%m:%lf,%m:%lf,%m:%lf,%m:%m},\
|
|
1401
|
+%m:{%m:%m,%m:%f,%m:%f,%m:%f,%m:%f,%m:%f,%m:%m},\
|
1333
|
1402
|
%m:{%m:%m,%m:%m,%m:%m,%m:%m,%m:%m,%m:%m,%m:%m,%m:%m,%m:%m},\
|
1334
|
|
-%m:{%m:%m,%m:%m,%m:%lf,%m:%lf,%m:%lf,%m:%lf,%m:%lf,%m:%lf,%m:%m,%m:%m,%m:%m,%m:%m,%m:%m,%m:%m},\
|
|
1403
|
+%m:{%m:%m,%m:%m,%m:%f,%m:%f,%m:%f,%m:%f,%m:%f,%m:%f,%m:%m,%m:%m,%m:%m,%m:%m,%m:%m,%m:%m},\
|
1335
|
1404
|
%m:{%m:%m,%m:%m,%m:%d,%m:%m}}\n",
|
1336
|
1405
|
/*1*/MG_ESC("辅助电表"),MG_ESC("通信状态"),MG_ESC(adl->szCommState),MG_ESC("正向有功总电能"),adl->PosAe,MG_ESC("反向有功总电能"),adl->NegAe,MG_ESC("有功功率"),adl->Ap,MG_ESC("无功功率"),adl->Rap,MG_ESC("功率因数"),adl->Pf,MG_ESC("数据更新时间"),MG_ESC(adl->szLastUpdate),
|
1337
|
1406
|
/*2*/MG_ESC("DIDO"),MG_ESC("状态"),MG_ESC(dido->szState),MG_ESC("数据更新时间"),MG_ESC(dido->szLastUpdate),MG_ESC("1#水浸"),MG_ESC(dido->szWaterDec1),MG_ESC("2#水浸"),MG_ESC(dido->szWaterDec2),MG_ESC("前门"),MG_ESC(dido->szFrontDoor),MG_ESC("后门"),MG_ESC(dido->szBackDoor),MG_ESC("急停"),MG_ESC(dido->szEmgStop),MG_ESC("状态灯"),MG_ESC(dido->szLedMode),MG_ESC("消防喷发反馈"),MG_ESC(dido->szFeEruptFb),
|
|
@@ -1512,6 +1581,10 @@ static void fn(struct mg_connection* c,int ev,void* ev_data)
|
1512
|
1581
|
{
|
1513
|
1582
|
handle_bms_get(c);
|
1514
|
1583
|
}
|
|
1584
|
+ else if(mg_http_match_uri(hm,"/api/bms/set"))
|
|
1585
|
+ {
|
|
1586
|
+ handle_bms_set(c,hm->body);
|
|
1587
|
+ }
|
1515
|
1588
|
else if(mg_http_match_uri(hm,"/api/ac/get"))
|
1516
|
1589
|
{
|
1517
|
1590
|
handle_ac_get(c);
|