diff --git a/ThreatSource.Tests/ThreatSource.Tests.csproj b/ThreatSource.Tests/ThreatSource.Tests.csproj index 14b70b7..3d1a722 100644 --- a/ThreatSource.Tests/ThreatSource.Tests.csproj +++ b/ThreatSource.Tests/ThreatSource.Tests.csproj @@ -11,6 +11,8 @@ + + diff --git a/ThreatSource.Tests/src/Jamming/JammingTests.cs b/ThreatSource.Tests/src/Jamming/JammingTests.cs new file mode 100644 index 0000000..b230f74 --- /dev/null +++ b/ThreatSource.Tests/src/Jamming/JammingTests.cs @@ -0,0 +1,264 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using ThreatSource.Jamming; +using ThreatSource.Sensor; +using ThreatSource.Missile; +using ThreatSource.Simulation; +using ThreatSource.Utils; + +namespace ThreatSource.Tests.Jamming +{ + [TestClass] + public class JammingTests + { + private InfraredDetector infraredDetector = null!; + private MillimeterWaveRadiometer radiometer = null!; + private LaserRangefinder rangefinder = null!; + private MillimeterWaveAltimeter altimeter = null!; + private TerminalSensitiveSubmunition submunition = null!; + private MockSimulationManager simulationManager = null!; + + [TestInitialize] + public void Setup() + { + simulationManager = new MockSimulationManager(); + var properties = new MissileProperties + { + Mass = 10, + ExplosionRadius = 5, + MaxSpeed = 2000 + }; + + submunition = new TerminalSensitiveSubmunition("target1", properties, simulationManager); + + // 初始化传感器 + infraredDetector = new InfraredDetector(submunition, 500, InfraredBand.Short, 10); + radiometer = new MillimeterWaveRadiometer(submunition, 500, MillimeterWaveBand.Band3, 11); + altimeter = new MillimeterWaveAltimeter(submunition, 1000, MillimeterWaveBand.Band8, 0.5, 25); + rangefinder = new LaserRangefinder(submunition, 500, 1.06, 100, 0.5); + + // 设置子弹到Detection阶段 + for (int i = 0; i < 5; i++) + { + submunition.Update(0.1); + } + } + + [TestMethod] + public void TestInfraredJamming() + { + // 激活红外探测器 + infraredDetector.Activate(); + Assert.IsTrue(infraredDetector.IsActive); + + // 应用红外干扰 + var jammingParams = new JammingParameters + { + Type = JammingType.Infrared, + Power = 100, + AngleRange = 30, + Duration = 5, + Direction = new Vector3D(1, 0, 0) + }; + + infraredDetector.ApplyJamming(jammingParams); + Assert.IsFalse(infraredDetector.IsActive, "红外探测器应该在干扰下失效"); + + // 清除干扰 + infraredDetector.ClearJamming(JammingType.Infrared); + Assert.IsTrue(infraredDetector.IsActive, "红外探测器应该在干扰清除后恢复工作"); + } + + [TestMethod] + public void TestMillimeterWaveJamming() + { + // 激活毫米波辐射计 + radiometer.Activate(); + Assert.IsTrue(radiometer.IsActive); + + // 应用毫米波干扰 + var jammingParams = new JammingParameters + { + Type = JammingType.MillimeterWave, + Power = 200, + AngleRange = 45, + Duration = 3, + Direction = new Vector3D(1, 0, 0) + }; + + radiometer.ApplyJamming(jammingParams); + Assert.IsFalse(radiometer.IsActive, "毫米波辐射计应该在干扰下失效"); + + // 清除干扰 + radiometer.ClearJamming(JammingType.MillimeterWave); + Assert.IsTrue(radiometer.IsActive, "毫米波辐射计应该在干扰清除后恢复工作"); + } + + [TestMethod] + public void TestLaserJamming() + { + // 激活激光测距仪 + rangefinder.Activate(); + Assert.IsTrue(rangefinder.IsActive); + + // 应用激光干扰 + var jammingParams = new JammingParameters + { + Type = JammingType.Laser, + Power = 150, + AngleRange = 15, + Duration = 4, + Direction = new Vector3D(1, 0, 0) + }; + + rangefinder.ApplyJamming(jammingParams); + Assert.IsFalse(rangefinder.IsActive, "激光测距仪应该在干扰下失效"); + + // 清除干扰 + rangefinder.ClearJamming(JammingType.Laser); + Assert.IsTrue(rangefinder.IsActive, "激光测距仪应该在干扰清除后恢复工作"); + } + + [TestMethod] + public void TestSubmunitionJammingResponse() + { + // 初始化仿真管理器 + var mockManager = new MockSimulationManager(); + var mockTarget = new MockTarget("target1") { Position = new Vector3D(100, 0, 100) }; + mockManager.RegisterEntity("target1", mockTarget); + + // 初始化子弹,设置初始位置在目标正上方120米处(刚好进入探测距离) + var properties = new MissileProperties + { + Mass = 10, + ExplosionRadius = 5, + MaxSpeed = 2000 + }; + var submunition = new TerminalSensitiveSubmunition("target1", properties, mockManager) + { + Position = new Vector3D(100, 120, 100), // 设置在目标正上方120米处 + Velocity = new Vector3D(0, -10, 0) // 设置垂直下降速度为10米/秒 + }; + submunition.Activate(); + + // 获取子弹内部的传感器实例 + var infraredDetector = submunition.GetType().GetField("infraredDetector", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(submunition) as InfraredDetector; + var radiometer = submunition.GetType().GetField("radiometer", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(submunition) as MillimeterWaveRadiometer; + var rangefinder = submunition.GetType().GetField("rangefinder", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)?.GetValue(submunition) as LaserRangefinder; + + // 激活传感器 + infraredDetector?.Activate(); + radiometer?.Activate(); + rangefinder?.Activate(); + + // 更新子弹状态,让它进入Detection阶段 + for (int i = 0; i < 3; i++) + { + submunition.Update(0.1); + var currentStatus = submunition.GetStatus(); + Console.WriteLine($"更新 {i + 1} 后的状态:{currentStatus}"); // 添加状态输出,帮助调试 + } + + // 手动设置子弹阶段为Detection + var stageField = submunition.GetType().GetField("currentStage", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); + var stageEnum = submunition.GetType().GetNestedType("SubmunitionStage", System.Reflection.BindingFlags.NonPublic); + var detectionStage = Enum.Parse(stageEnum!, "Detection"); + stageField?.SetValue(submunition, detectionStage); + + // 创建干扰参数 + var infraredJamming = new JammingParameters + { + Type = JammingType.Infrared, + Power = 100, + Duration = 5, + Direction = new Vector3D(1, 0, 0) + }; + + var millimeterWaveJamming = new JammingParameters + { + Type = JammingType.MillimeterWave, + Power = 200, + Duration = 5, + Direction = new Vector3D(1, 0, 0) + }; + + // 应用干扰 + infraredDetector?.ApplyJamming(infraredJamming); + radiometer?.ApplyJamming(millimeterWaveJamming); + + // 更新子弹状态 + submunition.Update(0.1); + + // 验证子弹响应 + var status = submunition.GetStatus(); + Console.WriteLine($"应用干扰后的状态:{status}"); // 添加状态输出,帮助调试 + Assert.IsTrue(status.Contains("传感器受到干扰"), "子弹状态应该反映传感器受到干扰"); + + // 清除干扰 + infraredDetector?.ClearJamming(JammingType.Infrared); + radiometer?.ClearJamming(JammingType.MillimeterWave); + + // 再次更新子弹状态 + submunition.Update(0.1); + status = submunition.GetStatus(); + Console.WriteLine($"清除干扰后的状态:{status}"); // 添加状态输出,帮助调试 + Assert.IsFalse(infraredDetector?.IsActive == false || radiometer?.IsActive == false, "传感器应该恢复正常工作状态"); + Assert.IsFalse(status.Contains("传感器受到干扰"), "子弹状态应该反映传感器恢复正常"); + } + } + + // 模拟仿真管理器 + public class MockSimulationManager : ISimulationManager + { + private readonly Dictionary entities = new(); + private ISimulationAdapter? adapter; + + void ISimulationManager.PublishEvent(T evt) { } + + void ISimulationManager.SubscribeToEvent(Action handler) { } + + void ISimulationManager.UnsubscribeFromEvent(Action handler) { } + + public bool RegisterEntity(string id, object entity) + { + entities[id] = entity; + return true; + } + + public bool UnregisterEntity(string id) + { + return entities.Remove(id); + } + + public object GetEntityById(string id) + { + return entities.TryGetValue(id, out var entity) ? entity : new MockTarget("mock_target") { Position = new Vector3D(100, 50, 100) }; + } + + public IReadOnlyList GetEntitiesByType() where T : class + { + return entities.Values.OfType().ToList(); + } + + public IReadOnlyList GetAllEntities() + { + return entities.Values.ToList(); + } + + public void SetSimulationAdapter(ISimulationAdapter adapter) + { + this.adapter = adapter; + } + + public ISimulationAdapter? GetSimulationAdapter() + { + return adapter; + } + } + + // 模拟目标 + public class MockTarget : SimulationElement + { + public MockTarget(string id) : base(id, new Vector3D(100, 50, 100), new Orientation(), 1000, null) { } + public override void Update(double deltaTime) { } + } +} \ No newline at end of file diff --git a/ThreatSource/src/Indicator/IIndicator.cs b/ThreatSource/src/Indicator/IIndicator.cs index 6f1d94b..62afd96 100644 --- a/ThreatSource/src/Indicator/IIndicator.cs +++ b/ThreatSource/src/Indicator/IIndicator.cs @@ -144,9 +144,18 @@ namespace ThreatSource.Indicator /// public enum IndicatorType { - LaserDisintegrator, // 激光指示器 - LaserBeamRider, // 激光波束制导器 - InfraredTracker // 红外跟踪器 + /// + /// 激光指示器 + /// + LaserDisintegrator, + /// + /// 激光波束制导器 + /// + LaserBeamRider, + /// + /// 红外跟踪器 + /// + InfraredTracker } /// @@ -160,7 +169,13 @@ namespace ThreatSource.Indicator /// public enum IndicatorState { - Indicating, // 指示状态 - Idle // 空闲状态 + /// + /// 指示状态 + /// + Indicating, + /// + /// 空闲状态 + /// + Idle } } diff --git a/ThreatSource/src/Jamming/IJammable.cs b/ThreatSource/src/Jamming/IJammable.cs new file mode 100644 index 0000000..687ffa9 --- /dev/null +++ b/ThreatSource/src/Jamming/IJammable.cs @@ -0,0 +1,32 @@ +using ThreatSource.Utils; + +namespace ThreatSource.Jamming +{ + /// + /// 可干扰设备接口 + /// + public interface IJammable + { + /// + /// 获取设备支持的干扰类型 + /// + IEnumerable SupportedJammingTypes { get; } + + /// + /// 获取设备当前是否处于被干扰状态 + /// + bool IsJammed { get; } + + /// + /// 应用干扰 + /// + /// 干扰参数 + void ApplyJamming(JammingParameters parameters); + + /// + /// 清除干扰 + /// + /// 要清除的干扰类型 + void ClearJamming(JammingType type); + } +} \ No newline at end of file diff --git a/ThreatSource/src/Jamming/InfraredJammingHandler.cs b/ThreatSource/src/Jamming/InfraredJammingHandler.cs new file mode 100644 index 0000000..4daa4a1 --- /dev/null +++ b/ThreatSource/src/Jamming/InfraredJammingHandler.cs @@ -0,0 +1,37 @@ +using ThreatSource.Sensor; + +namespace ThreatSource.Jamming +{ + /// + /// 红外干扰处理器 + /// + /// + /// + /// 红外干扰处理器 + /// + /// 红外探测器 + public class InfraredJammingHandler(InfraredDetector detector) : JammingHandler + { + private readonly InfraredDetector detector = detector; + + /// + /// 当干扰被应用时调用 + /// + /// 干扰参数 + protected override void OnJammingApplied(JammingParameters parameters) + { + detector.IsActive = false; + Console.WriteLine($"红外探测器受到干扰,功率:{parameters.Power}瓦特"); + } + + /// + /// 当干扰被清除时调用 + /// + /// 被清除的干扰参数 + protected override void OnJammingCleared(JammingParameters? parameters) + { + detector.IsActive = true; + Console.WriteLine("红外探测器干扰解除"); + } + } +} \ No newline at end of file diff --git a/ThreatSource/src/Jamming/JammingHandler.cs b/ThreatSource/src/Jamming/JammingHandler.cs new file mode 100644 index 0000000..bd27c5b --- /dev/null +++ b/ThreatSource/src/Jamming/JammingHandler.cs @@ -0,0 +1,73 @@ +namespace ThreatSource.Jamming +{ + /// + /// 干扰处理基类 + /// + public abstract class JammingHandler + { + /// + /// 是否处于被干扰状态 + /// + public bool IsJammed { get; private set; } + + /// + /// 当前干扰参数 + /// + protected JammingParameters? CurrentJamming { get; private set; } + + /// + /// 更新干扰状态 + /// + /// 时间步长,单位:秒 + public virtual void Update(double deltaTime) + { + if (IsJammed && CurrentJamming?.Duration != null) + { + // 检查是否超时 + var elapsed = (DateTime.Now - CurrentJamming.StartTime).TotalSeconds; + if (elapsed >= CurrentJamming.Duration) + { + ClearJamming(); + } + } + } + + /// + /// 处理干扰 + /// + /// 干扰参数 + public virtual void HandleJamming(JammingParameters parameters) + { + parameters.StartTime = DateTime.Now; + IsJammed = true; + CurrentJamming = parameters; + OnJammingApplied(parameters); + } + + /// + /// 清除干扰 + /// + public virtual void ClearJamming() + { + if (IsJammed) + { + IsJammed = false; + var oldJamming = CurrentJamming; + CurrentJamming = null; + OnJammingCleared(oldJamming); + } + } + + /// + /// 当干扰被应用时调用 + /// + /// 干扰参数 + protected abstract void OnJammingApplied(JammingParameters parameters); + + /// + /// 当干扰被清除时调用 + /// + /// 被清除的干扰参数 + protected abstract void OnJammingCleared(JammingParameters? parameters); + } +} \ No newline at end of file diff --git a/ThreatSource/src/Jamming/JammingMode.cs b/ThreatSource/src/Jamming/JammingMode.cs new file mode 100644 index 0000000..ef52a89 --- /dev/null +++ b/ThreatSource/src/Jamming/JammingMode.cs @@ -0,0 +1,28 @@ +namespace ThreatSource.Jamming +{ + /// + /// 干扰模式枚举 + /// + public enum JammingMode + { + /// + /// 噪声干扰 + /// + Noise, + + /// + /// 欺骗干扰 + /// + Deception, + + /// + /// 阻塞干扰 + /// + Blocking, + + /// + /// 扫频干扰 + /// + Sweep + } +} \ No newline at end of file diff --git a/ThreatSource/src/Jamming/JammingParameters.cs b/ThreatSource/src/Jamming/JammingParameters.cs new file mode 100644 index 0000000..d3037f6 --- /dev/null +++ b/ThreatSource/src/Jamming/JammingParameters.cs @@ -0,0 +1,54 @@ +using ThreatSource.Utils; + +namespace ThreatSource.Jamming +{ + /// + /// 干扰参数类 + /// + public class JammingParameters + { + /// + /// 干扰类型 + /// + public JammingType Type { get; set; } + + /// + /// 干扰功率,单位:瓦特 + /// + public double Power { get; set; } + + /// + /// 干扰方向 + /// + public required Vector3D Direction { get; set; } + + /// + /// 干扰角度范围,单位:弧度 + /// + /// + /// 定义了干扰波束的发散角度 + /// 影响干扰的覆盖范围 + /// + public double AngleRange { get; set; } + + /// + /// 干扰频率,单位:赫兹 + /// + public double Frequency { get; set; } + + /// + /// 持续时间,单位:秒,null表示持续干扰 + /// + public double? Duration { get; set; } + + /// + /// 干扰模式 + /// + public JammingMode Mode { get; set; } + + /// + /// 干扰开始时间 + /// + public DateTime StartTime { get; set; } + } +} \ No newline at end of file diff --git a/ThreatSource/src/Jamming/JammingType.cs b/ThreatSource/src/Jamming/JammingType.cs new file mode 100644 index 0000000..d8b1a86 --- /dev/null +++ b/ThreatSource/src/Jamming/JammingType.cs @@ -0,0 +1,33 @@ +namespace ThreatSource.Jamming +{ + /// + /// 干扰类型枚举 + /// + public enum JammingType + { + /// + /// 红外干扰 + /// + Infrared, + + /// + /// 毫米波干扰 + /// + MillimeterWave, + + /// + /// 激光干扰 + /// + Laser, + + /// + /// 射频干扰 + /// + RadioFrequency, + + /// + /// GPS干扰 + /// + GPS + } +} \ No newline at end of file diff --git a/ThreatSource/src/Jamming/LaserJammingHandler.cs b/ThreatSource/src/Jamming/LaserJammingHandler.cs new file mode 100644 index 0000000..9874db4 --- /dev/null +++ b/ThreatSource/src/Jamming/LaserJammingHandler.cs @@ -0,0 +1,36 @@ +using ThreatSource.Sensor; + +namespace ThreatSource.Jamming +{ + /// + /// 激光干扰处理器 + /// + /// + /// 激光干扰处理器 + /// + /// 激光测距仪 + public class LaserJammingHandler(LaserRangefinder rangefinder) : JammingHandler + { + private readonly LaserRangefinder rangefinder = rangefinder; + + /// + /// 当干扰被应用时调用 + /// + /// 干扰参数 + protected override void OnJammingApplied(JammingParameters parameters) + { + rangefinder.IsActive = false; + Console.WriteLine($"激光测距仪受到干扰,功率:{parameters.Power}瓦特"); + } + + /// + /// 当干扰被清除时调用 + /// + /// 被清除的干扰参数 + protected override void OnJammingCleared(JammingParameters? parameters) + { + rangefinder.IsActive = true; + Console.WriteLine("激光测距仪干扰解除"); + } + } +} \ No newline at end of file diff --git a/ThreatSource/src/Jamming/MillimeterWaveAltimeterJammingHandler.cs b/ThreatSource/src/Jamming/MillimeterWaveAltimeterJammingHandler.cs new file mode 100644 index 0000000..fdce37c --- /dev/null +++ b/ThreatSource/src/Jamming/MillimeterWaveAltimeterJammingHandler.cs @@ -0,0 +1,36 @@ +using ThreatSource.Sensor; + +namespace ThreatSource.Jamming +{ + /// + /// 毫米波测高雷达干扰处理器 + /// + /// + /// 初始化毫米波测高雷达干扰处理器 + /// + /// 毫米波测高雷达 + public class MillimeterWaveAltimeterJammingHandler(MillimeterWaveAltimeter altimeter) : JammingHandler + { + private readonly MillimeterWaveAltimeter altimeter = altimeter; + + /// + /// 当干扰被应用时调用 + /// + /// 干扰参数 + protected override void OnJammingApplied(JammingParameters parameters) + { + altimeter.IsActive = false; + Console.WriteLine($"毫米波测高雷达受到干扰,功率:{parameters.Power}瓦特"); + } + + /// + /// 当干扰被清除时调用 + /// + /// 被清除的干扰参数 + protected override void OnJammingCleared(JammingParameters? parameters) + { + altimeter.IsActive = true; + Console.WriteLine("毫米波测高雷达干扰解除"); + } + } +} \ No newline at end of file diff --git a/ThreatSource/src/Jamming/MillimeterWaveJammingHandler.cs b/ThreatSource/src/Jamming/MillimeterWaveJammingHandler.cs new file mode 100644 index 0000000..1a10b77 --- /dev/null +++ b/ThreatSource/src/Jamming/MillimeterWaveJammingHandler.cs @@ -0,0 +1,36 @@ +using ThreatSource.Sensor; + +namespace ThreatSource.Jamming +{ + /// + /// 毫米波干扰处理器 + /// + /// + /// 毫米波干扰处理器 + /// + /// 毫米波辐射计 + public class MillimeterWaveJammingHandler(MillimeterWaveRadiometer radiometer) : JammingHandler + { + private readonly MillimeterWaveRadiometer radiometer = radiometer; + + /// + /// 当干扰被应用时调用 + /// + /// 干扰参数 + protected override void OnJammingApplied(JammingParameters parameters) + { + radiometer.IsActive = false; + Console.WriteLine($"毫米波辐射计受到干扰,功率:{parameters.Power}瓦特"); + } + + /// + /// 当干扰被清除时调用 + /// + /// 被清除的干扰参数 + protected override void OnJammingCleared(JammingParameters? parameters) + { + radiometer.IsActive = true; + Console.WriteLine("毫米波辐射计干扰解除"); + } + } +} \ No newline at end of file diff --git a/ThreatSource/src/MIssile/BaseMissile.cs b/ThreatSource/src/MIssile/BaseMissile.cs index 8b487ce..b2d1220 100644 --- a/ThreatSource/src/MIssile/BaseMissile.cs +++ b/ThreatSource/src/MIssile/BaseMissile.cs @@ -154,6 +154,16 @@ namespace ThreatSource.Missile } } + /// + /// 更新导弹的运动状态 + /// + /// 时间步长,单位:秒 + /// + /// 更新过程: + /// - 计算合加速度 + /// - 根据制导状态选择运动更新方法 + /// - 更新导弹的位置和速度 + /// protected virtual void UpdateMotionState(double deltaTime) { //Vector3D acceleration = CalculateAcceleration(Velocity); @@ -299,12 +309,28 @@ namespace ThreatSource.Missile Deactivate(); } + /// + /// 激活导弹 + /// + /// + /// 激活过程: + /// - 调用基类激活方法 + /// - 订阅目标命中事件 + /// public override void Activate() { base.Activate(); SimulationManager.SubscribeToEvent(OnTargetHitEvent); } + /// + /// 停用导弹 + /// + /// + /// 停用过程: + /// - 调用基类停用方法 + /// - 取消订阅目标命中事件 + /// public override void Deactivate() { base.Deactivate(); diff --git a/ThreatSource/src/MIssile/MissileProperties.cs b/ThreatSource/src/MIssile/MissileProperties.cs index 86f2cae..bb4d4f1 100644 --- a/ThreatSource/src/MIssile/MissileProperties.cs +++ b/ThreatSource/src/MIssile/MissileProperties.cs @@ -17,13 +17,34 @@ namespace ThreatSource.Missile /// public enum MissileType { - StandardMissile, // 标准导弹 - LaserSemiActiveGuidance, // 激光半主动制导 - LaserBeamRiderGuidance, // 激光驾束制导 - InfraredCommandGuidance, // 红外指令制导 - InfraredImagingTerminalGuidance, // 红外成像末制导 - MillimeterWaveTerminalGuidance, // 毫米波末制导 - TerminalSensitiveMissile // 末敏弹 + /// + /// 标准导弹 + /// + StandardMissile, + /// + /// 激光半主动制导 + /// + LaserSemiActiveGuidance, + /// + /// 激光驾束制导 + /// + LaserBeamRiderGuidance, + /// + /// 红外指令制导 + /// + InfraredCommandGuidance, + /// + /// 红外成像末制导 + /// + InfraredImagingTerminalGuidance, + /// + /// 毫米波末制导 + /// + MillimeterWaveTerminalGuidance, + /// + /// 末敏弹 + /// + TerminalSensitiveMissile } /// diff --git a/ThreatSource/src/MIssile/TerminalSensitiveSubmunition.cs b/ThreatSource/src/MIssile/TerminalSensitiveSubmunition.cs index d192901..5c64ff6 100644 --- a/ThreatSource/src/MIssile/TerminalSensitiveSubmunition.cs +++ b/ThreatSource/src/MIssile/TerminalSensitiveSubmunition.cs @@ -21,10 +21,12 @@ namespace ThreatSource.Missile /// 子弹飞行阶段枚举 /// /// - /// 定义了子弹飞行的六个主要阶段: + /// 定义了子弹飞行的八个主要阶段: /// - Separation:分离阶段,从母弹分离 /// - Deceleration:减速阶段,调整速度 - /// - SpiralScan:螺旋扫描阶段,搜索目标 + /// - ParachuteDeployment:降落伞打开阶段,稳定下降 + /// - StableScan:稳定扫描阶段,稳定下降 + /// - Detection:目标探测阶段,搜索确定目标 /// - Attack:攻击阶段,末端制导 /// - Explode:爆炸阶段,命中目标 /// - SelfDestruct:自毁阶段,触发自毁 @@ -33,7 +35,9 @@ namespace ThreatSource.Missile { Separation, // 分离阶段 Deceleration, // 减速阶段 - SpiralScan, // 螺旋扫描阶段 + ParachuteDeployment, // 降落伞打开阶段 + StableScan, // 稳定扫描阶段 + Detection, // 目标探测阶段 Attack, // 攻击阶段 Explode, // 爆炸阶段 SelfDestruct // 自毁阶段 @@ -57,13 +61,21 @@ namespace ThreatSource.Missile /// private const double SpiralRotationSpeed = 8 * Math.PI; + /// + /// 减速阶段末速,单位:米/秒 + /// + /// + /// 定义了减速阶段的垂直下降速度 + /// + private const double DecelerationEndSpeed = 40; + /// /// 垂直下降速度,单位:米/秒 /// /// /// 定义了扫描和攻击阶段的垂直下降速度 /// - private const double VerticalDescentSpeed = 10; + private const double VerticalDeclineSpeed = 10; /// /// 扫描角度,单位:弧度 @@ -72,16 +84,16 @@ namespace ThreatSource.Missile /// 定义了螺旋扫描的锥角 /// 30度 = π/6弧度 /// - private const double ScanAngle = 30 * Math.PI / 180; + public const double ScanAngle = 30 * Math.PI / 180; /// - /// 减速高度,单位:米 + /// 开伞高度,单位:米 /// /// - /// 开始减速的高度阈值 - /// 影响减速阶段的触发时机 + /// 打开降落伞的高度阈值 + /// 影响降落伞打开阶段的触发时机 /// - private const double DecelerationHeight = 400; + private const double ParachuteDeploymentHeight = 400; /// /// 减速加速度,单位:米/秒² @@ -93,13 +105,22 @@ namespace ThreatSource.Missile private const double DecelerationAcceleration = 50; /// - /// 扫描高度,单位:米 + /// 稳定扫描高度,单位:米 /// /// /// 开始螺旋扫描的高度阈值 /// 影响扫描阶段的触发时机 /// - private const double ScanningHeight = 200; + private const double StableScanHeight = 200; + + /// + /// 目标探测距离,单位:米 + /// + /// + /// 目标探测的距离阈值 + /// 影响目标探测阶段的触发时机 + /// + private const double TargetDetectionDistance = 120; /// /// 自毁高度,单位:米 @@ -224,10 +245,10 @@ namespace ThreatSource.Missile detectionAngle = 0; // 初始化传感器 - infraredDetector = new InfraredDetector(this, 500, 5); // 红外探测器,探测距离 500 米,视场角5度 - radiometer = new MillimeterWaveRadiometer(this, 3, 5); // 毫米波辐射计,工作波段3mm,扫描视场角5度 - altimeter = new MillimeterWaveAltimeter(this, 1000, 0.1); // 毫米波测高仪,测量精度0.1米 - rangefinder = new LaserRangefinder(Position, Orientation, 1000, 1000); + infraredDetector = new InfraredDetector(this, 500, InfraredBand.Short, 10); // 红外探测器,探测距离 500 米,近红外,视场角10度 + radiometer = new MillimeterWaveRadiometer(this, 500, MillimeterWaveBand.Band3, 11); // 毫米波辐射计,探测距离500米,工作波段3mm,扫描视场角11度 + altimeter = new MillimeterWaveAltimeter(this, 1000, MillimeterWaveBand.Band8, 0.5, 25); // 毫米波测高仪,测量精度0.5米 + rangefinder = new LaserRangefinder(this, 500, 1.06, 100, 0.5); // 激光测距仪,测量距离500米,波长1.06µm,测量频率100Hz,测量精度0.5米 } /// @@ -259,8 +280,14 @@ namespace ThreatSource.Missile case SubmunitionStage.Deceleration: UpdateDecelerationStage(deltaTime); break; - case SubmunitionStage.SpiralScan: - UpdateSpiralScanStage(deltaTime); + case SubmunitionStage.ParachuteDeployment: + UpdateParachuteDeploymentStage(deltaTime); + break; + case SubmunitionStage.StableScan: + UpdateStableScanStage(deltaTime); + break; + case SubmunitionStage.Detection: + UpdateDetectionStage(deltaTime); break; case SubmunitionStage.Attack: UpdateAttackStage(deltaTime); @@ -282,8 +309,7 @@ namespace ThreatSource.Missile /// 分离阶段处理: /// - 施加重力加速度 /// - 更新位置和速度 - /// - 激活测高仪 - /// - 检查高度条件 + /// - 分离阶段结束,进入减速阶段 /// private void UpdateSeparationStage(double deltaTime) { @@ -292,18 +318,8 @@ namespace ThreatSource.Missile Velocity += deceleration * deltaTime; Position += Velocity * deltaTime; - if(!altimeter.IsActive) - { - // 激活毫米波测高雷达 - altimeter.Activate(); - } - - // 检查高度是否小于等于减速高度 - if(((AltimeterSensorData)altimeter.GetSensorData()).Altitude <= DecelerationHeight) - { - // 如果是,则进入减速阶段 - currentStage = SubmunitionStage.Deceleration; - } + // 分离阶段结束,进入减速阶段 + currentStage = SubmunitionStage.Deceleration; } /// @@ -316,28 +332,79 @@ namespace ThreatSource.Missile /// - 计算减速加速度 /// - 更新速度和位置 /// - 检查高度条件 + /// - 如果高度小于等于开伞高度,则进入降落伞打开阶段 /// private void UpdateDecelerationStage(double deltaTime) { IsGuidance = true; + + if(!altimeter.IsActive) + { + // 激活毫米波测高雷达 + altimeter.Activate(); + } + // 减速减旋,垂直速度减小 Vector3D deceleration = - Velocity.Normalize() * DecelerationAcceleration; Velocity += deceleration * deltaTime; - if (Velocity.Magnitude() <= VerticalDescentSpeed) + if (Velocity.Magnitude() <= DecelerationEndSpeed) { - Velocity = new Vector3D(0, -VerticalDescentSpeed, 0); + Velocity = new Vector3D(0, -DecelerationEndSpeed, 0); GuidanceAcceleration = Vector3D.Zero; } - - if (((AltimeterSensorData)altimeter.GetSensorData()).Altitude <= ScanningHeight) + + if(IsSensorsJammed()) { - currentStage = SubmunitionStage.SpiralScan; + // 如果传感器受到干扰,则高度计无法工作 + Console.WriteLine("减速阶段:传感器受到干扰,无法进行高度测量"); + return; + } + + // 检查高度是否小于等于开伞高度 + if(((AltimeterSensorData)altimeter.GetSensorData()).Altitude <= ParachuteDeploymentHeight) + { + // 如果是,则进入降落伞打开阶段 + currentStage = SubmunitionStage.ParachuteDeployment; + } + } + + /// + /// 更新降落伞打开阶段状态 + /// + /// 时间步长,单位:秒 + /// + /// 降落伞打开阶段处理: + /// - 打开降落伞 + /// - 降落伞减速和稳定 + /// - 调整姿态准备扫描 + /// - 激活测高雷达开始工作(第二次测高) + /// - 在200米高度进入扫描阶段 + /// - 此时子弹速度 10 米/秒 + /// + private void UpdateParachuteDeploymentStage(double deltaTime) + { + if (Velocity.Magnitude() <= VerticalDeclineSpeed) + { + Velocity = new Vector3D(0, -VerticalDeclineSpeed, 0); + GuidanceAcceleration = Vector3D.Zero; + } + + if(IsSensorsJammed()) + { + // 如果传感器受到干扰,则高度计无法工作 + Console.WriteLine("开伞阶段:传感器受到干扰,无法进行高度测量"); + return; + } + + if (((AltimeterSensorData)altimeter.GetSensorData()).Altitude <= StableScanHeight) + { + currentStage = SubmunitionStage.StableScan; } } /// - /// 更新螺旋扫描阶段状态 + /// 更新稳定扫描阶段状态 /// /// 时间步长,单位:秒 /// @@ -347,7 +414,7 @@ namespace ThreatSource.Missile /// - 处理目标探测 /// - 检查目标确认条件 /// - private void UpdateSpiralScanStage(double deltaTime) + private void UpdateStableScanStage(double deltaTime) { if(!radiometer.IsActive) { @@ -359,15 +426,51 @@ namespace ThreatSource.Missile // 激活红外探测器 infraredDetector.Activate(); } - - Velocity = new Vector3D(0, -VerticalDescentSpeed, 0); - GuidanceAcceleration = Vector3D.Zero; + if(!rangefinder.IsActive) + { + // 激活激光测距仪 + rangefinder.Activate(); + } + // 检查传感器干扰状态 + if (IsSensorsJammed()) + { + Console.WriteLine("稳定扫描阶段:传感器受到干扰,无法进行距离测量"); + return; + } + + // 如果距离小于等于目标探测距离,则进入目标探测阶段 + if (((RangefinderSensorData)rangefinder.GetSensorData()).Distance <= TargetDetectionDistance) + { + currentStage = SubmunitionStage.Detection; + } + } + + /// + /// 更新目标探测阶段状态 + /// + /// 时间步长,单位:秒 + /// + /// 目标探测阶段处理: + /// - 多传感器协同工作 + /// - 进行目标特征识别 + /// - 执行二次扫描确认 + /// - 为攻击阶段做准备 + /// + private void UpdateDetectionStage(double deltaTime) + { + // 检查传感器干扰状态 + if (IsSensorsJammed()) + { + Console.WriteLine("探测阶段:传感器受到干扰,无法进行目标探测"); + return; + } + // 更新螺旋角度 spiralAngle = (spiralAngle + SpiralRotationSpeed * deltaTime) % (2 * Math.PI); // 计算水平速度分量 - double horizontalSpeed = VerticalDescentSpeed * Math.Tan(ScanAngle); + double horizontalSpeed = VerticalDeclineSpeed * Math.Tan(ScanAngle); Vector3D horizontalVelocity = new( Math.Cos(spiralAngle) * horizontalSpeed, 0, @@ -375,7 +478,7 @@ namespace ThreatSource.Missile ); // 更新速度 - Velocity = new(horizontalVelocity.X, -VerticalDescentSpeed, horizontalVelocity.Z); + Velocity = new(horizontalVelocity.X, -VerticalDeclineSpeed, horizontalVelocity.Z); // 计算扫描方向 scanDirection = new( @@ -408,12 +511,12 @@ namespace ThreatSource.Missile } // 使用模式匹配简化类型转换 - if (altimeter.GetSensorData() is AltimeterSensorData altimeterData && - altimeterData.Altitude <= SelfDestructHeight) + if (rangefinder.GetSensorData() is RangefinderSensorData rangefinderData && + rangefinderData.Distance <= SelfDestructHeight) { currentStage = SubmunitionStage.SelfDestruct; } - } + } /// /// 更新攻击阶段状态 @@ -422,18 +525,21 @@ namespace ThreatSource.Missile /// /// 攻击阶段处理: /// - 获取目标位置 - /// - 计算制导指令 - /// - 更新速度和方向 + /// - 计算攻击速度 + /// - 更新速度和位置 /// - 检查命中条件 /// private void UpdateAttackStage(double deltaTime) { - Console.WriteLine("攻击阶段"); // 攻击逻辑 SimulationElement target = SimulationManager.GetEntityById(TargetId) as SimulationElement ?? throw new Exception("目标不存在"); Vector3D targetPosition = target.Position; - Vector3D direction = (targetPosition - Position).Normalize(); - Velocity = direction * AttackSpeed; + + // 计算攻击速度,攻击角度为最后的扫描方向 + Velocity = scanDirection * AttackSpeed; + Position += Velocity * deltaTime; + + // 检查命中条件 if ((targetPosition - Position).Magnitude() <= MissileProperties.ExplosionRadius) { currentStage = SubmunitionStage.Explode; @@ -553,7 +659,52 @@ namespace ThreatSource.Missile /// public override string GetStatus() { - return $"{base.GetStatus()}\n运行状态: {currentStage}\n检测角度: {detectionAngle * 180 / Math.PI:F2}°\n螺旋角度: {spiralAngle * 180 / Math.PI:F2}°\n目标检测: {lastDetectionTime != null}"; + var status = $"{base.GetStatus()}\n运行状态: {currentStage}\n检测角度: {detectionAngle * 180 / Math.PI:F2}°\n螺旋角度: {spiralAngle * 180 / Math.PI:F2}°\n目标检测: {lastDetectionTime != null}"; + + // 使用IsSensorsJammed方法检查当前阶段所需传感器的状态 + if (IsSensorsJammed()) + { + status += "\n传感器受到干扰"; + } + + return status; + } + + /// + /// 检查传感器是否受到干扰 + /// + /// 如果当前阶段的关键传感器都被干扰返回true,否则返回false + /// + /// 不同阶段的检查逻辑: + /// - Deceleration阶段:测高仪被干扰才返回true + /// - ParachuteDeployment阶段:测高仪被干扰才返回true + /// - StableScan阶段:激光测距仪被干扰才返回true + /// - Detection阶段:红外探测器和毫米波辐射计都被干扰才返回true + /// - Attack阶段:红外探测器和毫米波辐射计都被干扰才返回true + /// + private bool IsSensorsJammed() + { + // 根据当前阶段检查相应传感器的干扰状态 + switch (currentStage) + { + case SubmunitionStage.Deceleration: + // 减速阶段需要测高仪 + return altimeter.IsJammed; + case SubmunitionStage.ParachuteDeployment: + // 开伞阶段需要测高仪 + return altimeter.IsJammed; + case SubmunitionStage.StableScan: + // 稳定扫描阶段需要激光测距仪 + return rangefinder.IsJammed; + case SubmunitionStage.Detection: + // 目标探测阶段需要红外探测器和毫米波辐射计 + return infraredDetector.IsJammed && radiometer.IsJammed; + case SubmunitionStage.Attack: + // 攻击阶段需要红外探测器和毫米波辐射计 + return infraredDetector.IsJammed && radiometer.IsJammed; + default: + return false; + } } } } diff --git a/ThreatSource/src/Sensor/InfraredDetector.cs b/ThreatSource/src/Sensor/InfraredDetector.cs index 10a2492..dbe83af 100644 --- a/ThreatSource/src/Sensor/InfraredDetector.cs +++ b/ThreatSource/src/Sensor/InfraredDetector.cs @@ -1,4 +1,6 @@ using ThreatSource.Missile; +using ThreatSource.Utils; +using ThreatSource.Jamming; namespace ThreatSource.Sensor { @@ -34,6 +36,11 @@ namespace ThreatSource.Sensor /// public double DetectionRange { get; set; } + /// + /// 获取或设置红外波段 + /// + public InfraredBand Band { get; set; } + /// /// 获取或设置视场角,单位:度 /// @@ -41,7 +48,7 @@ namespace ThreatSource.Sensor /// 定义了探测器的视场范围 /// 影响目标探测的空间覆盖 /// - public double FieldOfView { get; set; } + public double FieldOfView { get; set; } = 10; /// /// 末敏子弹实例 @@ -66,6 +73,7 @@ namespace ThreatSource.Sensor /// /// 末敏子弹实例 /// 探测范围,单位:米 + /// /// 视场角,单位:度 /// /// 构造过程: @@ -74,11 +82,12 @@ namespace ThreatSource.Sensor /// - 初始化传感器数据 /// - 继承基类位置和姿态 /// - public InfraredDetector(TerminalSensitiveSubmunition submunition, double detectionRange, double fieldOfView) + public InfraredDetector(TerminalSensitiveSubmunition submunition, double detectionRange, InfraredBand band, double fieldOfView) : base(submunition.Position, submunition.Orientation) { DetectionRange = detectionRange; FieldOfView = fieldOfView; + Band = band; this.submunition = submunition; sensorData = new InfraredSensorData(); } @@ -130,6 +139,39 @@ namespace ThreatSource.Sensor return submunition.DetectTarget(FieldOfView) ? 100 : 0; } + /// + /// 处理红外干扰事件 + /// + /// 事件源对象 + /// 事件参数 + /// + /// 当检测到红外干扰时: + /// - 输出警告信息 + /// - 可能影响探测精度 + /// - 需要采取抗干扰措施 + /// + public void OnInfraredJamming(object sender, EventArgs e) + { + IsActive = false; + Console.WriteLine("红外探测器受到干扰,失效"); + } + + /// + /// 处理红外干扰停止事件 + /// + /// 事件源对象 + /// 事件参数 + /// + /// 当红外干扰停止时: + /// - 输出恢复信息 + /// - 恢复探测状态 + /// + public void OnInfraredJammingStop(object sender, EventArgs e) + { + IsActive = true; + Console.WriteLine("红外探测器干扰停止,恢复工作"); + } + /// /// 获取红外探测器的最新数据 /// @@ -145,5 +187,19 @@ namespace ThreatSource.Sensor // 返回红外探测器的数据 return sensorData; } + + /// + /// 获取支持的干扰类型集合 + /// + public override IEnumerable SupportedJammingTypes => + [JammingType.Infrared]; + + /// + /// 初始化干扰处理器 + /// + protected override void InitializeJammingHandler() + { + JammingHandler = new InfraredJammingHandler(this); + } } } \ No newline at end of file diff --git a/ThreatSource/src/Sensor/LaserRangefinder.cs b/ThreatSource/src/Sensor/LaserRangefinder.cs index 3d96136..77478bd 100644 --- a/ThreatSource/src/Sensor/LaserRangefinder.cs +++ b/ThreatSource/src/Sensor/LaserRangefinder.cs @@ -1,4 +1,6 @@ using ThreatSource.Utils; +using ThreatSource.Missile; +using ThreatSource.Jamming; namespace ThreatSource.Sensor { @@ -15,6 +17,23 @@ namespace ThreatSource.Sensor /// public class LaserRangefinder : Sensor { + /// + /// 当前测量距离,单位:米 + /// + /// + /// 包含测量精度引入的随机误差 + /// + private double currentDistance; + + /// + /// 末敏子弹实例 + /// + /// + /// 关联的末敏子弹对象 + /// 用于获取位置和姿态信息 + /// + private readonly TerminalSensitiveSubmunition submunition; + /// /// 获取或设置最大测量距离,单位:米 /// @@ -25,6 +44,15 @@ namespace ThreatSource.Sensor /// public double MaxRange { get; set; } + /// + /// 获取或设置工作波长,单位:微米 + /// + /// + /// 定义了激光测距仪的工作波段 + /// 影响测量的准确性和可靠性 + /// + public double WaveLength { get; set; } + /// /// 获取或设置脉冲频率,单位:赫兹 /// @@ -35,24 +63,38 @@ namespace ThreatSource.Sensor /// public double PulseRate { get; set; } + /// + /// 获取或设置测量精度,单位:米 + /// + /// + /// 定义了测距仪的测量误差范围 + /// 影响测量的可靠性和稳定性 + /// 需要根据应用场景选择合适的精度 + /// + public double Accuracy { get; set; } + /// /// 初始化激光测距仪的新实例 /// - /// 测距仪的位置坐标 - /// 测距仪的朝向 + /// 末敏子弹实例 /// 最大测量距离,单位:米 + /// 工作波段,单位:毫米 /// 脉冲频率,单位:赫兹 + /// 测量精度,单位:米 /// /// 构造过程: /// - 设置位置和姿态 /// - 配置测量参数 /// - 初始化工作状态 /// - public LaserRangefinder(Vector3D position, Orientation orientation, double maxRange, double pulseRate) - : base(position, orientation) + public LaserRangefinder(TerminalSensitiveSubmunition submunition, double maxRange, double waveLength, double pulseRate, double accuracy) + : base(submunition.Position, submunition.Orientation) { + this.submunition = submunition; MaxRange = maxRange; + WaveLength = waveLength; PulseRate = pulseRate; + Accuracy = accuracy; } /// @@ -68,7 +110,13 @@ namespace ThreatSource.Sensor /// public override void Update(double deltaTime) { - // 实现激光测距仪的更新逻辑 + // 激光测距仪的更新逻辑,考虑测量精度 + if (IsActive) + { + // 计算斜向距离:高度/cos(扫描角度) + double slantRange = submunition.Position.Y / Math.Cos(TerminalSensitiveSubmunition.ScanAngle); + currentDistance = slantRange + (2 * new Random().NextDouble() - 1) * Accuracy; + } } /// @@ -78,14 +126,29 @@ namespace ThreatSource.Sensor /// /// 返回数据: /// - 目标距离值 - /// - 信号强度 - /// - 测量时间戳 - /// - 数据可靠性 /// public override SensorData GetSensorData() { // 返回激光测距仪的数据 - return new RangefinderSensorData(); + RangefinderSensorData rangefinderSensorData = new() + { + Distance = currentDistance + }; + return rangefinderSensorData; + } + + /// + /// 获取支持的干扰类型集合 + /// + public override IEnumerable SupportedJammingTypes => + [JammingType.Laser]; + + /// + /// 初始化干扰处理器 + /// + protected override void InitializeJammingHandler() + { + JammingHandler = new LaserJammingHandler(this); } } } \ No newline at end of file diff --git a/ThreatSource/src/Sensor/MillimeterWaveAltimeter.cs b/ThreatSource/src/Sensor/MillimeterWaveAltimeter.cs index b45b2a8..ef2a410 100644 --- a/ThreatSource/src/Sensor/MillimeterWaveAltimeter.cs +++ b/ThreatSource/src/Sensor/MillimeterWaveAltimeter.cs @@ -1,4 +1,6 @@ using ThreatSource.Missile; +using ThreatSource.Utils; +using ThreatSource.Jamming; namespace ThreatSource.Sensor { @@ -42,6 +44,20 @@ namespace ThreatSource.Sensor /// public double MaxAltitude { get; set; } + /// + /// 获取或设置工作波段,枚举 + /// + public MillimeterWaveBand Band { get; set; } + + /// + /// 获取或设置视场角,单位:度 + /// + /// + /// 定义了探测器的视场范围 + /// 影响目标探测的空间覆盖 + /// + public double FieldOfView { get; set; } + /// /// 获取或设置测量精度,单位:米 /// @@ -56,18 +72,22 @@ namespace ThreatSource.Sensor /// /// 末敏子弹实例 /// 最大测量高度,单位:米 + /// 工作波段,枚举 /// 测量精度,单位:米 + /// 视场角,单位:度 /// /// 构造过程: /// - 设置量程参数 /// - 初始化高度记录 /// - 继承基类位置和姿态 /// - public MillimeterWaveAltimeter(TerminalSensitiveSubmunition submunition, double maxAltitude, double accuracy) + public MillimeterWaveAltimeter(TerminalSensitiveSubmunition submunition, double maxAltitude, MillimeterWaveBand band, double accuracy, double fieldOfView) : base(submunition.Position, submunition.Orientation) { MaxAltitude = maxAltitude; Accuracy = accuracy; + Band = band; + FieldOfView = fieldOfView; currentAltitude = 0; this.submunition = submunition; } @@ -85,7 +105,10 @@ namespace ThreatSource.Sensor public override void Update(double deltaTime) { // 更新当前高度,考虑测量精度 - currentAltitude = submunition.Position.Y + Accuracy * new Random().NextDouble(); + if (IsActive) + { + currentAltitude = submunition.Position.Y + (2 * new Random().NextDouble() - 1) * Accuracy; + } } /// @@ -101,7 +124,24 @@ namespace ThreatSource.Sensor /// public void OnMillimeterWaveJamming(object sender, EventArgs e) { - Console.WriteLine("毫米波测高雷达受到干扰"); + IsActive = false; + Console.WriteLine("毫米波测高雷达受到干扰,失效"); + } + + /// + /// 处理毫米波干扰停止事件 + /// + /// 事件源对象 + /// 事件参数 + /// + /// 当毫米波干扰停止时: + /// - 输出恢复信息 + /// - 恢复探测状态 + /// + public void OnMillimeterWaveJammingStop(object sender, EventArgs e) + { + IsActive = true; + Console.WriteLine("毫米波测高雷达干扰停止,恢复工作"); } /// @@ -111,17 +151,29 @@ namespace ThreatSource.Sensor /// /// 返回数据: /// - 当前高度值 - /// - 测量时间戳 - /// - 数据可靠性 /// public override SensorData GetSensorData() { // 返回毫米波测高雷达的数据 - AltimeterSensorData altimeterSensorData = new AltimeterSensorData + AltimeterSensorData altimeterSensorData = new() { Altitude = currentAltitude }; return altimeterSensorData; } + + /// + /// 获取支持的干扰类型集合 + /// + public override IEnumerable SupportedJammingTypes => + [JammingType.MillimeterWave]; + + /// + /// 初始化干扰处理器 + /// + protected override void InitializeJammingHandler() + { + JammingHandler = new MillimeterWaveAltimeterJammingHandler(this); + } } } \ No newline at end of file diff --git a/ThreatSource/src/Sensor/MillimeterWaveRadiometer.cs b/ThreatSource/src/Sensor/MillimeterWaveRadiometer.cs index 0bb7b30..444555a 100644 --- a/ThreatSource/src/Sensor/MillimeterWaveRadiometer.cs +++ b/ThreatSource/src/Sensor/MillimeterWaveRadiometer.cs @@ -1,4 +1,6 @@ using ThreatSource.Missile; +using ThreatSource.Utils; +using ThreatSource.Jamming; namespace ThreatSource.Sensor { @@ -16,13 +18,22 @@ namespace ThreatSource.Sensor public class MillimeterWaveRadiometer : Sensor { /// - /// 获取或设置工作波段,单位:毫米 + /// 获取或设置探测距离,单位:米 + /// + /// + /// 定义了辐射计的探测范围 + /// 影响目标探测的可靠性和稳定性 + /// + public double DetectionDistance { get; set; } + + /// + /// 获取或设置工作波段,枚举 /// /// /// 可选波段:3mm 或 8mm /// 影响辐射计的探测性能和大气衰减 /// - public double Wavelength { get; set; } + public MillimeterWaveBand Band { get; set; } /// /// 扫描视场角,单位:度 @@ -82,7 +93,8 @@ namespace ThreatSource.Sensor /// 初始化毫米波辐射计的新实例 /// /// 末敏子弹实例 - /// 工作波段,单位:毫米 + /// 探测距离,单位:米 + /// 工作波段,枚举 /// 视场角,单位:度 /// /// 构造过程: @@ -91,10 +103,11 @@ namespace ThreatSource.Sensor /// - 创建传感器数据 /// - 继承基类位置和姿态 /// - public MillimeterWaveRadiometer(TerminalSensitiveSubmunition submunition, double wavelength, double fieldOfView) + public MillimeterWaveRadiometer(TerminalSensitiveSubmunition submunition, double detectionDistance, MillimeterWaveBand band, double fieldOfView) : base(submunition.Position, submunition.Orientation) { - Wavelength = wavelength; + DetectionDistance = detectionDistance; + Band = band; FieldOfView = fieldOfView; lastDetectionTemperature = 0; sensorData = new RadiometerSensorData(); @@ -153,6 +166,39 @@ namespace ThreatSource.Sensor return submunition.DetectTarget(FieldOfView) ? 90 : 300; } + /// + /// 处理毫米波干扰事件 + /// + /// 事件源对象 + /// 事件参数 + /// + /// 当检测到毫米波干扰时: + /// - 输出警告信息 + /// - 可能影响测量精度 + /// - 需要采取抗干扰措施 + /// + public void OnMillimeterWaveJamming(object sender, EventArgs e) + { + IsActive = false; + Console.WriteLine("毫米波辐射计受到干扰,失效"); + } + + /// + /// 处理毫米波干扰停止事件 + /// + /// 事件源对象 + /// 事件参数 + /// + /// 当毫米波干扰停止时: + /// - 输出恢复信息 + /// - 恢复探测状态 + /// + public void OnMillimeterWaveJammingStop(object sender, EventArgs e) + { + IsActive = true; + Console.WriteLine("毫米波辐射计干扰停止,恢复工作"); + } + /// /// 获取毫米波辐射计的最新数据 /// @@ -168,5 +214,19 @@ namespace ThreatSource.Sensor // 返回毫米波辐射计的数据 return sensorData; } + + /// + /// 获取支持的干扰类型集合 + /// + public override IEnumerable SupportedJammingTypes => + [JammingType.MillimeterWave]; + + /// + /// 初始化干扰处理器 + /// + protected override void InitializeJammingHandler() + { + JammingHandler = new MillimeterWaveJammingHandler(this); + } } } \ No newline at end of file diff --git a/ThreatSource/src/Sensor/Sensors.cs b/ThreatSource/src/Sensor/Sensors.cs index c4fead3..9808bc3 100644 --- a/ThreatSource/src/Sensor/Sensors.cs +++ b/ThreatSource/src/Sensor/Sensors.cs @@ -1,4 +1,5 @@ using ThreatSource.Utils; +using ThreatSource.Jamming; namespace ThreatSource.Sensor { @@ -79,10 +80,26 @@ namespace ThreatSource.Sensor /// - 位置和姿态管理 /// - 激活状态控制 /// - 数据采集框架 + /// - 干扰处理机制 /// 是具体传感器类的实现基础 /// - public abstract class Sensor : ISensor + public abstract class Sensor : ISensor, IJammable { + /// + /// 干扰处理器 + /// + private protected JammingHandler? JammingHandler { get; set; } + + /// + /// 获取设备支持的干扰类型 + /// + public abstract IEnumerable SupportedJammingTypes { get; } + + /// + /// 获取设备当前是否处于被干扰状态 + /// + public bool IsJammed => JammingHandler?.IsJammed ?? false; + /// /// 获取或设置传感器是否处于激活状态 /// @@ -121,14 +138,21 @@ namespace ThreatSource.Sensor /// - 设置初始位置 /// - 设置初始朝向 /// - 初始化工作状态 + /// - 创建干扰处理器 /// protected Sensor(Vector3D position, Orientation orientation) { Position = position; Orientation = orientation; IsActive = false; + InitializeJammingHandler(); } + /// + /// 初始化干扰处理器 + /// + protected abstract void InitializeJammingHandler(); + /// /// 激活传感器,使其开始工作 /// @@ -158,17 +182,40 @@ namespace ThreatSource.Sensor } /// - /// 更新传感器状态(需要在子类中实现) + /// 更新传感器状态 /// - /// 自上次更新以来的时间间隔,单位:秒 - /// - /// 更新要求: - /// - 检查工作状态 - /// - 采集最新数据 - /// - 更新内部状态 - /// - 处理异常情况 - /// - public abstract void Update(double deltaTime); + /// 时间步长,单位:秒 + public virtual void Update(double deltaTime) + { + if (IsActive) + { + JammingHandler?.Update(deltaTime); + } + } + + /// + /// 应用干扰 + /// + /// 干扰参数 + public virtual void ApplyJamming(JammingParameters parameters) + { + if (SupportedJammingTypes.Contains(parameters.Type)) + { + JammingHandler?.HandleJamming(parameters); + } + } + + /// + /// 清除干扰 + /// + /// 要清除的干扰类型 + public virtual void ClearJamming(JammingType type) + { + if (SupportedJammingTypes.Contains(type)) + { + JammingHandler?.ClearJamming(); + } + } /// /// 获取传感器数据(需要在子类中实现) diff --git a/ThreatSource/src/Simulation/SimulationEvents.cs b/ThreatSource/src/Simulation/SimulationEvents.cs index 174cf5b..0549241 100644 --- a/ThreatSource/src/Simulation/SimulationEvents.cs +++ b/ThreatSource/src/Simulation/SimulationEvents.cs @@ -445,6 +445,9 @@ namespace ThreatSource.Simulation /// public class TargetDestroyedEvent : SimulationEvent { + /// + /// 目标ID + /// public string? TargetId { get; set; } } diff --git a/ThreatSource/src/Simulation/Testing/TestSimulationAdapter.cs b/ThreatSource/src/Simulation/Testing/TestSimulationAdapter.cs index 2c3ad9f..59f6692 100644 --- a/ThreatSource/src/Simulation/Testing/TestSimulationAdapter.cs +++ b/ThreatSource/src/Simulation/Testing/TestSimulationAdapter.cs @@ -14,22 +14,41 @@ namespace ThreatSource.Simulation.Testing private readonly List _publishedEvents = new(); private ISimulationManager? _simulationManager; + /// + /// 构造函数,初始化测试适配器 + /// + /// 仿真管理器 public TestSimulationAdapter(ISimulationManager simulationManager) { _simulationManager = simulationManager; } + /// + /// 获取实体 + /// + /// 实体ID + /// 实体对象或null public object? GetEntity(string id) { return _testEntities.TryGetValue(id, out var entity) ? entity : null; } + /// + /// 发布事件到外部仿真 + /// + /// 事件类型 + /// 事件对象 public void PublishToExternalSimulation(T evt) { ArgumentNullException.ThrowIfNull(evt); _publishedEvents.Add(evt); } + /// + /// 接收来自外部仿真的事件 + /// + /// 事件类型 + /// 事件对象 public void ReceiveFromExternalSimulation(T evt) { ArgumentNullException.ThrowIfNull(evt); @@ -37,27 +56,45 @@ namespace ThreatSource.Simulation.Testing _simulationManager?.PublishEvent(evt); } - // 测试辅助方法 + /// + /// 添加测试实体 + /// + /// 实体ID + /// 实体对象 public void AddTestEntity(string id, object entity) { _testEntities[id] = entity; } + /// + /// 清除测试实体 + /// public void ClearTestEntities() { _testEntities.Clear(); } + /// + /// 获取已发布的事件 + /// + /// 已发布的事件列表 public IReadOnlyList GetPublishedEvents() { return _publishedEvents; } + /// + /// 获取已接收的事件 + /// + /// 已接收的事件列表 public IReadOnlyList GetReceivedEvents() { return _receivedEvents; } + /// + /// 清除事件 + /// public void ClearEvents() { _publishedEvents.Clear(); diff --git a/ThreatSource/src/Utils/Common.cs b/ThreatSource/src/Utils/Common.cs index 4d5b05f..22b08db 100644 --- a/ThreatSource/src/Utils/Common.cs +++ b/ThreatSource/src/Utils/Common.cs @@ -438,5 +438,37 @@ namespace ThreatSource.Utils public static Vector2D Zero => new Vector2D(0, 0); } + /// + /// 红外波段,枚举 + /// + public enum InfraredBand + { + /// + /// 远红外波段,6-15um + /// + Long, + /// + /// 中红外波段,3-6um + /// + Medium, + /// + /// 近红外波段,0.75-3um + /// + Short + } -} + /// + /// 毫米波波段,枚举 + /// + public enum MillimeterWaveBand + { + /// + /// 3mm波段 + /// + Band3, + /// + /// 8mm波段 + /// + Band8 + } +} \ No newline at end of file diff --git a/docs/articles/reference.md b/docs/articles/reference.md new file mode 100644 index 0000000..ef60569 --- /dev/null +++ b/docs/articles/reference.md @@ -0,0 +1,57 @@ +# 导弹工作原理 + +## 末敏弹工作过程 + +### 工作阶段 + +1. 母弹抛撒阶段 + - 母弹飞抵目标上空后,时间引信作用 + - 启动抛射装置,将末敏子弹按一定距离抛撒出来 + +2. 子弹减速阶段 + - 减速减旋装置动作,对子弹起减速、减旋、定向、稳向作用 + - 启动热电池,达到规定值时开始对内部电子系统供电 + +3. 第一期测距阶段 + - 子弹以大着角下落 + - 在中央控制器控制下,测距雷达开始第1期测距 + - 测定子弹到地面的距离 + - 达到预定高度时,抛去减速减旋装置 + - 稳定扫描装置动作,带动子弹旋转 + +4. 第二期测距阶段 + - 稳定扫描装置带动末敏子弹稳态降落 + - 在中央控制器控制下,测距雷达进行第2期测距 + - 中央控制器完成对目标探测数据采集的准备工作 + - 末敏子弹进入稳态扫描 + +5. 目标探测阶段 + - 末敏子弹进入威力有效高度 + - 敏感探测器在中央控制器指令下进行工作扫描 + - 在中央控制器控制下安保装置解除最后一道保险 + - 采用相邻2次扫描判定目标: + - 第1次扫过目标后,向中央控制器报告目标信息 + - 第2次扫过目标后,将目标敏感数据与特征值比较 + +6. 攻击/自毁阶段 + - 如果第2次扫描确认是目标,且目标在威力窗口内: + - 中央控制器下达指令起爆战斗部 + - 抛射出爆炸成形弹丸(EFP) + - EFP以大于2000m/s的高速射向目标 + - 在目标来不及运动的瞬间命中并摧毁目标 + - 如果第2次扫描判定为非目标: + - 可以改换对象,继续探测其他潜在目标 + - 如果一直没有发现目标: + - 末敏子弹将在距离地面一定高度时自毁 + +### 关键特性 + +1. 扫描特性 + - 抛出的末敏子弹在实施扫描时相距一定距离 + - 各自的扫描区相互衔接 + - 避免击中同一目标或漏掉目标 + +2. 安全特性 + - 多重保险装置 + - 高度自毁保护 + - 稳定扫描控制 diff --git a/docs/articles/threat-source-spec.md b/docs/articles/threat-source-spec.md index dd307ce..937fd46 100644 --- a/docs/articles/threat-source-spec.md +++ b/docs/articles/threat-source-spec.md @@ -928,21 +928,50 @@ graph TB 1. 母弹飞行阶段 - 母弹发射并飞向预定分离点 - 分离点位于目标上方1000米高度,水平距离1000米 - - 到达分离点50米范围内时释放子弹 + - 到达分离点50米范围内时触发分离 - 释放完成后母弹自动销毁 -2. 子弹分离阶段 - - 子弹从母弹分离 - - 初始速度200米/秒 - - 初始朝向指向目标 - - 激活传感器系统 +2. 子弹分离阶段 (Separation) + - 子弹从母弹分离并获得初始速度,与母弹分离速度一致 + - 初始朝向与母弹分离方向一致 + - 准备进入减速阶段 -3. 子弹制导阶段 - - 减速调整(400米高度开始) - - 螺旋扫描搜索(200米高度开始) - - 目标确认和跟踪 - - 末端精确制导 +3. 减速阶段 (Deceleration) + - 开始减速减旋 + - 激活测高雷达开始工作(第一次测高) + - 降落到高度 400 米进入降落伞打开阶段 + - 此时子弹速度 40 米/秒 + +4. 降落伞打开阶段 (ParachuteDeployment) + - 打开降落伞 + - 降落伞减速和稳定 + - 调整姿态准备扫描 + - 激活测高雷达开始工作(第二次测高) + - 在200米高度进入扫描阶段 + - 此时子弹速度 10 米/秒 + +5. 稳定扫描阶段 (StableScanning) + - 开始稳定扫描 + - 保持稳定的下降速度(10米/秒) + - 执行扫描搜索(扫描锥角30度) + - 在 120 米高度进入目标探测阶段 + - 此时子弹速度 10 米/秒 + +6. 目标探测阶段 (Detection) + - 多传感器协同工作 + - 进行目标特征识别 + - 执行二次扫描确认 + - 为攻击阶段做准备 + +7. 攻击阶段 (Attack) + - 目标确认后进入攻击 + - 保持2000米/秒攻击速度 + - 执行末端精确制导 + +8. 爆炸/自毁阶段 (Explode/SelfDestruct) + - 接近目标后引爆 - 低于20米高度时自毁 + - 未发现目标时自毁 #### 3.6.2 系统组成