Haobin Luo 1 éve
szülő
commit
6b5cb70be2
2 módosított fájl, 382 hozzáadás és 506 törlés
  1. 377 501
      wsserver.cpp
  2. 5 5
      wsserver.h

+ 377 - 501
wsserver.cpp

@@ -1,13 +1,13 @@
-//#pragma execution_character_set("utf-8")
+#pragma execution_character_set("utf-8")
 #include "wsserver.h"
 
 WSServer::WSServer(QObject *parent, quint16 port) : QObject(parent)
 {
-    EsmworkPara.uRrPowerOn=1;
-    EsmworkPara.uRrWorkMode=0;
-    EsmworkPara.dScanAzCentDeg=0;
-    EsmworkPara.dScanAzWidthDeg=5;
-    EsmworkPara.dScanElCentDeg= 0;
+    EsmworkPara.uRrPowerOn = 1;
+    EsmworkPara.uRrWorkMode = 0;
+    EsmworkPara.dScanAzCentDeg = 0;
+    EsmworkPara.dScanAzWidthDeg = 5;
+    EsmworkPara.dScanElCentDeg = 0;
     EsmworkPara.uLineNumPerFrame = 20;
     EsmworkPara.fAntScanVel = 1;
     EsmworkPara.fFreqScanVel = 100;
@@ -15,13 +15,13 @@ WSServer::WSServer(QObject *parent, quint16 port) : QObject(parent)
     EsmworkPara.fTecEndFreqMhz = 10000;
 
     m_pWebSocketServer = new QWebSocketServer(QStringLiteral("ZC Server"),
-                                                    QWebSocketServer::NonSecureMode,
-                                                    this);
+                                              QWebSocketServer::NonSecureMode,
+                                              this);
     if (m_pWebSocketServer->listen(QHostAddress::Any, port))
     {
-      qDebug() << "ZC Server listening on port" << port;
-      connect(m_pWebSocketServer, &QWebSocketServer::newConnection,
-              this, &WSServer::onNewConnection);
+        qDebug() << "ZC Server listening on port" << port;
+        connect(m_pWebSocketServer, &QWebSocketServer::newConnection,
+                this, &WSServer::onNewConnection);
     }
 }
 
@@ -69,11 +69,11 @@ QJsonObject WSServer::processJsonObj(QJsonObject objin)
                 QJsonObject Dataout;
                 for (auto propkey : Propkeys)
                 {
-                    if (propkey.compare("InstanceID")==0)
+                    if (propkey.compare("InstanceID") == 0)
                     {
                         objout.insert("InstanceID", Props.value("InstanceID"));
                     }
-                    else if (propkey.compare("PlatformID")==0)
+                    else if (propkey.compare("PlatformID") == 0)
                     {
                         objout.insert("PlatformID", Props.value("PlatformID"));
                     }
@@ -86,31 +86,31 @@ QJsonObject WSServer::processJsonObj(QJsonObject objin)
                     objout.insert("data", Dataout);
             }
         }
-//            if (v.isArray())
-//            {
-//                for (auto i : v.toArray())
-//                {
-//                    if (i.isString())
-//                    {
-//                        objout->insert(i.toString(),QJsonValue());
-//                    }
-//                }
-//            }
-//            else if (v.isObject())
-//            {
-//                QJsonObject Props = v.toObject();
-//                QStringList Propkeys = Props.keys();
-//                for (auto propkey: Propkeys)
-//                {
-//                    objout->insert(propkey,Props.value(k));
-//                }
-//            }
+        //            if (v.isArray())
+        //            {
+        //                for (auto i : v.toArray())
+        //                {
+        //                    if (i.isString())
+        //                    {
+        //                        objout->insert(i.toString(),QJsonValue());
+        //                    }
+        //                }
+        //            }
+        //            else if (v.isObject())
+        //            {
+        //                QJsonObject Props = v.toObject();
+        //                QStringList Propkeys = Props.keys();
+        //                for (auto propkey: Propkeys)
+        //                {
+        //                    objout->insert(propkey,Props.value(k));
+        //                }
+        //            }
 
         // 不想打印
-//        if (v.isObject())
-//        {
-//            processJsonObj(v.toObject(),objout);
-//        }
+        //        if (v.isObject())
+        //        {
+        //            processJsonObj(v.toObject(),objout);
+        //        }
 
         // 打印调试信息
         if (v.isDouble())
@@ -144,7 +144,7 @@ QJsonObject WSServer::processJsonObj(QJsonObject objin)
     }
 
     return objout;
-    //qDebug() << QString(QJsonDocument(*objout).toJson());
+    // qDebug() << QString(QJsonDocument(*objout).toJson());
 }
 
 void WSServer::processMessage(QString message)
@@ -171,70 +171,67 @@ void WSServer::processMessage(QString message)
             // 判断请求
             if (url == "getInit")
             {
-                getInit(pSender,msgobj);
+                getInit(pSender, msgobj);
             }
             else if (url == "getPlatformTable")
             {
-                getPlatformTable(pSender,msgobj);
+                getPlatformTable(pSender, msgobj);
             }
             else if (url == "getGlobalMap")
             {
-                getGlobalMap(pSender,msgobj);
+                getGlobalMap(pSender, msgobj);
             }
             else
             {
                 // 其他接口都需要带平台ID
-                if (msgobj.contains("PlatformID")==false || msgobj.value("PlatformID") == QJsonValue())
+                if (msgobj.contains("PlatformID") == false || msgobj.value("PlatformID") == QJsonValue())
                 {
                     // 要是没有平台ID,返回空数据
                     QJsonObject *ret = new QJsonObject(
-                    {
-                        {"url",url},
-                        {"data",""}
-                    });
+                        {{"url", url},
+                         {"data", ""}});
                     returnMessage(pSender, ret);
                 }
                 // 态势接口
                 else if (url == "getLocalMap" || url == "getRemoteMap" || url == "getCombineMap")
                 {
-
                 }
                 // ESM接口
                 else if (url == "getESMInstances")
                 {
-                    getESMInstances(pSender,msgobj);
+                    getESMInstances(pSender, msgobj);
                 }
                 else if (url == "setESMParams")
                 {
-                    setESMParams(pSender,msgobj);
+                    setESMParams(pSender, msgobj);
                 }
                 else if (url == "getESMParams")
                 {
-                    getESMParams(pSender,msgobj);
+                    getESMParams(pSender, msgobj);
                 }
                 else if (url == "getESMStatus")
                 {
-                    getESMStatus(pSender,msgobj);
+                    getESMStatus(pSender, msgobj);
                 }
                 else if (url == "getESMData")
                 {
-                    getESMData(pSender,msgobj);
+                    getESMData(pSender, msgobj);
                 }
                 else if (url == "getNavParams")
                 {
-                    getNavParams(pSender,msgobj);
+                    getNavParams(pSender, msgobj);
                 }
                 else if (url == "setFreePost")
                 {
-                    setFreePost(pSender,msgobj);
+                    setFreePost(pSender, msgobj);
                 }
                 else if (url == "getLeadPost")
                 {
-                    getLeadPost(pSender,msgobj);
+                    getLeadPost(pSender, msgobj);
                 }
                 else if (url == "getTaskPlan")
                 {
-                    getTaskPlan(pSender,msgobj);
+                    getTaskPlan(pSender, msgobj);
                 }
             }
         }
@@ -253,8 +250,8 @@ void WSServer::socketDisconnected()
 
 void WSServer::returnMessage(QWebSocket *pSender, QJsonObject *jsonObj)
 {
-//    qDebug() << "return message:";
-//    qDebug() << QString(QJsonDocument(*jsonObj).toJson());
+    //    qDebug() << "return message:";
+    //    qDebug() << QString(QJsonDocument(*jsonObj).toJson());
     pSender->sendTextMessage(QString(QJsonDocument(*jsonObj).toJson()));
     delete jsonObj;
 }
@@ -264,22 +261,18 @@ void WSServer::getInit(QWebSocket *pSender, QJsonObject obj)
 {
     qDebug() << "网页请求初始化状态";
     // 假接口
-    QJsonObject InitState
-    {
-        {"InitState",100}
-    };
+    QJsonObject InitState{
+        {"InitState", 100}};
 
     // 真实接口
-//    QJsonObject InitState
-//    {
-//        {"InitState",100*(int)this->zcman->common_inter->InitState}
-//    };
+    //    QJsonObject InitState
+    //    {
+    //        {"InitState",100*(int)this->zcman->common_inter->InitState}
+    //    };
 
-   QJsonObject *ret = new QJsonObject(
-   {
-      {"url", obj.value("url")},
-      {"data", InitState}
-   });
+    QJsonObject *ret = new QJsonObject(
+        {{"url", obj.value("url")},
+         {"data", InitState}});
 
     returnMessage(pSender, ret);
 }
@@ -290,38 +283,32 @@ void WSServer::getPlatformTable(QWebSocket *pSender, QJsonObject obj)
     qDebug() << "网页请求平台信息";
     QJsonArray Platforms;
     // 假接口
-    QJsonObject SinglePlatform[] {
-        {
-            {"platformID", 8015},
-            {"platformName", "侦察机_1"}
-        },
-        {
-            {"platformID", 8016},
-            {"platformName", "侦察机_2"}
-        },
+    QJsonObject SinglePlatform[]{
+        {{"platformID", 8015},
+         {"platformName", "侦察机_1"}},
+        {{"platformID", 8016},
+         {"platformName", "侦察机_2"}},
     };
-    for (auto i: SinglePlatform)
+    for (auto i : SinglePlatform)
     {
         Platforms.append(i);
     }
 
     // 真实接口
-//    for (auto i : this->grman->grtaskplats)
-//    {
-//        QJsonObject SinglePlatform
-//        {
-//            {"platformID", (int)i->PlatID},
-//            {"platformName", QString::fromLocal8Bit(i->PlatName.c_str())}
-//        };
-//        Platforms.append(SinglePlatform);
-//    }
+    //    for (auto i : this->grman->grtaskplats)
+    //    {
+    //        QJsonObject SinglePlatform
+    //        {
+    //            {"platformID", (int)i->PlatID},
+    //            {"platformName", QString::fromLocal8Bit(i->PlatName.c_str())}
+    //        };
+    //        Platforms.append(SinglePlatform);
+    //    }
 
     // 构造返回对象
     QJsonObject *ret = new QJsonObject(
-    {
-        {"url", obj.value("url")},
-        {"data", Platforms}
-    });
+        {{"url", obj.value("url")},
+         {"data", Platforms}});
     returnMessage(pSender, ret);
 }
 
@@ -330,51 +317,40 @@ void WSServer::getLeadPost(QWebSocket *pSender, QJsonObject obj)
 {
     qDebug() << "网页请求指挥电文";
     // 假接口
-    QJsonObject CurrentLeadPost1
-    {
+    QJsonObject CurrentLeadPost1{
         {"time", "20:20:01"},
         {"GroupID", "0001"},
         {"LeaderID", "8015"},
-        {"Abstract", "开始侦察"}
-    };
-    QJsonObject CurrentLeadPost2
-    {
+        {"Abstract", "开始侦察"}};
+    QJsonObject CurrentLeadPost2{
         {"time", "20:20:30"},
         {"GroupID", "0001"},
         {"LeaderID", "8015"},
-        {"Abstract", "发现辐射源"}
-    };
-    QJsonObject CurrentLeadPost3
-    {
+        {"Abstract", "发现辐射源"}};
+    QJsonObject CurrentLeadPost3{
         {"time", "20:20:40"},
         {"GroupID", "0001"},
         {"LeaderID", "8015"},
-        {"Abstract", "请求干扰"}
-    };
-    QJsonObject CurrentLeadPost4
-    {
+        {"Abstract", "请求干扰"}};
+    QJsonObject CurrentLeadPost4{
         {"time", "20:20:01"},
         {"GroupID", "0003"},
         {"LeaderID", "8014"},
-        {"Abstract", "开始干扰"}
-    };
+        {"Abstract", "开始干扰"}};
 
     QJsonArray LeadPost = {
         CurrentLeadPost1,
         CurrentLeadPost2,
         CurrentLeadPost3,
-        CurrentLeadPost4
-    };
+        CurrentLeadPost4};
     // 真实接口
     // 待定
 
     // 构造返回对象
     QJsonObject *ret = new QJsonObject(
-    {
-        {"url", obj.value("url")},
-        {"PlatformID", obj.value("PlatformID")},
-        {"data", LeadPost}
-    });
+        {{"url", obj.value("url")},
+         {"PlatformID", obj.value("PlatformID")},
+         {"data", LeadPost}});
     returnMessage(pSender, ret);
 }
 
@@ -382,34 +358,128 @@ void WSServer::getTaskPlan(QWebSocket *pSender, QJsonObject obj)
 {
     qDebug() << "网页请求任务计划";
     // 假接口
-    QJsonObject CurrentAirLine
-    {
+    QJsonObject CurrentAirLine{
         {"TargetArea", 3},
         {"Longitude", 123},
         {"Longitude", 27},
-        {"Radius", 300000}
-    };
-    QJsonObject CurrentTaskPlan
-    {
+        {"Radius", 300000}};
+    QJsonObject CurrentTaskPlan{
         {"TargetArea", 2},
         {"ThrowGas", 2},
-        {"ThrowBT", 2}
-    };
+        {"ThrowBT", 2}};
 
-    QJsonObject TaskPlan
-    {
+    QJsonObject TaskPlan{
         {"Airline", CurrentAirLine},
-        {"TaskPlan", CurrentTaskPlan}
-    };
+        {"TaskPlan", CurrentTaskPlan}};
     // 真实接口 待定
 
     // 构造返回对象
     QJsonObject *ret = new QJsonObject(
+        {{"url", obj.value("url")},
+         {"PlatformID", obj.value("PlatformID")},
+         {"data", TaskPlan}});
+    returnMessage(pSender, ret);
+}
+
+// --------------------------态势显控接口---------------------------------
+void WSServer::getLocalMap(QWebSocket *pSender, QJsonObject obj)
+{
+    qDebug() << "网页请求本地态势";
+    // 来源1:导航位置信息
+    // 来源2:ESM数据
+}
+
+void WSServer::getRemoteMap(QWebSocket *pSender, QJsonObject obj)
+{
+    qDebug() << "网页请求远端态势";
+    // 来源:保存下来的平台参数情报和航迹情报
+}
+
+void WSServer::getCombineMap(QWebSocket *pSender, QJsonObject obj)
+{
+    qDebug() << "网页请求融合态势";
+    // 来源1:导航位置信息
+    // 来源2:ESM数据
+    // 来源3:保存下来的平台参数情报和航迹情报
+}
+
+void WSServer::getGlobalMap(QWebSocket *pSender, QJsonObject obj)
+{
+    qDebug() << "网页请求全局态势";
+    // 来源:支撑平台的平台位置信息
+    // 假接口
+    QJsonArray allyNames = {
+        "导弹发射架_1",
+        "机场_1",
+        "预警机_1",
+        "运侦8_1"};
+    QJsonArray allyPos[] = {
+        {117.525, 25.826, 100},
+        {119.271, 26.26, 100},
+        {120.288, 25.5734, 100},
+        {117.525, 25.826, 100}};
+    QJsonArray enemyNames = {
+        "80xxA电子侦察船_1",
+        "宙斯盾舰"};
+    QJsonArray enemyPos[] = {
+        {120.446, 24.8902, 100},
+        {123.528, 25.2951, 100}};
+
+    QJsonArray ally;
+    QJsonArray enemy;
+
+    for (int i= 0;i<allyNames.count();i++)
+    {
+        QJsonObject temp {
+            {"name",allyNames.at(i)},
+            {"value",allyPos[i]}
+        };
+        ally.append(temp);
+    }
+    for (int i= 0;i<enemyNames.count();i++)
     {
-        {"url", obj.value("url")},
-        {"PlatformID", obj.value("PlatformID")},
-        {"data", TaskPlan}
-    });
+        QJsonObject temp {
+            {"name",enemyNames.at(i)},
+            {"value",enemyPos[i]}
+        };
+        enemy.append(temp);
+    }
+
+    // 真实接口
+    //    QJsonArray ally;
+    //    QJsonArray enemy;
+    //    for (auto i : this->zcman->common_inter->PlatformMovement)
+    //    {
+    //        QJsonArray currentPos = {
+    //            i.second.PlatLon,
+    //            i.second.PlatLat,
+    //            100
+    //        };
+    //        QJsonObject currentPlat
+    //        {
+    //            {"name", QString::fromLocal8Bit(i.second.PlatName.c_str())},
+    //            {"value", currentPos}
+    //        };
+    //        // 判断敌我
+    //        if (i.second.PlatIdentification == 2)
+    //        {
+    //            ally.append(currentPlat);
+    //        }
+    //        else if (i.second.PlatIdentification == 1)
+    //        {
+    //            enemy.append(currentPlat);
+    //        }
+    //    }
+
+    // 构造返回对象
+    QJsonObject GlobalMap
+    {
+        {"friend", QJsonValue(ally)},
+        {"enemy", QJsonValue(enemy)}
+    };
+    QJsonObject *ret = new QJsonObject({{"url", obj.value("url")},
+                                        {"data", GlobalMap}});
+
     returnMessage(pSender, ret);
 }
 
@@ -418,25 +488,24 @@ void WSServer::getESMInstances(QWebSocket *pSender, QJsonObject obj)
 {
     qDebug() << "网页请求ESM传感器实例";
     // 假接口
-    QJsonArray *Instances = new QJsonArray();
-    QJsonObject *SingleInstance;
-    if (true)
+    QJsonArray Instances;
+    QJsonObject SingleInstance[] = {
+        {{"instanceID", 62},
+         {"instanceName", "信号侦察_1"}},
+        {{"instanceID", 63},
+         {"instanceName", "信号侦察_2"}}};
+    // 真实接口 待开发
+
+    // 构造返回对象
+    for (auto i : SingleInstance)
     {
-        SingleInstance = new QJsonObject();
-        SingleInstance->insert("instanceID", 62);
-        SingleInstance->insert("instanceName", "信号侦察_1");
-        Instances->append(*SingleInstance);
-        delete SingleInstance;
+        Instances.append(i);
     }
-
-    QJsonObject *ret = new QJsonObject({
-                                           {"url", obj.value("url")},
-                                           {"PlatformID", obj.value("PlatformID")},
-                                           {"data", *Instances}
-                                       });
+    QJsonObject *ret = new QJsonObject({{"url", obj.value("url")},
+                                        {"PlatformID", obj.value("PlatformID")},
+                                        {"data", Instances}});
 
     returnMessage(pSender, ret);
-    delete Instances;
 }
 
 void WSServer::setESMParams(QWebSocket *pSender, QJsonObject obj)
@@ -449,7 +518,7 @@ void WSServer::setESMParams(QWebSocket *pSender, QJsonObject obj)
     QJsonObject data = obj.value("data").toObject();
     if (data.contains("uRrPoweron"))
     {
-        EsmworkPara.uRrPowerOn = data.value("uRrPoweron").toBool()?1:0;
+        EsmworkPara.uRrPowerOn = data.value("uRrPoweron").toBool() ? 1 : 0;
     }
     if (data.contains("uRrWorkMode"))
     {
@@ -499,11 +568,9 @@ void WSServer::setESMParams(QWebSocket *pSender, QJsonObject obj)
         }
     }
 
-    QJsonObject *ret = new QJsonObject({
-                                           {"url", obj.value("url")},
-                                           {"PlatformID", obj.value("PlatformID")},
-                                           {"data", 1}
-                                       });
+    QJsonObject *ret = new QJsonObject({{"url", obj.value("url")},
+                                        {"PlatformID", obj.value("PlatformID")},
+                                        {"data", 1}});
 
     returnMessage(pSender, ret);
 }
@@ -516,148 +583,119 @@ void WSServer::getESMParams(QWebSocket *pSender, QJsonObject obj)
 
     if (true)
     {
-        QJsonObject ESMProps[]
-        {
-            //fBeamAzWidth
+        QJsonObject ESMProps[]{
+            // fBeamAzWidth
             {
-                {"key","方位波束宽度"},
-                {"value", 2}
-            },
-            //fBeamElWidth
+                {"key", "方位波束宽度"},
+                {"value", 2}},
+            // fBeamElWidth
             {
-                {"key","俯仰波束宽度"},
-                {"value", 2}
-            },
-            //fTecMinFreqMhz
+                {"key", "俯仰波束宽度"},
+                {"value", 2}},
+            // fTecMinFreqMhz
             {
-                {"key","侦收最小频率"},
-                {"value", 2e3}
-            },
-            //fTecMaxFreqMhz
+                {"key", "侦收最小频率"},
+                {"value", 2e3}},
+            // fTecMaxFreqMhz
             {
-                {"key","侦收最大频率"},
-                {"value", 18e3}
-            },
-            //fInstantPageWidMhz
+                {"key", "侦收最大频率"},
+                {"value", 18e3}},
+            // fInstantPageWidMhz
             {
-                {"key","瞬时侦察工作频带带宽"},
-                {"value", 500}
-            },
-            //ulChanNum
+                {"key", "瞬时侦察工作频带带宽"},
+                {"value", 500}},
+            // ulChanNum
             {
-                {"key","信道个数"},
-                {"value", 64}
-            },
-            //fTecMinPW
+                {"key", "信道个数"},
+                {"value", 64}},
+            // fTecMinPW
             {
-                {"key","侦收最小脉冲宽度"},
-                {"value", 0.5}
-            },
-            //fTecMaxPW
+                {"key", "侦收最小脉冲宽度"},
+                {"value", 0.5}},
+            // fTecMaxPW
             {
-                {"key","侦收最大脉冲宽度"},
-                {"value", 10}
-            },
-            //fTecPriMean
+                {"key", "侦收最大脉冲宽度"},
+                {"value", 10}},
+            // fTecPriMean
             {
-                {"key","侦收平均重复周期"},
-                {"value", 40}
-            },
-            //ulTecTrNumMean
+                {"key", "侦收平均重复周期"},
+                {"value", 40}},
+            // ulTecTrNumMean
             {
-                {"key","侦收平均脉冲个数"},
-                {"value", 5}
-            },
-            //fMinSnrdB
+                {"key", "侦收平均脉冲个数"},
+                {"value", 5}},
+            // fMinSnrdB
             {
-                {"key","最小信噪比"},
-                {"value", 0.5}
-            },
-            //fSysRcvLoss
+                {"key", "最小信噪比"},
+                {"value", 0.5}},
+            // fSysRcvLoss
             {
-                {"key","接收内部系统损耗"},
-                {"value", 5}
-            },
-            //fFreqAccuracyReq
+                {"key", "接收内部系统损耗"},
+                {"value", 5}},
+            // fFreqAccuracyReq
             {
-                {"key","频率测量精度要求"},
-                {"value", 100}
-            },
-            //uRrPowerOn
+                {"key", "频率测量精度要求"},
+                {"value", 100}},
+            // uRrPowerOn
             {
-                {"key","工作状态"},
-                {"value",(int)EsmworkPara.uRrPowerOn}
-            },
-            //uRrWorkMode
+                {"key", "工作状态"},
+                {"value", (int)EsmworkPara.uRrPowerOn}},
+            // uRrWorkMode
             {
-                {"key","工作模式"},
-                {"value",(int)EsmworkPara.uRrWorkMode}
-            },
-            //dScanAzCentDeg
+                {"key", "工作模式"},
+                {"value", (int)EsmworkPara.uRrWorkMode}},
+            // dScanAzCentDeg
             {
-                {"key","侦察方位中心"},
-                {"value",EsmworkPara.dScanAzCentDeg}
-            },
-            //dScanAzWidthDeg
+                {"key", "侦察方位中心"},
+                {"value", EsmworkPara.dScanAzCentDeg}},
+            // dScanAzWidthDeg
             {
-                {"key","侦察方位范围"},
-                {"value",EsmworkPara.dScanAzWidthDeg}
-            },
-            //dScanElCentDeg
+                {"key", "侦察方位范围"},
+                {"value", EsmworkPara.dScanAzWidthDeg}},
+            // dScanElCentDeg
             {
-                {"key","侦察俯仰中心"},
-                {"value",EsmworkPara.dScanElCentDeg}
-            },
-            //uLineNumPerFrame
+                {"key", "侦察俯仰中心"},
+                {"value", EsmworkPara.dScanElCentDeg}},
+            // uLineNumPerFrame
             {
-                {"key","景幅行数"},
-                {"value",(int)EsmworkPara.uLineNumPerFrame}
-            },
-            //fAntScanVel
+                {"key", "景幅行数"},
+                {"value", (int)EsmworkPara.uLineNumPerFrame}},
+            // fAntScanVel
             {
-                {"key","天线扫描速度"},
-                {"value",EsmworkPara.fAntScanVel}
-            },
-            //fFreqScanVel
+                {"key", "天线扫描速度"},
+                {"value", EsmworkPara.fAntScanVel}},
+            // fFreqScanVel
             {
-                {"key","频率扫描速度"},
-                {"value",EsmworkPara.fFreqScanVel}
-            },
-            //fTecBeginFreqMhz
+                {"key", "频率扫描速度"},
+                {"value", EsmworkPara.fFreqScanVel}},
+            // fTecBeginFreqMhz
             {
-                {"key","侦收起始频率"},
-                {"value",EsmworkPara.fTecBeginFreqMhz}
-            },
-            //fTecEndFreqMhz
+                {"key", "侦收起始频率"},
+                {"value", EsmworkPara.fTecBeginFreqMhz}},
+            // fTecEndFreqMhz
             {
-                {"key","侦收终止频率"},
-                {"value",EsmworkPara.fTecEndFreqMhz}
-            }
-        };
+                {"key", "侦收终止频率"},
+                {"value", EsmworkPara.fTecEndFreqMhz}}};
 
         QJsonArray ESMInitParams, ESMCtrlParams;
 
-        for (int i =0;i<13;i++)
+        for (int i = 0; i < 13; i++)
         {
             ESMInitParams.append(ESMProps[i]);
         }
-        for (int i =13;i<23;i++)
+        for (int i = 13; i < 23; i++)
         {
             ESMCtrlParams.append(ESMProps[i]);
         }
 
-        QJsonObject ESMParams
-        {
+        QJsonObject ESMParams{
             {"InitParams", ESMInitParams},
-            {"CtrlParams", ESMCtrlParams}
-        };
+            {"CtrlParams", ESMCtrlParams}};
 
-        QJsonObject *ret = new QJsonObject({
-                                               {"url", obj.value("url")},
-                                               {"PlatformID", obj.value("PlatformID")},
-                                               {"InstanceID", InstanceID},
-                                               {"data", ESMParams}
-                                           });
+        QJsonObject *ret = new QJsonObject({{"url", obj.value("url")},
+                                            {"PlatformID", obj.value("PlatformID")},
+                                            {"InstanceID", InstanceID},
+                                            {"data", ESMParams}});
 
         returnMessage(pSender, ret);
     }
@@ -669,39 +707,22 @@ void WSServer::getESMStatus(QWebSocket *pSender, QJsonObject obj)
     // 假接口
     QJsonArray ESMStatus;
     QJsonObject ESMState[]{
-        {
-            {"key","扫描行号"},
-            {"value",0}
-        },
-        {
-            {"key","扫描行状态"},
-            {"value",0}
-        },
-        {
-            {"key","侦察频率中心"},
-            {"value",0}
-        },
-        {
-            {"key","侦察频率带宽"},
-            {"value",0}
-        },
-        {
-            {"key","天线系波束方位"},
-            {"value",0}
-        },
-        {
-            {"key","天线系波束俯仰"},
-            {"value",0}
-        },
-        {
-            {"key","天线系波束方位"},
-            {"value",0}
-        },
-        {
-            {"key","天线系波束方位"},
-            {"value",0}
-        }
-    };
+        {{"key", "扫描行号"},
+         {"value", 0}},
+        {{"key", "扫描行状态"},
+         {"value", 0}},
+        {{"key", "侦察频率中心"},
+         {"value", 0}},
+        {{"key", "侦察频率带宽"},
+         {"value", 0}},
+        {{"key", "天线系波束方位"},
+         {"value", 0}},
+        {{"key", "天线系波束俯仰"},
+         {"value", 0}},
+        {{"key", "天线系波束方位"},
+         {"value", 0}},
+        {{"key", "天线系波束方位"},
+         {"value", 0}}};
     for (int i = 0; i < 8; i++)
     {
         ESMStatus.append(ESMState[i]);
@@ -711,229 +732,84 @@ void WSServer::getESMStatus(QWebSocket *pSender, QJsonObject obj)
     int PlatformID = obj.value("PlatformID").toInt();
     int InstanceID = obj.value("InstanceID").toInt();
 
-
     // 构造返回对象
     QJsonObject *ret = new QJsonObject(
-    {
-        {"url", obj.value("url")},
-        {"PlatformID", obj.value("PlatformID")},
-        {"data", ESMStatus}
-    });
+        {{"url", obj.value("url")},
+         {"PlatformID", obj.value("PlatformID")},
+         {"data", ESMStatus}});
 
     returnMessage(pSender, ret);
 }
 
 void WSServer::getESMData(QWebSocket *pSender, QJsonObject obj)
 {
-
-}
-
-// --------------------------态势显控接口---------------------------------
-void WSServer::getLocalMap(QWebSocket *pSender, QJsonObject obj)
-{
-    qDebug() << "网页请求本地态势";
-    // 来源1:导航位置信息
-    // 来源2:ESM数据
-}
-
-void WSServer::getRemoteMap(QWebSocket *pSender, QJsonObject obj)
-{
-    qDebug() << "网页请求远端态势";
-    // 来源:保存下来的平台参数情报和航迹情报
-}
-
-void WSServer::getCombineMap(QWebSocket *pSender, QJsonObject obj)
-{
-    qDebug() << "网页请求融合态势";
-    // 来源1:导航位置信息
-    // 来源2:ESM数据
-    // 来源3:保存下来的平台参数情报和航迹情报
-}
-
-void WSServer::getGlobalMap(QWebSocket *pSender, QJsonObject obj)
-{
-    qDebug() << "网页请求全局态势";
-    // 来源:支撑平台的平台位置信息
-    // 假接口
-    QJsonArray *alies = new QJsonArray();
-    QJsonArray *enemys = new QJsonArray();
-    QJsonArray *temparray;
-    QJsonObject *tempobj;
-
-    {
-        temparray = new QJsonArray();
-        tempobj = new QJsonObject();
-        tempobj->insert("name", "80xxA电子侦察船_1");
-        temparray->append(120.446), temparray->append(24.8902), temparray->append(100);
-        tempobj->insert("value", *temparray);
-//        alies->insert(("80xxA电子侦察船_1"), QJsonValue(*temparray));
-        alies->append(*tempobj);
-        delete temparray;
-        delete tempobj;
-
-        temparray = new QJsonArray();
-        tempobj = new QJsonObject();
-        tempobj->insert("name", "导弹发射架_1");
-        temparray->append(117.525), temparray->append(25.826), temparray->append(100);
-        tempobj->insert("value", *temparray);
-        alies->append(*tempobj);
-        delete temparray;
-        delete tempobj;
-
-        temparray = new QJsonArray();
-        tempobj = new QJsonObject();
-        tempobj->insert("name", "机场_1");
-        temparray->append(119.271), temparray->append(26.26), temparray->append(100);
-        tempobj->insert("value", *temparray);
-        alies->append(*tempobj);
-        delete temparray;
-        delete tempobj;
-
-        temparray = new QJsonArray();
-        tempobj = new QJsonObject();
-        tempobj->insert("name", "预警机_1");
-        temparray->append(120.288), temparray->append(25.5734), temparray->append(100);
-        tempobj->insert("value", *temparray);
-        alies->append(*tempobj);
-        delete temparray;
-        delete tempobj;
-
-        temparray = new QJsonArray();
-        tempobj = new QJsonObject();
-        tempobj->insert("name", "运侦8_1");
-        temparray->append(117.525), temparray->append(25.826), temparray->append(100);
-        tempobj->insert("value", *temparray);
-        alies->append(*tempobj);
-        delete temparray;
-        delete tempobj;
-    }
-
-    {
-        temparray = new QJsonArray();
-        tempobj = new QJsonObject();
-        tempobj->insert("name", "宙斯盾舰");
-        temparray->append(123.528), temparray->append(25.2951), temparray->append(100);
-        tempobj->insert("value",*temparray);
-        enemys->append(*tempobj);
-        delete temparray;
-        delete tempobj;
-    }
-
-    QJsonObject GlobalMap
-    {
-        {"friend", QJsonValue(*alies)},
-        {"enemy", QJsonValue(*enemys)}
-    };
-    delete alies;
-    delete enemys;
-    // 真实接口
-//    QJsonArray ally;
-//    QJsonArray enemy;
-//    for (auto i : this->zcman->common_inter->PlatformMovement)
-//    {
-//        QJsonArray currentPos = {
-//            i.second.PlatLon,
-//            i.second.PlatLat,
-//            100
-//        };
-//        QJsonObject currentPlat
-//        {
-//            {"name", QString::fromLocal8Bit(i.second.PlatName.c_str())},
-//            {"value", currentPos}
-//        };
-//        // 判断敌我
-//        if (i.second.PlatIdentification == 2)
-//        {
-//            ally.append(currentPlat);
-//        }
-//        else if (i.second.PlatIdentification == 1)
-//        {
-//            enemy.append(currentPlat);
-//        }
-//    }
-//    QJsonObject GlobalMap
-//    {
-//        {"friend", QJsonValue(ally)},
-//        {"enemy", QJsonValue(enemy)}
-//    };
-
-    // 构造返回对象
-    QJsonObject *ret = new QJsonObject({
-                                           {"url", obj.value("url")},
-                                           {"data", GlobalMap}
-                                       });
-
-    returnMessage(pSender, ret);
 }
 
 void WSServer::getNavParams(QWebSocket *pSender, QJsonObject obj)
 {
 
-    int InstanceID = obj.value("InstanceID").toInt();
-
-    QJsonArray *NavInitParams;
-    QJsonArray *NavCtrlParams;
-    QJsonObject *NavPropTemp;
-
-    NavInitParams = new QJsonArray();
-    NavCtrlParams = new QJsonArray();
-
-    NavPropTemp = new QJsonObject();
-    NavPropTemp->insert("key","precision");
-    NavPropTemp->insert("value",QJsonValue(5));
-    NavInitParams->append(*NavPropTemp);
-    delete NavPropTemp;
-
-    qDebug() << "aaa" << QString(QJsonDocument(*NavCtrlParams).toJson());
-
-    NavPropTemp = new QJsonObject();
-    NavPropTemp->insert("key","longitude");
-    NavPropTemp->insert("value",QJsonValue(120));
-    NavCtrlParams->append(*NavPropTemp);
-    delete NavPropTemp;
-
-    NavPropTemp = new QJsonObject();
-    NavPropTemp->insert("key","latitude");
-    NavPropTemp->insert("value",QJsonValue(30));
-    NavCtrlParams->append(*NavPropTemp);
-    delete NavPropTemp;
-
-    NavPropTemp = new QJsonObject();
-    NavPropTemp->insert("key","altitude");
-    NavPropTemp->insert("value",QJsonValue(8014.8));
-    NavCtrlParams->append(*NavPropTemp);
-    delete NavPropTemp;
-
-    NavPropTemp = new QJsonObject();
-    NavPropTemp->insert("key","azimush");
-    NavPropTemp->insert("value",QJsonValue(10));
-    NavCtrlParams->append(*NavPropTemp);
-    delete NavPropTemp;
-
-    NavPropTemp = new QJsonObject();
-    NavPropTemp->insert("key","elevation");
-    NavPropTemp->insert("value",QJsonValue(-3));
-    NavCtrlParams->append(*NavPropTemp);
-    delete NavPropTemp;
-
-    QJsonObject *NAVParams = new QJsonObject();
-    NAVParams->insert("InitParams", *NavInitParams);
-    NAVParams->insert("CtrlParams", *NavCtrlParams);
-
-    QJsonObject *ret = new QJsonObject({
-                                           {"url", obj.value("url")},
-                                           {"PlatformID", obj.value("PlatformID")},
-                                           {"data", *NAVParams}
-                                       });
-
-    returnMessage(pSender, ret);
-
-    delete NavInitParams;
-    delete NavCtrlParams;
-    delete NAVParams;
+//    int InstanceID = obj.value("InstanceID").toInt();
+
+//    QJsonArray *NavInitParams;
+//    QJsonArray *NavCtrlParams;
+//    QJsonObject *NavPropTemp;
+
+//    NavInitParams = new QJsonArray();
+//    NavCtrlParams = new QJsonArray();
+
+//    NavPropTemp = new QJsonObject();
+//    NavPropTemp->insert("key", "precision");
+//    NavPropTemp->insert("value", QJsonValue(5));
+//    NavInitParams->append(*NavPropTemp);
+//    delete NavPropTemp;
+
+//    qDebug() << "aaa" << QString(QJsonDocument(*NavCtrlParams).toJson());
+
+//    NavPropTemp = new QJsonObject();
+//    NavPropTemp->insert("key", "longitude");
+//    NavPropTemp->insert("value", QJsonValue(120));
+//    NavCtrlParams->append(*NavPropTemp);
+//    delete NavPropTemp;
+
+//    NavPropTemp = new QJsonObject();
+//    NavPropTemp->insert("key", "latitude");
+//    NavPropTemp->insert("value", QJsonValue(30));
+//    NavCtrlParams->append(*NavPropTemp);
+//    delete NavPropTemp;
+
+//    NavPropTemp = new QJsonObject();
+//    NavPropTemp->insert("key", "altitude");
+//    NavPropTemp->insert("value", QJsonValue(8014.8));
+//    NavCtrlParams->append(*NavPropTemp);
+//    delete NavPropTemp;
+
+//    NavPropTemp = new QJsonObject();
+//    NavPropTemp->insert("key", "azimush");
+//    NavPropTemp->insert("value", QJsonValue(10));
+//    NavCtrlParams->append(*NavPropTemp);
+//    delete NavPropTemp;
+
+//    NavPropTemp = new QJsonObject();
+//    NavPropTemp->insert("key", "elevation");
+//    NavPropTemp->insert("value", QJsonValue(-3));
+//    NavCtrlParams->append(*NavPropTemp);
+//    delete NavPropTemp;
+
+//    QJsonObject *NAVParams = new QJsonObject();
+//    NAVParams->insert("InitParams", *NavInitParams);
+//    NAVParams->insert("CtrlParams", *NavCtrlParams);
+
+//    QJsonObject *ret = new QJsonObject({{"url", obj.value("url")},
+//                                        {"PlatformID", obj.value("PlatformID")},
+//                                        {"data", *NAVParams}});
+
+//    returnMessage(pSender, ret);
+
+//    delete NavInitParams;
+//    delete NavCtrlParams;
+//    delete NAVParams;
 }
 
 void WSServer::setFreePost(QWebSocket *pSender, QJsonObject obj)
 {
-
 }

+ 5 - 5
wsserver.h

@@ -62,17 +62,17 @@ public slots:
     // 任务管理显控接口
     void getLeadPost(QWebSocket *pSender, QJsonObject obj);
     void getTaskPlan(QWebSocket *pSender, QJsonObject obj);
+    // 态势显控接口
+    void getLocalMap(QWebSocket *pSender, QJsonObject obj);
+    void getRemoteMap(QWebSocket *pSender, QJsonObject obj);
+    void getCombineMap(QWebSocket *pSender, QJsonObject obj);
+    void getGlobalMap(QWebSocket *pSender, QJsonObject obj);
     // 雷侦、通侦显控接口
     void getESMInstances(QWebSocket *pSender, QJsonObject obj);
     void setESMParams(QWebSocket *pSender, QJsonObject obj);
     void getESMParams(QWebSocket *pSender, QJsonObject obj);
     void getESMStatus(QWebSocket *pSender, QJsonObject obj);
     void getESMData(QWebSocket *pSender, QJsonObject obj);
-    // 态势显控接口
-    void getLocalMap(QWebSocket *pSender, QJsonObject obj);
-    void getRemoteMap(QWebSocket *pSender, QJsonObject obj);
-    void getCombineMap(QWebSocket *pSender, QJsonObject obj);
-    void getGlobalMap(QWebSocket *pSender, QJsonObject obj);
 
     void getNavParams(QWebSocket *pSender, QJsonObject obj);
     void setFreePost(QWebSocket *pSender, QJsonObject obj);