123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971 |
- #include "simulationcontrol.h"
- SimulationControl::SimulationControl(QObject *parent) : QObject(parent)
- {
- // 添加场景平台
- allyplane.push_back(new Platform(this, 1001, QString::fromLocal8Bit("干扰机_1"),120,27,8000,-200,200,-300));
- allyplane.push_back(new Platform(this, 1002, QString::fromLocal8Bit("干扰机_2"),120.3,27,8000,-200,200,-300));
- allyplane.push_back(new Platform(this, 1003, QString::fromLocal8Bit("干扰机_3"),120,27.3,8000,-200,200,-300));
- allyplane.push_back(new Platform(this, 1004, QString::fromLocal8Bit("干扰机_4"),120.3,27.3,8000,-200,200,-300));
- allymissile.push_back(new Platform(this, 2001, QString::fromLocal8Bit("弹道导弹1"),117,33,0));
- allymissile.push_back(new Platform(this, 2001, QString::fromLocal8Bit("弹道导弹2"),117,33,0));
- allymissile.push_back(new Platform(this, 2001, QString::fromLocal8Bit("弹道导弹3"),117,33,0));
- allymissile.push_back(new Platform(this, 2001, QString::fromLocal8Bit("弹道导弹4"),117,33,0));
- ally.push_back(allyplane);
- ally.push_back(allymissile);
- enemyradar.push_back(new Platform(this,6001,QString::fromLocal8Bit("Thaad系统1"),121,24.5,0));
- enemyradar.push_back(new Platform(this,6002,QString::fromLocal8Bit("Thaad系统2"),121,22.5,0));
- enemy.push_back(enemyradar);
- enemy.push_back(enemysat);
- // 添加雷达模拟器
- Radar *radar1 = new Radar(this, 6001, 12, true, QString::fromLocal8Bit("AN-TPY/2雷达-1"),
- QStringLiteral("ws://localhost:1235"));
- Radar *radar2 = new Radar(this, 6002, 13, false, QString::fromLocal8Bit("AN-TPY/2雷达-2"),
- QStringLiteral("ws://localhost:1236"));
- // connect(this,&SimulationControl::SigRadarStyleUpdate,
- // radar1,&Radar::StyleUpdate);
- // connect(this,&SimulationControl::SigRadarStyleUpdate,
- // radar2,&Radar::StyleUpdate);
- enemyThaadRadarSim.insert(std::pair<int, Radar*>(12, radar1));
- enemyThaadRadarSim.insert(std::pair<int, Radar*>(13, radar2));
- Jamming *jamming1 = new Jamming(this, 1001, 20, true, QString::fromLocal8Bit("干扰器1"),
- QStringLiteral("ws://localhost:1240"),1);
- Jamming *jamming2 = new Jamming(this, 1002, 21, true, QString::fromLocal8Bit("干扰器2"),
- QStringLiteral("ws://localhost:1241"),1);
- Jamming *jamming3 = new Jamming(this, 1003, 22, true, QString::fromLocal8Bit("干扰器3"),
- QStringLiteral("ws://localhost:1242"),1);
- Jamming *jamming4 = new Jamming(this, 1004, 23, true, QString::fromLocal8Bit("干扰器4"),
- QStringLiteral("ws://localhost:1243"),1);
- // 添加干扰器
- allyJammingSim.insert(std::pair<int, Jamming*>(20, jamming1));
- allyJammingSim.insert(std::pair<int, Jamming*>(21, jamming2));
- allyJammingSim.insert(std::pair<int, Jamming*>(22, jamming3));
- allyJammingSim.insert(std::pair<int, Jamming*>(23, jamming4));
- }
- void SimulationControl::SlotGetInit(QWebSocket *pSender, QJsonObject obj)
- {
- qDebug() << "Build with Slot";
- QJsonObject *InitState = new QJsonObject();
- InitState->insert("InitState", 100);
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("data", *InitState);
- delete InitState;
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetLeadPost(QWebSocket *pSender, QJsonObject obj)
- {
- QJsonArray *LeadPost = new QJsonArray();
- QJsonObject *CurrentLeadPost;
- CurrentLeadPost = new QJsonObject();
- CurrentLeadPost->insert("time", "20:20:01");
- CurrentLeadPost->insert("GroupID", "0001");
- CurrentLeadPost->insert("LeaderID", "8013");
- CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("发现雷达"));
- LeadPost->append(*CurrentLeadPost);
- delete CurrentLeadPost;
- CurrentLeadPost = new QJsonObject();
- CurrentLeadPost->insert("time", "20:20:30");
- CurrentLeadPost->insert("GroupID", "0001");
- CurrentLeadPost->insert("LeaderID", "8013");
- CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("请求施加干扰"));
- LeadPost->append(*CurrentLeadPost);
- delete CurrentLeadPost;
- CurrentLeadPost = new QJsonObject();
- CurrentLeadPost->insert("time", "20:20:40");
- CurrentLeadPost->insert("GroupID", "0003");
- CurrentLeadPost->insert("LeaderID", "8014");
- CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("干扰样式生成"));
- LeadPost->append(*CurrentLeadPost);
- delete CurrentLeadPost;
- CurrentLeadPost = new QJsonObject();
- CurrentLeadPost->insert("time", "20:21:00");
- CurrentLeadPost->insert("GroupID", "0002");
- CurrentLeadPost->insert("LeaderID", "8015");
- CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("干扰信号发射"));
- LeadPost->append(*CurrentLeadPost);
- delete CurrentLeadPost;
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("data", *LeadPost);
- delete LeadPost;
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetTaskPlan(QWebSocket *pSender, QJsonObject obj)
- {
- QJsonObject *TaskPlan = new QJsonObject();
- QJsonObject *CurrentAirLine;
- QJsonObject *CurrentTaskPlan;
- CurrentAirLine = new QJsonObject;
- CurrentAirLine->insert("TargetArea", 3);
- CurrentAirLine->insert("Longitude", 123);
- CurrentAirLine->insert("Longitude", 27);
- CurrentAirLine->insert("Radius", 300000);
- CurrentTaskPlan = new QJsonObject;
- CurrentTaskPlan->insert("TargetArea", 2);
- CurrentTaskPlan->insert("ThrowGas", 2);
- CurrentTaskPlan->insert("ThrowBT", 2);
- TaskPlan->insert("Airline", *CurrentAirLine);
- TaskPlan->insert("TaskPlan", *CurrentTaskPlan);
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("data", *TaskPlan);
- delete TaskPlan;
- delete CurrentAirLine;
- delete CurrentTaskPlan;
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetGlobalMap(QWebSocket *pSender, QJsonObject obj)
- {
- QJsonObject GlobalMap;
- // QJsonObject *alies = new QJsonObject();
- // QJsonObject *enemys = new QJsonObject();
- QJsonObject allies;
- QJsonObject enemys;
- for (int i=0; i < ally.size(); i++)
- {
- QJsonArray allyNow;
- for (auto j: ally.at(i))
- {
- QJsonArray temparray = {j->lon, j->lat, j->h};
- QJsonObject tempObject
- {
- {"name", j->Name},
- {"value", temparray}
- };
- allyNow.append(tempObject);
- }
- if (i == 0)
- {
- allies.insert("Planes", allyNow);
- }
- else if (i == 1)
- {
- allies.insert("Missiles",allyNow);
- }
- }
- for (int i=0; i < enemy.size(); i++)
- {
- QJsonArray enemyNow;
- for (auto j: enemy.at(i))
- {
- QJsonArray temparray = {j->lon, j->lat, j->h};
- QJsonObject tempObject
- {
- {"name", j->Name},
- {"value", temparray}
- };
- enemyNow.append(tempObject);
- }
- if (i == 0)
- {
- enemys.insert("Radars", enemyNow);
- }
- }
- GlobalMap.insert("friend", QJsonValue(allies));
- GlobalMap.insert("enemy", QJsonValue(enemys));
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("data",QJsonValue(GlobalMap));
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetPlatformTable(QWebSocket *pSender, QJsonObject obj)
- {
- QJsonArray Platforms;
- for (int i = 0; i < ally.size(); i++)
- {
- std::vector<Platform *> allyplatforms = ally.at(i);
- if (i == 0)
- {
- for (auto j : allyplatforms)
- {
- QJsonObject SinglePlatform
- {
- {"platformID", QString::number(j->ID)},
- {"platformName", j->Name}
- };
- Platforms.append(SinglePlatform);
- }
- }
- }
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("data",QJsonValue(Platforms));
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetInstanceTable(QWebSocket *pSender, QJsonObject obj)
- {
- QJsonArray *Instances = new QJsonArray();
- QJsonObject *SingleInstance;
- if (true)
- {
- SingleInstance = new QJsonObject();
- SingleInstance->insert("instanceID", 22);
- SingleInstance->insert("instanceName", QString::fromLocal8Bit("侦察机_1"));
- Instances->append(*SingleInstance);
- delete SingleInstance;
- SingleInstance = new QJsonObject();
- SingleInstance->insert("instanceID", 62);
- SingleInstance->insert("instanceName", QString::fromLocal8Bit("信号侦察_1"));
- Instances->append(*SingleInstance);
- delete SingleInstance;
- SingleInstance = new QJsonObject();
- SingleInstance->insert("instanceID", 96);
- SingleInstance->insert("instanceName", QString::fromLocal8Bit("体系增量_1"));
- Instances->append(*SingleInstance);
- delete SingleInstance;
- SingleInstance = new QJsonObject();
- SingleInstance->insert("instanceID", 111);
- SingleInstance->insert("instanceName", QString::fromLocal8Bit("侦察平台任务系统_1"));
- Instances->append(*SingleInstance);
- delete SingleInstance;
- SingleInstance = new QJsonObject();
- SingleInstance->insert("instanceID", 171);
- SingleInstance->insert("instanceName", QString::fromLocal8Bit("导航_1"));
- Instances->append(*SingleInstance);
- delete SingleInstance;
- }
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("data",QJsonValue(*Instances));
- delete Instances;
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetRadarInstances(QWebSocket *pSender, QJsonObject obj)
- {
- int nowPlatform = obj.value("PlatformID").toInt();
- QJsonArray RadarInstances;
- for (auto i : enemyThaadRadarSim)
- {
- QJsonObject tempThaad;
- if (1 || nowPlatform == i.second->PlatformID)
- {
- tempThaad.insert("instanceID", QString::number(i.first));
- tempThaad.insert("instanceName",i.second->Name);
- if (i.second->SwitchMode)
- {
- tempThaad.insert("instanceState", QString::fromLocal8Bit("开机"));
- }
- else
- {
- tempThaad.insert("instanceState", QString::fromLocal8Bit("关机"));
- }
- }
- RadarInstances.append(tempThaad);
- }
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("data",QJsonValue(RadarInstances));
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetRadarParams(QWebSocket *pSender, QJsonObject obj)
- {
- int nowInstance = obj.value("InstanceID").toString().toInt();
- Radar *nowRadar = enemyThaadRadarSim.at(nowInstance);
- if (nowRadar == nullptr)
- {
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("InstanceID", obj.value("InstanceID"));
- ret->insert("data",QJsonValue());
- emit SigReturnData(pSender, ret);
- }
- else if (true || nowRadar->PlatformID == obj.value("PlatformID").toInt())
- {
- int styleIdx = nowRadar->style;
- qDebug() << styleIdx;
- Style nowStyle = nowRadar->RadarStyleList.at(styleIdx);
- QJsonObject nowfs {
- {"key", QString::fromLocal8Bit("采样频率")},
- {"value", nowStyle.fs}
- };
- QJsonObject nowfc {
- {"key", QString::fromLocal8Bit("载波频率")},
- {"value", nowStyle.fc}
- };
- QJsonObject nowModuType {
- {"key", QString::fromLocal8Bit("调制类型")},
- {"value", nowStyle.moduType}
- };
- QJsonObject nowPRFMode {
- {"key", QString::fromLocal8Bit("PRF模式")},
- {"value", nowStyle.PRFMode}
- };
- QJsonArray PRFarray;
- for (auto i : nowStyle.PRFs)
- {
- PRFarray.push_back(i);
- }
- QJsonObject nowPRF
- {
- {"key", QString::fromLocal8Bit("PRF")},
- {"value", PRFarray}
- };
- QJsonObject nowPW
- {
- {"key", QString::fromLocal8Bit("脉冲宽度")},
- {"value", nowStyle.PulseWidth}
- };
- QJsonObject nowBW
- {
- {"key", QString::fromLocal8Bit("带宽")},
- {"value", nowStyle.BandWidth}
- };
- QJsonArray nowParams = {nowfs, nowfc, nowModuType, nowPRFMode, nowPRF, nowPW, nowBW};
- QJsonObject initMaxDis {
- {"key", QString::fromLocal8Bit("最大量程")},
- {"value", 800000}
- };
- QJsonObject initMinDis {
- {"key", QString::fromLocal8Bit("最小量程")},
- {"value", 1000}
- };
- QJsonObject initMaxFre {
- {"key", QString::fromLocal8Bit("最大频率")},
- {"value", 12e9}
- };
- QJsonObject initMinFre {
- {"key", QString::fromLocal8Bit("最大频率")},
- {"value", 8e9}
- };
- QJsonObject initNumArrayElement {
- {"key", QString::fromLocal8Bit("阵元数")},
- {"value", 25344}
- };
- QJsonObject initGain {
- {"key", QString::fromLocal8Bit("天线增益")},
- {"value", 48.77}
- };
- QJsonObject initPt {
- {"key", QString::fromLocal8Bit("发射机功率")},
- {"value", 405e3}
- };
- QJsonArray initParams = {initMaxDis, initMinDis, initMaxFre, initMinFre, initNumArrayElement, initGain, initPt};
- QJsonObject retParams {
- {"InitParams", initParams},
- {"CtrlParams", nowParams}
- };
- QJsonObject *ret = new QJsonObject({
- {"url", obj.value("url")},
- {"PlatformID", obj.value("PlatformID")},
- {"InstanceID", obj.value("InstanceID")},
- {"data",QJsonValue(retParams)}
- });
- emit SigReturnData(pSender, ret);
- }
- }
- void SimulationControl::SlotGetThaadInstances(QWebSocket *pSender, QJsonObject obj)
- {
- QJsonArray RadarInstances;
- for (auto i : enemyThaadRadarSim)
- {
- QJsonObject tempThaad;
- if (1)
- {
- tempThaad.insert("instanceID", QString::number(i.first));
- tempThaad.insert("instanceName",i.second->Name);
- if (i.second->SwitchMode)
- {
- tempThaad.insert("instanceState", QString::fromLocal8Bit("开机"));
- }
- else
- {
- tempThaad.insert("instanceState", QString::fromLocal8Bit("关机"));
- }
- }
- RadarInstances.append(tempThaad);
- }
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("data",QJsonValue(RadarInstances));
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetThaadParams(QWebSocket *pSender, QJsonObject obj)
- {
- int nowInstance = obj.value("InstanceID").toString().toInt();
- Radar *nowRadar = enemyThaadRadarSim.at(nowInstance);
- if (nowRadar == nullptr)
- {
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("InstanceID", obj.value("InstanceID"));
- ret->insert("data",QJsonValue());
- emit SigReturnData(pSender, ret);
- }
- else if (true || nowRadar->PlatformID == obj.value("PlatformID").toInt())
- {
- int styleIdx = nowRadar->style;
- qDebug() << styleIdx;
- Style nowStyle = nowRadar->RadarStyleList.at(styleIdx);
- QJsonObject nowfs {
- {"key", QString::fromLocal8Bit("采样频率")},
- {"value", nowStyle.fs}
- };
- QJsonObject nowfc {
- {"key", QString::fromLocal8Bit("载波频率")},
- {"value", nowStyle.fc}
- };
- QJsonObject nowModuType {
- {"key", QString::fromLocal8Bit("调制类型")},
- {"value", nowStyle.moduType}
- };
- QJsonObject nowPRFMode {
- {"key", QString::fromLocal8Bit("PRF模式")},
- {"value", nowStyle.PRFMode}
- };
- QJsonArray PRFarray;
- for (auto i : nowStyle.PRFs)
- {
- PRFarray.push_back(i);
- }
- QJsonObject nowPRF
- {
- {"key", QString::fromLocal8Bit("PRF")},
- {"value", PRFarray}
- };
- QJsonObject nowPW
- {
- {"key", QString::fromLocal8Bit("脉冲宽度")},
- {"value", nowStyle.PulseWidth}
- };
- QJsonObject nowBW
- {
- {"key", QString::fromLocal8Bit("带宽")},
- {"value", nowStyle.BandWidth}
- };
- QJsonArray nowParams = {nowfs, nowfc, nowModuType, nowPRFMode, nowPRF, nowPW, nowBW};
- QJsonObject initMaxDis {
- {"key", QString::fromLocal8Bit("最大量程")},
- {"value", 800000}
- };
- QJsonObject initMinDis {
- {"key", QString::fromLocal8Bit("最小量程")},
- {"value", 1000}
- };
- QJsonObject initMaxFre {
- {"key", QString::fromLocal8Bit("最大频率")},
- {"value", 12e9}
- };
- QJsonObject initMinFre {
- {"key", QString::fromLocal8Bit("最大频率")},
- {"value", 8e9}
- };
- QJsonObject initNumArrayElement {
- {"key", QString::fromLocal8Bit("阵元数")},
- {"value", 25344}
- };
- QJsonObject initGain {
- {"key", QString::fromLocal8Bit("天线增益")},
- {"value", 48.77}
- };
- QJsonObject initPt {
- {"key", QString::fromLocal8Bit("发射机功率")},
- {"value", 405e3}
- };
- QJsonArray initParams = {initMaxDis, initMinDis, initMaxFre, initMinFre, initNumArrayElement, initGain, initPt};
- QJsonObject retParams {
- {"InitParams", initParams},
- {"CtrlParams", nowParams}
- };
- QJsonObject *ret = new QJsonObject({
- {"url", obj.value("url")},
- {"PlatformID", obj.value("PlatformID")},
- {"InstanceID", obj.value("InstanceID")},
- {"data",QJsonValue(retParams)}
- });
- emit SigReturnData(pSender, ret);
- }
- }
- void SimulationControl::SlotSetThaadStyle(QWebSocket *pSender, QJsonObject obj)
- {
- // PlatformID和InstanceID是字符串
- int nowPlatform = obj.value("PlatformID").toString().toInt();
- int nowInstance = obj.value("InstanceID").toString().toInt();
- QJsonObject nowdata = obj.value("data").toObject();
- if (nowdata.contains("Style"))
- {
- // Style索引是整型
- int nowStyle = nowdata.value("Style").toInt();
- // qDebug() << nowPlatform <<" "<< nowInstance << " " << nowStyle;
- Radar *nowRadar = enemyThaadRadarSim.at(nowInstance);
- if (nowRadar == nullptr)
- {
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("InstanceID", obj.value("InstanceID"));
- ret->insert("data", QJsonValue(""));
- emit SigReturnData(pSender, ret);
- }
- else
- {
- nowRadar->StyleUpdate(nowStyle);
- int styleIdx = nowRadar->style;
- qDebug() << styleIdx;
- Style nowStyle = nowRadar->RadarStyleList.at(styleIdx);
- QJsonObject nowfs {
- {"key", QString::fromLocal8Bit("采样频率")},
- {"value", nowStyle.fs}
- };
- QJsonObject nowfc {
- {"key", QString::fromLocal8Bit("载波频率")},
- {"value", nowStyle.fc}
- };
- QJsonObject nowModuType {
- {"key", QString::fromLocal8Bit("调制类型")},
- {"value", nowStyle.moduType}
- };
- QJsonObject nowPRFMode {
- {"key", QString::fromLocal8Bit("PRF模式")},
- {"value", nowStyle.PRFMode}
- };
- QJsonArray PRFarray;
- for (auto i : nowStyle.PRFs)
- {
- PRFarray.push_back(i);
- }
- QJsonObject nowPRF
- {
- {"key", QString::fromLocal8Bit("PRF")},
- {"value", PRFarray}
- };
- QJsonObject nowPW
- {
- {"key", QString::fromLocal8Bit("脉冲宽度")},
- {"value", nowStyle.PulseWidth}
- };
- QJsonObject nowBW
- {
- {"key", QString::fromLocal8Bit("带宽")},
- {"value", nowStyle.BandWidth}
- };
- QJsonArray nowParams = {nowfs, nowfc, nowModuType, nowPRFMode, nowPRF, nowPW, nowBW};
- QJsonObject initMaxDis {
- {"key", QString::fromLocal8Bit("最大量程")},
- {"value", 800000}
- };
- QJsonObject initMinDis {
- {"key", QString::fromLocal8Bit("最小量程")},
- {"value", 1000}
- };
- QJsonObject initMaxFre {
- {"key", QString::fromLocal8Bit("最大频率")},
- {"value", 12e9}
- };
- QJsonObject initMinFre {
- {"key", QString::fromLocal8Bit("最大频率")},
- {"value", 8e9}
- };
- QJsonObject initNumArrayElement {
- {"key", QString::fromLocal8Bit("阵元数")},
- {"value", 25344}
- };
- QJsonObject initGain {
- {"key", QString::fromLocal8Bit("天线增益")},
- {"value", 48.77}
- };
- QJsonObject initPt {
- {"key", QString::fromLocal8Bit("发射机功率")},
- {"value", 405e3}
- };
- QJsonArray initParams = {initMaxDis, initMinDis, initMaxFre, initMinFre, initNumArrayElement, initGain, initPt};
- QJsonObject retParams {
- {"InitParams", initParams},
- {"CtrlParams", nowParams}
- };
- QJsonObject *ret = new QJsonObject({
- {"url", obj.value("url")},
- {"PlatformID", obj.value("PlatformID")},
- {"InstanceID", obj.value("InstanceID")},
- {"data",QJsonValue(retParams)}
- });
- emit SigReturnData(pSender, ret);
- }
- }
- }
- void SimulationControl::SlotGetJammingInstances(QWebSocket *pSender, QJsonObject obj)
- {
- int nowPlatform = obj.value("PlatformID").toString().toInt();
- QJsonArray JammingInstances;
- for (auto i : allyJammingSim)
- {
- QJsonObject tempJamming;
- if (true || nowPlatform == i.second->PlatformID)
- {
- tempJamming.insert("instanceID", QString::number(i.first));
- tempJamming.insert("instanceName",i.second->Name);
- if (i.second->SwitchMode)
- {
- tempJamming.insert("instanceState", QString::fromLocal8Bit("开机"));
- }
- else
- {
- tempJamming.insert("instanceState", QString::fromLocal8Bit("关机"));
- }
- JammingInstances.append(tempJamming);
- }
- }
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("data",QJsonValue(JammingInstances));
- emit SigReturnData(pSender, ret);
- }
- void SimulationControl::SlotGetJammingParams(QWebSocket *pSender, QJsonObject obj)
- {
- int nowInstance = obj.value("InstanceID").toString().toInt();
- Jamming *nowJamming = allyJammingSim.at(nowInstance);
- if (true || nowJamming->PlatformID == obj.value("PlatformID").toString().toInt())
- {
- int styleIdx = nowJamming->style;
- qDebug() << styleIdx;
- JammingStyle nowStyle = nowJamming->JammingStyleList.at(styleIdx);
- QJsonObject nowfs
- {
- {"key", QString::fromLocal8Bit("采样频率")},
- {"value", nowStyle.fs}
- };
- QJsonObject nowfc
- {
- {"key", QString::fromLocal8Bit("载波频率")},
- {"value", nowStyle.fc}
- };
- QJsonObject nowOpMode
- {
- {"key", QString::fromLocal8Bit("调制类型")},
- {"value", nowStyle.OpMode}
- };
- QJsonArray nowParams = {nowfs, nowfc, nowOpMode};
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("InstanceID", obj.value("InstanceID"));
- ret->insert("data",QJsonValue(nowParams));
- emit SigReturnData(pSender, ret);
- }
- }
- void SimulationControl::SlotSetJammingStyle(QWebSocket *pSender, QJsonObject obj)
- {
- // PlatformID和InstanceID是字符串
- int nowPlatform = obj.value("PlatformID").toString().toInt();
- int nowInstance = obj.value("InstanceID").toString().toInt();
- QJsonObject nowdata = obj.value("data").toObject();
- if (nowdata.contains("Style"))
- {
- // Style索引是整型
- int nowStyle = nowdata.value("Style").toInt();
- // qDebug() << nowPlatform <<" "<< nowInstance << " " << nowStyle;
- Jamming *nowJamming = allyJammingSim.at(nowInstance);
- if (nowJamming == nullptr)
- {
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("InstanceID", obj.value("InstanceID"));
- ret->insert("data", QJsonValue(""));
- emit SigReturnData(pSender, ret);
- }
- else
- {
- nowJamming->StyleUpdate(nowStyle);
- int styleIdx = nowJamming->style;
- qDebug() << styleIdx;
- JammingStyle nowStyle = nowJamming->JammingStyleList.at(styleIdx);
- QJsonObject nowfs {
- {"key", QString::fromLocal8Bit("采样频率")},
- {"value", nowStyle.fs}
- };
- QJsonObject nowfc {
- {"key", QString::fromLocal8Bit("载波频率")},
- {"value", nowStyle.fc}
- };
- QJsonObject nowOpMode {
- {"key", QString::fromLocal8Bit("开关机状态")},
- {"value", nowStyle.OpMode}
- };
- QJsonArray nowParams = {nowfs, nowfc, nowOpMode};
- QJsonObject *ret = new QJsonObject({
- {"url", obj.value("url")},
- {"PlatformID", obj.value("PlatformID")},
- {"InstanceID", obj.value("InstanceID")},
- {"data",QJsonValue(nowParams)}
- });
- emit SigReturnData(pSender, ret);
- }
- }
- }
- void SimulationControl::SlotGetESMParams(QWebSocket *pSender, QJsonObject obj)
- {
- int InstanceID = obj.value("InstanceID").toInt();
- QJsonArray *ESMInitParams;
- QJsonArray *ESMCtrlParams;
- QJsonObject *ESMPropTemp;
- if (true)
- {
- ESMInitParams = new QJsonArray();
- ESMCtrlParams = new QJsonArray();
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fBeamAzWidth");
- ESMPropTemp->insert("value",2);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fBeamElWidth");
- ESMPropTemp->insert("value",2);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fTecMinFreqMhz");
- ESMPropTemp->insert("value",2e3);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fTecMaxFreqMhz");
- ESMPropTemp->insert("value",18e3);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fInstantPageWidMhz");
- ESMPropTemp->insert("value",500);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","ulChanNum");
- ESMPropTemp->insert("value",64);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fTecMinPW");
- ESMPropTemp->insert("value",0.5);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fTecMaxPW");
- ESMPropTemp->insert("value",10);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fTecPriMean");
- ESMPropTemp->insert("value",40);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","ulTecTrNumMean");
- ESMPropTemp->insert("value",5);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fMinSnrdB");
- ESMPropTemp->insert("value",0.5);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fSysRcvLoss");
- ESMPropTemp->insert("value",5);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fFreqAccuracyReq");
- ESMPropTemp->insert("value",100);
- ESMInitParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","uRrPowerOn");
- ESMPropTemp->insert("value",0);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","uRrWorkMode");
- ESMPropTemp->insert("value",0);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","dScanAzCentDeg");
- ESMPropTemp->insert("value",0);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","dScanAzWidthDeg");
- ESMPropTemp->insert("value",5);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","dScanElCentDeg");
- ESMPropTemp->insert("value",0);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","uLineNumPerFrame");
- ESMPropTemp->insert("value",20);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fAntScanVel");
- ESMPropTemp->insert("value",1);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fFreqScanVel");
- ESMPropTemp->insert("value",100);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fTecBeginFreqMhz");
- ESMPropTemp->insert("value",500);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- ESMPropTemp = new QJsonObject();
- ESMPropTemp->insert("key","fTecEndFreqMhz");
- ESMPropTemp->insert("value",10000);
- ESMCtrlParams->append(*ESMPropTemp);
- delete ESMPropTemp;
- }
- QJsonObject *ESMParams = new QJsonObject();
- ESMParams->insert("InitParams", *ESMInitParams);
- ESMParams->insert("CtrlParams", *ESMCtrlParams);
- QJsonObject *ret = new QJsonObject();
- ret->insert("url", obj.value("url"));
- ret->insert("PlatformID", obj.value("PlatformID"));
- ret->insert("InstanceID", InstanceID);
- ret->insert("data", *ESMParams);
- emit SigReturnData(pSender, ret);
- delete ESMInitParams;
- delete ESMCtrlParams;
- delete ESMParams;
- }
|