|
@@ -35,15 +35,20 @@ SimulationControl::SimulationControl(QObject *parent) : QObject(parent)
|
|
|
enemyThaadRadarSim.insert(std::pair<int, Radar*>(13, radar2));
|
|
|
|
|
|
|
|
|
- // 添加干扰机
|
|
|
- allyJammingSim.insert(std::pair<int, Jamming*>
|
|
|
- (20, new Jamming(this, 1001, 20, true, QString::fromLocal8Bit("干扰器1"))));
|
|
|
- allyJammingSim.insert(std::pair<int, Jamming*>
|
|
|
- (21, new Jamming(this, 1002, 21, true, QString::fromLocal8Bit("干扰器1"))));
|
|
|
- allyJammingSim.insert(std::pair<int, Jamming*>
|
|
|
- (22, new Jamming(this, 1003, 22, true, QString::fromLocal8Bit("干扰器1"))));
|
|
|
- allyJammingSim.insert(std::pair<int, Jamming*>
|
|
|
- (23, new Jamming(this, 1004, 23, true, QString::fromLocal8Bit("干扰器1"))));
|
|
|
+ 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)
|
|
@@ -668,7 +673,7 @@ void SimulationControl::SlotSetThaadStyle(QWebSocket *pSender, QJsonObject obj)
|
|
|
|
|
|
void SimulationControl::SlotGetJammingInstances(QWebSocket *pSender, QJsonObject obj)
|
|
|
{
|
|
|
- int nowPlatform = obj.value("PlatformID").toInt();
|
|
|
+ int nowPlatform = obj.value("PlatformID").toString().toInt();
|
|
|
|
|
|
QJsonArray JammingInstances;
|
|
|
|
|
@@ -703,14 +708,13 @@ void SimulationControl::SlotGetJammingInstances(QWebSocket *pSender, QJsonObject
|
|
|
|
|
|
void SimulationControl::SlotGetJammingParams(QWebSocket *pSender, QJsonObject obj)
|
|
|
{
|
|
|
- int nowInstance = obj.value("InstanceID").toInt();
|
|
|
-
|
|
|
- Radar *nowRadar = enemyThaadRadarSim.at(nowInstance);
|
|
|
-
|
|
|
- if (true || nowRadar->PlatformID == obj.value("PlatformID").toInt())
|
|
|
+ int nowInstance = obj.value("InstanceID").toString().toInt();
|
|
|
+ Jamming *nowJamming = allyJammingSim.at(nowInstance);
|
|
|
+ if (true || nowJamming->PlatformID == obj.value("PlatformID").toString().toInt())
|
|
|
{
|
|
|
- int styleIdx = nowRadar->style;
|
|
|
- Style nowStyle = nowRadar->RadarStyleList.at(styleIdx);
|
|
|
+ int styleIdx = nowJamming->style;
|
|
|
+ qDebug() << styleIdx;
|
|
|
+ JammingStyle nowStyle = nowJamming->JammingStyleList.at(styleIdx);
|
|
|
|
|
|
QJsonObject nowfs
|
|
|
{
|
|
@@ -722,38 +726,13 @@ void SimulationControl::SlotGetJammingParams(QWebSocket *pSender, QJsonObject ob
|
|
|
{"key", QString::fromLocal8Bit("载波频率")},
|
|
|
{"value", nowStyle.fc}
|
|
|
};
|
|
|
- QJsonObject nowModuType
|
|
|
+ QJsonObject nowOpMode
|
|
|
{
|
|
|
{"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}
|
|
|
+ {"value", nowStyle.OpMode}
|
|
|
};
|
|
|
|
|
|
- QJsonArray nowParams = {nowfs, nowfc, nowModuType, nowPRFMode, nowPRF, nowPW, nowBW};
|
|
|
+ QJsonArray nowParams = {nowfs, nowfc, nowOpMode};
|
|
|
|
|
|
QJsonObject *ret = new QJsonObject();
|
|
|
ret->insert("url", obj.value("url"));
|
|
@@ -766,6 +745,64 @@ void SimulationControl::SlotGetJammingParams(QWebSocket *pSender, QJsonObject ob
|
|
|
|
|
|
}
|
|
|
|
|
|
+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();
|