完善了部分逻辑,优化网页
This commit is contained in:
@@ -144,10 +144,10 @@ document.getElementById('moos-send-btn').addEventListener('click', sendMoosNotif
|
|||||||
setInterval(updateData, 1000);
|
setInterval(updateData, 1000);
|
||||||
updateData(); // 初始加载
|
updateData(); // 初始加载
|
||||||
|
|
||||||
// 每3秒检查一次数据库连接状态
|
// 每10秒检查一次数据库连接状态
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
checkDbConnection();
|
checkDbConnection();
|
||||||
checkMoosDbConnection();
|
checkMoosDbConnection();
|
||||||
}, 3000);
|
}, 10000);
|
||||||
checkDbConnection(); // 初始检查
|
checkDbConnection(); // 初始检查
|
||||||
checkMoosDbConnection(); // 初始检查
|
checkMoosDbConnection(); // 初始检查
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
"HVABbusBVol_uint16": 0,
|
"HVABbusBVol_uint16": 0,
|
||||||
"HVABmastSteGeaCur_uint16": 0,
|
"HVABmastSteGeaCur_uint16": 0,
|
||||||
"HVABopenWaterCur_uint16": 0,
|
"HVABopenWaterCur_uint16": 0,
|
||||||
"HVABxczCur_uint16": 0,
|
"HVABxczCur_uint16": 1,
|
||||||
"HVBBCCUCur_uint16": 0,
|
"HVBBCCUCur_uint16": 0,
|
||||||
"HVBBFCSSecurSysCur_uint16": 0,
|
"HVBBFCSSecurSysCur_uint16": 0,
|
||||||
"HVBBbatInsCur_uint16": 0,
|
"HVBBbatInsCur_uint16": 0,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"HVolABusBreaker_unit16": 0,
|
"HVolABusBreaker_unit16": 0,
|
||||||
"HVolBBusBreaker_unit16": 0,
|
"HVolBBusBreaker_unit16": 79,
|
||||||
"HVolBusBreaker_uint16": 0,
|
"HVolBusBreaker_uint16": 58,
|
||||||
"LVolBusBreaker_uint16": 0,
|
"LVolBusBreaker_uint16": 159,
|
||||||
"faultCode_array":
|
"faultCode_array":
|
||||||
[
|
[
|
||||||
0
|
0
|
||||||
|
|||||||
@@ -1,30 +1,30 @@
|
|||||||
{
|
{
|
||||||
"backpressure1_fp32": 0.0,
|
"backpressure1_fp32": 3.0,
|
||||||
"backpressure2_fp32": 0.0,
|
"backpressure2_fp32": 8.0,
|
||||||
"ch4oConcent1_fp32": 0.0,
|
"ch4oConcent1_fp32": 13.0,
|
||||||
"ch4oConcent2_fp32": 0.0,
|
"ch4oConcent2_fp32": 57.0,
|
||||||
"ch4o_fp32": 0.0,
|
"ch4o_fp32": 0.0,
|
||||||
"excTemp_fp32": 0.0,
|
"excTemp_fp32": 64.0,
|
||||||
"faultCode1_uint16": 0,
|
"faultCode1_uint16": 0,
|
||||||
"faultCode2_uint16": 0,
|
"faultCode2_uint16": 0,
|
||||||
"faultCode3_uint16": 0,
|
"faultCode3_uint16": 0,
|
||||||
"fcuCurIns_fp32": 0.0,
|
"fcuCurIns_fp32": 0.0,
|
||||||
"fcuCurPower_fp32": 0.0,
|
"fcuCurPower_fp32": 0.0,
|
||||||
"fcuCur_fp32": 0.0,
|
"fcuCur_fp32": 74.0,
|
||||||
"fcuFaultLeve_uint8": 0,
|
"fcuFaultLeve_uint8": 0,
|
||||||
"fcuOutIns_fp32": 0.0,
|
"fcuOutIns_fp32": 81.0,
|
||||||
"fcuOutPower_fp32": 0.0,
|
"fcuOutPower_fp32": 848.0,
|
||||||
"fcuState_uint8": 0,
|
"fcuState_uint8": 0,
|
||||||
"fcuVolIns_fp32": 0.0,
|
"fcuVolIns_fp32": 0.0,
|
||||||
"fcuVolPower_fp32": 0.0,
|
"fcuVolPower_fp32": 0.0,
|
||||||
"fcuVol_fp32": 0.0,
|
"fcuVol_fp32": 384.0,
|
||||||
"flameDet_uint8": 0,
|
"flameDet_uint8": 1,
|
||||||
"h2Concent1_fp32": 0.0,
|
"h2Concent1_fp32": 55.0,
|
||||||
"h2Concent2_fp32": 0.0,
|
"h2Concent2_fp32": 34.0,
|
||||||
"o2Concent1_fp32": 0.0,
|
"o2Concent1_fp32": 67.0,
|
||||||
"o2Concent2_fp32": 0.0,
|
"o2Concent2_fp32": 53.0,
|
||||||
"o2Level_fp32": 0.0,
|
"o2Level_fp32": 0.0,
|
||||||
"o2_fp32": 0.0,
|
"o2_fp32": 0.0,
|
||||||
"powLimit_fp32": 0.0,
|
"powLimit_fp32": 23.0,
|
||||||
"powerGen_fp32": 0.0
|
"powerGen_fp32": 539.0
|
||||||
}
|
}
|
||||||
@@ -2,14 +2,14 @@
|
|||||||
"fcuCurToInsLimit1_uint8": 0,
|
"fcuCurToInsLimit1_uint8": 0,
|
||||||
"fcuCurToinsLimit2_uint8": 0,
|
"fcuCurToinsLimit2_uint8": 0,
|
||||||
"insBatCurElect_uint16": 0,
|
"insBatCurElect_uint16": 0,
|
||||||
"insBatLimit_uint16": 0,
|
"insBatLimit_uint16": 86,
|
||||||
"insBatSoc_uint8": 0,
|
"insBatSoc_uint8": 95,
|
||||||
"insBatTotalElect_uint16": 0,
|
"insBatTotalElect_uint16": 741,
|
||||||
"insChargeState_uint8": 0,
|
"insChargeState_uint8": 0,
|
||||||
"insCurSocHold1_uint8": 0,
|
"insCurSocHold1_uint8": 0,
|
||||||
"insCurSocHold2_uint8": 0,
|
"insCurSocHold2_uint8": 0,
|
||||||
"insCurSocHold3_uint8": 0,
|
"insCurSocHold3_uint8": 0,
|
||||||
"insCurrent_uint16": 0,
|
"insCurrent_uint16": 9,
|
||||||
"insLinkVol_uint16": 0,
|
"insLinkVol_uint16": 0,
|
||||||
"insNegRelayState_uint8": 0,
|
"insNegRelayState_uint8": 0,
|
||||||
"insNegRes_uint16": 0,
|
"insNegRes_uint16": 0,
|
||||||
@@ -18,21 +18,21 @@
|
|||||||
"insPosRes_uint16": 0,
|
"insPosRes_uint16": 0,
|
||||||
"insfaultCode_uint8": 0,
|
"insfaultCode_uint8": 0,
|
||||||
"powBatCurElect_uint16": 0,
|
"powBatCurElect_uint16": 0,
|
||||||
"powBatSoc_uint8": 0,
|
"powBatSoc_uint8": 47,
|
||||||
"powBatTotalElect_uint16": 0,
|
"powBatTotalElect_uint16": 860,
|
||||||
"powChargeState_uint8": 0,
|
"powChargeState_uint8": 0,
|
||||||
"powCurSocHold1_uint8": 0,
|
"powCurSocHold1_uint8": 0,
|
||||||
"powCurSocHold2_uint8": 0,
|
"powCurSocHold2_uint8": 0,
|
||||||
"powCurSocHold3_uint8": 0,
|
"powCurSocHold3_uint8": 0,
|
||||||
"powCurToInsLimit1_uint8": 0,
|
"powCurToInsLimit1_uint8": 0,
|
||||||
"powCurToinsLimit2_uint8": 0,
|
"powCurToinsLimit2_uint8": 0,
|
||||||
"powCur_uint16": 0,
|
"powCur_uint16": 34,
|
||||||
"powLinkVol_uint16": 0,
|
"powLinkVol_uint16": 0,
|
||||||
"powNegRelayState_uint8": 0,
|
"powNegRelayState_uint8": 0,
|
||||||
"powNegRes_uint16": 0,
|
"powNegRes_uint16": 0,
|
||||||
"powPosRelayState_uint8": 0,
|
"powPosRelayState_uint8": 1,
|
||||||
"powPosRes_uint16": 0,
|
"powPosRes_uint16": 0,
|
||||||
"powerBatLimit_uint16": 0,
|
"powerBatLimit_uint16": 65,
|
||||||
"powerPackVol_uint16": 0,
|
"powerPackVol_uint16": 0,
|
||||||
"powfaultCode_uint8": 0
|
"powfaultCode_uint8": 0
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"powerCMD":0,
|
||||||
|
"modCMD":0,
|
||||||
|
"workCMD":0
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ int main() {
|
|||||||
SQLiteDB db("/home/zjk/project/H100/H100PowerManger/data/power_data.db");
|
SQLiteDB db("/home/zjk/project/H100/H100PowerManger/data/power_data.db");
|
||||||
MOOS::MOOSAsyncCommClient moosClient;
|
MOOS::MOOSAsyncCommClient moosClient;
|
||||||
moosClient.Run("localhost", 9000, "appPowerMangerWebUI");
|
moosClient.Run("localhost", 9000, "appPowerMangerWebUI");
|
||||||
|
|
||||||
std::cout << " Current Path -> " << std::system("pwd") << std::endl;
|
std::cout << " Current Path -> " << std::system("pwd") << std::endl;
|
||||||
|
|
||||||
// 定义路由,处理根路径的请求
|
// 定义路由,处理根路径的请求
|
||||||
@@ -100,8 +100,6 @@ int main() {
|
|||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 定义路由,处理 /api/moos-notify 的请求(POST)
|
// 定义路由,处理 /api/moos-notify 的请求(POST)
|
||||||
CROW_ROUTE(app, "/api/moos-notify").methods("POST"_method)
|
CROW_ROUTE(app, "/api/moos-notify").methods("POST"_method)
|
||||||
([&moosClient](const crow::request& req) {
|
([&moosClient](const crow::request& req) {
|
||||||
@@ -137,8 +135,14 @@ int main() {
|
|||||||
return res;
|
return res;
|
||||||
});
|
});
|
||||||
|
|
||||||
// 启动服务器,监听端口 18080
|
// 启动服务器,监听端口 18080 并启动多线程
|
||||||
app.port(18080).multithreaded().run();
|
std::cout << "Server started on port 18080" << std::endl;
|
||||||
|
// app.port(18080).multithreaded().run();
|
||||||
|
|
||||||
|
app.port(18080)
|
||||||
|
.multithreaded()
|
||||||
|
.concurrency(16) // 增加并发线程数
|
||||||
|
.run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -584,6 +584,19 @@ bool PowerManger::writeDataToDB()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PowerManger::checkError()
|
||||||
|
{
|
||||||
|
//1.检查复合管控器状态
|
||||||
|
if(m_pmCurrentState.ccustate.fcuGZ_1H != 0 ||
|
||||||
|
m_pmCurrentState.ccustate.fcuGZ_1L != 0 ||
|
||||||
|
m_pmCurrentState.ccustate.fcuGZ_2H != 0 ||
|
||||||
|
m_pmCurrentState.ccustate.fcuGZ_2L != 0 ||
|
||||||
|
m_pmCurrentState.ccustate.fcuGZ_3H != 0 ||
|
||||||
|
m_pmCurrentState.ccustate.fcuGZ_3L != 0 ||
|
||||||
|
m_pmCurrentState.ccustate.insEmergencyStatusWord != 0)
|
||||||
|
return 0;
|
||||||
|
//2.检查断路器状态
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PowerManger::printState(FSM_State st, string desp){
|
void PowerManger::printState(FSM_State st, string desp){
|
||||||
@@ -619,13 +632,7 @@ int PowerManger::handleInite_s1(FSM_State &fsm, void* pData)
|
|||||||
pm->printState(fsm,desp);
|
pm->printState(fsm,desp);
|
||||||
}
|
}
|
||||||
//2. 检查复合管控器是否上报故障 如果故障则进入故障状态
|
//2. 检查复合管控器是否上报故障 如果故障则进入故障状态
|
||||||
if(pm->m_pmCurrentState.ccustate.fcuGZ_1H != 0 ||
|
if(pm->checkError() < 0)
|
||||||
pm->m_pmCurrentState.ccustate.fcuGZ_1L != 0 ||
|
|
||||||
pm->m_pmCurrentState.ccustate.fcuGZ_2H != 0 ||
|
|
||||||
pm->m_pmCurrentState.ccustate.fcuGZ_2L != 0 ||
|
|
||||||
pm->m_pmCurrentState.ccustate.fcuGZ_3H != 0 ||
|
|
||||||
pm->m_pmCurrentState.ccustate.fcuGZ_3L != 0 ||
|
|
||||||
pm->m_pmCurrentState.ccustate.insEmergencyStatusWord != 0)
|
|
||||||
{
|
{
|
||||||
ok = false;
|
ok = false;
|
||||||
pm->m_faultNum = 2; //能源故障
|
pm->m_faultNum = 2; //能源故障
|
||||||
@@ -633,11 +640,30 @@ int PowerManger::handleInite_s1(FSM_State &fsm, void* pData)
|
|||||||
//3. 初始化系统为待机状态
|
//3. 初始化系统为待机状态
|
||||||
pm->initControlCmd();
|
pm->initControlCmd();
|
||||||
//4.判断关键断路器是否闭合
|
//4.判断关键断路器是否闭合
|
||||||
|
ok = false;
|
||||||
|
while (!ok)
|
||||||
|
{
|
||||||
|
if(pm->m_currentDisBreakerState.bus3Breaker.unit4InstrumentDC48VCircuitBreaker == 1 ||
|
||||||
|
pm->m_currentDisBreakerState.bus4Breaker.unit5CircuitBreaker == 1 ||
|
||||||
|
pm->m_currentDisBreakerState.bus4Breaker.unit2CircuitBreaker == 1 ||
|
||||||
|
pm->m_currentDisBreakerState.bus4Breaker.unit3CircuitBreaker == 1 ||
|
||||||
|
pm->m_currentDisBreakerState.bus4Breaker.unit1CircuitBreaker == 1)
|
||||||
|
{
|
||||||
|
ok = true;
|
||||||
|
}
|
||||||
|
pm->m_pmEvent = "等待关键断路器闭合";
|
||||||
|
MOOSPause(1000);
|
||||||
|
pm->printState(fsm,pm->m_pmEvent);
|
||||||
|
}
|
||||||
|
//5. 进入下一状态
|
||||||
|
if(ok)
|
||||||
|
{
|
||||||
|
pm->m_pmState = pm->m_Standby_s2;
|
||||||
|
}
|
||||||
if(!ok)
|
if(!ok)
|
||||||
{
|
{
|
||||||
pm->m_pmState = pm->m_Fault_s99;
|
pm->m_pmState = pm->m_Fault_s99;
|
||||||
}
|
}
|
||||||
pm->m_pmState = pm->m_Standby_s2;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,6 +675,109 @@ int PowerManger::handleStandby_s2(FSM_State &fsm, void* pData)
|
|||||||
{
|
{
|
||||||
string desp = "待机状态";
|
string desp = "待机状态";
|
||||||
pm->printState(fsm,desp);
|
pm->printState(fsm,desp);
|
||||||
|
//1. 检查当前是否存在故障
|
||||||
|
if(pm->checkError() < 0)
|
||||||
|
{
|
||||||
|
pm->m_pmState = pm->m_Fault_s99;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//2. 检查上位机上电控制指令
|
||||||
|
switch (pm->m_msCmd.powerCMD)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
pm->m_pmEvent = "收到上位机控制指令:关机";
|
||||||
|
pm->shutdown();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
pm->m_pmEvent = "动力电上电";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pm->m_pmEvent = "锂动力电启动";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
pm->m_pmEvent = "燃料电池启动";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
pm->m_pmEvent = "锂动力电关闭";
|
||||||
|
case 5:
|
||||||
|
pm->m_pmEvent = "燃料电池停机";
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
pm->m_pmEvent = "燃料电池预热指令";
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
pm->m_pmEvent = "燃料电池自检指令";
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
pm->m_pmEvent = "燃料电池紧急停机";
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
pm->m_pmEvent = "燃料电池复位指令";
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
pm->m_pmEvent = "燃料电池补给指令";
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
pm->m_pmEvent = "燃料电池停机维护";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//2. 检查上位机模式切换指令
|
||||||
|
switch (pm->m_msCmd.modCMD)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
//无效
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
pm->m_pmEvent = "待机工况";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pm->m_pmEvent = "岸基备航";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
pm->m_pmEvent = "水中备航";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
pm->m_pmEvent = "遥控工况";
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
pm->m_pmEvent = "巡航模式";
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
pm->m_pmEvent = "高速模式";
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
pm->m_pmEvent = "上浮下潜";
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
pm->m_pmEvent = "浮调模式";
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
pm->m_pmEvent = "水下侦查";
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
pm->m_pmEvent = "水面侦查";
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
pm->m_pmEvent = "DJ模式";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//3. 检查上位机工作模式切换控制指令
|
||||||
|
switch (pm->m_msCmd.workCMD)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
pm->m_pmEvent = "正常模式(默认)";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
pm->m_pmEvent = "试验模式";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
pm->m_pmEvent = "调试模式";
|
||||||
|
break;
|
||||||
|
}
|
||||||
MOOSPause(1000);
|
MOOSPause(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -673,6 +802,14 @@ int PowerManger::handleFault_s99(FSM_State &fsm, void* pData)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==============================系统操作函数====================
|
||||||
|
bool PowerManger::shutdown()
|
||||||
|
{
|
||||||
|
m_CcuColCmd.masterState = 0xFF; //关机
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PowerManger::initControlCmd()
|
void PowerManger::initControlCmd()
|
||||||
{
|
{
|
||||||
//================初始化配电指令=============================
|
//================初始化配电指令=============================
|
||||||
@@ -724,9 +861,9 @@ void PowerManger::initControlCmd()
|
|||||||
m_CcuColCmd.masterState = 0xAA;//主站状态,运行中
|
m_CcuColCmd.masterState = 0xAA;//主站状态,运行中
|
||||||
|
|
||||||
//================初始化上位机指令=========================
|
//================初始化上位机指令=========================
|
||||||
m_msCmd.modCMD = 0;
|
m_msCmd.modCMD = 99;
|
||||||
m_msCmd.powerCMD = 0;
|
m_msCmd.powerCMD = 99;
|
||||||
m_msCmd.workCMD = 0;
|
m_msCmd.workCMD = 99;
|
||||||
|
|
||||||
//================初始化设备驱动指令========================
|
//================初始化设备驱动指令========================
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ class PowerManger : public AppCastingMOOSApp
|
|||||||
msg_disLowBusFbMsg m_disLowBusState;
|
msg_disLowBusFbMsg m_disLowBusState;
|
||||||
|
|
||||||
//下位机操作函数
|
//下位机操作函数
|
||||||
//断路器状态
|
|
||||||
ccuColCmd m_CcuColCmd;
|
ccuColCmd m_CcuColCmd;
|
||||||
void disSysOption();
|
void disSysOption();
|
||||||
void ccuOption();
|
void ccuOption();
|
||||||
@@ -172,10 +171,22 @@ class PowerManger : public AppCastingMOOSApp
|
|||||||
FSM_State m_Standby_s2;
|
FSM_State m_Standby_s2;
|
||||||
static int handleStandby_s2(FSM_State &fsm, void* pData);
|
static int handleStandby_s2(FSM_State &fsm, void* pData);
|
||||||
|
|
||||||
|
//岸基备航
|
||||||
|
// FSM_State m_ShoreReady_s3;
|
||||||
|
|
||||||
|
//水中备航
|
||||||
|
|
||||||
|
//自动工况
|
||||||
|
|
||||||
//故障处理
|
//故障处理
|
||||||
FSM_State m_Fault_s99;
|
FSM_State m_Fault_s99;
|
||||||
static int handleFault_s99(FSM_State &fsm, void* pData);
|
static int handleFault_s99(FSM_State &fsm, void* pData);
|
||||||
//======================================================================================
|
//======================================================================================
|
||||||
|
int checkError();
|
||||||
|
bool shutdown();
|
||||||
|
bool powerOn();
|
||||||
|
bool powerOff();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user