wsserver.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef WSSERVER_H
  2. #define WSSERVER_H
  3. #include <QObject>
  4. #include <QList>
  5. #include <QByteArray>
  6. #include <QJsonArray>
  7. #include <QJsonDocument>
  8. #include <QJsonObject>
  9. #include <QJsonValue>
  10. #include <QJsonParseError>
  11. #include "QtWebSockets/QWebSocketServer"
  12. #include "QtWebSockets/QWebSocket"
  13. struct EsmWorkParaStruct
  14. {
  15. // 工作状态 0: stby 1: 工作
  16. uint32_t uRrPowerOn;
  17. // 0: 全面搜索模式,1 精测向模式
  18. uint32_t uRrWorkMode;
  19. //侦察方位中心,机体系,单位:deg
  20. double dScanAzCentDeg;
  21. //侦察方位范围,单位:deg
  22. double dScanAzWidthDeg;
  23. //侦察俯仰中心,机体系,单位:deg
  24. double dScanElCentDeg;
  25. //一个景福所拥有的行数
  26. uint32_t uLineNumPerFrame;
  27. //天线扫描速度,单位:deg/s
  28. float fAntScanVel;
  29. //频率扫描速度,单位:MHz/s
  30. float fFreqScanVel;
  31. //侦收起始频率,如2000MHz
  32. float fTecBeginFreqMhz;
  33. //侦收终止频率,如18000MHz
  34. float fTecEndFreqMhz;
  35. };
  36. class WSServer : public QObject
  37. {
  38. Q_OBJECT
  39. public:
  40. QWebSocketServer *m_pWebSocketServer;
  41. QList<QWebSocket *> m_clients;
  42. EsmWorkParaStruct EsmworkPara;
  43. explicit WSServer(QObject *parent = nullptr, quint16 port = 80);
  44. virtual ~WSServer();
  45. signals:
  46. public slots:
  47. void onNewConnection();
  48. QJsonObject processJsonObj(QJsonObject objin);
  49. void processMessage(QString message);
  50. void socketDisconnected();
  51. void returnMessage(QWebSocket *pSender, QJsonObject *jsonObj);
  52. // 初始化状态接口
  53. void getInit(QWebSocket *pSender, QJsonObject obj);
  54. // 平台表接口
  55. void getPlatformTable(QWebSocket *pSender, QJsonObject obj);
  56. // 任务管理显控接口
  57. void getLeadPost(QWebSocket *pSender, QJsonObject obj);
  58. void getTaskPlan(QWebSocket *pSender, QJsonObject obj);
  59. // 态势显控接口
  60. void getLocalMap(QWebSocket *pSender, QJsonObject obj);
  61. void getRemoteMap(QWebSocket *pSender, QJsonObject obj);
  62. void getCombineMap(QWebSocket *pSender, QJsonObject obj);
  63. void getGlobalMap(QWebSocket *pSender, QJsonObject obj);
  64. // 雷侦、通侦显控接口
  65. void getESMInstances(QWebSocket *pSender, QJsonObject obj);
  66. void setESMParams(QWebSocket *pSender, QJsonObject obj);
  67. void getESMParams(QWebSocket *pSender, QJsonObject obj);
  68. void getESMStatus(QWebSocket *pSender, QJsonObject obj);
  69. void getESMData(QWebSocket *pSender, QJsonObject obj);
  70. void getNavParams(QWebSocket *pSender, QJsonObject obj);
  71. void setFreePost(QWebSocket *pSender, QJsonObject obj);
  72. };
  73. #endif // WSSERVER_H