12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076 |
- #include "simulationcontrol.h"
- SimulationControl::SimulationControl(QObject *parent) : QObject(parent)
- {
- // 想定文件路径
- QFile file(QString::fromLocal8Bit("C:\\Users\\luo_h\\Downloads\\突防想定002.json"));
- if (!file.open(QFile::ReadOnly | QFile::Text)) {
- qDebug() << "can't open error!";
- return;
- }
- // 读取文件的全部内容
- QTextStream stream(&file);
- stream.setCodec("UTF-8"); // 设置读取编码是UTF8
- QString str = stream.readAll();
- file.close();
- // QJsonParseError类用于在JSON解析期间报告错误。
- QJsonParseError jsonError;
- // 将json解析为UTF-8编码的json文档,并从中创建一个QJsonDocument。
- // 如果解析成功,返回QJsonDocument对象,否则返回null
- QJsonDocument doc = QJsonDocument::fromJson(str.toUtf8(), &jsonError);
- // 判断是否解析失败
- if (jsonError.error != QJsonParseError::NoError && !doc.isNull()) {
- qDebug() << "Json格式错误!" << jsonError.error;
- return;
- }
- qDebug() << QString::fromLocal8Bit("想定文件读取成功");
- if (doc.isObject()) {
- QJsonObject docobj = doc.object();
- qDebug() << QString::fromLocal8Bit("想定编号:") << docobj.value("id").toString();
- qDebug() << QString::fromLocal8Bit("想定名称:") << docobj.value("xdname").toString();
- qDebug() << QString::fromLocal8Bit("想定类型:") << docobj.value("type").toString();
- qDebug() << QString::fromLocal8Bit("开始时间:") << docobj.value("starttime").toString();
- qDebug() << QString::fromLocal8Bit("结束时间:") << docobj.value("endtime").toString();
- qDebug() << QString::fromLocal8Bit("仿真步长:") << docobj.value("steptime").toDouble();
- int redcnt = docobj.value("redcnt").toInt();
- int bluecnt = docobj.value("bluecnt").toInt();
- qDebug() << QString::fromLocal8Bit("红方作战单元数:") << redcnt;
- QJsonArray redunits = docobj.value("redunit").toArray();
- for (int i = 0; i < redcnt; i++) {
- QJsonObject unit = redunits.at(i).toObject();
- int unitid = unit.value("unitID").toInt();
- QString unitType = unit.value("type").toString();
- QString unitName = unit.value("name").toString();
- QString unitTask = unit.value("task").toString();
- int unitMovementID = unit.value("component_movementid").toInt();
- if (i == 0) {
- allymissile.push_back(new Platform(this, unitid, unitName, 120,27, 8000, -600, 600, -900));
- }
- else {
- allymissile.push_back(new Platform(this, unitid, unitName, 120.5,27.5, 8000, -600, 600, -900));
- }
- qDebug() << "\t" << QString::fromLocal8Bit("初始化作战单元:") << unitid << unitName;
- qDebug() << "\t" << QString::fromLocal8Bit("作战单元类型:") << unitType;
- qDebug() << "\t" << QString::fromLocal8Bit("作战单元意图:") << unitTask;
- qDebug() << "\t" << QString::fromLocal8Bit("作战单元运动模型ID:") << unitMovementID;
- int componentCnt = unit.value("components_ids").toInt();
- QJsonObject componentsJson = unit.value("components_json").toObject();
- for (auto i : componentsJson.keys())
- {
- QJsonObject componentNow = componentsJson.value(i).toObject();
- int componentID = componentNow.value("id").toInt();
- QString componentName = componentNow.value("number").toString();
- QString componentType = componentNow.value("type").toString();
- QString componentUrl = componentNow.value("url").toString();
- Jamming *jammingtmp = new Jamming(this, unitid, componentID, true, componentName,
- componentUrl, 1);
- allyJammingSim.insert(std::pair<int, Jamming*>(componentID, jammingtmp));
- qDebug() << "\t\t" << QString::fromLocal8Bit("初始化单元组件:") << i << componentID << (componentName);
- qDebug() << "\t\t" << QString::fromLocal8Bit("单元组件类型:") << (componentType) << (componentUrl);
- }
- }
- qDebug() << QString::fromLocal8Bit("蓝方作战单元数:") << ":" << bluecnt;
- QJsonArray blueunits = docobj.value("blueunit").toArray();
- for (int i = 0; i < bluecnt; i++) {
- QJsonObject unit = blueunits.at(i).toObject();
- int unitid = unit.value("unitID").toInt();
- QString unitType = unit.value("type").toString();
- QString unitName = unit.value("name").toString();
- QString unitTask = unit.value("task").toString();
- int unitMovementID = unit.value("component_movementid").toInt();
- qDebug() << "\t" << QString::fromLocal8Bit("初始化作战单元:") << unitid << unitName;
- qDebug() << "\t" << QString::fromLocal8Bit("作战单元类型:") << unitType;
- qDebug() << "\t" << QString::fromLocal8Bit("作战单元意图:") << unitTask;
- qDebug() << "\t" << QString::fromLocal8Bit("作战单元运动模型ID:") << unitMovementID;
- if (unitType.compare(QString::fromLocal8Bit("末端拦截系统"))==0) {
- if (i == 0) {
- enemyradar.push_back(new Platform(this,unitid,unitName,121,24.5,0));
- }
- else {
- enemyradar.push_back(new Platform(this,unitid,unitName,121,22.5,0));
- }
- }
- else if (unitType.compare(QString::fromLocal8Bit("预警卫星"))==0){
- // ...
- enemysat.push_back(new Platform(this,unitid,unitName));
- }
- int componentCnt = unit.value("components_ids").toInt();
- QJsonObject componentsJson = unit.value("components_json").toObject();
- for (auto i : componentsJson.keys())
- {
- QJsonObject componentNow = componentsJson.value(i).toObject();
- int componentID = componentNow.value("id").toInt();
- QString componentName = componentNow.value("name").toString();
- QString componentType = componentNow.value("type").toString();
- QString componentUrl = componentNow.value("url").toString();
- if (componentType.compare(QString::fromLocal8Bit("雷达"))==0)
- {
- Radar *radarNow = new Radar(this, unitid, componentID, true, componentName,
- componentUrl);
- enemyThaadRadarSim.insert(std::pair<int, Radar*>(componentID, radarNow));
- }
- else
- {
- // ...
- }
- qDebug() << "\t\t" << QString::fromLocal8Bit("初始化单元组件:") << i << componentID << (componentName);
- qDebug() << "\t\t" << QString::fromLocal8Bit("单元组件类型:") << (componentType) << (componentUrl);
- }
- }
- }
- qDebug() << QString::fromLocal8Bit("启动推演...");
- // 添加场景平台
- // allyplane.push_back(new Platform(this, 1001, QString::fromLocal8Bit("弹道导弹1"),120,27,8000,-600,600,-900));
- // allymissile.push_back(new Platform(this, 1004, QString::fromLocal8Bit("弹道导弹4"),120.3,27.3,8000,-600,600,-900));
- ally.push_back(allyplane);
- ally.push_back(allymissile);
- 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"));
- // enemyThaadRadarSim.insert(std::pair<int, Radar*>(12, radar1));
- // // 添加干扰器
- // Jamming *jamming1 = new Jamming(this, 1001, 20, true, QString::fromLocal8Bit("干扰器1"),
- // QStringLiteral("ws://localhost:1240"),1);
- // allyJammingSim.insert(std::pair<int, Jamming*>(20, jamming1));
- }
- 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", QString::fromLocal8Bit("编队1"));
- CurrentLeadPost->insert("LeaderID", "1001");
- CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("发现雷达"));
- LeadPost->append(*CurrentLeadPost);
- delete CurrentLeadPost;
- CurrentLeadPost = new QJsonObject();
- CurrentLeadPost->insert("time", "20:20:30");
- CurrentLeadPost->insert("GroupID", QString::fromLocal8Bit("编队1"));
- CurrentLeadPost->insert("LeaderID", "1002");
- CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("请求施加干扰"));
- LeadPost->append(*CurrentLeadPost);
- delete CurrentLeadPost;
- CurrentLeadPost = new QJsonObject();
- CurrentLeadPost->insert("time", "20:20:40");
- CurrentLeadPost->insert("GroupID", QString::fromLocal8Bit("编队1"));
- CurrentLeadPost->insert("LeaderID", "1002");
- CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("干扰样式生成"));
- LeadPost->append(*CurrentLeadPost);
- delete CurrentLeadPost;
- CurrentLeadPost = new QJsonObject();
- CurrentLeadPost->insert("time", "20:21:00");
- CurrentLeadPost->insert("GroupID", QString::fromLocal8Bit("编队1"));
- CurrentLeadPost->insert("LeaderID", "1003");
- 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 (true || i == 0) // for simplicity
- {
- 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;
- }
|