simulationcontrol.cpp 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  1. #include "simulationcontrol.h"
  2. SimulationControl::SimulationControl(QObject *parent) : QObject(parent)
  3. {
  4. // 添加场景平台
  5. allyplane.push_back(new Platform(this, 1001, QString::fromLocal8Bit("干扰机_1"),120,27,8000,-200,200,-300));
  6. allyplane.push_back(new Platform(this, 1002, QString::fromLocal8Bit("干扰机_2"),120.3,27,8000,-200,200,-300));
  7. allyplane.push_back(new Platform(this, 1003, QString::fromLocal8Bit("干扰机_3"),120,27.3,8000,-200,200,-300));
  8. allyplane.push_back(new Platform(this, 1004, QString::fromLocal8Bit("干扰机_4"),120.3,27.3,8000,-200,200,-300));
  9. allymissile.push_back(new Platform(this, 2001, QString::fromLocal8Bit("弹道导弹1"),117,33,0));
  10. allymissile.push_back(new Platform(this, 2001, QString::fromLocal8Bit("弹道导弹2"),117,33,0));
  11. allymissile.push_back(new Platform(this, 2001, QString::fromLocal8Bit("弹道导弹3"),117,33,0));
  12. allymissile.push_back(new Platform(this, 2001, QString::fromLocal8Bit("弹道导弹4"),117,33,0));
  13. ally.push_back(allyplane);
  14. ally.push_back(allymissile);
  15. enemyradar.push_back(new Platform(this,6001,QString::fromLocal8Bit("Thaad系统1"),121,24.5,0));
  16. enemyradar.push_back(new Platform(this,6002,QString::fromLocal8Bit("Thaad系统2"),121,22.5,0));
  17. enemy.push_back(enemyradar);
  18. enemy.push_back(enemysat);
  19. // 添加雷达模拟器
  20. Radar *radar1 = new Radar(this, 6001, 12, true, QString::fromLocal8Bit("AN-TPY/2雷达-1"),
  21. QStringLiteral("ws://localhost:1235"));
  22. Radar *radar2 = new Radar(this, 6002, 13, false, QString::fromLocal8Bit("AN-TPY/2雷达-2"),
  23. QStringLiteral("ws://localhost:1236"));
  24. // connect(this,&SimulationControl::SigRadarStyleUpdate,
  25. // radar1,&Radar::StyleUpdate);
  26. // connect(this,&SimulationControl::SigRadarStyleUpdate,
  27. // radar2,&Radar::StyleUpdate);
  28. enemyThaadRadarSim.insert(std::pair<int, Radar*>(12, radar1));
  29. enemyThaadRadarSim.insert(std::pair<int, Radar*>(13, radar2));
  30. // 添加干扰机
  31. allyJammingSim.insert(std::pair<int, Jamming*>
  32. (20, new Jamming(this, 1001, 20, true, QString::fromLocal8Bit("干扰器1"))));
  33. allyJammingSim.insert(std::pair<int, Jamming*>
  34. (21, new Jamming(this, 1002, 21, true, QString::fromLocal8Bit("干扰器1"))));
  35. allyJammingSim.insert(std::pair<int, Jamming*>
  36. (22, new Jamming(this, 1003, 22, true, QString::fromLocal8Bit("干扰器1"))));
  37. allyJammingSim.insert(std::pair<int, Jamming*>
  38. (23, new Jamming(this, 1004, 23, true, QString::fromLocal8Bit("干扰器1"))));
  39. }
  40. void SimulationControl::SlotGetInit(QWebSocket *pSender, QJsonObject obj)
  41. {
  42. qDebug() << "Build with Slot";
  43. QJsonObject *InitState = new QJsonObject();
  44. InitState->insert("InitState", 100);
  45. QJsonObject *ret = new QJsonObject();
  46. ret->insert("url", obj.value("url"));
  47. ret->insert("data", *InitState);
  48. delete InitState;
  49. emit SigReturnData(pSender, ret);
  50. }
  51. void SimulationControl::SlotGetLeadPost(QWebSocket *pSender, QJsonObject obj)
  52. {
  53. QJsonArray *LeadPost = new QJsonArray();
  54. QJsonObject *CurrentLeadPost;
  55. CurrentLeadPost = new QJsonObject();
  56. CurrentLeadPost->insert("time", "20:20:01");
  57. CurrentLeadPost->insert("GroupID", "0001");
  58. CurrentLeadPost->insert("LeaderID", "8013");
  59. CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("发现雷达"));
  60. LeadPost->append(*CurrentLeadPost);
  61. delete CurrentLeadPost;
  62. CurrentLeadPost = new QJsonObject();
  63. CurrentLeadPost->insert("time", "20:20:30");
  64. CurrentLeadPost->insert("GroupID", "0001");
  65. CurrentLeadPost->insert("LeaderID", "8013");
  66. CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("请求施加干扰"));
  67. LeadPost->append(*CurrentLeadPost);
  68. delete CurrentLeadPost;
  69. CurrentLeadPost = new QJsonObject();
  70. CurrentLeadPost->insert("time", "20:20:40");
  71. CurrentLeadPost->insert("GroupID", "0003");
  72. CurrentLeadPost->insert("LeaderID", "8014");
  73. CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("干扰样式生成"));
  74. LeadPost->append(*CurrentLeadPost);
  75. delete CurrentLeadPost;
  76. CurrentLeadPost = new QJsonObject();
  77. CurrentLeadPost->insert("time", "20:21:00");
  78. CurrentLeadPost->insert("GroupID", "0002");
  79. CurrentLeadPost->insert("LeaderID", "8015");
  80. CurrentLeadPost->insert("Abstract", QString::fromLocal8Bit("干扰信号发射"));
  81. LeadPost->append(*CurrentLeadPost);
  82. delete CurrentLeadPost;
  83. QJsonObject *ret = new QJsonObject();
  84. ret->insert("url", obj.value("url"));
  85. ret->insert("PlatformID", obj.value("PlatformID"));
  86. ret->insert("data", *LeadPost);
  87. delete LeadPost;
  88. emit SigReturnData(pSender, ret);
  89. }
  90. void SimulationControl::SlotGetTaskPlan(QWebSocket *pSender, QJsonObject obj)
  91. {
  92. QJsonObject *TaskPlan = new QJsonObject();
  93. QJsonObject *CurrentAirLine;
  94. QJsonObject *CurrentTaskPlan;
  95. CurrentAirLine = new QJsonObject;
  96. CurrentAirLine->insert("TargetArea", 3);
  97. CurrentAirLine->insert("Longitude", 123);
  98. CurrentAirLine->insert("Longitude", 27);
  99. CurrentAirLine->insert("Radius", 300000);
  100. CurrentTaskPlan = new QJsonObject;
  101. CurrentTaskPlan->insert("TargetArea", 2);
  102. CurrentTaskPlan->insert("ThrowGas", 2);
  103. CurrentTaskPlan->insert("ThrowBT", 2);
  104. TaskPlan->insert("Airline", *CurrentAirLine);
  105. TaskPlan->insert("TaskPlan", *CurrentTaskPlan);
  106. QJsonObject *ret = new QJsonObject();
  107. ret->insert("url", obj.value("url"));
  108. ret->insert("PlatformID", obj.value("PlatformID"));
  109. ret->insert("data", *TaskPlan);
  110. delete TaskPlan;
  111. delete CurrentAirLine;
  112. delete CurrentTaskPlan;
  113. emit SigReturnData(pSender, ret);
  114. }
  115. void SimulationControl::SlotGetGlobalMap(QWebSocket *pSender, QJsonObject obj)
  116. {
  117. QJsonObject GlobalMap;
  118. // QJsonObject *alies = new QJsonObject();
  119. // QJsonObject *enemys = new QJsonObject();
  120. QJsonObject allies;
  121. QJsonObject enemys;
  122. for (int i=0; i < ally.size(); i++)
  123. {
  124. QJsonArray allyNow;
  125. for (auto j: ally.at(i))
  126. {
  127. QJsonArray temparray = {j->lon, j->lat, j->h};
  128. QJsonObject tempObject
  129. {
  130. {"name", j->Name},
  131. {"value", temparray}
  132. };
  133. allyNow.append(tempObject);
  134. }
  135. if (i == 0)
  136. {
  137. allies.insert("Planes", allyNow);
  138. }
  139. else if (i == 1)
  140. {
  141. allies.insert("Missiles",allyNow);
  142. }
  143. }
  144. for (int i=0; i < enemy.size(); i++)
  145. {
  146. QJsonArray enemyNow;
  147. for (auto j: enemy.at(i))
  148. {
  149. QJsonArray temparray = {j->lon, j->lat, j->h};
  150. QJsonObject tempObject
  151. {
  152. {"name", j->Name},
  153. {"value", temparray}
  154. };
  155. enemyNow.append(tempObject);
  156. }
  157. if (i == 0)
  158. {
  159. enemys.insert("Radars", enemyNow);
  160. }
  161. }
  162. GlobalMap.insert("friend", QJsonValue(allies));
  163. GlobalMap.insert("enemy", QJsonValue(enemys));
  164. QJsonObject *ret = new QJsonObject();
  165. ret->insert("url", obj.value("url"));
  166. ret->insert("PlatformID", obj.value("PlatformID"));
  167. ret->insert("data",QJsonValue(GlobalMap));
  168. emit SigReturnData(pSender, ret);
  169. }
  170. void SimulationControl::SlotGetPlatformTable(QWebSocket *pSender, QJsonObject obj)
  171. {
  172. QJsonArray Platforms;
  173. for (int i = 0; i < ally.size(); i++)
  174. {
  175. std::vector<Platform *> allyplatforms = ally.at(i);
  176. if (i == 0)
  177. {
  178. for (auto j : allyplatforms)
  179. {
  180. QJsonObject SinglePlatform
  181. {
  182. {"platformID", QString::number(j->ID)},
  183. {"platformName", j->Name}
  184. };
  185. Platforms.append(SinglePlatform);
  186. }
  187. }
  188. }
  189. QJsonObject *ret = new QJsonObject();
  190. ret->insert("url", obj.value("url"));
  191. ret->insert("data",QJsonValue(Platforms));
  192. emit SigReturnData(pSender, ret);
  193. }
  194. void SimulationControl::SlotGetInstanceTable(QWebSocket *pSender, QJsonObject obj)
  195. {
  196. QJsonArray *Instances = new QJsonArray();
  197. QJsonObject *SingleInstance;
  198. if (true)
  199. {
  200. SingleInstance = new QJsonObject();
  201. SingleInstance->insert("instanceID", 22);
  202. SingleInstance->insert("instanceName", QString::fromLocal8Bit("侦察机_1"));
  203. Instances->append(*SingleInstance);
  204. delete SingleInstance;
  205. SingleInstance = new QJsonObject();
  206. SingleInstance->insert("instanceID", 62);
  207. SingleInstance->insert("instanceName", QString::fromLocal8Bit("信号侦察_1"));
  208. Instances->append(*SingleInstance);
  209. delete SingleInstance;
  210. SingleInstance = new QJsonObject();
  211. SingleInstance->insert("instanceID", 96);
  212. SingleInstance->insert("instanceName", QString::fromLocal8Bit("体系增量_1"));
  213. Instances->append(*SingleInstance);
  214. delete SingleInstance;
  215. SingleInstance = new QJsonObject();
  216. SingleInstance->insert("instanceID", 111);
  217. SingleInstance->insert("instanceName", QString::fromLocal8Bit("侦察平台任务系统_1"));
  218. Instances->append(*SingleInstance);
  219. delete SingleInstance;
  220. SingleInstance = new QJsonObject();
  221. SingleInstance->insert("instanceID", 171);
  222. SingleInstance->insert("instanceName", QString::fromLocal8Bit("导航_1"));
  223. Instances->append(*SingleInstance);
  224. delete SingleInstance;
  225. }
  226. QJsonObject *ret = new QJsonObject();
  227. ret->insert("url", obj.value("url"));
  228. ret->insert("PlatformID", obj.value("PlatformID"));
  229. ret->insert("data",QJsonValue(*Instances));
  230. delete Instances;
  231. emit SigReturnData(pSender, ret);
  232. }
  233. void SimulationControl::SlotGetRadarInstances(QWebSocket *pSender, QJsonObject obj)
  234. {
  235. int nowPlatform = obj.value("PlatformID").toInt();
  236. QJsonArray RadarInstances;
  237. for (auto i : enemyThaadRadarSim)
  238. {
  239. QJsonObject tempThaad;
  240. if (1 || nowPlatform == i.second->PlatformID)
  241. {
  242. tempThaad.insert("instanceID", QString::number(i.first));
  243. tempThaad.insert("instanceName",i.second->Name);
  244. if (i.second->SwitchMode)
  245. {
  246. tempThaad.insert("instanceState", QString::fromLocal8Bit("开机"));
  247. }
  248. else
  249. {
  250. tempThaad.insert("instanceState", QString::fromLocal8Bit("关机"));
  251. }
  252. }
  253. RadarInstances.append(tempThaad);
  254. }
  255. QJsonObject *ret = new QJsonObject();
  256. ret->insert("url", obj.value("url"));
  257. ret->insert("PlatformID", obj.value("PlatformID"));
  258. ret->insert("data",QJsonValue(RadarInstances));
  259. emit SigReturnData(pSender, ret);
  260. }
  261. void SimulationControl::SlotGetRadarParams(QWebSocket *pSender, QJsonObject obj)
  262. {
  263. int nowInstance = obj.value("InstanceID").toString().toInt();
  264. Radar *nowRadar = enemyThaadRadarSim.at(nowInstance);
  265. if (nowRadar == nullptr)
  266. {
  267. QJsonObject *ret = new QJsonObject();
  268. ret->insert("url", obj.value("url"));
  269. ret->insert("PlatformID", obj.value("PlatformID"));
  270. ret->insert("InstanceID", obj.value("InstanceID"));
  271. ret->insert("data",QJsonValue());
  272. emit SigReturnData(pSender, ret);
  273. }
  274. else if (true || nowRadar->PlatformID == obj.value("PlatformID").toInt())
  275. {
  276. int styleIdx = nowRadar->style;
  277. qDebug() << styleIdx;
  278. Style nowStyle = nowRadar->RadarStyleList.at(styleIdx);
  279. QJsonObject nowfs {
  280. {"key", QString::fromLocal8Bit("采样频率")},
  281. {"value", nowStyle.fs}
  282. };
  283. QJsonObject nowfc {
  284. {"key", QString::fromLocal8Bit("载波频率")},
  285. {"value", nowStyle.fc}
  286. };
  287. QJsonObject nowModuType {
  288. {"key", QString::fromLocal8Bit("调制类型")},
  289. {"value", nowStyle.moduType}
  290. };
  291. QJsonObject nowPRFMode {
  292. {"key", QString::fromLocal8Bit("PRF模式")},
  293. {"value", nowStyle.PRFMode}
  294. };
  295. QJsonArray PRFarray;
  296. for (auto i : nowStyle.PRFs)
  297. {
  298. PRFarray.push_back(i);
  299. }
  300. QJsonObject nowPRF
  301. {
  302. {"key", QString::fromLocal8Bit("PRF")},
  303. {"value", PRFarray}
  304. };
  305. QJsonObject nowPW
  306. {
  307. {"key", QString::fromLocal8Bit("脉冲宽度")},
  308. {"value", nowStyle.PulseWidth}
  309. };
  310. QJsonObject nowBW
  311. {
  312. {"key", QString::fromLocal8Bit("带宽")},
  313. {"value", nowStyle.BandWidth}
  314. };
  315. QJsonArray nowParams = {nowfs, nowfc, nowModuType, nowPRFMode, nowPRF, nowPW, nowBW};
  316. QJsonObject initMaxDis {
  317. {"key", QString::fromLocal8Bit("最大量程")},
  318. {"value", 800000}
  319. };
  320. QJsonObject initMinDis {
  321. {"key", QString::fromLocal8Bit("最小量程")},
  322. {"value", 1000}
  323. };
  324. QJsonObject initMaxFre {
  325. {"key", QString::fromLocal8Bit("最大频率")},
  326. {"value", 12e9}
  327. };
  328. QJsonObject initMinFre {
  329. {"key", QString::fromLocal8Bit("最大频率")},
  330. {"value", 8e9}
  331. };
  332. QJsonObject initNumArrayElement {
  333. {"key", QString::fromLocal8Bit("阵元数")},
  334. {"value", 25344}
  335. };
  336. QJsonObject initGain {
  337. {"key", QString::fromLocal8Bit("天线增益")},
  338. {"value", 48.77}
  339. };
  340. QJsonObject initPt {
  341. {"key", QString::fromLocal8Bit("发射机功率")},
  342. {"value", 405e3}
  343. };
  344. QJsonArray initParams = {initMaxDis, initMinDis, initMaxFre, initMinFre, initNumArrayElement, initGain, initPt};
  345. QJsonObject retParams {
  346. {"InitParams", initParams},
  347. {"CtrlParams", nowParams}
  348. };
  349. QJsonObject *ret = new QJsonObject({
  350. {"url", obj.value("url")},
  351. {"PlatformID", obj.value("PlatformID")},
  352. {"InstanceID", obj.value("InstanceID")},
  353. {"data",QJsonValue(retParams)}
  354. });
  355. emit SigReturnData(pSender, ret);
  356. }
  357. }
  358. void SimulationControl::SlotGetThaadInstances(QWebSocket *pSender, QJsonObject obj)
  359. {
  360. QJsonArray RadarInstances;
  361. for (auto i : enemyThaadRadarSim)
  362. {
  363. QJsonObject tempThaad;
  364. if (1)
  365. {
  366. tempThaad.insert("instanceID", QString::number(i.first));
  367. tempThaad.insert("instanceName",i.second->Name);
  368. if (i.second->SwitchMode)
  369. {
  370. tempThaad.insert("instanceState", QString::fromLocal8Bit("开机"));
  371. }
  372. else
  373. {
  374. tempThaad.insert("instanceState", QString::fromLocal8Bit("关机"));
  375. }
  376. }
  377. RadarInstances.append(tempThaad);
  378. }
  379. QJsonObject *ret = new QJsonObject();
  380. ret->insert("url", obj.value("url"));
  381. ret->insert("PlatformID", obj.value("PlatformID"));
  382. ret->insert("data",QJsonValue(RadarInstances));
  383. emit SigReturnData(pSender, ret);
  384. }
  385. void SimulationControl::SlotGetThaadParams(QWebSocket *pSender, QJsonObject obj)
  386. {
  387. int nowInstance = obj.value("InstanceID").toString().toInt();
  388. Radar *nowRadar = enemyThaadRadarSim.at(nowInstance);
  389. if (nowRadar == nullptr)
  390. {
  391. QJsonObject *ret = new QJsonObject();
  392. ret->insert("url", obj.value("url"));
  393. ret->insert("PlatformID", obj.value("PlatformID"));
  394. ret->insert("InstanceID", obj.value("InstanceID"));
  395. ret->insert("data",QJsonValue());
  396. emit SigReturnData(pSender, ret);
  397. }
  398. else if (true || nowRadar->PlatformID == obj.value("PlatformID").toInt())
  399. {
  400. int styleIdx = nowRadar->style;
  401. qDebug() << styleIdx;
  402. Style nowStyle = nowRadar->RadarStyleList.at(styleIdx);
  403. QJsonObject nowfs {
  404. {"key", QString::fromLocal8Bit("采样频率")},
  405. {"value", nowStyle.fs}
  406. };
  407. QJsonObject nowfc {
  408. {"key", QString::fromLocal8Bit("载波频率")},
  409. {"value", nowStyle.fc}
  410. };
  411. QJsonObject nowModuType {
  412. {"key", QString::fromLocal8Bit("调制类型")},
  413. {"value", nowStyle.moduType}
  414. };
  415. QJsonObject nowPRFMode {
  416. {"key", QString::fromLocal8Bit("PRF模式")},
  417. {"value", nowStyle.PRFMode}
  418. };
  419. QJsonArray PRFarray;
  420. for (auto i : nowStyle.PRFs)
  421. {
  422. PRFarray.push_back(i);
  423. }
  424. QJsonObject nowPRF
  425. {
  426. {"key", QString::fromLocal8Bit("PRF")},
  427. {"value", PRFarray}
  428. };
  429. QJsonObject nowPW
  430. {
  431. {"key", QString::fromLocal8Bit("脉冲宽度")},
  432. {"value", nowStyle.PulseWidth}
  433. };
  434. QJsonObject nowBW
  435. {
  436. {"key", QString::fromLocal8Bit("带宽")},
  437. {"value", nowStyle.BandWidth}
  438. };
  439. QJsonArray nowParams = {nowfs, nowfc, nowModuType, nowPRFMode, nowPRF, nowPW, nowBW};
  440. QJsonObject initMaxDis {
  441. {"key", QString::fromLocal8Bit("最大量程")},
  442. {"value", 800000}
  443. };
  444. QJsonObject initMinDis {
  445. {"key", QString::fromLocal8Bit("最小量程")},
  446. {"value", 1000}
  447. };
  448. QJsonObject initMaxFre {
  449. {"key", QString::fromLocal8Bit("最大频率")},
  450. {"value", 12e9}
  451. };
  452. QJsonObject initMinFre {
  453. {"key", QString::fromLocal8Bit("最大频率")},
  454. {"value", 8e9}
  455. };
  456. QJsonObject initNumArrayElement {
  457. {"key", QString::fromLocal8Bit("阵元数")},
  458. {"value", 25344}
  459. };
  460. QJsonObject initGain {
  461. {"key", QString::fromLocal8Bit("天线增益")},
  462. {"value", 48.77}
  463. };
  464. QJsonObject initPt {
  465. {"key", QString::fromLocal8Bit("发射机功率")},
  466. {"value", 405e3}
  467. };
  468. QJsonArray initParams = {initMaxDis, initMinDis, initMaxFre, initMinFre, initNumArrayElement, initGain, initPt};
  469. QJsonObject retParams {
  470. {"InitParams", initParams},
  471. {"CtrlParams", nowParams}
  472. };
  473. QJsonObject *ret = new QJsonObject({
  474. {"url", obj.value("url")},
  475. {"PlatformID", obj.value("PlatformID")},
  476. {"InstanceID", obj.value("InstanceID")},
  477. {"data",QJsonValue(retParams)}
  478. });
  479. emit SigReturnData(pSender, ret);
  480. }
  481. }
  482. void SimulationControl::SlotSetThaadStyle(QWebSocket *pSender, QJsonObject obj)
  483. {
  484. // PlatformID和InstanceID是字符串
  485. int nowPlatform = obj.value("PlatformID").toString().toInt();
  486. int nowInstance = obj.value("InstanceID").toString().toInt();
  487. QJsonObject nowdata = obj.value("data").toObject();
  488. if (nowdata.contains("Style"))
  489. {
  490. // Style索引是整型
  491. int nowStyle = nowdata.value("Style").toInt();
  492. // qDebug() << nowPlatform <<" "<< nowInstance << " " << nowStyle;
  493. Radar *nowRadar = enemyThaadRadarSim.at(nowInstance);
  494. if (nowRadar == nullptr)
  495. {
  496. QJsonObject *ret = new QJsonObject();
  497. ret->insert("url", obj.value("url"));
  498. ret->insert("PlatformID", obj.value("PlatformID"));
  499. ret->insert("InstanceID", obj.value("InstanceID"));
  500. ret->insert("data", QJsonValue(""));
  501. emit SigReturnData(pSender, ret);
  502. }
  503. else
  504. {
  505. nowRadar->StyleUpdate(nowStyle);
  506. int styleIdx = nowRadar->style;
  507. qDebug() << styleIdx;
  508. Style nowStyle = nowRadar->RadarStyleList.at(styleIdx);
  509. QJsonObject nowfs {
  510. {"key", QString::fromLocal8Bit("采样频率")},
  511. {"value", nowStyle.fs}
  512. };
  513. QJsonObject nowfc {
  514. {"key", QString::fromLocal8Bit("载波频率")},
  515. {"value", nowStyle.fc}
  516. };
  517. QJsonObject nowModuType {
  518. {"key", QString::fromLocal8Bit("调制类型")},
  519. {"value", nowStyle.moduType}
  520. };
  521. QJsonObject nowPRFMode {
  522. {"key", QString::fromLocal8Bit("PRF模式")},
  523. {"value", nowStyle.PRFMode}
  524. };
  525. QJsonArray PRFarray;
  526. for (auto i : nowStyle.PRFs)
  527. {
  528. PRFarray.push_back(i);
  529. }
  530. QJsonObject nowPRF
  531. {
  532. {"key", QString::fromLocal8Bit("PRF")},
  533. {"value", PRFarray}
  534. };
  535. QJsonObject nowPW
  536. {
  537. {"key", QString::fromLocal8Bit("脉冲宽度")},
  538. {"value", nowStyle.PulseWidth}
  539. };
  540. QJsonObject nowBW
  541. {
  542. {"key", QString::fromLocal8Bit("带宽")},
  543. {"value", nowStyle.BandWidth}
  544. };
  545. QJsonArray nowParams = {nowfs, nowfc, nowModuType, nowPRFMode, nowPRF, nowPW, nowBW};
  546. QJsonObject initMaxDis {
  547. {"key", QString::fromLocal8Bit("最大量程")},
  548. {"value", 800000}
  549. };
  550. QJsonObject initMinDis {
  551. {"key", QString::fromLocal8Bit("最小量程")},
  552. {"value", 1000}
  553. };
  554. QJsonObject initMaxFre {
  555. {"key", QString::fromLocal8Bit("最大频率")},
  556. {"value", 12e9}
  557. };
  558. QJsonObject initMinFre {
  559. {"key", QString::fromLocal8Bit("最大频率")},
  560. {"value", 8e9}
  561. };
  562. QJsonObject initNumArrayElement {
  563. {"key", QString::fromLocal8Bit("阵元数")},
  564. {"value", 25344}
  565. };
  566. QJsonObject initGain {
  567. {"key", QString::fromLocal8Bit("天线增益")},
  568. {"value", 48.77}
  569. };
  570. QJsonObject initPt {
  571. {"key", QString::fromLocal8Bit("发射机功率")},
  572. {"value", 405e3}
  573. };
  574. QJsonArray initParams = {initMaxDis, initMinDis, initMaxFre, initMinFre, initNumArrayElement, initGain, initPt};
  575. QJsonObject retParams {
  576. {"InitParams", initParams},
  577. {"CtrlParams", nowParams}
  578. };
  579. QJsonObject *ret = new QJsonObject({
  580. {"url", obj.value("url")},
  581. {"PlatformID", obj.value("PlatformID")},
  582. {"InstanceID", obj.value("InstanceID")},
  583. {"data",QJsonValue(retParams)}
  584. });
  585. emit SigReturnData(pSender, ret);
  586. }
  587. }
  588. }
  589. void SimulationControl::SlotGetJammingInstances(QWebSocket *pSender, QJsonObject obj)
  590. {
  591. int nowPlatform = obj.value("PlatformID").toInt();
  592. QJsonArray JammingInstances;
  593. for (auto i : allyJammingSim)
  594. {
  595. QJsonObject tempJamming;
  596. if (true || nowPlatform == i.second->PlatformID)
  597. {
  598. tempJamming.insert("instanceID", QString::number(i.first));
  599. tempJamming.insert("instanceName",i.second->Name);
  600. if (i.second->SwitchMode)
  601. {
  602. tempJamming.insert("instanceState", QString::fromLocal8Bit("开机"));
  603. }
  604. else
  605. {
  606. tempJamming.insert("instanceState", QString::fromLocal8Bit("关机"));
  607. }
  608. JammingInstances.append(tempJamming);
  609. }
  610. }
  611. QJsonObject *ret = new QJsonObject();
  612. ret->insert("url", obj.value("url"));
  613. ret->insert("PlatformID", obj.value("PlatformID"));
  614. ret->insert("data",QJsonValue(JammingInstances));
  615. emit SigReturnData(pSender, ret);
  616. }
  617. void SimulationControl::SlotGetJammingParams(QWebSocket *pSender, QJsonObject obj)
  618. {
  619. int nowInstance = obj.value("InstanceID").toInt();
  620. Radar *nowRadar = enemyThaadRadarSim.at(nowInstance);
  621. if (true || nowRadar->PlatformID == obj.value("PlatformID").toInt())
  622. {
  623. int styleIdx = nowRadar->style;
  624. Style nowStyle = nowRadar->RadarStyleList.at(styleIdx);
  625. QJsonObject nowfs
  626. {
  627. {"key", QString::fromLocal8Bit("采样频率")},
  628. {"value", nowStyle.fs}
  629. };
  630. QJsonObject nowfc
  631. {
  632. {"key", QString::fromLocal8Bit("载波频率")},
  633. {"value", nowStyle.fc}
  634. };
  635. QJsonObject nowModuType
  636. {
  637. {"key", QString::fromLocal8Bit("调制类型")},
  638. {"value", nowStyle.moduType}
  639. };
  640. QJsonObject nowPRFMode
  641. {
  642. {"key", QString::fromLocal8Bit("PRF模式")},
  643. {"value", nowStyle.PRFMode}
  644. };
  645. QJsonArray PRFarray;
  646. for (auto i : nowStyle.PRFs)
  647. {
  648. PRFarray.push_back(i);
  649. }
  650. QJsonObject nowPRF
  651. {
  652. {"key", QString::fromLocal8Bit("PRF")},
  653. {"value", PRFarray}
  654. };
  655. QJsonObject nowPW
  656. {
  657. {"key", QString::fromLocal8Bit("脉冲宽度")},
  658. {"value", nowStyle.PulseWidth}
  659. };
  660. QJsonObject nowBW
  661. {
  662. {"key", QString::fromLocal8Bit("带宽")},
  663. {"value", nowStyle.BandWidth}
  664. };
  665. QJsonArray nowParams = {nowfs, nowfc, nowModuType, nowPRFMode, nowPRF, nowPW, nowBW};
  666. QJsonObject *ret = new QJsonObject();
  667. ret->insert("url", obj.value("url"));
  668. ret->insert("PlatformID", obj.value("PlatformID"));
  669. ret->insert("InstanceID", obj.value("InstanceID"));
  670. ret->insert("data",QJsonValue(nowParams));
  671. emit SigReturnData(pSender, ret);
  672. }
  673. }
  674. void SimulationControl::SlotGetESMParams(QWebSocket *pSender, QJsonObject obj)
  675. {
  676. int InstanceID = obj.value("InstanceID").toInt();
  677. QJsonArray *ESMInitParams;
  678. QJsonArray *ESMCtrlParams;
  679. QJsonObject *ESMPropTemp;
  680. if (true)
  681. {
  682. ESMInitParams = new QJsonArray();
  683. ESMCtrlParams = new QJsonArray();
  684. ESMPropTemp = new QJsonObject();
  685. ESMPropTemp->insert("key","fBeamAzWidth");
  686. ESMPropTemp->insert("value",2);
  687. ESMInitParams->append(*ESMPropTemp);
  688. delete ESMPropTemp;
  689. ESMPropTemp = new QJsonObject();
  690. ESMPropTemp->insert("key","fBeamElWidth");
  691. ESMPropTemp->insert("value",2);
  692. ESMInitParams->append(*ESMPropTemp);
  693. delete ESMPropTemp;
  694. ESMPropTemp = new QJsonObject();
  695. ESMPropTemp->insert("key","fTecMinFreqMhz");
  696. ESMPropTemp->insert("value",2e3);
  697. ESMInitParams->append(*ESMPropTemp);
  698. delete ESMPropTemp;
  699. ESMPropTemp = new QJsonObject();
  700. ESMPropTemp->insert("key","fTecMaxFreqMhz");
  701. ESMPropTemp->insert("value",18e3);
  702. ESMInitParams->append(*ESMPropTemp);
  703. delete ESMPropTemp;
  704. ESMPropTemp = new QJsonObject();
  705. ESMPropTemp->insert("key","fInstantPageWidMhz");
  706. ESMPropTemp->insert("value",500);
  707. ESMInitParams->append(*ESMPropTemp);
  708. delete ESMPropTemp;
  709. ESMPropTemp = new QJsonObject();
  710. ESMPropTemp->insert("key","ulChanNum");
  711. ESMPropTemp->insert("value",64);
  712. ESMInitParams->append(*ESMPropTemp);
  713. delete ESMPropTemp;
  714. ESMPropTemp = new QJsonObject();
  715. ESMPropTemp->insert("key","fTecMinPW");
  716. ESMPropTemp->insert("value",0.5);
  717. ESMInitParams->append(*ESMPropTemp);
  718. delete ESMPropTemp;
  719. ESMPropTemp = new QJsonObject();
  720. ESMPropTemp->insert("key","fTecMaxPW");
  721. ESMPropTemp->insert("value",10);
  722. ESMInitParams->append(*ESMPropTemp);
  723. delete ESMPropTemp;
  724. ESMPropTemp = new QJsonObject();
  725. ESMPropTemp->insert("key","fTecPriMean");
  726. ESMPropTemp->insert("value",40);
  727. ESMInitParams->append(*ESMPropTemp);
  728. delete ESMPropTemp;
  729. ESMPropTemp = new QJsonObject();
  730. ESMPropTemp->insert("key","ulTecTrNumMean");
  731. ESMPropTemp->insert("value",5);
  732. ESMInitParams->append(*ESMPropTemp);
  733. delete ESMPropTemp;
  734. ESMPropTemp = new QJsonObject();
  735. ESMPropTemp->insert("key","fMinSnrdB");
  736. ESMPropTemp->insert("value",0.5);
  737. ESMInitParams->append(*ESMPropTemp);
  738. delete ESMPropTemp;
  739. ESMPropTemp = new QJsonObject();
  740. ESMPropTemp->insert("key","fSysRcvLoss");
  741. ESMPropTemp->insert("value",5);
  742. ESMInitParams->append(*ESMPropTemp);
  743. delete ESMPropTemp;
  744. ESMPropTemp = new QJsonObject();
  745. ESMPropTemp->insert("key","fFreqAccuracyReq");
  746. ESMPropTemp->insert("value",100);
  747. ESMInitParams->append(*ESMPropTemp);
  748. delete ESMPropTemp;
  749. ESMPropTemp = new QJsonObject();
  750. ESMPropTemp->insert("key","uRrPowerOn");
  751. ESMPropTemp->insert("value",0);
  752. ESMCtrlParams->append(*ESMPropTemp);
  753. delete ESMPropTemp;
  754. ESMPropTemp = new QJsonObject();
  755. ESMPropTemp->insert("key","uRrWorkMode");
  756. ESMPropTemp->insert("value",0);
  757. ESMCtrlParams->append(*ESMPropTemp);
  758. delete ESMPropTemp;
  759. ESMPropTemp = new QJsonObject();
  760. ESMPropTemp->insert("key","dScanAzCentDeg");
  761. ESMPropTemp->insert("value",0);
  762. ESMCtrlParams->append(*ESMPropTemp);
  763. delete ESMPropTemp;
  764. ESMPropTemp = new QJsonObject();
  765. ESMPropTemp->insert("key","dScanAzWidthDeg");
  766. ESMPropTemp->insert("value",5);
  767. ESMCtrlParams->append(*ESMPropTemp);
  768. delete ESMPropTemp;
  769. ESMPropTemp = new QJsonObject();
  770. ESMPropTemp->insert("key","dScanElCentDeg");
  771. ESMPropTemp->insert("value",0);
  772. ESMCtrlParams->append(*ESMPropTemp);
  773. delete ESMPropTemp;
  774. ESMPropTemp = new QJsonObject();
  775. ESMPropTemp->insert("key","uLineNumPerFrame");
  776. ESMPropTemp->insert("value",20);
  777. ESMCtrlParams->append(*ESMPropTemp);
  778. delete ESMPropTemp;
  779. ESMPropTemp = new QJsonObject();
  780. ESMPropTemp->insert("key","fAntScanVel");
  781. ESMPropTemp->insert("value",1);
  782. ESMCtrlParams->append(*ESMPropTemp);
  783. delete ESMPropTemp;
  784. ESMPropTemp = new QJsonObject();
  785. ESMPropTemp->insert("key","fFreqScanVel");
  786. ESMPropTemp->insert("value",100);
  787. ESMCtrlParams->append(*ESMPropTemp);
  788. delete ESMPropTemp;
  789. ESMPropTemp = new QJsonObject();
  790. ESMPropTemp->insert("key","fTecBeginFreqMhz");
  791. ESMPropTemp->insert("value",500);
  792. ESMCtrlParams->append(*ESMPropTemp);
  793. delete ESMPropTemp;
  794. ESMPropTemp = new QJsonObject();
  795. ESMPropTemp->insert("key","fTecEndFreqMhz");
  796. ESMPropTemp->insert("value",10000);
  797. ESMCtrlParams->append(*ESMPropTemp);
  798. delete ESMPropTemp;
  799. }
  800. QJsonObject *ESMParams = new QJsonObject();
  801. ESMParams->insert("InitParams", *ESMInitParams);
  802. ESMParams->insert("CtrlParams", *ESMCtrlParams);
  803. QJsonObject *ret = new QJsonObject();
  804. ret->insert("url", obj.value("url"));
  805. ret->insert("PlatformID", obj.value("PlatformID"));
  806. ret->insert("InstanceID", InstanceID);
  807. ret->insert("data", *ESMParams);
  808. emit SigReturnData(pSender, ret);
  809. delete ESMInitParams;
  810. delete ESMCtrlParams;
  811. delete ESMParams;
  812. }