完善了干扰体系,完善了集成测试程序。
This commit is contained in:
parent
2b5b803402
commit
5e61f357b4
@ -120,7 +120,7 @@ namespace ThreatSource.Tests.Indicator
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser,
|
||||
Duration = null
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(10, 10, 0), // 更靠近探测器,且角度更小
|
||||
Direction = new Vector3D(0, 1, 0), // 45度角指向探测器
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
@ -108,7 +108,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 150, 0), // 位于上方
|
||||
Direction = new Vector3D(0, 0, 1), // 指向前方,不是指向探测器
|
||||
AngleRange = 0.1, // 很小的角度范围
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
};
|
||||
@ -135,7 +135,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 100, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
};
|
||||
@ -162,7 +162,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(10, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
@ -199,7 +199,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(10, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
@ -213,7 +213,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_infraredDetector.IsJammed, "红外探测器应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_infraredDetector.ClearJamming(JammingType.Infrared);
|
||||
_infraredDetector.ClearJamming(jammingEvent.Parameters);
|
||||
_infraredDetector.Update(0.1);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -255,7 +255,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 100, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
};
|
||||
|
||||
@ -107,7 +107,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0), // 修改为50米,与激光指示器一致
|
||||
Direction = new Vector3D(1, 0, 0), // 修改为(1,0,0),指向设备的方向
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
@ -148,7 +148,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 50, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = 0.1,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
};
|
||||
@ -184,7 +184,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
};
|
||||
@ -220,7 +220,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0), // 修改为50米,与激光指示器一致
|
||||
Direction = new Vector3D(1, 0, 0), // 修改为(1,0,0),指向设备的方向
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
@ -267,7 +267,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0), // 修改为50米,与激光指示器一致
|
||||
Direction = new Vector3D(1, 0, 0), // 修改为(1,0,0),指向设备的方向
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
@ -281,7 +281,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_guidanceSystem.IsJammed, "红外引导系统应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_guidanceSystem.ClearJamming(JammingType.Infrared);
|
||||
_guidanceSystem.ClearJamming(jammingEvent.Parameters);
|
||||
_guidanceSystem.Update(0.1, initialPosition, initialVelocity);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -311,7 +311,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0), // 修改为50米,与激光指示器一致
|
||||
Direction = new Vector3D(1, 0, 0), // 修改为(1,0,0),指向设备的方向
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Infrared
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0), // 指向跟踪器
|
||||
AngleRange = Math.PI / 4, // 45度角
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null // 持续干扰
|
||||
}
|
||||
};
|
||||
@ -101,7 +101,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 50, 0), // 位于上方
|
||||
Direction = new Vector3D(0, 0, 1), // 指向前方,不是指向跟踪器
|
||||
AngleRange = 0.1, // 很小的角度范围
|
||||
Mode = JammingMode.Noise
|
||||
Mode = JammingMode.Blocking
|
||||
}
|
||||
};
|
||||
|
||||
@ -131,7 +131,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise
|
||||
Mode = JammingMode.Blocking
|
||||
}
|
||||
};
|
||||
|
||||
@ -159,7 +159,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise
|
||||
Mode = JammingMode.Blocking
|
||||
}
|
||||
};
|
||||
|
||||
@ -187,7 +187,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise
|
||||
Mode = JammingMode.Blocking
|
||||
}
|
||||
};
|
||||
|
||||
@ -215,7 +215,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5 // 0.5秒后过期
|
||||
}
|
||||
};
|
||||
@ -256,7 +256,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null // 持续干扰
|
||||
}
|
||||
};
|
||||
@ -269,7 +269,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_infraredTracker.IsJammed, "红外测角仪应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_infraredTracker.ClearJamming(JammingType.Infrared);
|
||||
_infraredTracker.ClearJamming(jammingEvent.Parameters);
|
||||
_infraredTracker.Update(0.1);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -295,7 +295,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise
|
||||
Mode = JammingMode.Blocking
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0), // 50米
|
||||
Direction = new Vector3D(1, 0, 0), // 指向设备的方向
|
||||
AngleRange = Math.PI / 4, // 45度
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Wavelength = 1.06,
|
||||
Type = JammingType.Laser
|
||||
@ -174,7 +174,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 50, 0), // 从Y轴方向
|
||||
Direction = new Vector3D(1, 0, 0), // 指向X轴方向
|
||||
AngleRange = 0.1, // 约5.7度
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
@ -217,7 +217,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4, // 45度
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
@ -260,7 +260,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4, // 45度
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5, // 0.5秒
|
||||
Wavelength = 1.06,
|
||||
Type = JammingType.Laser
|
||||
@ -315,7 +315,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4, // 45度
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Wavelength = 1.06,
|
||||
Type = JammingType.Laser
|
||||
@ -330,7 +330,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_guidanceSystem.IsJammed, "激光驾束引导系统应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_guidanceSystem.ClearJamming(JammingType.Laser);
|
||||
_guidanceSystem.ClearJamming(jammingEvent.Parameters);
|
||||
_guidanceSystem.Update(0.1, initialPosition, initialVelocity);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -367,7 +367,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4, // 45度
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Wavelength = 1.06,
|
||||
Type = JammingType.Laser
|
||||
|
||||
@ -88,7 +88,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0), // 指向激光驾束仪
|
||||
AngleRange = Math.PI / 4, // 45度角
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
@ -123,7 +123,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -146,7 +146,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
publishedEvents.Clear();
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_laserBeamRider.ClearJamming(JammingType.Laser);
|
||||
_laserBeamRider.ClearJamming(jammingEvent.Parameters);
|
||||
_laserBeamRider.Update(0.1);
|
||||
|
||||
// Assert - 干扰清除后激光束应该恢复
|
||||
@ -171,7 +171,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5, // 0.5秒后过期
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -213,7 +213,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null, // 持续干扰
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -227,7 +227,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_laserBeamRider.IsJammed, "激光驾束仪应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_laserBeamRider.ClearJamming(JammingType.Laser);
|
||||
_laserBeamRider.ClearJamming(jammingEvent.Parameters);
|
||||
_laserBeamRider.Update(0.1);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -253,7 +253,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Duration = null,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
|
||||
@ -170,11 +170,11 @@ namespace ThreatSource.Tests.Jamming
|
||||
// 创建诱偏目标配置
|
||||
var decoyConfig = new LaserDecoyConfig
|
||||
{
|
||||
DecoyPower = decoyPower,
|
||||
DecoyLaserDivergenceAngle = DefaultDecoyLaserDivergenceAngle,
|
||||
Power = decoyPower,
|
||||
DivergenceAngle = DefaultDecoyLaserDivergenceAngle,
|
||||
ReflectiveArea = DefaultReflectiveArea,
|
||||
ReflectionCoefficient = DefaultReflectionCoefficient,
|
||||
LifeTime = lifeTime
|
||||
Duration = lifeTime
|
||||
};
|
||||
|
||||
// 创建诱偏目标运动参数
|
||||
|
||||
@ -87,7 +87,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(5, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -119,7 +119,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 50, 0), // 位于上方
|
||||
Direction = new Vector3D(0, 0, 1), // 指向前方,不是指向指示器
|
||||
AngleRange = 0.1, // 很小的角度范围
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -151,7 +151,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -181,7 +181,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -211,7 +211,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(5, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -251,7 +251,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(5, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -265,7 +265,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_laserDesignator.IsJammed, "激光指示器应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_laserDesignator.ClearJamming(JammingType.Laser);
|
||||
_laserDesignator.ClearJamming(jammingEvent.Parameters);
|
||||
_laserDesignator.Update(0.1);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -291,7 +291,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(5, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -327,7 +327,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -339,7 +339,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_laserDesignator.IsJammed, "波长匹配时应该被干扰");
|
||||
|
||||
// 清除干扰状态,准备下一个测试
|
||||
_laserDesignator.ClearJamming(JammingType.Laser);
|
||||
_laserDesignator.ClearJamming(matchingJammingEvent.Parameters);
|
||||
_laserDesignator.Update(0.1);
|
||||
|
||||
// 测试2:波长不匹配的情况
|
||||
@ -352,7 +352,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
@ -107,7 +107,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 150, 0), // 位于上方
|
||||
Direction = new Vector3D(0, 0, 1), // 指向前方,不是指向测距仪
|
||||
AngleRange = 0.1, // 很小的角度范围
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
@ -134,7 +134,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
@ -161,7 +161,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
@ -198,7 +198,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
@ -211,7 +211,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_laserRangefinder.IsJammed, "激光测距仪应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_laserRangefinder.ClearJamming(JammingType.Laser);
|
||||
_laserRangefinder.ClearJamming(jammingEvent.Parameters);
|
||||
_laserRangefinder.Update(0.1);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -237,7 +237,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser
|
||||
}
|
||||
};
|
||||
|
||||
@ -115,7 +115,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Wavelength = 1.06,
|
||||
Type = JammingType.Laser
|
||||
@ -157,7 +157,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 50, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = 0.1,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser,
|
||||
Wavelength = 1.06,
|
||||
Duration = null
|
||||
@ -195,7 +195,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.Laser,
|
||||
Wavelength = 1.06,
|
||||
Duration = null
|
||||
@ -233,7 +233,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5,
|
||||
Type = JammingType.Laser,
|
||||
Wavelength = 1.06
|
||||
@ -281,7 +281,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Wavelength = 1.06,
|
||||
Type = JammingType.Laser
|
||||
@ -296,7 +296,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_guidanceSystem.IsJammed, "激光半主动制导系统应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_guidanceSystem.ClearJamming(JammingType.Laser);
|
||||
_guidanceSystem.ClearJamming(jammingEvent.Parameters);
|
||||
_guidanceSystem.Update(0.1, initialPosition, initialVelocity);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -326,7 +326,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Type = JammingType.Laser,
|
||||
Wavelength = 1.06
|
||||
|
||||
@ -80,7 +80,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 6,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -107,7 +107,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 150, 0), // 位于上方
|
||||
Direction = new Vector3D(0, 0, 1), // 指向前方,不是指向测高雷达
|
||||
AngleRange = 0.1, // 很小的角度范围
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -134,7 +134,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 100, 0),
|
||||
Direction = new Vector3D(-1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -161,7 +161,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -188,7 +188,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 120, 0),
|
||||
Direction = new Vector3D(0, -1, 0),
|
||||
AngleRange = Math.PI / 6,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5, // 0.5秒后过期
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
@ -225,7 +225,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 6,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -238,7 +238,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_altimeter.IsJammed, "毫米波测高雷达应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_altimeter.ClearJamming(JammingType.MillimeterWave);
|
||||
_altimeter.ClearJamming(jammingEvent.Parameters);
|
||||
_altimeter.Update(0.1);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -264,7 +264,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 6,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
|
||||
@ -113,7 +113,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Wavelength = 3.19,
|
||||
Type = JammingType.MillimeterWave
|
||||
@ -155,7 +155,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 50, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = 0.1,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave,
|
||||
Wavelength = 3.19
|
||||
}
|
||||
@ -192,7 +192,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise
|
||||
Mode = JammingMode.Blocking
|
||||
}
|
||||
};
|
||||
|
||||
@ -227,7 +227,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5,
|
||||
Type = JammingType.MillimeterWave,
|
||||
Wavelength = 3.19
|
||||
@ -275,7 +275,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Wavelength = 3.19,
|
||||
Type = JammingType.MillimeterWave
|
||||
@ -290,7 +290,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_guidanceSystem.IsJammed, "毫米波制导系统应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_guidanceSystem.ClearJamming(JammingType.MillimeterWave);
|
||||
_guidanceSystem.ClearJamming(jammingEvent.Parameters);
|
||||
_guidanceSystem.Update(0.1, initialPosition, initialVelocity);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -320,7 +320,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(50, 0, 0),
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null,
|
||||
Wavelength = 3.19,
|
||||
Type = JammingType.MillimeterWave
|
||||
|
||||
@ -79,7 +79,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(10, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4, // 45度角
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = null, // 持续干扰
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
@ -107,7 +107,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 150, 0), // 位于上方
|
||||
Direction = new Vector3D(0, 1, 0), // 指向上方,与辐射计方向完全相反
|
||||
AngleRange = 0.01, // 极小的角度范围
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -134,7 +134,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(10, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -161,7 +161,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -188,7 +188,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(10, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 0.5,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
@ -225,7 +225,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(10, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
@ -238,7 +238,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_radiometer.IsJammed, "毫米波辐射计应该处于被干扰状态");
|
||||
|
||||
// Act - 手动清除干扰
|
||||
_radiometer.ClearJamming(JammingType.MillimeterWave);
|
||||
_radiometer.ClearJamming(jammingEvent.Parameters);
|
||||
_radiometer.Update(0.1);
|
||||
|
||||
// Assert - 确认干扰已清除
|
||||
@ -280,7 +280,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI / 4,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
};
|
||||
|
||||
@ -163,7 +163,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_infraredDetector.IsJammed, "红外探测器应该被干扰");
|
||||
|
||||
// 清除干扰
|
||||
_infraredDetector.ClearJamming(JammingType.Infrared);
|
||||
_infraredDetector.ClearJamming(jammingParams);
|
||||
Assert.IsFalse(_infraredDetector.IsJammed, "红外探测器应该在干扰清除后恢复正常");
|
||||
Assert.IsTrue(_infraredDetector.IsActive, "红外探测器应该在干扰清除后仍处于激活状态");
|
||||
}
|
||||
@ -190,7 +190,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_radiometer.IsJammed, "毫米波辐射计应该被干扰");
|
||||
|
||||
// 清除干扰
|
||||
_radiometer.ClearJamming(JammingType.MillimeterWave);
|
||||
_radiometer.ClearJamming(jammingParams);
|
||||
Assert.IsFalse(_radiometer.IsJammed, "毫米波辐射计应该在干扰清除后恢复正常");
|
||||
Assert.IsTrue(_radiometer.IsActive, "毫米波辐射计应该在干扰清除后仍处于激活状态");
|
||||
}
|
||||
@ -217,7 +217,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(_rangefinder.IsJammed, "激光测距仪应该被干扰");
|
||||
|
||||
// 清除干扰
|
||||
_rangefinder.ClearJamming(JammingType.Laser);
|
||||
_rangefinder.ClearJamming(jammingParams);
|
||||
Assert.IsFalse(_rangefinder.IsJammed, "激光测距仪应该在干扰清除后恢复正常");
|
||||
Assert.IsTrue(_rangefinder.IsActive, "激光测距仪应该在干扰清除后仍处于激活状态");
|
||||
}
|
||||
@ -399,7 +399,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
SourcePosition = new Vector3D(0, 10, 0),
|
||||
Direction = new Vector3D(0, 1, 0),
|
||||
AngleRange = Math.PI/2,
|
||||
Mode = JammingMode.Noise,
|
||||
Mode = JammingMode.Blocking,
|
||||
Duration = 10,
|
||||
Type = JammingType.MillimeterWave
|
||||
}
|
||||
@ -421,7 +421,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Assert.IsTrue(status.Contains("传感器受到干扰"), "子弹状态应该反映传感器受到干扰");
|
||||
|
||||
// 清除干扰
|
||||
altimeter.ClearJamming(JammingType.MillimeterWave);
|
||||
altimeter.ClearJamming(millimeterWaveJamming.Parameters);
|
||||
submunition.Update(0.1);
|
||||
|
||||
// 验证恢复效果
|
||||
@ -547,7 +547,7 @@ namespace ThreatSource.Tests.Jamming
|
||||
Console.WriteLine($"干扰期间位置变化:从 {jammedPosition} 到 {currentPosition}");
|
||||
|
||||
// 清除干扰
|
||||
altimeter.ClearJamming(JammingType.MillimeterWave);
|
||||
altimeter.ClearJamming(millimeterWaveJamming);
|
||||
submunition.Update(0.1);
|
||||
|
||||
// 验证恢复效果
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "激光诱偏目标",
|
||||
"en": "Laser Decoy"
|
||||
},
|
||||
"type": "LaserDecoy",
|
||||
"LaserDecoyConfig": {
|
||||
"decoyPower": 25.0,
|
||||
"decoyLaserDivergenceAngle": 0.001,
|
||||
"reflectiveArea": 1.2,
|
||||
"reflectionCoefficient": 0.8,
|
||||
"lifeTime": 60.0
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/ir_jammers/infrared_blocking.json
Normal file
14
ThreatSource/data/jammers/ir_jammers/infrared_blocking.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "红外阻塞干扰器",
|
||||
"en": "Infrared Blocking Jammer"
|
||||
},
|
||||
"type": "Infrared",
|
||||
"InfraredJammerConfig": {
|
||||
"Power": 1000,
|
||||
"Wavelength": 5,
|
||||
"AngleRange": 10,
|
||||
"Mode": "Blocking",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/ir_jammers/infrared_deception.json
Normal file
14
ThreatSource/data/jammers/ir_jammers/infrared_deception.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "红外欺骗干扰器",
|
||||
"en": "Infrared Deception Jammer"
|
||||
},
|
||||
"type": "Infrared",
|
||||
"InfraredJammerConfig": {
|
||||
"Power": 800,
|
||||
"Wavelength": 5,
|
||||
"AngleRange": 15,
|
||||
"Mode": "Deception",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/ir_jammers/infrared_standard.json
Normal file
14
ThreatSource/data/jammers/ir_jammers/infrared_standard.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "红外阻塞干扰器",
|
||||
"en": "Infrared Blocking Jammer"
|
||||
},
|
||||
"type": "Infrared",
|
||||
"InfraredJammerConfig": {
|
||||
"Power": 1000,
|
||||
"Wavelength": 5,
|
||||
"AngleRange": 10,
|
||||
"Mode": "Blocking",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/laser_jammers/laser_blocking.json
Normal file
14
ThreatSource/data/jammers/laser_jammers/laser_blocking.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "激光阻塞干扰器",
|
||||
"en": "Laser Blocking Jammer"
|
||||
},
|
||||
"type": "Laser",
|
||||
"LaserJammerConfig": {
|
||||
"Power": 1000,
|
||||
"Wavelength": 1.06,
|
||||
"AngleRange": 10,
|
||||
"Mode": "Blocking",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/laser_jammers/laser_deception.json
Normal file
14
ThreatSource/data/jammers/laser_jammers/laser_deception.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "激光欺骗干扰器",
|
||||
"en": "Laser Deception Jammer"
|
||||
},
|
||||
"type": "Laser",
|
||||
"LaserJammerConfig": {
|
||||
"Power": 800,
|
||||
"Wavelength": 1.06,
|
||||
"AngleRange": 15,
|
||||
"Mode": "Deception",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
16
ThreatSource/data/jammers/laser_jammers/laser_decoy.json
Normal file
16
ThreatSource/data/jammers/laser_jammers/laser_decoy.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "激光诱偏目标",
|
||||
"en": "Laser Decoy"
|
||||
},
|
||||
"type": "LaserDecoy",
|
||||
"LaserDecoyConfig": {
|
||||
"Mode": "Deception",
|
||||
"Power": 25.0,
|
||||
"Wavelength": 1.06,
|
||||
"DivergenceAngle": 0.001,
|
||||
"ReflectiveArea": 1.2,
|
||||
"ReflectionCoefficient": 0.8,
|
||||
"Duration": 60.0
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/laser_jammers/laser_standard.json
Normal file
14
ThreatSource/data/jammers/laser_jammers/laser_standard.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "激光阻塞干扰器",
|
||||
"en": "Laser Blocking Jammer"
|
||||
},
|
||||
"type": "Laser",
|
||||
"LaserJammerConfig": {
|
||||
"Power": 1000,
|
||||
"Wavelength": 1.06,
|
||||
"AngleRange": 10,
|
||||
"Mode": "Blocking",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/mmw_jammers/mmw_blocking.json
Normal file
14
ThreatSource/data/jammers/mmw_jammers/mmw_blocking.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "毫米波阻塞干扰器",
|
||||
"en": "Millimeter Wave Blocking Jammer"
|
||||
},
|
||||
"type": "MillimeterWave",
|
||||
"MillimeterWaveJammerConfig": {
|
||||
"Power": 1000,
|
||||
"Wavelength": 3.16,
|
||||
"AngleRange": 10,
|
||||
"Mode": "Blocking",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/mmw_jammers/mmw_deception.json
Normal file
14
ThreatSource/data/jammers/mmw_jammers/mmw_deception.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "毫米波欺骗干扰器",
|
||||
"en": "Millimeter Wave Deception Jammer"
|
||||
},
|
||||
"type": "MillimeterWave",
|
||||
"MillimeterWaveJammerConfig": {
|
||||
"Power": 800,
|
||||
"Wavelength": 3.16,
|
||||
"AngleRange": 15,
|
||||
"Mode": "Deception",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
14
ThreatSource/data/jammers/mmw_jammers/mmw_standard.json
Normal file
14
ThreatSource/data/jammers/mmw_jammers/mmw_standard.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": {
|
||||
"zh": "毫米波阻塞干扰器",
|
||||
"en": "Millimeter Wave Blocking Jammer"
|
||||
},
|
||||
"type": "MillimeterWave",
|
||||
"MillimeterWaveJammerConfig": {
|
||||
"Power": 1000,
|
||||
"Wavelength": 3.16,
|
||||
"AngleRange": 10,
|
||||
"Mode": "Blocking",
|
||||
"Duration": 60
|
||||
}
|
||||
}
|
||||
@ -384,6 +384,30 @@ namespace ThreatSource.Data
|
||||
/// 包含激光诱偏目标的配置信息
|
||||
/// </remarks>
|
||||
public LaserDecoyConfig LaserDecoyConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置激光干扰机的配置
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 包含激光干扰机的配置信息
|
||||
/// </remarks>
|
||||
public LaserJammerConfig LaserJammerConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置红外干扰机的配置
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 包含红外干扰机的配置信息
|
||||
/// </remarks>
|
||||
public InfraredJammerConfig InfraredJammerConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置毫米波干扰机的配置
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 包含毫米波干扰机的配置信息
|
||||
/// </remarks>
|
||||
public MillimeterWaveJammerConfig MillimeterWaveJammerConfig { get; set; } = new();
|
||||
}
|
||||
|
||||
}
|
||||
@ -264,7 +264,7 @@ namespace ThreatSource.Data
|
||||
{
|
||||
if (_missiles.TryGetValue(model, out var data))
|
||||
return data;
|
||||
throw new KeyNotFoundException($"Missile {model} not found");
|
||||
throw new KeyNotFoundException($"导弹 {model} 不存在");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -276,7 +276,7 @@ namespace ThreatSource.Data
|
||||
{
|
||||
if (_indicators.TryGetValue(model, out var data))
|
||||
return data;
|
||||
throw new KeyNotFoundException($"Indicator {model} not found");
|
||||
throw new KeyNotFoundException($"指示器 {model} 不存在");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -288,7 +288,7 @@ namespace ThreatSource.Data
|
||||
{
|
||||
if (_sensors.TryGetValue(model, out var data))
|
||||
return data;
|
||||
throw new KeyNotFoundException($"Sensor {model} not found");
|
||||
throw new KeyNotFoundException($"传感器 {model} 不存在");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -300,7 +300,7 @@ namespace ThreatSource.Data
|
||||
{
|
||||
if (_targets.TryGetValue(model, out var data))
|
||||
return data;
|
||||
throw new KeyNotFoundException($"Target {model} not found");
|
||||
throw new KeyNotFoundException($"目标 {model} 不存在");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -312,7 +312,7 @@ namespace ThreatSource.Data
|
||||
{
|
||||
if (_weathers.TryGetValue(weatherType, out var data))
|
||||
return data;
|
||||
throw new KeyNotFoundException($"Weather {weatherType} not found");
|
||||
throw new KeyNotFoundException($"天气 {weatherType} 不存在");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -324,7 +324,7 @@ namespace ThreatSource.Data
|
||||
{
|
||||
if (_jammers.TryGetValue(model, out var data))
|
||||
return data;
|
||||
throw new KeyNotFoundException($"Jammer {model} not found");
|
||||
throw new KeyNotFoundException($"干扰机 {model} 不存在");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -136,9 +136,7 @@ namespace ThreatSource.Data
|
||||
public IIndicator CreateIndicator(string indicatorId, string indicatorModel, string targetId, string missileId, MotionParameters motionParameters)
|
||||
{
|
||||
var data = _dataManager.GetIndicator(indicatorModel);
|
||||
|
||||
Console.WriteLine($"dataType: {data.Type}, indicatorModel: {indicatorModel}, indicatorId: {indicatorId}, targetId: {targetId}, missileId: {missileId}");
|
||||
|
||||
|
||||
return data.Type switch
|
||||
{
|
||||
IndicatorType.LaserDesignator when data.DesignatorConfig != null => new LaserDesignator(
|
||||
@ -247,6 +245,24 @@ namespace ThreatSource.Data
|
||||
sourceId,
|
||||
_simulationManager
|
||||
),
|
||||
JammerType.Laser => new LaserJammer(
|
||||
jammerId,
|
||||
data.LaserJammerConfig,
|
||||
motionParameters,
|
||||
_simulationManager
|
||||
),
|
||||
JammerType.Infrared => new InfraredJammer(
|
||||
jammerId,
|
||||
data.InfraredJammerConfig,
|
||||
motionParameters,
|
||||
_simulationManager
|
||||
),
|
||||
JammerType.MillimeterWave => new MillimeterWaveJammer(
|
||||
jammerId,
|
||||
data.MillimeterWaveJammerConfig,
|
||||
motionParameters,
|
||||
_simulationManager
|
||||
),
|
||||
_ => throw new ArgumentException($"不支持的干扰机类型: {data.Type}"),
|
||||
};
|
||||
}
|
||||
|
||||
@ -134,6 +134,7 @@ namespace ThreatSource.Guidance
|
||||
IsActive = true;
|
||||
// 统一订阅 JammingEvent
|
||||
SimulationManager.SubscribeToEvent<JammingEvent>(HandleJammingEvent);
|
||||
SimulationManager.SubscribeToEvent<JammingStoppedEvent>(HandleJammingStoppedEvent);
|
||||
// 子类应在此方法中调用 base.Activate() 并订阅其他需要的事件
|
||||
}
|
||||
// 调用 SimulationElement 的基类 Activate (如果存在)
|
||||
@ -148,9 +149,10 @@ namespace ThreatSource.Guidance
|
||||
if (IsActive)
|
||||
{
|
||||
IsActive = false;
|
||||
// 统一取消订阅 JammingEvent
|
||||
// 统一取消订阅 JammingEvent和JammingStoppedEvent
|
||||
SimulationManager.UnsubscribeFromEvent<JammingEvent>(HandleJammingEvent);
|
||||
// 子类应在此方法中调用 base.Deactivate() 并取消订阅其他事件
|
||||
SimulationManager.UnsubscribeFromEvent<JammingStoppedEvent>(HandleJammingStoppedEvent);
|
||||
// 子类应在此方法中调用 base.Deactivate() 并取消订阅其他事件
|
||||
}
|
||||
HasGuidance = false; // 停用时失去制导
|
||||
GuidanceAcceleration = Vector3D.Zero;
|
||||
@ -238,12 +240,22 @@ namespace ThreatSource.Guidance
|
||||
if (evt != null)
|
||||
{
|
||||
// 在应用干扰前检查是否应该处理此干扰
|
||||
if (!ShouldHandleJamming(evt.Parameters))
|
||||
if (ShouldHandleJamming(evt.Parameters))
|
||||
{
|
||||
// Debug.WriteLine($"[BaseGuidanceSystem] {Id} 忽略干扰事件,类型: {evt.Parameters.Type}");
|
||||
return;
|
||||
ApplyJamming(evt.Parameters);
|
||||
}
|
||||
ApplyJamming(evt.Parameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理干扰事件
|
||||
/// </summary>
|
||||
/// <param name="evt">干扰事件</param>
|
||||
protected virtual void HandleJammingStoppedEvent(JammingStoppedEvent evt)
|
||||
{
|
||||
if (evt != null)
|
||||
{
|
||||
ClearJamming(evt.Parameters);
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,10 +305,10 @@ namespace ThreatSource.Guidance
|
||||
/// <summary>
|
||||
/// 清除干扰
|
||||
/// </summary>
|
||||
/// <param name="type">要清除的干扰类型</param>
|
||||
public virtual void ClearJamming(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
public virtual void ClearJamming(JammingParameters parameters)
|
||||
{
|
||||
_jammingComponent.ClearJamming(type);
|
||||
_jammingComponent.ClearJamming(parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -306,8 +318,8 @@ namespace ThreatSource.Guidance
|
||||
protected virtual void HandleJammingApplied(JammingParameters parameters)
|
||||
{
|
||||
// 子类可以重写此方法以实现特定的干扰响应
|
||||
// 默认:非烟幕干扰是硬干扰
|
||||
if (parameters.Type != JammingType.SmokeScreen)
|
||||
// 阻塞干扰是硬干扰
|
||||
if (parameters.Mode == JammingMode.Blocking)
|
||||
{
|
||||
IsHardJammed = true;
|
||||
HasGuidance = false; // 硬干扰立即停止制导
|
||||
@ -318,29 +330,23 @@ namespace ThreatSource.Guidance
|
||||
/// <summary>
|
||||
/// 处理制导系统干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected virtual void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected virtual void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
// 子类可以重写此方法以实现干扰清除后的特定行为
|
||||
if (type != JammingType.SmokeScreen)
|
||||
if (parameters.Mode == JammingMode.Blocking)
|
||||
{
|
||||
// 尝试清除硬干扰标志。如果还有其他硬干扰,组件状态可能仍反映,
|
||||
// 或者后续 ApplyJamming 会再次设置 IsHardJammed。
|
||||
// 简化处理:清除任何硬干扰时都清除标志。
|
||||
IsHardJammed = false;
|
||||
Trace.WriteLine($"[{this.GetType().Name}] 硬干扰已清除: {type}");
|
||||
Trace.WriteLine($"[{GetType().Name}] 硬干扰已清除: {parameters.Type}");
|
||||
}
|
||||
// 子类需要重写此方法来处理 SmokeScreen 清除。
|
||||
|
||||
// 检查整体干扰状态
|
||||
if (!_jammingComponent.IsJammed)
|
||||
{
|
||||
IsHardJammed = false; // 确保清除
|
||||
HasGuidance = true; // 恢复制导
|
||||
Trace.WriteLine($"[{this.GetType().Name}] 所有干扰已清除。");
|
||||
IsHardJammed = false;
|
||||
HasGuidance = true;
|
||||
Trace.WriteLine($"[{GetType().Name}] 所有干扰已清除。");
|
||||
}
|
||||
// 如果 _jammingComponent 仍然 IsJammed (因为可能有烟幕),
|
||||
// HasGuidance 的最终状态由 Update 决定。
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -24,7 +24,7 @@ namespace ThreatSource.Guidance
|
||||
/// 记录上一次接收到的跟踪器指向导弹的方向
|
||||
/// 用于计算导弹的相对位置
|
||||
/// </remarks>
|
||||
private Vector3D? lastTrackerToMissileVector { get; set; }
|
||||
private Vector3D? LastTrackerToMissileVector { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 跟踪器到目标的方向向量 (使用可空类型)
|
||||
@ -33,7 +33,7 @@ namespace ThreatSource.Guidance
|
||||
/// 记录上一次接收到的跟踪器指向目标的方向
|
||||
/// 用于计算目标的相对位置
|
||||
/// </remarks>
|
||||
private Vector3D? lastTrackerToTargetVector { get; set; }
|
||||
private Vector3D? LastTrackerToTargetVector { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 上一次的期望飞行方向 (使用可空类型)
|
||||
@ -42,7 +42,7 @@ namespace ThreatSource.Guidance
|
||||
/// 记录上一次计算的期望飞行方向
|
||||
/// 用于计算转向速率
|
||||
/// </remarks>
|
||||
private Vector3D? lastDesiredDirection { get; set; }
|
||||
private Vector3D? LastDesiredDirection { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前转向速率,单位:弧度/秒
|
||||
@ -108,7 +108,7 @@ namespace ThreatSource.Guidance
|
||||
public override void Update(double deltaTime, Vector3D missilePosition, Vector3D missileVelocity)
|
||||
{
|
||||
base.Update(deltaTime, missilePosition, missileVelocity);
|
||||
if (!IsJammed)
|
||||
if (!IsHardJammed)
|
||||
{
|
||||
if (HasGuidance)
|
||||
{
|
||||
@ -117,9 +117,9 @@ namespace ThreatSource.Guidance
|
||||
else
|
||||
{
|
||||
GuidanceAcceleration = Vector3D.Zero;
|
||||
lastTrackerToMissileVector = null;
|
||||
lastTrackerToTargetVector = null;
|
||||
lastDesiredDirection = null;
|
||||
LastTrackerToMissileVector = null;
|
||||
LastTrackerToTargetVector = null;
|
||||
LastDesiredDirection = null;
|
||||
turnRate = 0;
|
||||
}
|
||||
}
|
||||
@ -127,9 +127,9 @@ namespace ThreatSource.Guidance
|
||||
{
|
||||
HasGuidance = false;
|
||||
GuidanceAcceleration = Vector3D.Zero;
|
||||
lastTrackerToMissileVector = null;
|
||||
lastTrackerToTargetVector = null;
|
||||
lastDesiredDirection = null;
|
||||
LastTrackerToMissileVector = null;
|
||||
LastTrackerToTargetVector = null;
|
||||
LastDesiredDirection = null;
|
||||
turnRate = 0;
|
||||
}
|
||||
}
|
||||
@ -148,8 +148,8 @@ namespace ThreatSource.Guidance
|
||||
public void ReceiveGuidanceCommand(Vector3D trackerToMissileVector, Vector3D trackerToTargetVector)
|
||||
{
|
||||
HasGuidance = true;
|
||||
lastTrackerToMissileVector = trackerToMissileVector;
|
||||
lastTrackerToTargetVector = trackerToTargetVector;
|
||||
LastTrackerToMissileVector = trackerToMissileVector;
|
||||
LastTrackerToTargetVector = trackerToTargetVector;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -166,20 +166,20 @@ namespace ThreatSource.Guidance
|
||||
/// </remarks>
|
||||
protected void CalculateGuidanceAcceleration(double deltaTime)
|
||||
{
|
||||
if (lastTrackerToMissileVector == null || lastTrackerToTargetVector == null)
|
||||
if (LastTrackerToMissileVector == null || LastTrackerToTargetVector == null)
|
||||
{
|
||||
GuidanceAcceleration = Vector3D.Zero;
|
||||
HasGuidance = false;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3D currentDesiredDirection = (lastTrackerToTargetVector - lastTrackerToMissileVector).Normalize();
|
||||
Vector3D currentDesiredDirection = (LastTrackerToTargetVector - LastTrackerToMissileVector).Normalize();
|
||||
|
||||
Vector3D currentDirection = Velocity.Normalize();
|
||||
|
||||
if (lastDesiredDirection != null && deltaTime > 0)
|
||||
if (LastDesiredDirection != null && deltaTime > 0)
|
||||
{
|
||||
double instantTurnRate = Vector3D.CrossProduct(lastDesiredDirection, currentDesiredDirection).Magnitude() / deltaTime;
|
||||
double instantTurnRate = Vector3D.CrossProduct(LastDesiredDirection, currentDesiredDirection).Magnitude() / deltaTime;
|
||||
turnRate = turnRate * (1 - TurnRateSmoothingFactor) + instantTurnRate * TurnRateSmoothingFactor;
|
||||
}
|
||||
else
|
||||
@ -198,7 +198,7 @@ namespace ThreatSource.Guidance
|
||||
{
|
||||
GuidanceAcceleration = GuidanceAcceleration.Normalize() * MaxAcceleration;
|
||||
}
|
||||
lastDesiredDirection = currentDesiredDirection;
|
||||
LastDesiredDirection = currentDesiredDirection;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -216,9 +216,9 @@ namespace ThreatSource.Guidance
|
||||
public override string GetStatus()
|
||||
{
|
||||
string angleStr = "null";
|
||||
if (lastTrackerToTargetVector != null && lastTrackerToMissileVector != null)
|
||||
if (LastTrackerToTargetVector != null && LastTrackerToMissileVector != null)
|
||||
{
|
||||
angleStr = Vector3D.AngleBetween(lastTrackerToTargetVector, lastTrackerToMissileVector).ToString("F3");
|
||||
angleStr = Vector3D.AngleBetween(LastTrackerToTargetVector, LastTrackerToMissileVector).ToString("F3");
|
||||
}
|
||||
|
||||
return base.GetStatus() +
|
||||
|
||||
@ -188,25 +188,20 @@ namespace ThreatSource.Guidance
|
||||
/// <summary>
|
||||
/// 处理系统干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
if (type == JammingType.Infrared)
|
||||
base.HandleJammingCleared(parameters);
|
||||
|
||||
if (parameters.Type == JammingType.Infrared)
|
||||
{
|
||||
Debug.WriteLine("红外引导系统干扰已清除");
|
||||
// 确保基类的处理逻辑被调用
|
||||
base.HandleJammingCleared(type);
|
||||
// 干扰清除后的恢复逻辑
|
||||
}
|
||||
else if (type == JammingType.SmokeScreen)
|
||||
else if (parameters.Type == JammingType.SmokeScreen)
|
||||
{
|
||||
SmokeAttenuation = 1.0; // Reset smoke attenuation
|
||||
Debug.WriteLine("[烟幕干扰清除 IR]");
|
||||
base.HandleJammingCleared(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.HandleJammingCleared(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -520,9 +520,9 @@ namespace ThreatSource.Guidance
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingApplied(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingApplied(parameters);
|
||||
if (parameters.Type == JammingType.Laser)
|
||||
{
|
||||
base.HandleJammingApplied(parameters);
|
||||
Debug.WriteLine("激光驾束制导系统受到激光干扰");
|
||||
}
|
||||
}
|
||||
@ -530,12 +530,12 @@ namespace ThreatSource.Guidance
|
||||
/// <summary>
|
||||
/// 处理系统干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
if (type == JammingType.Laser)
|
||||
base.HandleJammingCleared(parameters);
|
||||
if (parameters.Type == JammingType.Laser)
|
||||
{
|
||||
base.HandleJammingCleared(type);
|
||||
Debug.WriteLine("激光驾束制导系统干扰已清除");
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ using ThreatSource.Indicator;
|
||||
using ThreatSource.Jammer;
|
||||
using System.Diagnostics;
|
||||
using AirTransmission;
|
||||
using System.Transactions;
|
||||
|
||||
namespace ThreatSource.Guidance
|
||||
{
|
||||
@ -165,7 +166,7 @@ namespace ThreatSource.Guidance
|
||||
// 初始化加速度平滑处理
|
||||
PreviousGuidanceAcceleration = Vector3D.Zero;
|
||||
|
||||
InitializeJamming(guidanceConfig.JammingResistanceThreshold, [JammingType.Laser, JammingType.SmokeScreen]);
|
||||
InitializeJamming(guidanceConfig.JammingResistanceThreshold, [JammingType.Laser, JammingType.SmokeScreen, JammingType.Decoy]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -183,12 +184,6 @@ namespace ThreatSource.Guidance
|
||||
// 订阅激光照射事件
|
||||
SimulationManager.SubscribeToEvent<LaserIlluminationUpdateEvent>(OnLaserIlluminationUpdate);
|
||||
SimulationManager.SubscribeToEvent<LaserIlluminationStopEvent>(OnLaserIlluminationStop);
|
||||
// 订阅激光干扰事件
|
||||
SimulationManager.SubscribeToEvent<JammingEvent>(HandleJammingEvent);
|
||||
|
||||
// 订阅诱偏目标照射事件
|
||||
SimulationManager.SubscribeToEvent<LaserDecoyEvent>(OnLaserDecoy);
|
||||
SimulationManager.SubscribeToEvent<LaserDecoyStopEvent>(OnLaserDecoyStop);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -206,12 +201,6 @@ namespace ThreatSource.Guidance
|
||||
SimulationManager.UnsubscribeFromEvent<LaserIlluminationUpdateEvent>(OnLaserIlluminationUpdate);
|
||||
SimulationManager.UnsubscribeFromEvent<LaserIlluminationStopEvent>(OnLaserIlluminationStop);
|
||||
|
||||
// 取消订阅激光干扰事件
|
||||
SimulationManager.UnsubscribeFromEvent<JammingEvent>(HandleJammingEvent);
|
||||
|
||||
// 取消订阅诱偏目标照射事件
|
||||
SimulationManager.UnsubscribeFromEvent<LaserDecoyEvent>(OnLaserDecoy);
|
||||
SimulationManager.UnsubscribeFromEvent<LaserDecoyStopEvent>(OnLaserDecoyStop);
|
||||
TargetPosition = null;
|
||||
}
|
||||
|
||||
@ -287,36 +276,6 @@ namespace ThreatSource.Guidance
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理诱偏目标照射事件
|
||||
/// </summary>
|
||||
/// <param name="evt">诱偏目标照射事件</param>
|
||||
private void OnLaserDecoy(LaserDecoyEvent evt)
|
||||
{
|
||||
if (evt.LaserDecoyId != null && evt.SourceId != null)
|
||||
{
|
||||
LaserDecoy decoyTarget = SimulationManager.GetEntityById(evt.LaserDecoyId) as LaserDecoy ?? throw new Exception("诱偏目标不存在");
|
||||
SimulationElement decoySource = SimulationManager.GetEntityById(evt.SourceId) as SimulationElement ?? throw new Exception("诱偏源不存在");
|
||||
// 添加激光目标
|
||||
if (!laserTargets.Any(t => t.Target.Id == decoyTarget.Id))
|
||||
{
|
||||
laserTargets.Add((decoyTarget, decoyTarget.Position, decoySource));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理诱偏目标照射停止事件
|
||||
/// </summary>
|
||||
/// <param name="evt">诱偏目标照射停止事件</param>
|
||||
private void OnLaserDecoyStop(LaserDecoyStopEvent evt)
|
||||
{
|
||||
if (evt?.LaserDecoyId != null)
|
||||
{
|
||||
laserTargets.RemoveAll(t => t.Target.Id == evt.LaserDecoyId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理系统被干扰的事件
|
||||
/// </summary>
|
||||
@ -339,27 +298,47 @@ namespace ThreatSource.Guidance
|
||||
SmokeAttenuation = CalculateSmokeAttenuation(parameters);
|
||||
Debug.WriteLine($"[LASER_SEMI_ACTIVE] 烟幕干扰应用,衰减因子: {SmokeAttenuation:P2}", "Jamming");
|
||||
}
|
||||
else if (parameters.Type == JammingType.Decoy)
|
||||
{
|
||||
if (parameters.JammerId != null && parameters.SourceId != null)
|
||||
{
|
||||
LaserDecoy decoyTarget = SimulationManager.GetEntityById(parameters.JammerId) as LaserDecoy ?? throw new Exception("诱偏目标不存在");
|
||||
SimulationElement decoySource = SimulationManager.GetEntityById(parameters.SourceId) as SimulationElement ?? throw new Exception("诱偏源不存在");
|
||||
// 添加激光目标
|
||||
if (!laserTargets.Any(t => t.Target.Id == decoyTarget.Id))
|
||||
{
|
||||
laserTargets.Add((decoyTarget, decoyTarget.Position, decoySource));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理系统干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type); // Calls base logic (IsHardJammed, maybe HasGuidance = true)
|
||||
base.HandleJammingCleared(parameters); // Calls base logic (IsHardJammed, maybe HasGuidance = true)
|
||||
|
||||
if (type == JammingType.Laser)
|
||||
if (parameters.Type == JammingType.Laser)
|
||||
{
|
||||
Debug.WriteLine($"[LASER_SEMI_ACTIVE] 激光干扰已清除。", "Jamming");
|
||||
// 不需要设置 HasGuidance = true, 基类可能已处理
|
||||
// 激光照射状态 LaserIlluminationOn 会在收到下一个有效 Update 事件时恢复
|
||||
}
|
||||
else if (type == JammingType.SmokeScreen)
|
||||
else if (parameters.Type == JammingType.SmokeScreen)
|
||||
{
|
||||
SmokeAttenuation = 1.0; // 重置烟幕衰减
|
||||
Debug.WriteLine($"[LASER_SEMI_ACTIVE] 烟幕干扰已清除。", "Jamming");
|
||||
}
|
||||
else if (parameters.Type == JammingType.Decoy)
|
||||
{
|
||||
if (parameters.JammerId != null)
|
||||
{
|
||||
laserTargets.RemoveAll(t => t.Target.Id == parameters.JammerId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -466,7 +445,7 @@ namespace ThreatSource.Guidance
|
||||
if (target.Target is LaserDecoy decoy)
|
||||
{
|
||||
// 计算接收功率
|
||||
receivedPower = CalculateReceivedPower(target.Source.Position, target.SpotPosition, decoy.config.DecoyPower, decoy.config.DecoyLaserDivergenceAngle);
|
||||
receivedPower = CalculateReceivedPower(target.Source.Position, target.SpotPosition, decoy.config.Power, decoy.config.DivergenceAngle);
|
||||
Console.WriteLine($"处理激光信号: 诱偏目标接收功率={receivedPower:E}W, 诱偏目标ID: {target.Target.Id}, 诱偏目标位置: {target.SpotPosition}");
|
||||
}
|
||||
else if (target.Source is LaserDesignator laserDesignator)
|
||||
|
||||
@ -90,24 +90,6 @@ namespace ThreatSource.Guidance
|
||||
/// </summary>
|
||||
private WorkMode currentMode = WorkMode.Search;
|
||||
|
||||
/// <summary>
|
||||
/// 是否受到干扰
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 指示当前是否受到电子干扰
|
||||
/// 影响系统的工作状态
|
||||
/// </remarks>
|
||||
private bool isJammed = false;
|
||||
|
||||
/// <summary>
|
||||
/// 干扰功率,单位:瓦特
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 记录接收到的干扰信号功率
|
||||
/// 用于评估干扰效果
|
||||
/// </remarks>
|
||||
private double jammingPower = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 是否有目标
|
||||
/// </summary>
|
||||
@ -245,50 +227,40 @@ namespace ThreatSource.Guidance
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingApplied(JammingParameters parameters)
|
||||
{
|
||||
// 1. 让基类处理通用硬干扰逻辑 (如果不是SmokeScreen, 会设置 IsHardJammed 和 HasGuidance = false)
|
||||
base.HandleJammingApplied(parameters);
|
||||
|
||||
// 2. 处理毫米波干扰特定逻辑
|
||||
if (parameters.Type == JammingType.MillimeterWave)
|
||||
{
|
||||
isJammed = true; // 使用局部变量,与基类 IsJammed 分开? 还是统一? **统一使用基类的 IsJammed**
|
||||
// isJammed = _jammingComponent.IsJammed; // Correct way to get status
|
||||
jammingPower = parameters.Power; // 记录干扰功率
|
||||
Debug.WriteLine($"[MMW_GUIDANCE] 受到毫米波干扰,功率:{jammingPower} W。切换到搜索模式。", "Jamming");
|
||||
Debug.WriteLine($"[MMW_GUIDANCE] 受到毫米波干扰,功率:{parameters.Power} W。切换到搜索模式。", "Jamming");
|
||||
// 干扰时切换到搜索模式
|
||||
if (currentMode != WorkMode.Search)
|
||||
{
|
||||
SwitchToSearchMode();
|
||||
}
|
||||
// 基类已经设置 HasGuidance = false
|
||||
}
|
||||
// 3. 处理烟幕干扰特定逻辑
|
||||
else if (parameters.Type == JammingType.SmokeScreen)
|
||||
{
|
||||
// 计算烟幕透过率
|
||||
// TODO: 实现基于 JammingParameters 中烟幕属性 (浓度、厚度等) 的真实透过率计算。
|
||||
_currentSmokeTransmittance = 1.0; // 暂时设置为无遮挡
|
||||
Debug.WriteLine($"[MMW_GUIDANCE] 烟幕干扰应用,(临时) 透过率: {_currentSmokeTransmittance:P2}", "Jamming");
|
||||
Debug.WriteLine($"[MMW_GUIDANCE] 烟幕干扰应用,(临时) 透过率: {_currentSmokeTransmittance:P2}", "Jamming");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理系统干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type); // 调用基类处理 IsHardJammed 和 HasGuidance
|
||||
base.HandleJammingCleared(parameters); // 调用基类处理 IsHardJammed 和 HasGuidance
|
||||
|
||||
if (type == JammingType.MillimeterWave)
|
||||
if (parameters.Type == JammingType.MillimeterWave)
|
||||
{
|
||||
isJammed = false; // 重置局部变量? **统一使用基类的 IsJammed**
|
||||
// isJammed = _jammingComponent.IsJammed; // Correct way to get status
|
||||
jammingPower = 0; // 重置干扰功率
|
||||
Debug.WriteLine($"[MMW_GUIDANCE] 毫米波干扰已清除。", "Jamming");
|
||||
Debug.WriteLine($"[MMW_GUIDANCE] 毫米波干扰已清除。", "Jamming");
|
||||
// 干扰清除后是否需要切换模式?取决于当前是否有目标。Update 会处理。
|
||||
}
|
||||
else if (type == JammingType.SmokeScreen)
|
||||
else if (parameters.Type == JammingType.SmokeScreen)
|
||||
{
|
||||
_currentSmokeTransmittance = 1.0; // 重置烟幕透过率
|
||||
Debug.WriteLine($"[MMW_GUIDANCE] 烟幕干扰已清除。", "Jamming");
|
||||
@ -566,9 +538,8 @@ namespace ThreatSource.Guidance
|
||||
bool foundTarget = false;
|
||||
double currentSNR = double.MinValue;
|
||||
|
||||
if (isJammed)
|
||||
if (IsJammed)
|
||||
{
|
||||
Trace.WriteLine($"毫米波导引头受到干扰,干扰功率: {jammingPower:F2}W");
|
||||
HasGuidance = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -127,14 +127,14 @@ namespace ThreatSource.Indicator
|
||||
/// <summary>
|
||||
/// 清除干扰
|
||||
/// </summary>
|
||||
/// <param name="type">要清除的干扰类型</param>
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
/// <remarks>
|
||||
/// 移除特定类型的干扰影响
|
||||
/// 恢复指示器的正常工作状态
|
||||
/// </remarks>
|
||||
public virtual void ClearJamming(JammingType type)
|
||||
public virtual void ClearJamming(JammingParameters parameters)
|
||||
{
|
||||
_jammingComponent.ClearJamming(type);
|
||||
_jammingComponent.ClearJamming(parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -160,11 +160,11 @@ namespace ThreatSource.Indicator
|
||||
/// <summary>
|
||||
/// 处理指示器干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected virtual void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected virtual void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
// 如果是烟幕干扰,重新计算遮挡状态
|
||||
if (type == JammingType.SmokeScreen)
|
||||
if (parameters.Type == JammingType.SmokeScreen)
|
||||
{
|
||||
RecalculateObscurationStatus();
|
||||
Debug.WriteLine($"[BaseIndicator] 烟幕状态更新,IsTargetObscured: {IsTargetObscured}", "Jamming");
|
||||
@ -172,7 +172,7 @@ namespace ThreatSource.Indicator
|
||||
else // 其他干扰类型打印通用消息
|
||||
{
|
||||
// 子类可以重写此方法以实现干扰清除后的特定行为
|
||||
Debug.WriteLine($"[BaseIndicator] {this.GetType().Name} {Id} {type} 类型干扰已清除", "Jamming");
|
||||
Debug.WriteLine($"[BaseIndicator] {this.GetType().Name} {Id} {parameters.Type} 类型干扰已清除", "Jamming");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -415,13 +415,13 @@ namespace ThreatSource.Indicator
|
||||
/// <summary>
|
||||
/// 处理指示器干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type); // Calls RecalculateObscurationStatus for smoke
|
||||
base.HandleJammingCleared(parameters); // Calls RecalculateObscurationStatus for smoke
|
||||
|
||||
// 红外干扰清除后,不需要特殊操作,UpdateIndicator 会重新评估跟踪状态
|
||||
if (type == JammingType.Infrared)
|
||||
if (parameters.Type == JammingType.Infrared)
|
||||
{
|
||||
Debug.WriteLine($"[InfraredTracker] {Id} 红外干扰已清除。", "Jamming");
|
||||
}
|
||||
|
||||
@ -367,13 +367,13 @@ namespace ThreatSource.Indicator
|
||||
/// <summary>
|
||||
/// 处理指示器干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type); // Calls RecalculateObscurationStatus for smoke
|
||||
base.HandleJammingCleared(parameters); // Calls RecalculateObscurationStatus for smoke
|
||||
|
||||
// 添加子类特定响应:如果是激光干扰清除,并且设备仍激活,尝试启动光束
|
||||
if (type == JammingType.Laser)
|
||||
if (parameters.Type == JammingType.Laser)
|
||||
{
|
||||
Debug.WriteLine($"[LaserBeamRider] {Id} 激光干扰已清除。", "Jamming");
|
||||
if (IsActive && !IsJammed) // Check IsJammed in case other jams exist
|
||||
|
||||
@ -194,13 +194,13 @@ namespace ThreatSource.Indicator
|
||||
/// <summary>
|
||||
/// 处理指示器干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type); // Calls RecalculateObscurationStatus for smoke
|
||||
base.HandleJammingCleared(parameters); // Calls RecalculateObscurationStatus for smoke
|
||||
|
||||
// 添加子类特定响应:如果是激光干扰清除,并且设备仍激活,尝试启动照射
|
||||
if (type == JammingType.Laser)
|
||||
if (parameters.Type == JammingType.Laser)
|
||||
{
|
||||
Debug.WriteLine($"[LaserDesignator] {Id} 激光干扰已清除。", "Jamming");
|
||||
// 如果设备仍处于激活状态,并且没有其他干扰,恢复激光照射
|
||||
@ -223,9 +223,7 @@ namespace ThreatSource.Indicator
|
||||
{
|
||||
if (!IsActive)
|
||||
{
|
||||
base.Activate(); // Handles IsActive and subscribes HandleJammingEvent
|
||||
// Removed JammingEvent subscriptions for OnLaserJamming and HandleSmokeEvent
|
||||
|
||||
base.Activate();
|
||||
// 子类特定的激活逻辑
|
||||
Debug.WriteLine($"激光指示器 {Id} 已激活");
|
||||
StartLaserIllumination();
|
||||
@ -246,8 +244,7 @@ namespace ThreatSource.Indicator
|
||||
{
|
||||
// 子类特定的停用逻辑
|
||||
StopLaserIllumination();
|
||||
// Removed JammingEvent subscriptions for OnLaserJamming and HandleSmokeEvent
|
||||
Debug.WriteLine($"激光指示器 {Id} 已停用");
|
||||
Debug.WriteLine($"激光指示器 {Id} 已停用");
|
||||
base.Deactivate(); // Handles IsActive and unsubscribes HandleJammingEvent
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,7 +26,7 @@ namespace ThreatSource.Jammable
|
||||
/// <summary>
|
||||
/// 清除干扰
|
||||
/// </summary>
|
||||
/// <param name="type">要清除的干扰类型</param>
|
||||
void ClearJamming(JammingType type);
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
void ClearJamming(JammingParameters parameters);
|
||||
}
|
||||
}
|
||||
@ -49,7 +49,7 @@ namespace ThreatSource.Jammable
|
||||
/// <summary>
|
||||
/// 当干扰被清除时触发
|
||||
/// </summary>
|
||||
public event Action<JammingType>? JammingCleared;
|
||||
public event Action<JammingParameters>? JammingCleared;
|
||||
|
||||
/// <summary>
|
||||
/// 获取设备支持的干扰类型
|
||||
@ -131,10 +131,10 @@ namespace ThreatSource.Jammable
|
||||
/// <summary>
|
||||
/// 清除干扰
|
||||
/// </summary>
|
||||
/// <param name="type">要清除的干扰类型 (Note: JammingHandler clears all current jamming regardless of type)</param>
|
||||
public void ClearJamming(JammingType type)
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
public void ClearJamming(JammingParameters parameters)
|
||||
{
|
||||
_jammingHandler.ClearJamming();
|
||||
_jammingHandler.ClearJamming(parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -247,7 +247,7 @@ namespace ThreatSource.Jammable
|
||||
// 触发公共事件,如果可用,则提供类型
|
||||
if (parameters != null)
|
||||
{
|
||||
JammingCleared?.Invoke(parameters.Type);
|
||||
JammingCleared?.Invoke(parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@ namespace ThreatSource.Jammable
|
||||
// 检查是否超时
|
||||
if (_elapsedTime >= CurrentJamming.Duration.Value)
|
||||
{
|
||||
ClearJamming();
|
||||
ClearJamming(CurrentJamming);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,7 +65,7 @@ namespace ThreatSource.Jammable
|
||||
/// <summary>
|
||||
/// 清除干扰
|
||||
/// </summary>
|
||||
public virtual void ClearJamming()
|
||||
public virtual void ClearJamming(JammingParameters parameters)
|
||||
{
|
||||
if (IsJammed)
|
||||
{
|
||||
|
||||
@ -25,16 +25,16 @@ namespace ThreatSource.Jammer
|
||||
/// </summary>
|
||||
protected abstract JammerType Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 支持的干扰类型
|
||||
/// </summary>
|
||||
protected abstract JammingType[] SupportedJammingTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 干扰器状态
|
||||
/// </summary>
|
||||
protected JammerState State { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取干扰器支持的干扰类型
|
||||
/// </summary>
|
||||
public abstract IEnumerable<JammingType> SupportedJammingTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取干扰器当前是否处于工作状态
|
||||
/// </summary>
|
||||
@ -59,9 +59,14 @@ namespace ThreatSource.Jammer
|
||||
public override void Activate()
|
||||
{
|
||||
IsActive = true;
|
||||
if (!IsJamming && CurrentParameters != null)
|
||||
if (!IsJamming)
|
||||
{
|
||||
StartJamming(CurrentParameters);
|
||||
CurrentParameters ??= CreateJammingParameters();
|
||||
|
||||
if (CurrentParameters != null)
|
||||
{
|
||||
StartJamming(CurrentParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +102,7 @@ namespace ThreatSource.Jammer
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
public virtual void StartJamming(JammingParameters parameters)
|
||||
{
|
||||
// 检查是否支持该类型的干扰
|
||||
// 检查是否是该类型的干扰
|
||||
if (!SupportedJammingTypes.Contains(parameters.Type))
|
||||
{
|
||||
Console.WriteLine($"干扰器 {Id} 不支持 {parameters.Type} 类型的干扰");
|
||||
|
||||
@ -13,11 +13,6 @@ namespace ThreatSource.Jammer
|
||||
/// </remarks>
|
||||
public interface IJammer
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取干扰器支持的干扰类型
|
||||
/// </summary>
|
||||
IEnumerable<JammingType> SupportedJammingTypes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取干扰器当前是否处于工作状态
|
||||
/// </summary>
|
||||
|
||||
@ -23,7 +23,7 @@ namespace ThreatSource.Jammer
|
||||
/// <summary>
|
||||
/// 支持的干扰类型
|
||||
/// </summary>
|
||||
public override IEnumerable<JammingType> SupportedJammingTypes => [JammingType.Infrared];
|
||||
protected override JammingType[] SupportedJammingTypes => [JammingType.Infrared];
|
||||
|
||||
/// <summary>
|
||||
/// 初始化红外干扰器的新实例
|
||||
@ -53,8 +53,26 @@ namespace ThreatSource.Jammer
|
||||
SourcePosition = Position,
|
||||
AngleRange = config.AngleRange,
|
||||
Mode = config.Mode,
|
||||
Duration = config.Duration
|
||||
Duration = config.Duration,
|
||||
StartTime = DateTime.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新干扰效果
|
||||
/// </summary>
|
||||
protected override void UpdateJamming(double deltaTime)
|
||||
{
|
||||
base.UpdateJamming(deltaTime);
|
||||
|
||||
// 更新位置
|
||||
Position += Velocity * deltaTime;
|
||||
|
||||
// 更新干扰事件
|
||||
if (CurrentParameters != null)
|
||||
{
|
||||
PublishJammingEvent(CurrentParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,11 +12,21 @@ namespace ThreatSource.Jammer
|
||||
/// </summary>
|
||||
public JammingType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 干扰模式
|
||||
/// </summary>
|
||||
public JammingMode Mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 干扰源ID
|
||||
/// </summary>
|
||||
public string JammerId { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 干扰源ID
|
||||
/// </summary>
|
||||
public string? SourceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 干扰目标ID
|
||||
/// </summary>
|
||||
@ -56,11 +66,6 @@ namespace ThreatSource.Jammer
|
||||
/// </summary>
|
||||
public double? Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 干扰模式
|
||||
/// </summary>
|
||||
public JammingMode Mode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 干扰开始时间
|
||||
/// </summary>
|
||||
@ -132,9 +137,9 @@ namespace ThreatSource.Jammer
|
||||
public enum JammingMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 噪声干扰
|
||||
/// 阻塞干扰
|
||||
/// </summary>
|
||||
Noise,
|
||||
Blocking,
|
||||
|
||||
/// <summary>
|
||||
/// 欺骗干扰
|
||||
@ -142,14 +147,9 @@ namespace ThreatSource.Jammer
|
||||
Deception,
|
||||
|
||||
/// <summary>
|
||||
/// 阻塞干扰
|
||||
/// 噪声干扰
|
||||
/// </summary>
|
||||
Blocking,
|
||||
|
||||
/// <summary>
|
||||
/// 扫频干扰
|
||||
/// </summary>
|
||||
Sweep,
|
||||
Noise,
|
||||
|
||||
/// <summary>
|
||||
/// 遮蔽干扰(烟幕)
|
||||
|
||||
@ -17,9 +17,9 @@ namespace ThreatSource.Jammer
|
||||
protected override JammerType Type => JammerType.LaserDecoy;
|
||||
|
||||
/// <summary>
|
||||
/// 获取支持的干扰类型
|
||||
/// 支持的干扰类型
|
||||
/// </summary>
|
||||
public override IEnumerable<JammingType> SupportedJammingTypes => [JammingType.Decoy];
|
||||
protected override JammingType[] SupportedJammingTypes => [JammingType.Decoy];
|
||||
|
||||
/// <summary>
|
||||
/// 激光诱偏目标配置
|
||||
@ -57,27 +57,44 @@ namespace ThreatSource.Jammer
|
||||
return new JammingParameters
|
||||
{
|
||||
Type = JammingType.Decoy,
|
||||
Mode = config.Mode,
|
||||
JammerId = Id,
|
||||
Power = config.DecoyPower,
|
||||
Wavelength = config.DecoyWavelength,
|
||||
SourceId = SourceId,
|
||||
Power = config.Power,
|
||||
Wavelength = config.Wavelength,
|
||||
SourcePosition = sourcePosition,
|
||||
Direction = Orientation.ToVector(),
|
||||
DecoyPosition = Position,
|
||||
AngleRange = config.DecoyLaserDivergenceAngle,
|
||||
Duration = config.LifeTime,
|
||||
AngleRange = config.DivergenceAngle,
|
||||
Duration = config.Duration,
|
||||
ReflectiveArea = config.ReflectiveArea,
|
||||
ReflectionCoefficient = config.ReflectionCoefficient,
|
||||
StartTime = DateTime.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新干扰效果
|
||||
/// </summary>
|
||||
protected override void UpdateJamming(double deltaTime)
|
||||
{
|
||||
base.UpdateJamming(deltaTime);
|
||||
// 更新诱偏目标的位置
|
||||
Position += Velocity * deltaTime;
|
||||
|
||||
if (CurrentParameters != null)
|
||||
{
|
||||
PublishJammingEvent(CurrentParameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取激光诱偏目标状态
|
||||
/// </summary>
|
||||
/// <returns>激光诱偏目标状态</returns>
|
||||
public override string GetStatus()
|
||||
{
|
||||
return base.GetStatus() + $"诱饵位置: {Position}, 源 ID: {SourceId}, 诱偏功率: {config.DecoyPower}, 诱偏激光发散角: {config.DecoyLaserDivergenceAngle}, 反射系数: {config.ReflectionCoefficient}, 有效反射面积: {config.ReflectiveArea}, 生命周期: {config.LifeTime}\n";
|
||||
return base.GetStatus() + $"诱饵位置: {Position}, 源 ID: {SourceId}, 诱偏功率: {config.Power}, 诱偏激光发散角: {config.DivergenceAngle}, 反射系数: {config.ReflectionCoefficient}, 有效反射面积: {config.ReflectiveArea}, 生命周期: {config.Duration}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@ namespace ThreatSource.Jammer
|
||||
/// <summary>
|
||||
/// 支持的干扰类型
|
||||
/// </summary>
|
||||
public override IEnumerable<JammingType> SupportedJammingTypes => [JammingType.Laser];
|
||||
protected override JammingType[] SupportedJammingTypes => [JammingType.Laser];
|
||||
|
||||
/// <summary>
|
||||
/// 激光干扰器配置
|
||||
@ -52,8 +52,26 @@ namespace ThreatSource.Jammer
|
||||
Direction = Orientation.ToVector(),
|
||||
SourcePosition = Position,
|
||||
Mode = config.Mode,
|
||||
Duration = config.Duration
|
||||
Duration = config.Duration,
|
||||
StartTime = DateTime.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新干扰效果
|
||||
/// </summary>
|
||||
protected override void UpdateJamming(double deltaTime)
|
||||
{
|
||||
base.UpdateJamming(deltaTime);
|
||||
|
||||
// 更新位置
|
||||
Position += Velocity * deltaTime;
|
||||
|
||||
// 更新干扰事件
|
||||
if (CurrentParameters != null)
|
||||
{
|
||||
PublishJammingEvent(CurrentParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@ namespace ThreatSource.Jammer
|
||||
/// <summary>
|
||||
/// 支持的干扰类型
|
||||
/// </summary>
|
||||
public override IEnumerable<JammingType> SupportedJammingTypes => [JammingType.MillimeterWave];
|
||||
protected override JammingType[] SupportedJammingTypes => [JammingType.MillimeterWave];
|
||||
|
||||
/// <summary>
|
||||
/// 毫米波干扰器配置
|
||||
@ -52,10 +52,26 @@ namespace ThreatSource.Jammer
|
||||
Direction = Orientation.ToVector(),
|
||||
SourcePosition = Position,
|
||||
Mode = config.Mode,
|
||||
Duration = config.Duration
|
||||
Duration = config.Duration,
|
||||
StartTime = DateTime.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
// 可在此处重写 UpdateJamming(double deltaTime) 以实现毫米波干扰的特定效果更新逻辑
|
||||
/// <summary>
|
||||
/// 更新干扰效果
|
||||
/// </summary>
|
||||
protected override void UpdateJamming(double deltaTime)
|
||||
{
|
||||
base.UpdateJamming(deltaTime);
|
||||
|
||||
// 更新位置
|
||||
Position += Velocity * deltaTime;
|
||||
|
||||
// 更新干扰事件
|
||||
if (CurrentParameters != null)
|
||||
{
|
||||
PublishJammingEvent(CurrentParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,12 +21,12 @@ namespace ThreatSource.Jammer
|
||||
/// 获取干扰器类型
|
||||
/// </summary>
|
||||
protected override JammerType Type => JammerType.SmokeGrenade;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取支持的干扰类型
|
||||
/// 支持的干扰类型
|
||||
/// </summary>
|
||||
public override IEnumerable<JammingType> SupportedJammingTypes => [JammingType.SmokeScreen];
|
||||
|
||||
protected override JammingType[] SupportedJammingTypes => [JammingType.SmokeScreen];
|
||||
|
||||
/// <summary>
|
||||
/// 初始化烟幕弹实例
|
||||
/// </summary>
|
||||
@ -45,32 +45,6 @@ namespace ThreatSource.Jammer
|
||||
IsActive = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激活烟幕弹
|
||||
/// </summary>
|
||||
public override void Activate()
|
||||
{
|
||||
IsActive = true;
|
||||
_elapsedTime = 0;
|
||||
if (!IsJamming)
|
||||
{
|
||||
var parameters = CreateJammingParameters();
|
||||
StartJamming(parameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁用烟幕弹
|
||||
/// </summary>
|
||||
public override void Deactivate()
|
||||
{
|
||||
IsActive = false;
|
||||
if (IsJamming)
|
||||
{
|
||||
StopJamming();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建烟幕干扰参数
|
||||
/// </summary>
|
||||
@ -79,6 +53,7 @@ namespace ThreatSource.Jammer
|
||||
return new JammingParameters
|
||||
{
|
||||
Type = JammingType.SmokeScreen,
|
||||
Mode = config.Mode,
|
||||
JammerId = Id,
|
||||
Power = 0, // 烟幕不需要功率参数
|
||||
Direction = Orientation.ToVector(),
|
||||
|
||||
@ -240,12 +240,12 @@ namespace ThreatSource.Sensor
|
||||
/// <summary>
|
||||
/// 处理红外干扰清除
|
||||
/// </summary>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type);
|
||||
base.HandleJammingCleared(parameters);
|
||||
// 基类 JammableComponent 和 Sensor 已经处理了 IsJammed 状态
|
||||
// 这里只处理探测器特定的响应
|
||||
if (type == JammingType.Infrared)
|
||||
if (parameters.Type == JammingType.Infrared)
|
||||
{
|
||||
Debug.WriteLine("[InfraredDetector] 红外探测器干扰已清除", "Jamming");
|
||||
// 只有在整体未被干扰时才恢复有效状态
|
||||
|
||||
@ -216,12 +216,12 @@ namespace ThreatSource.Sensor
|
||||
/// <summary>
|
||||
/// 处理激光干扰清除
|
||||
/// </summary>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type);
|
||||
base.HandleJammingCleared(parameters);
|
||||
// 基类 JammableComponent 和 Sensor 已经处理了 IsJammed 状态
|
||||
// 这里只处理测距仪特定的响应
|
||||
if (type == JammingType.Laser)
|
||||
if (parameters.Type == JammingType.Laser)
|
||||
{
|
||||
Debug.WriteLine("[LaserRangefinder] 激光测距仪干扰已清除", "Jamming");
|
||||
// 只有在整体未被干扰时才恢复有效状态
|
||||
|
||||
@ -220,12 +220,12 @@ namespace ThreatSource.Sensor
|
||||
/// <summary>
|
||||
/// 处理毫米波干扰清除
|
||||
/// </summary>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type);
|
||||
base.HandleJammingCleared(parameters);
|
||||
// 基类 JammableComponent 和 Sensor 已经处理了 IsJammed 状态
|
||||
// 这里只处理测高雷达特定的响应
|
||||
if (type == JammingType.MillimeterWave)
|
||||
if (parameters.Type == JammingType.MillimeterWave)
|
||||
{
|
||||
Debug.WriteLine("[MillimeterWaveAltimeter] 毫米波测高雷达干扰已清除", "Jamming");
|
||||
// 只有在整体未被干扰时才恢复有效状态
|
||||
|
||||
@ -279,12 +279,12 @@ namespace ThreatSource.Sensor
|
||||
/// <summary>
|
||||
/// 处理毫米波干扰清除
|
||||
/// </summary>
|
||||
protected override void HandleJammingCleared(JammingType type)
|
||||
protected override void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
base.HandleJammingCleared(type);
|
||||
base.HandleJammingCleared(parameters);
|
||||
// 基类 JammableComponent 和 Sensor 已经处理了 IsJammed 状态
|
||||
// 这里只处理辐射计特定的响应
|
||||
if (type == JammingType.MillimeterWave)
|
||||
if (parameters.Type == JammingType.MillimeterWave)
|
||||
{
|
||||
Debug.WriteLine("[MillimeterWaveRadiometer] 毫米波辐射计干扰已清除", "Jamming");
|
||||
// 只有在整体未被干扰时才恢复有效状态
|
||||
|
||||
@ -116,15 +116,15 @@ namespace ThreatSource.Sensor
|
||||
/// <summary>
|
||||
/// 处理传感器干扰被清除的事件
|
||||
/// </summary>
|
||||
/// <param name="type">被清除的干扰类型</param>
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
/// <remarks>
|
||||
/// 当干扰被清除时调用
|
||||
/// 子类可以重写以实现干扰清除后的特定行为
|
||||
/// </remarks>
|
||||
protected virtual void HandleJammingCleared(JammingType type)
|
||||
protected virtual void HandleJammingCleared(JammingParameters parameters)
|
||||
{
|
||||
// 子类可以重写此方法以实现干扰清除后的特定行为
|
||||
System.Diagnostics.Debug.WriteLine($"传感器{type}类型干扰已清除");
|
||||
System.Diagnostics.Debug.WriteLine($"传感器{parameters.Type}类型干扰已清除");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -179,17 +179,26 @@ namespace ThreatSource.Sensor
|
||||
/// <param name="evt">干扰事件</param>
|
||||
protected virtual void HandleJammingEvent(JammingEvent evt)
|
||||
{
|
||||
if (evt == null) return;
|
||||
|
||||
// 在应用干扰前检查是否应该处理此干扰
|
||||
if (!ShouldHandleJamming(evt.Parameters))
|
||||
if (evt != null)
|
||||
{
|
||||
// 可选择记录日志:Debug.WriteLine($"传感器 {Id} 忽略干扰事件,类型: {evt.Parameters.Type}");
|
||||
return;
|
||||
// 在应用干扰前检查是否应该处理此干扰
|
||||
if (ShouldHandleJamming(evt.Parameters))
|
||||
{
|
||||
ApplyJamming(evt.Parameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 如果应该处理,则应用干扰
|
||||
ApplyJamming(evt.Parameters);
|
||||
/// <summary>
|
||||
/// 统一处理干扰停止事件
|
||||
/// </summary>
|
||||
/// <param name="evt">干扰停止事件</param>
|
||||
protected virtual void HandleJammingStoppedEvent(JammingStoppedEvent evt)
|
||||
{
|
||||
if (evt != null)
|
||||
{
|
||||
ClearJamming(evt.Parameters);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -220,14 +229,14 @@ namespace ThreatSource.Sensor
|
||||
/// <summary>
|
||||
/// 清除干扰
|
||||
/// </summary>
|
||||
/// <param name="type">要清除的干扰类型</param>
|
||||
/// <param name="parameters">干扰参数</param>
|
||||
/// <remarks>
|
||||
/// 移除特定类型的干扰影响
|
||||
/// 恢复传感器的正常工作状态
|
||||
/// </remarks>
|
||||
public virtual void ClearJamming(JammingType type)
|
||||
public virtual void ClearJamming(JammingParameters parameters)
|
||||
{
|
||||
_jammingComponent.ClearJamming(type);
|
||||
_jammingComponent.ClearJamming(parameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -248,12 +257,12 @@ namespace ThreatSource.Sensor
|
||||
/// </summary>
|
||||
public override void Activate()
|
||||
{
|
||||
if (!IsActive)
|
||||
if (!IsActive)
|
||||
{
|
||||
IsActive = true;
|
||||
// 统一订阅 HandleJammingEvent
|
||||
SimulationManager.SubscribeToEvent<JammingEvent>(HandleJammingEvent);
|
||||
// 移除可能存在的旧订阅(如果子类之前有单独订阅)
|
||||
SimulationManager.SubscribeToEvent<JammingStoppedEvent>(HandleJammingStoppedEvent);
|
||||
}
|
||||
base.Activate();
|
||||
}
|
||||
@ -263,12 +272,12 @@ namespace ThreatSource.Sensor
|
||||
/// </summary>
|
||||
public override void Deactivate()
|
||||
{
|
||||
if (IsActive)
|
||||
if (IsActive)
|
||||
{
|
||||
IsActive = false;
|
||||
// 统一取消订阅 HandleJammingEvent
|
||||
SimulationManager.UnsubscribeFromEvent<JammingEvent>(HandleJammingEvent);
|
||||
// 移除可能存在的旧取消订阅
|
||||
SimulationManager.UnsubscribeFromEvent<JammingStoppedEvent>(HandleJammingStoppedEvent);
|
||||
}
|
||||
base.Deactivate();
|
||||
}
|
||||
|
||||
@ -1574,6 +1574,11 @@ namespace ThreatSource.Simulation
|
||||
/// </remarks>
|
||||
public SmokeScreenType SmokeType { get; set; } = SmokeScreenType.Cloud;
|
||||
|
||||
/// <summary>
|
||||
/// 干扰模式
|
||||
/// </summary>
|
||||
public JammingMode Mode { get; set; } = JammingMode.Obscuration;
|
||||
|
||||
/// <summary>
|
||||
/// 是否是遮蔽型烟幕
|
||||
/// </summary>
|
||||
@ -1708,7 +1713,7 @@ namespace ThreatSource.Simulation
|
||||
/// <summary>
|
||||
/// 干扰模式
|
||||
/// </summary>
|
||||
public JammingMode Mode { get; set; } = JammingMode.Noise;
|
||||
public JammingMode Mode { get; set; } = JammingMode.Blocking;
|
||||
|
||||
/// <summary>
|
||||
/// 持续时间,单位:秒
|
||||
@ -1739,7 +1744,7 @@ namespace ThreatSource.Simulation
|
||||
/// <summary>
|
||||
/// 干扰模式
|
||||
/// </summary>
|
||||
public JammingMode Mode { get; set; } = JammingMode.Noise;
|
||||
public JammingMode Mode { get; set; } = JammingMode.Blocking;
|
||||
|
||||
/// <summary>
|
||||
/// 持续时间,单位:秒
|
||||
@ -1770,7 +1775,7 @@ namespace ThreatSource.Simulation
|
||||
/// <summary>
|
||||
/// 干扰模式
|
||||
/// </summary>
|
||||
public JammingMode Mode { get; set; } = JammingMode.Noise;
|
||||
public JammingMode Mode { get; set; } = JammingMode.Blocking;
|
||||
|
||||
/// <summary>
|
||||
/// 持续时间,单位:秒
|
||||
@ -1783,20 +1788,25 @@ namespace ThreatSource.Simulation
|
||||
/// </summary>
|
||||
public class LaserDecoyConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 干扰模式
|
||||
/// </summary>
|
||||
public JammingMode Mode { get; set; } = JammingMode.Deception;
|
||||
|
||||
/// <summary>
|
||||
/// 诱偏源功率,单位:瓦特
|
||||
/// </summary>
|
||||
public double DecoyPower { get; set; } = 0;
|
||||
public double Power { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 诱偏激光波长,单位:微米
|
||||
/// </summary>
|
||||
public double DecoyWavelength { get; set; } = 1.06;
|
||||
public double Wavelength { get; set; } = 1.06;
|
||||
|
||||
/// <summary>
|
||||
/// 诱偏激光发散角,单位:度
|
||||
/// </summary>
|
||||
public double DecoyLaserDivergenceAngle { get; set; } = 0;
|
||||
public double DivergenceAngle { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 有效反射面积,单位:平方米
|
||||
@ -1809,9 +1819,9 @@ namespace ThreatSource.Simulation
|
||||
public double ReflectionCoefficient { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 生命周期,单位:秒
|
||||
/// 持续时间,单位:秒
|
||||
/// </summary>
|
||||
public double LifeTime { get; set; } = 0;
|
||||
public double Duration { get; set; } = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -487,51 +487,6 @@ namespace ThreatSource.Simulation
|
||||
public LaserCodeConfig? ReceivedCodeConfig { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 激光诱偏目标事件,表示激光诱偏目标被照射
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 用于模拟激光诱偏目标被照射的情况
|
||||
/// 触发时机:激光诱偏目标被照射时
|
||||
/// </remarks>
|
||||
public class LaserDecoyEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置激光诱偏目标的ID
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 标识被照射的激光诱偏目标
|
||||
/// </remarks>
|
||||
public string? LaserDecoyId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置激光诱偏源的ID
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 标识照射激光诱偏目标的激光诱偏源
|
||||
/// </remarks>
|
||||
public string? SourceId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 激光诱偏目标停止事件,表示激光诱偏目标停止
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 用于模拟激光诱偏目标停止的情况
|
||||
/// 触发时机:激光诱偏目标停止时
|
||||
/// </remarks>
|
||||
public class LaserDecoyStopEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取或设置激光诱偏目标的ID
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// 标识停止的激光诱偏目标
|
||||
/// </remarks>
|
||||
public string? LaserDecoyId { get; set; }
|
||||
}
|
||||
|
||||
// --- General Jamming Events ---
|
||||
|
||||
/// <summary>
|
||||
|
||||
33
docs/project/missiles_jamming_methods.md
Normal file
33
docs/project/missiles_jamming_methods.md
Normal file
@ -0,0 +1,33 @@
|
||||
# 导弹-干扰方式对照表
|
||||
|
||||
| 导弹类型 | 干扰方式 | 干扰模式 | 作用对象 | 干扰效果 |
|
||||
|---------|----------|---------|---------|---------|
|
||||
| 激光驾束导弹 | 激光干扰 | 阻塞 | 指示器 | 通过强光干扰激光指示器,使其无法发射引导光束 |
|
||||
| 激光驾束导弹 | 烟幕弹 | 遮蔽 | 两者 | 阻断激光束的传播,导弹无法接收到正确的光束信号 |
|
||||
| 激光半主动制导导弹 | 激光干扰 | 阻塞 | 指示器 | 干扰照射器使其无法正常照射目标 |
|
||||
| 激光半主动制导导弹 | 激光干扰 | 阻塞 | 导弹 | 干扰导弹上的激光接收器,使其无法正确感知反射激光 |
|
||||
| 激光半主动制导导弹 | 激光诱偏目标 | 欺骗 | 导弹 | 在目标附近创建虚假的激光反射点,误导导弹攻击错误目标 |
|
||||
| 激光半主动制导导弹 | 烟幕弹 | 遮蔽 | 两者 | 阻断激光传播和反射,同时影响照射器和导弹的激光接收 |
|
||||
| 红外指令制导导弹 | 红外干扰 | 阻塞 | 指示器 | 干扰红外指示器的成像系统,使其无法正确识别和跟踪目标
|
||||
| 红外指令制导导弹 | 烟幕弹 | 遮蔽 | 指示器 | 阻断红外辐射,指示器无法探测目标热特征 |
|
||||
| 红外成像末制导导弹 | 红外干扰 | 阻塞 | 导弹 | 向导弹红外成像系统发射强红外干扰信号,使导弹无法形成有效目标图像 |
|
||||
| 红外成像末制导导弹 | 烟幕弹 | 遮蔽 | 导弹 | 遮挡目标红外特征,使导弹无法形成有效目标图像 |
|
||||
| 毫米波末制导导弹 | 毫米波干扰 | 阻塞 | 导弹 | 高功率阻塞干扰,使毫米波雷达接收机饱和 |
|
||||
| 毫米波末制导导弹 | 烟幕弹 | 遮蔽 | 导弹 | 阻断毫米波传播,使导弹无法形成有效目标图像 |
|
||||
| 末敏子弹药 | 激光干扰 | 阻塞 | 子弹药 | 干扰激光测高仪,影响高度测量 |
|
||||
| 末敏子弹药 | 红外干扰 | 阻塞 | 子弹药 | 干扰红外探测器,影响发现目标 |
|
||||
| 末敏子弹药 | 毫米波干扰 | 阻塞 | 子弹药 | 干扰毫米波探测器,影响发现目标 |
|
||||
| 末敏子弹药 | 毫米波假信号 | 欺骗 | 子弹药 | 发射假背景信号,干扰毫米波发现目标 |
|
||||
| 末敏子弹药 | 烟幕弹 | 遮蔽 | 子弹药 | 减弱各种传感器信号,降低引信触发概率 |
|
||||
|
||||
## 干扰方式分类说明
|
||||
|
||||
### 干扰模式
|
||||
1. **阻塞干扰**:使用高功率干扰信号完全覆盖目标频段或通道,目的在于完全中断信号传输
|
||||
2. **欺骗干扰**:发送伪造信号,使目标系统产生错误判断
|
||||
3. **遮蔽干扰**:通过物理屏障阻断信号传播,如烟幕遮挡光学和红外线
|
||||
|
||||
### 作用对象说明
|
||||
- **导弹**:干扰直接作用于导弹上的传感器或制导系统
|
||||
- **指示器**:干扰作用于地面/平台上的指示器或照射设备
|
||||
- **两者**:同时影响导弹和指示器的工作
|
||||
@ -6,6 +6,7 @@ using System.Diagnostics;
|
||||
using ThreatSource.Missile;
|
||||
using ThreatSource.Simulation;
|
||||
using ThreatSource.Utils;
|
||||
using ThreatSource.Jammable;
|
||||
using ThreatSource.Jammer;
|
||||
using ThreatSource.Sensor;
|
||||
using ThreatSource.Equipment;
|
||||
@ -33,6 +34,32 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
private readonly Dictionary<string, BaseJammer> jammers;
|
||||
private Dictionary<string, bool> missileActiveStatus;
|
||||
private readonly double timeStep = 0.01; // 时间步长,单位:秒
|
||||
|
||||
// 导弹-干扰映射表
|
||||
private Dictionary<string, List<(JammingType Type, string DisplayName, string JammerId, string Mode, string Target)>> missileJammingMap;
|
||||
|
||||
// 当前选中的导弹ID
|
||||
public string SelectedMissileId { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前选中导弹的显示名称
|
||||
/// </summary>
|
||||
public string SelectedMissileDisplayName
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (SelectedMissileId)
|
||||
{
|
||||
case "LSGM_1": return "激光半主动制导导弹";
|
||||
case "LBRM_1": return "激光驾束制导导弹";
|
||||
case "TSM_1": return "末敏子弹药";
|
||||
case "ICGM_1": return "红外指令制导导弹";
|
||||
case "ITGM_1": return "红外成像末制导导弹";
|
||||
case "MMWG_1": return "毫米波末制导导弹";
|
||||
default: return "未知导弹";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化综合导弹模拟器
|
||||
@ -47,8 +74,67 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
indicators = new Dictionary<string, SimulationElement>();
|
||||
jammers = new Dictionary<string, BaseJammer>();
|
||||
missileActiveStatus = new Dictionary<string, bool>();
|
||||
|
||||
// 初始化导弹-干扰映射
|
||||
InitializeMissileJammingMap();
|
||||
|
||||
InitializeSimulation();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化导弹-干扰映射关系
|
||||
/// </summary>
|
||||
private void InitializeMissileJammingMap()
|
||||
{
|
||||
missileJammingMap = new Dictionary<string, List<(JammingType, string, string, string, string)>>();
|
||||
|
||||
// 激光驾束导弹
|
||||
missileJammingMap["LBRM_1"] = new List<(JammingType, string, string, string, string)>
|
||||
{
|
||||
(JammingType.Laser, "激光干扰", "LaserJammer_Designator", "阻塞", "指示器"),
|
||||
(JammingType.SmokeScreen, "烟幕弹", "SG_1", "遮蔽", "两者")
|
||||
};
|
||||
|
||||
// 激光半主动制导导弹
|
||||
missileJammingMap["LSGM_1"] = new List<(JammingType, string, string, string, string)>
|
||||
{
|
||||
(JammingType.Laser, "激光干扰(指示器)", "LaserJammer_Designator", "阻塞", "指示器"),
|
||||
(JammingType.Laser, "激光干扰(导弹)", "LaserJammer_Missile", "阻塞", "导弹"),
|
||||
(JammingType.Decoy, "激光诱偏目标", "LDY_1", "欺骗", "导弹"),
|
||||
(JammingType.SmokeScreen, "烟幕弹", "SG_1", "遮蔽", "两者")
|
||||
};
|
||||
|
||||
// 红外指令制导导弹
|
||||
missileJammingMap["ICGM_1"] = new List<(JammingType, string, string, string, string)>
|
||||
{
|
||||
(JammingType.Infrared, "红外干扰", "InfraredJammer_Designator", "阻塞", "指示器"),
|
||||
(JammingType.SmokeScreen, "烟幕弹", "SG_2", "遮蔽", "指示器")
|
||||
};
|
||||
|
||||
// 红外成像末制导导弹
|
||||
missileJammingMap["ITGM_1"] = new List<(JammingType, string, string, string, string)>
|
||||
{
|
||||
(JammingType.Infrared, "红外干扰", "InfraredJammer_Missile", "阻塞", "导弹"),
|
||||
(JammingType.SmokeScreen, "红外烟幕弹", "SG_2", "遮蔽", "导弹")
|
||||
};
|
||||
|
||||
// 毫米波末制导导弹
|
||||
missileJammingMap["MMWG_1"] = new List<(JammingType, string, string, string, string)>
|
||||
{
|
||||
(JammingType.MillimeterWave, "毫米波干扰", "MillimeterWaveJammer_Missile", "阻塞", "导弹"),
|
||||
(JammingType.SmokeScreen, "烟幕弹", "SG_1", "遮蔽", "导弹")
|
||||
};
|
||||
|
||||
// 末敏子弹药
|
||||
missileJammingMap["TSM_1"] = new List<(JammingType, string, string, string, string)>
|
||||
{
|
||||
(JammingType.Laser, "激光干扰", "LaserJammer_Missile", "阻塞", "子弹药"),
|
||||
(JammingType.Infrared, "红外干扰", "InfraredJammer_Missile", "阻塞", "子弹药"),
|
||||
(JammingType.MillimeterWave, "毫米波干扰", "MillimeterWaveJammer_Submunition", "阻塞", "子弹药"),
|
||||
(JammingType.MillimeterWave, "毫米波假信号", "MillimeterWaveJammer_Submunition", "欺骗", "子弹药"),
|
||||
(JammingType.SmokeScreen, "烟幕弹", "SG_3", "遮蔽", "子弹药")
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化仿真环境
|
||||
@ -77,6 +163,12 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
|
||||
// 添加激光诱偏目标
|
||||
AddLaserDecoy();
|
||||
|
||||
// 添加各类型干扰器
|
||||
AddJammers();
|
||||
|
||||
// 打印所有注册的干扰器
|
||||
PrintAllJammers();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -330,6 +422,120 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
Console.WriteLine($"注册红外测角仪 {infraredTrackerId}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加各类型干扰器
|
||||
/// </summary>
|
||||
private void AddJammers()
|
||||
{
|
||||
// 添加激光干扰器 - 指向指示器
|
||||
var laserJammerParams = new MotionParameters
|
||||
{
|
||||
Position = new Vector3D(0, 0, 0),
|
||||
Orientation = CalculateOrientationToEntity(indicators["LD_1"]), // 朝向激光指示器
|
||||
InitialSpeed = 0.0
|
||||
};
|
||||
string laserJammerId = "LaserJammer_Designator";
|
||||
var laserJammer = _threatSourceFactory.CreateJammer(laserJammerId, "laser_blocking", laserJammerParams, "Tank_1");
|
||||
if (laserJammer != null)
|
||||
{
|
||||
simulationManager.RegisterEntity(laserJammerId, laserJammer);
|
||||
jammers[laserJammerId] = laserJammer as BaseJammer;
|
||||
Console.WriteLine($"注册激光干扰器(指向指示器) {laserJammerId}");
|
||||
}
|
||||
|
||||
// 添加激光干扰器 - 指向导弹
|
||||
laserJammerParams = new MotionParameters
|
||||
{
|
||||
Position = new Vector3D(0, 0, 0),
|
||||
Orientation = CalculateOrientationToEntity(missiles["LSGM_1"]), // 朝向激光半主动导弹
|
||||
InitialSpeed = 0.0
|
||||
};
|
||||
laserJammerId = "LaserJammer_Missile";
|
||||
laserJammer = _threatSourceFactory.CreateJammer(laserJammerId, "laser_blocking", laserJammerParams, "Tank_1");
|
||||
if (laserJammer != null)
|
||||
{
|
||||
simulationManager.RegisterEntity(laserJammerId, laserJammer);
|
||||
jammers[laserJammerId] = laserJammer as BaseJammer;
|
||||
Console.WriteLine($"注册激光干扰器(指向导弹) {laserJammerId}");
|
||||
}
|
||||
|
||||
// 添加红外干扰器 - 指向指示器
|
||||
var irJammerParams = new MotionParameters
|
||||
{
|
||||
Position = new Vector3D(0, 0, 0),
|
||||
Orientation = CalculateOrientationToEntity(indicators["IT_1"]), // 朝向红外指示器
|
||||
InitialSpeed = 0.0
|
||||
};
|
||||
string irJammerId = "InfraredJammer_Designator";
|
||||
var irJammer = _threatSourceFactory.CreateJammer(irJammerId, "infrared_blocking", irJammerParams, "Tank_1");
|
||||
if (irJammer != null)
|
||||
{
|
||||
simulationManager.RegisterEntity(irJammerId, irJammer);
|
||||
jammers[irJammerId] = irJammer as BaseJammer;
|
||||
Console.WriteLine($"注册红外干扰器(指向指示器) {irJammerId}");
|
||||
}
|
||||
|
||||
// 添加红外干扰器 - 指向导弹
|
||||
irJammerParams = new MotionParameters
|
||||
{
|
||||
Position = new Vector3D(0, 0, 0),
|
||||
Orientation = CalculateOrientationToEntity(missiles["ITGM_1"]), // 朝向红外成像导弹
|
||||
InitialSpeed = 0.0
|
||||
};
|
||||
irJammerId = "InfraredJammer_Missile";
|
||||
irJammer = _threatSourceFactory.CreateJammer(irJammerId, "infrared_blocking", irJammerParams, "Tank_1");
|
||||
if (irJammer != null)
|
||||
{
|
||||
simulationManager.RegisterEntity(irJammerId, irJammer);
|
||||
jammers[irJammerId] = irJammer as BaseJammer;
|
||||
Console.WriteLine($"注册红外干扰器(指向导弹) {irJammerId}");
|
||||
}
|
||||
|
||||
// 添加毫米波干扰器 - 指向导弹
|
||||
var mmwJammerParams = new MotionParameters
|
||||
{
|
||||
Position = new Vector3D(0, 0, 0),
|
||||
Orientation = CalculateOrientationToEntity(missiles["MMWG_1"]), // 朝向毫米波导弹
|
||||
InitialSpeed = 0.0
|
||||
};
|
||||
string mmwJammerId = "MillimeterWaveJammer_Missile";
|
||||
var mmwJammer = _threatSourceFactory.CreateJammer(mmwJammerId, "mmw_blocking", mmwJammerParams, "Tank_1");
|
||||
if (mmwJammer != null)
|
||||
{
|
||||
simulationManager.RegisterEntity(mmwJammerId, mmwJammer);
|
||||
jammers[mmwJammerId] = mmwJammer as BaseJammer;
|
||||
Console.WriteLine($"注册毫米波干扰器(指向导弹) {mmwJammerId}");
|
||||
}
|
||||
|
||||
// 添加毫米波干扰器 - 指向子弹药
|
||||
mmwJammerParams = new MotionParameters
|
||||
{
|
||||
Position = new Vector3D(0, 0, 0),
|
||||
Orientation = CalculateOrientationToEntity(missiles["TSM_1"]), // 朝向末敏子弹药
|
||||
InitialSpeed = 0.0
|
||||
};
|
||||
mmwJammerId = "MillimeterWaveJammer_Submunition";
|
||||
mmwJammer = _threatSourceFactory.CreateJammer(mmwJammerId, "mmw_deception", mmwJammerParams, "Tank_1");
|
||||
if (mmwJammer != null)
|
||||
{
|
||||
simulationManager.RegisterEntity(mmwJammerId, mmwJammer);
|
||||
jammers[mmwJammerId] = mmwJammer as BaseJammer;
|
||||
Console.WriteLine($"注册毫米波干扰器(指向子弹药) {mmwJammerId}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算朝向实体的方向
|
||||
/// </summary>
|
||||
private Orientation CalculateOrientationToEntity(SimulationElement target)
|
||||
{
|
||||
// 使用CalculateDirectionToTarget获取归一化方向向量
|
||||
Vector3D direction = CalculateDirectionToTarget(new Vector3D(0, 0, 0), target.Position);
|
||||
|
||||
// 创建朝向目标的方向
|
||||
return Orientation.FromVector(direction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择要激活的导弹
|
||||
/// </summary>
|
||||
@ -359,7 +565,8 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
// 激活选中的导弹
|
||||
missileActiveStatus[missileId] = true;
|
||||
missiles[missileId].Activate();
|
||||
Console.WriteLine($"已选择导弹:{missileId}");
|
||||
SelectedMissileId = missileId;
|
||||
Console.WriteLine($"已选择导弹:{missileId} ({SelectedMissileDisplayName})");
|
||||
|
||||
// 确保所有目标都处于激活状态
|
||||
foreach (var target in targets.Values)
|
||||
@ -410,84 +617,329 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前选中导弹可用的干扰选项
|
||||
/// </summary>
|
||||
public (JammingType Type, string DisplayName, string JammerId, string Mode, string Target)[] GetAvailableJammingOptions()
|
||||
{
|
||||
if (string.IsNullOrEmpty(SelectedMissileId) || !missileJammingMap.ContainsKey(SelectedMissileId))
|
||||
{
|
||||
return Array.Empty<(JammingType, string, string, string, string)>();
|
||||
}
|
||||
|
||||
return missileJammingMap[SelectedMissileId].ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用干扰
|
||||
/// </summary>
|
||||
public void ApplyJamming(JammingType type, string category, double power, double duration, Vector3D position)
|
||||
public void ApplyJamming(JammingType type, string displayName, string jammerId, string mode, string target)
|
||||
{
|
||||
var jammingParams = new JammingParameters
|
||||
// 检查并激活干扰器
|
||||
if (jammers.ContainsKey(jammerId))
|
||||
{
|
||||
Type = type,
|
||||
Power = power,
|
||||
Duration = duration,
|
||||
Direction = new Vector3D(1, 0, 0),
|
||||
SourcePosition = position
|
||||
};
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case JammingType.Laser:
|
||||
|
||||
break;
|
||||
case JammingType.Infrared:
|
||||
|
||||
break;
|
||||
case JammingType.MillimeterWave:
|
||||
|
||||
break;
|
||||
case JammingType.SmokeScreen:
|
||||
if (category == "水平烟幕弹")
|
||||
{
|
||||
jammingParams.JammerId = "SG_1";
|
||||
jammers["SG_1"].Activate();
|
||||
}
|
||||
else if (category == "红外烟幕弹")
|
||||
{
|
||||
jammingParams.JammerId = "SG_2";
|
||||
jammers["SG_2"].Activate();
|
||||
}
|
||||
else if (category == "顶部烟幕弹")
|
||||
{
|
||||
jammingParams.JammerId = "SG_3";
|
||||
jammers["SG_3"].Activate();
|
||||
}
|
||||
break;
|
||||
case JammingType.Decoy:
|
||||
jammingParams.JammerId = "LDY_1";
|
||||
jammers["LDY_1"].Activate();
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (var missile in missiles.Values)
|
||||
{
|
||||
if (missile is BaseMissile actualMissile)
|
||||
var jammer = jammers[jammerId];
|
||||
|
||||
// 激活干扰器实例
|
||||
jammer.Activate();
|
||||
|
||||
// 创建干扰参数
|
||||
JammingParameters jammingParams = new JammingParameters
|
||||
{
|
||||
// 获取导弹内部的传感器
|
||||
var infraredDetector = actualMissile.GetType().GetField("infraredDetector", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(actualMissile) as InfraredDetector;
|
||||
var radiometer = actualMissile.GetType().GetField("radiometer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(actualMissile) as MillimeterWaveRadiometer;
|
||||
var rangefinder = actualMissile.GetType().GetField("rangefinder", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(actualMissile) as LaserRangefinder;
|
||||
var altimeter = actualMissile.GetType().GetField("altimeter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(actualMissile) as MillimeterWaveAltimeter;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case JammingType.Infrared:
|
||||
infraredDetector?.ApplyJamming(jammingParams);
|
||||
break;
|
||||
case JammingType.MillimeterWave:
|
||||
radiometer?.ApplyJamming(jammingParams);
|
||||
altimeter?.ApplyJamming(jammingParams);
|
||||
break;
|
||||
case JammingType.Laser:
|
||||
rangefinder?.ApplyJamming(jammingParams);
|
||||
break;
|
||||
}
|
||||
Type = type,
|
||||
Mode = mode.Equals("阻塞") ? JammingMode.Blocking :
|
||||
mode.Equals("欺骗") ? JammingMode.Deception :
|
||||
mode.Equals("噪声") ? JammingMode.Noise : JammingMode.Blocking,
|
||||
JammerId = jammerId,
|
||||
SourceId = jammer.Id,
|
||||
Power = 1000, // 设置高功率
|
||||
Direction = jammer.Orientation.ToVector(),
|
||||
SourcePosition = jammer.Position,
|
||||
StartTime = DateTime.UtcNow, // 设置为当前时间
|
||||
Duration = 600 // 设置为10分钟(600秒)
|
||||
};
|
||||
|
||||
// 调用StartJamming方法开始干扰行为
|
||||
jammer.StartJamming(jammingParams);
|
||||
|
||||
Console.WriteLine($"激活干扰器并开始干扰: {jammerId}: {displayName} (模式: {mode}, 作用: {target})");
|
||||
Console.WriteLine($"干扰器 {jammerId} 激活状态: {jammer.IsActive}, 干扰状态: {jammer.IsJamming}");
|
||||
Console.WriteLine($"干扰参数: 类型={type}, 模式={jammingParams.Mode}, 开始时间={jammingParams.StartTime}, 持续时间={jammingParams.Duration}秒");
|
||||
Console.WriteLine($"干扰器 {jammerId} 状态信息: {jammer.GetStatus()}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"警告:找不到干扰器 {jammerId},可用干扰器: {string.Join(", ", jammers.Keys)}");
|
||||
PrintAllJammers();
|
||||
}
|
||||
|
||||
// 根据干扰目标对象应用干扰
|
||||
ApplyJammingToTargets(type, displayName, mode, target);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印所有注册的干扰器信息
|
||||
/// </summary>
|
||||
private void PrintAllJammers()
|
||||
{
|
||||
Console.WriteLine("\n所有注册的干扰器:");
|
||||
if (jammers.Count == 0)
|
||||
{
|
||||
Console.WriteLine("没有任何干扰器被注册!");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var jammer in jammers)
|
||||
{
|
||||
Console.WriteLine($"- {jammer.Key}: 类型={jammer.Value.GetType().Name}, 激活状态={jammer.Value.IsActive}");
|
||||
if (jammer.Value.IsActive)
|
||||
{
|
||||
Console.WriteLine($" 状态: {jammer.Value.GetStatus()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据目标类型应用干扰
|
||||
/// </summary>
|
||||
private void ApplyJammingToTargets(JammingType type, string displayName, string mode, string target)
|
||||
{
|
||||
// 根据target决定干扰作用对象
|
||||
switch (target.ToLower())
|
||||
{
|
||||
case "指示器":
|
||||
ApplyJammingToIndicators(type, mode);
|
||||
break;
|
||||
|
||||
case "导弹":
|
||||
ApplyJammingToMissiles(type, mode);
|
||||
break;
|
||||
|
||||
case "两者":
|
||||
ApplyJammingToIndicators(type, mode);
|
||||
ApplyJammingToMissiles(type, mode);
|
||||
break;
|
||||
|
||||
case "子弹药":
|
||||
ApplyJammingToMissiles(type, mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用干扰到指示器
|
||||
/// </summary>
|
||||
private void ApplyJammingToIndicators(JammingType type, string mode)
|
||||
{
|
||||
foreach (var indicator in indicators.Values.Where(i => i.IsActive))
|
||||
{
|
||||
Console.WriteLine($"应用{mode}干扰到指示器 {indicator.Id}");
|
||||
try
|
||||
{
|
||||
// 根据干扰类型选择合适的干扰器ID
|
||||
string jammerId = string.Empty;
|
||||
switch (type)
|
||||
{
|
||||
case JammingType.Laser:
|
||||
jammerId = "LaserJammer_Designator";
|
||||
break;
|
||||
case JammingType.Infrared:
|
||||
jammerId = "InfraredJammer_Designator";
|
||||
break;
|
||||
case JammingType.MillimeterWave:
|
||||
jammerId = "MillimeterWaveJammer_Missile"; // 假设这个也可以用于指示器
|
||||
break;
|
||||
case JammingType.SmokeScreen:
|
||||
if (indicator.Id.Contains("LD"))
|
||||
jammerId = "SG_1"; // 激光烟幕
|
||||
else if (indicator.Id.Contains("IR"))
|
||||
jammerId = "SG_2"; // 红外烟幕
|
||||
else
|
||||
jammerId = "SG_3"; // 默认烟幕
|
||||
break;
|
||||
case JammingType.Decoy:
|
||||
jammerId = "LDY_1";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(jammerId) && jammers.ContainsKey(jammerId))
|
||||
{
|
||||
var jammer = jammers[jammerId];
|
||||
|
||||
// 创建干扰参数
|
||||
JammingParameters jammingParams = new JammingParameters
|
||||
{
|
||||
Type = type,
|
||||
Mode = mode.Equals("阻塞") ? JammingMode.Blocking :
|
||||
mode.Equals("欺骗") ? JammingMode.Deception :
|
||||
mode.Equals("噪声") ? JammingMode.Noise : JammingMode.Blocking,
|
||||
JammerId = jammerId,
|
||||
SourceId = jammer.Id,
|
||||
Power = 800, // 设置合适功率
|
||||
Direction = CalculateDirectionToTarget(jammer.Position, indicator.Position),
|
||||
SourcePosition = jammer.Position,
|
||||
StartTime = DateTime.UtcNow,
|
||||
Duration = 600 // 10分钟
|
||||
};
|
||||
|
||||
// 找到指示器的实际实现类
|
||||
if (indicator is IJammable jammableIndicator)
|
||||
{
|
||||
// 调用IJammable接口的ApplyJamming方法
|
||||
jammableIndicator.ApplyJamming(jammingParams);
|
||||
Console.WriteLine($"成功应用干扰到指示器 {indicator.Id},干扰源: {jammerId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"警告: 指示器 {indicator.Id} 不支持IJammable接口");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"警告: 找不到合适的干扰器ID: {jammerId}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"对指示器 {indicator.Id} 应用干扰时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用干扰到导弹
|
||||
/// </summary>
|
||||
private void ApplyJammingToMissiles(JammingType type, string mode)
|
||||
{
|
||||
foreach (var missile in missiles.Values.Where(m => m.IsActive))
|
||||
{
|
||||
Console.WriteLine($"应用{mode}干扰到导弹 {missile.Id}");
|
||||
try
|
||||
{
|
||||
// 根据干扰类型和导弹类型选择合适的干扰器ID
|
||||
string jammerId = string.Empty;
|
||||
switch (type)
|
||||
{
|
||||
case JammingType.Laser:
|
||||
jammerId = "LaserJammer_Missile";
|
||||
break;
|
||||
case JammingType.Infrared:
|
||||
jammerId = "InfraredJammer_Missile";
|
||||
break;
|
||||
case JammingType.MillimeterWave:
|
||||
if (missile.Id.Contains("TSM"))
|
||||
jammerId = "MillimeterWaveJammer_Submunition"; // 针对子弹药
|
||||
else
|
||||
jammerId = "MillimeterWaveJammer_Missile";
|
||||
break;
|
||||
case JammingType.SmokeScreen:
|
||||
if (missile.Id.Contains("ITGM") || missile.Id.Contains("ICGM"))
|
||||
jammerId = "SG_2"; // 红外烟幕用于红外导弹
|
||||
else if (missile.Id.Contains("TSM"))
|
||||
jammerId = "SG_3"; // 顶部烟幕用于子弹药
|
||||
else
|
||||
jammerId = "SG_1"; // 默认烟幕
|
||||
break;
|
||||
case JammingType.Decoy:
|
||||
jammerId = "LDY_1";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(jammerId) && jammers.ContainsKey(jammerId))
|
||||
{
|
||||
var jammer = jammers[jammerId];
|
||||
|
||||
// 创建干扰参数
|
||||
JammingParameters jammingParams = new JammingParameters
|
||||
{
|
||||
Type = type,
|
||||
Mode = mode.Equals("阻塞") ? JammingMode.Blocking :
|
||||
mode.Equals("欺骗") ? JammingMode.Deception :
|
||||
mode.Equals("噪声") ? JammingMode.Noise : JammingMode.Blocking,
|
||||
JammerId = jammerId,
|
||||
SourceId = jammer.Id,
|
||||
Power = 1000, // 设置高功率
|
||||
Direction = CalculateDirectionToTarget(jammer.Position, missile.Position),
|
||||
SourcePosition = jammer.Position,
|
||||
StartTime = DateTime.UtcNow,
|
||||
Duration = 600 // 10分钟
|
||||
};
|
||||
|
||||
// 判断导弹是否实现了IJammable接口
|
||||
if (missile is IJammable jammableMissile)
|
||||
{
|
||||
// 调用IJammable接口的ApplyJamming方法
|
||||
jammableMissile.ApplyJamming(jammingParams);
|
||||
Console.WriteLine($"成功应用干扰到导弹 {missile.Id},干扰源: {jammerId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"警告: 导弹 {missile.Id} 不支持IJammable接口");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"警告: 找不到合适的干扰器ID: {jammerId}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"对导弹 {missile.Id} 应用干扰时出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算从源位置到目标位置的方向向量
|
||||
/// </summary>
|
||||
private Vector3D CalculateDirectionToTarget(Vector3D sourcePosition, Vector3D targetPosition)
|
||||
{
|
||||
Vector3D direction = targetPosition - sourcePosition;
|
||||
return direction.Normalize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除干扰
|
||||
/// </summary>
|
||||
public void ClearJamming(JammingType type, string displayName, string jammerId)
|
||||
{
|
||||
if (jammers.ContainsKey(jammerId))
|
||||
{
|
||||
jammers[jammerId].Deactivate();
|
||||
Console.WriteLine($"关闭干扰器 {jammerId}: {displayName}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 应用干扰 (原有方法,保留向后兼容)
|
||||
/// </summary>
|
||||
public void ApplyJamming(JammingType type, string category)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case JammingType.SmokeScreen:
|
||||
if (category == "水平烟幕弹")
|
||||
{
|
||||
jammers["SG_1"].Activate();
|
||||
}
|
||||
else if (category == "红外烟幕弹")
|
||||
{
|
||||
jammers["SG_2"].Activate();
|
||||
}
|
||||
else if (category == "顶部烟幕弹")
|
||||
{
|
||||
jammers["SG_3"].Activate();
|
||||
}
|
||||
break;
|
||||
case JammingType.Decoy:
|
||||
jammers["LDY_1"].Activate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清除干扰 (原有方法,保留向后兼容)
|
||||
/// </summary>
|
||||
public void ClearJamming(JammingType type, string category)
|
||||
{
|
||||
var jammingParams = new JammingParameters
|
||||
@ -499,31 +951,7 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
SourcePosition = new Vector3D(0, 0, 0)
|
||||
};
|
||||
|
||||
foreach (var missile in missiles.Values)
|
||||
{
|
||||
if (missile is BaseMissile actualMissile)
|
||||
{
|
||||
// 获取导弹内部的传感器
|
||||
var infraredDetector = actualMissile.GetType().GetField("infraredDetector", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(actualMissile) as InfraredDetector;
|
||||
var radiometer = actualMissile.GetType().GetField("radiometer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(actualMissile) as MillimeterWaveRadiometer;
|
||||
var rangefinder = actualMissile.GetType().GetField("rangefinder", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(actualMissile) as LaserRangefinder;
|
||||
var altimeter = actualMissile.GetType().GetField("altimeter", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(actualMissile) as MillimeterWaveAltimeter;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case JammingType.Infrared:
|
||||
infraredDetector?.ClearJamming(type);
|
||||
break;
|
||||
case JammingType.MillimeterWave:
|
||||
radiometer?.ClearJamming(type);
|
||||
altimeter?.ClearJamming(type);
|
||||
break;
|
||||
case JammingType.Laser:
|
||||
rangefinder?.ClearJamming(type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 保留原有实现...
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -573,53 +1001,142 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打印仿真状态
|
||||
/// 打印当前模拟状态
|
||||
/// </summary>
|
||||
private void PrintSimulationStatus()
|
||||
{
|
||||
// 打印当前天气状态
|
||||
Console.Clear();
|
||||
|
||||
// 获取当前仿真时间
|
||||
double simulationTime = simulationManager.CurrentTime;
|
||||
var weather = simulationManager.CurrentWeather;
|
||||
|
||||
Console.WriteLine($"\n========== 模拟状态 (时间: {simulationTime:F1}s)==========");
|
||||
|
||||
// 天气状态
|
||||
Console.WriteLine("\n--- 天气状态 ---");
|
||||
if (weather != null)
|
||||
{
|
||||
Console.WriteLine("\n========== 天气状态 ==========");
|
||||
Console.WriteLine($"天气类型: {weather.Type}");
|
||||
Console.WriteLine($"温度: {weather.Temperature}°C");
|
||||
Console.WriteLine($"湿度: {weather.RelativeHumidity}%");
|
||||
Console.WriteLine($"能见度: {weather.Visibility}公里");
|
||||
Console.WriteLine($"风速: {weather.WindSpeed}米/秒");
|
||||
Console.WriteLine($"风向: {weather.WindDirection}°");
|
||||
Console.WriteLine($"温度: {weather.Temperature:F1}°C, 湿度: {weather.RelativeHumidity:F1}%");
|
||||
Console.WriteLine($"风速: {weather.WindSpeed:F1} m/s, 方向: ({weather.WindDirection:F1}°)");
|
||||
Console.WriteLine($"雨量: {weather.Precipitation:F1} mm");
|
||||
Console.WriteLine($"能见度: {weather.Visibility:F1} m");
|
||||
}
|
||||
|
||||
// 打印所有活跃导弹的状态
|
||||
var activeMissiles = simulationManager.GetEntitiesByType<BaseMissile>()
|
||||
.Where(m => m.IsActive);
|
||||
|
||||
foreach (var missile in activeMissiles)
|
||||
// 导弹状态
|
||||
Console.WriteLine("\n--- 导弹状态 ---");
|
||||
var activeMissiles = missiles.Values.Where(m => m.IsActive).ToList();
|
||||
if (activeMissiles.Any())
|
||||
{
|
||||
Console.WriteLine("\n========== 导弹状态 ==========");
|
||||
Console.WriteLine(missile.GetStatus());
|
||||
foreach (var missile in activeMissiles)
|
||||
{
|
||||
// 直接调用导弹的GetStatus方法
|
||||
Console.WriteLine(missile.GetStatus());
|
||||
}
|
||||
}
|
||||
|
||||
// 打印目标状态
|
||||
foreach (var target in targets.Values)
|
||||
else
|
||||
{
|
||||
Console.WriteLine("\n========== 目标状态 ==========");
|
||||
Console.WriteLine(target.GetStatus());
|
||||
Console.WriteLine("没有激活的导弹");
|
||||
}
|
||||
|
||||
// 打印激活的传感器状态
|
||||
foreach (var sensor in indicators.Values.Where(s => s.IsActive))
|
||||
|
||||
// 目标状态
|
||||
Console.WriteLine("\n--- 目标状态 ---");
|
||||
var activeTargets = targets.Values.Where(t => t.IsActive).ToList();
|
||||
if (activeTargets.Any())
|
||||
{
|
||||
Console.WriteLine("\n========== 传感器状态 ==========");
|
||||
Console.WriteLine(sensor.GetStatus());
|
||||
foreach (var target in activeTargets)
|
||||
{
|
||||
// 调用目标的GetStatus方法
|
||||
Console.WriteLine(target.GetStatus());
|
||||
}
|
||||
}
|
||||
|
||||
// 打印激活的干扰器状态
|
||||
foreach (var jammer in jammers.Values.Where(j => j.IsActive))
|
||||
else
|
||||
{
|
||||
Console.WriteLine("\n========== 干扰器状态 ==========");
|
||||
Console.WriteLine(jammer.GetStatus());
|
||||
Console.WriteLine("没有激活的目标");
|
||||
}
|
||||
|
||||
// 传感器状态
|
||||
Console.WriteLine("\n--- 传感器和指示器状态 ---");
|
||||
var activeIndicators = indicators.Values.Where(i => i.IsActive).ToList();
|
||||
if (activeIndicators.Any())
|
||||
{
|
||||
foreach (var indicator in activeIndicators)
|
||||
{
|
||||
// 调用指示器的GetStatus方法
|
||||
Console.WriteLine(indicator.GetStatus());
|
||||
|
||||
// 如果是IIndicator接口,显示干扰状态信息
|
||||
if (indicator is IIndicator indInterface && indInterface.IsJammed)
|
||||
{
|
||||
Console.WriteLine($" 受干扰状态: 受到干扰");
|
||||
|
||||
// 尝试显示干扰类型
|
||||
if (indicator is LaserDesignator)
|
||||
Console.WriteLine($" 干扰类型: 激光干扰");
|
||||
else if (indicator is LaserBeamRider)
|
||||
Console.WriteLine($" 干扰类型: 激光干扰");
|
||||
else if (indicator is InfraredTracker)
|
||||
Console.WriteLine($" 干扰类型: 红外干扰");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("没有激活的传感器或指示器");
|
||||
}
|
||||
|
||||
// 干扰器状态
|
||||
Console.WriteLine("\n--- 干扰器状态 ---");
|
||||
var activeJammers = jammers.Values.Where(j => j.IsActive).ToList();
|
||||
if (activeJammers.Any())
|
||||
{
|
||||
foreach (var jammer in activeJammers)
|
||||
{
|
||||
// 调用干扰器的GetStatus方法
|
||||
Console.WriteLine(jammer.GetStatus());
|
||||
|
||||
// 如果正在干扰,显示更多详细信息
|
||||
if (jammer.IsJamming)
|
||||
{
|
||||
try
|
||||
{
|
||||
var runningState = jammer.GetRunningState();
|
||||
if (runningState.CurrentParameters != null)
|
||||
{
|
||||
var jammingParams = runningState.CurrentParameters;
|
||||
Console.WriteLine($" 干扰详情:");
|
||||
Console.WriteLine($" - 类型: {jammingParams.Type}");
|
||||
Console.WriteLine($" - 模式: {jammingParams.Mode}");
|
||||
Console.WriteLine($" - 功率: {jammingParams.Power:F1} W");
|
||||
|
||||
// 计算已干扰时间和剩余时间
|
||||
var jammingTimeSeconds = (DateTime.UtcNow.Ticks - jammingParams.StartTime.Ticks) / TimeSpan.TicksPerSecond;
|
||||
Console.WriteLine($" - 已干扰时间: {jammingTimeSeconds:F1} 秒");
|
||||
|
||||
if (jammingParams.Duration.HasValue)
|
||||
{
|
||||
var remainingTime = jammingParams.Duration.Value - jammingTimeSeconds;
|
||||
if (remainingTime > 0)
|
||||
Console.WriteLine($" - 剩余时间: {remainingTime:F1} 秒");
|
||||
else
|
||||
Console.WriteLine(" - 干扰即将结束");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($" 获取干扰器详细状态出错: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("没有激活的干扰器");
|
||||
}
|
||||
|
||||
Console.WriteLine("\n========================================");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -169,27 +169,22 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
|
||||
static bool ConfigureJamming(ComprehensiveMissileSimulator simulator)
|
||||
{
|
||||
var jammingTypes = new[]
|
||||
{
|
||||
(JammingType.Infrared, "红外干扰"),
|
||||
(JammingType.MillimeterWave, "毫米波干扰"),
|
||||
(JammingType.Laser, "激光干扰"),
|
||||
(JammingType.SmokeScreen, "水平烟幕弹"),
|
||||
(JammingType.SmokeScreen, "红外烟幕弹"),
|
||||
(JammingType.SmokeScreen, "顶部烟幕弹"),
|
||||
(JammingType.Decoy, "假目标干扰")
|
||||
};
|
||||
|
||||
var jammingStatus = new bool[jammingTypes.Length];
|
||||
var availableJammingOptions = simulator.GetAvailableJammingOptions();
|
||||
var jammingStatus = new bool[availableJammingOptions.Length];
|
||||
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine("\n第三步:配置干扰方式");
|
||||
Console.WriteLine("当前干扰状态:");
|
||||
for (int i = 0; i < jammingTypes.Length; i++)
|
||||
Console.WriteLine($"当前导弹: {simulator.SelectedMissileDisplayName}");
|
||||
Console.WriteLine("可用干扰方式:");
|
||||
|
||||
for (int i = 0; i < availableJammingOptions.Length; i++)
|
||||
{
|
||||
Console.WriteLine($" {i + 1}. {jammingTypes[i].Item2} [{(jammingStatus[i] ? "激活" : "未激活")}]");
|
||||
var option = availableJammingOptions[i];
|
||||
Console.WriteLine($" {i + 1}. {option.DisplayName} [{(jammingStatus[i] ? "激活" : "未激活")}] " +
|
||||
$"(干扰模式: {option.Mode}, 作用对象: {option.Target})");
|
||||
}
|
||||
|
||||
Console.WriteLine(" 0. 开始仿真");
|
||||
Console.WriteLine(" exit. 退出程序");
|
||||
|
||||
@ -200,13 +195,16 @@ namespace ThreatSource.Tools.MissileSimulation
|
||||
if (int.TryParse(input, out int choice))
|
||||
{
|
||||
if (choice == 0) return true;
|
||||
if (choice >= 1 && choice <= jammingTypes.Length)
|
||||
if (choice >= 1 && choice <= availableJammingOptions.Length)
|
||||
{
|
||||
var option = availableJammingOptions[choice - 1];
|
||||
jammingStatus[choice - 1] = !jammingStatus[choice - 1];
|
||||
|
||||
if (jammingStatus[choice - 1])
|
||||
simulator.ApplyJamming(jammingTypes[choice - 1].Item1, jammingTypes[choice - 1].Item2, 100, 5, new Vector3D(0, 0, 0));
|
||||
simulator.ApplyJamming(option.Type, option.DisplayName, option.JammerId, option.Mode, option.Target);
|
||||
else
|
||||
simulator.ClearJamming(jammingTypes[choice - 1].Item1, jammingTypes[choice - 1].Item2);
|
||||
simulator.ClearJamming(option.Type, option.DisplayName, option.JammerId);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user