增加了红外干扰器,红外告警器,毫米波告警器,紫外线告警器
This commit is contained in:
parent
dab6d497fc
commit
3f02f52074
@ -2,3 +2,4 @@
|
||||
bin/
|
||||
obj/
|
||||
.DS_Store
|
||||
SimulationRecords/
|
||||
|
||||
@ -12,10 +12,10 @@ namespace ActiveProtect
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// 运行仿真示例
|
||||
//SimulationExample.RunAllExamples();
|
||||
SimulationExample.RunAllExamples();
|
||||
|
||||
// 运行效能评估示例
|
||||
//EvaluationExample.RunAllExamples();
|
||||
EvaluationExample.RunAllExamples();
|
||||
|
||||
// 运行数据记录示例
|
||||
SimulationRecordExample.RunExample();
|
||||
|
||||
121
src/Models/Jammer/InfraredJammer.cs
Normal file
121
src/Models/Jammer/InfraredJammer.cs
Normal file
@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using ActiveProtect.Simulation;
|
||||
using ActiveProtect.Utility;
|
||||
|
||||
namespace ActiveProtect.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 红外干扰器类,用于对抗红外制导武器
|
||||
/// </summary>
|
||||
public class InfraredJammer : JammerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 干扰波长范围(微米)
|
||||
/// </summary>
|
||||
private readonly (double Min, double Max) wavelengthRange;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="id">红外干扰器ID</param>
|
||||
/// <param name="position">初始位置</param>
|
||||
/// <param name="orientation">初始朝向</param>
|
||||
/// <param name="manager">仿真管理器</param>
|
||||
/// <param name="tankId">所属坦克ID</param>
|
||||
/// <param name="maxJammingPower">最大干扰功率(瓦特)</param>
|
||||
/// <param name="initialJammingPower">初始干扰功率(瓦特)</param>
|
||||
/// <param name="powerIncreaseRate">功率增长率(瓦特/秒)</param>
|
||||
/// <param name="maxCooldownTime">最大冷却时间(秒)</param>
|
||||
/// <param name="wavelengthRange">干扰波长范围(微米)</param>
|
||||
public InfraredJammer(string id, Vector3D position, Orientation orientation,
|
||||
ISimulationManager manager, string tankId, double maxJammingPower,
|
||||
double initialJammingPower, double powerIncreaseRate, double maxCooldownTime,
|
||||
(double Min, double Max) wavelengthRange)
|
||||
: base(id, position, orientation, manager, tankId, maxJammingPower,
|
||||
initialJammingPower, powerIncreaseRate, maxCooldownTime)
|
||||
{
|
||||
this.wavelengthRange = wavelengthRange;
|
||||
SimulationManager.SubscribeToEvent<InfraredWarnerAlarmEvent>(OnInfraredWarnerAlarm);
|
||||
SimulationManager.SubscribeToEvent<InfraredWarnerAlarmStopEvent>(OnInfraredWarnerAlarmStop);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理红外告警器警报事件
|
||||
/// </summary>
|
||||
private void OnInfraredWarnerAlarm(InfraredWarnerAlarmEvent evt)
|
||||
{
|
||||
if (evt?.TargetId == TankId)
|
||||
{
|
||||
StartJamming();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理红外告警器警报停止事件
|
||||
/// </summary>
|
||||
private void OnInfraredWarnerAlarmStop(InfraredWarnerAlarmStopEvent evt)
|
||||
{
|
||||
if (evt?.TargetId == TankId)
|
||||
{
|
||||
StopJamming();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新干扰功率
|
||||
/// </summary>
|
||||
protected override void UpdateJammingPower(double deltaTime)
|
||||
{
|
||||
if (IsJamming)
|
||||
{
|
||||
CurrentJammingPower = Math.Min(MaxJammingPower,
|
||||
CurrentJammingPower + PowerIncreaseRate * deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发布干扰事件
|
||||
/// </summary>
|
||||
protected override void PublishJammingEvent()
|
||||
{
|
||||
if (IsJamming)
|
||||
{
|
||||
SimulationManager.PublishEvent(new InfraredJammingEvent
|
||||
{
|
||||
SenderId = Id,
|
||||
Timestamp = SimulationManager.CurrentTime,
|
||||
TargetId = TankId,
|
||||
JammingPower = CurrentJammingPower,
|
||||
WavelengthMin = wavelengthRange.Min,
|
||||
WavelengthMax = wavelengthRange.Max
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取干扰状态
|
||||
/// </summary>
|
||||
public override string GetJammingStatus()
|
||||
{
|
||||
return $"红外干扰器 {Id}:\n" +
|
||||
$" 干扰状态: {(IsJamming ? "干扰中" : "待机中")}\n" +
|
||||
$" 当前功率: {CurrentJammingPower:F2}/{MaxJammingPower:F2}\n" +
|
||||
$" 冷却时间: {CurrentCooldownTime:F2}/{MaxCooldownTime:F2}\n" +
|
||||
$" 波长范围: {wavelengthRange.Min:F2}-{wavelengthRange.Max:F2}微米";
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
base.Activate();
|
||||
SimulationManager.SubscribeToEvent<InfraredWarnerAlarmEvent>(OnInfraredWarnerAlarm);
|
||||
SimulationManager.SubscribeToEvent<InfraredWarnerAlarmStopEvent>(OnInfraredWarnerAlarmStop);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
base.Deactivate();
|
||||
SimulationManager.UnsubscribeFromEvent<InfraredWarnerAlarmEvent>(OnInfraredWarnerAlarm);
|
||||
SimulationManager.UnsubscribeFromEvent<InfraredWarnerAlarmStopEvent>(OnInfraredWarnerAlarmStop);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
src/Models/Wanner/InfraredWarner.cs
Normal file
51
src/Models/Wanner/InfraredWarner.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using ActiveProtect.Simulation;
|
||||
using ActiveProtect.Utility;
|
||||
|
||||
namespace ActiveProtect.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 红外告警器类,用于检测红外辐射并发出警报
|
||||
/// </summary>
|
||||
public class InfraredWarner : WarnerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 红外告警器灵敏度阈值
|
||||
/// </summary>
|
||||
private readonly double sensitivityThreshold;
|
||||
|
||||
public InfraredWarner(string id, Vector3D position, Orientation orientation,
|
||||
ISimulationManager manager, string tankId, double warningDuration, double sensitivityThreshold)
|
||||
: base(id, position, orientation, manager, tankId, warningDuration)
|
||||
{
|
||||
this.sensitivityThreshold = sensitivityThreshold;
|
||||
SimulationManager.SubscribeToEvent<InfraredDetectionEvent>(OnInfraredDetection);
|
||||
}
|
||||
|
||||
private void OnInfraredDetection(InfraredDetectionEvent evt)
|
||||
{
|
||||
if (evt?.TargetId == TankId && evt.Intensity >= sensitivityThreshold)
|
||||
{
|
||||
StartWarning();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetWarningStatus()
|
||||
{
|
||||
return $"红外告警器 {Id}:\n" +
|
||||
$" 告警状态: {(IsWarning ? "告警中" : "正常")}\n" +
|
||||
$" 告警持续时间: {CurrentWarningTime:F2}/{WarningDuration:F2}";
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
base.Activate();
|
||||
SimulationManager.SubscribeToEvent<InfraredDetectionEvent>(OnInfraredDetection);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
base.Deactivate();
|
||||
SimulationManager.UnsubscribeFromEvent<InfraredDetectionEvent>(OnInfraredDetection);
|
||||
}
|
||||
}
|
||||
}
|
||||
62
src/Models/Wanner/MillimeterWaveWarner.cs
Normal file
62
src/Models/Wanner/MillimeterWaveWarner.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using ActiveProtect.Simulation;
|
||||
using ActiveProtect.Utility;
|
||||
|
||||
namespace ActiveProtect.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 毫米波告警器类,用于检测毫米波辐射并发出警报
|
||||
/// </summary>
|
||||
public class MillimeterWaveWarner : WarnerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 毫米波告警器灵敏度阈值
|
||||
/// </summary>
|
||||
private readonly double sensitivityThreshold;
|
||||
|
||||
/// <summary>
|
||||
/// 频率范围(GHz)
|
||||
/// </summary>
|
||||
private readonly (double Min, double Max) frequencyRange;
|
||||
|
||||
public MillimeterWaveWarner(string id, Vector3D position, Orientation orientation,
|
||||
ISimulationManager manager, string tankId, double warningDuration,
|
||||
double sensitivityThreshold, (double Min, double Max) frequencyRange)
|
||||
: base(id, position, orientation, manager, tankId, warningDuration)
|
||||
{
|
||||
this.sensitivityThreshold = sensitivityThreshold;
|
||||
this.frequencyRange = frequencyRange;
|
||||
SimulationManager.SubscribeToEvent<MillimeterWaveDetectionEvent>(OnMillimeterWaveDetection);
|
||||
}
|
||||
|
||||
private void OnMillimeterWaveDetection(MillimeterWaveDetectionEvent evt)
|
||||
{
|
||||
if (evt?.TargetId == TankId &&
|
||||
evt.Intensity >= sensitivityThreshold &&
|
||||
evt.Frequency >= frequencyRange.Min &&
|
||||
evt.Frequency <= frequencyRange.Max)
|
||||
{
|
||||
StartWarning();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetWarningStatus()
|
||||
{
|
||||
return $"毫米波告警器 {Id}:\n" +
|
||||
$" 告警状态: {(IsWarning ? "告警中" : "正常")}\n" +
|
||||
$" 告警持续时间: {CurrentWarningTime:F2}/{WarningDuration:F2}\n" +
|
||||
$" 频率范围: {frequencyRange.Min}-{frequencyRange.Max} GHz";
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
base.Activate();
|
||||
SimulationManager.SubscribeToEvent<MillimeterWaveDetectionEvent>(OnMillimeterWaveDetection);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
base.Deactivate();
|
||||
SimulationManager.UnsubscribeFromEvent<MillimeterWaveDetectionEvent>(OnMillimeterWaveDetection);
|
||||
}
|
||||
}
|
||||
}
|
||||
51
src/Models/Wanner/UltravioletWarner.cs
Normal file
51
src/Models/Wanner/UltravioletWarner.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using ActiveProtect.Simulation;
|
||||
using ActiveProtect.Utility;
|
||||
|
||||
namespace ActiveProtect.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 紫外告警器类,用于检测紫外辐射并发出警报
|
||||
/// </summary>
|
||||
public class UltravioletWarner : WarnerBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 紫外告警器灵敏度阈值
|
||||
/// </summary>
|
||||
private readonly double sensitivityThreshold;
|
||||
|
||||
public UltravioletWarner(string id, Vector3D position, Orientation orientation,
|
||||
ISimulationManager manager, string tankId, double warningDuration, double sensitivityThreshold)
|
||||
: base(id, position, orientation, manager, tankId, warningDuration)
|
||||
{
|
||||
this.sensitivityThreshold = sensitivityThreshold;
|
||||
SimulationManager.SubscribeToEvent<UltravioletDetectionEvent>(OnUltravioletDetection);
|
||||
}
|
||||
|
||||
private void OnUltravioletDetection(UltravioletDetectionEvent evt)
|
||||
{
|
||||
if (evt?.TargetId == TankId && evt.Intensity >= sensitivityThreshold)
|
||||
{
|
||||
StartWarning();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetWarningStatus()
|
||||
{
|
||||
return $"紫外告警器 {Id}:\n" +
|
||||
$" 告警状态: {(IsWarning ? "告警中" : "正常")}\n" +
|
||||
$" 告警持续时间: {CurrentWarningTime:F2}/{WarningDuration:F2}";
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
base.Activate();
|
||||
SimulationManager.SubscribeToEvent<UltravioletDetectionEvent>(OnUltravioletDetection);
|
||||
}
|
||||
|
||||
public override void Deactivate()
|
||||
{
|
||||
base.Deactivate();
|
||||
SimulationManager.UnsubscribeFromEvent<UltravioletDetectionEvent>(OnUltravioletDetection);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -265,4 +265,154 @@ namespace ActiveProtect.Simulation
|
||||
public string? MissileId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 红外探测事件
|
||||
/// </summary>
|
||||
public class InfraredDetectionEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 红外辐射强度
|
||||
/// </summary>
|
||||
public double Intensity { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 红外告警器警报事件
|
||||
/// </summary>
|
||||
public class InfraredWarnerAlarmEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 红外告警器警报停止事件
|
||||
/// </summary>
|
||||
public class InfraredWarnerAlarmStopEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 紫外探测事件
|
||||
/// </summary>
|
||||
public class UltravioletDetectionEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 紫外辐射强度
|
||||
/// </summary>
|
||||
public double Intensity { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 紫外告警器警报事件
|
||||
/// </summary>
|
||||
public class UltravioletWarnerAlarmEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 紫外告警器警报停止事件
|
||||
/// </summary>
|
||||
public class UltravioletWarnerAlarmStopEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 毫米波探测事件
|
||||
/// </summary>
|
||||
public class MillimeterWaveDetectionEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 毫米波辐射强度
|
||||
/// </summary>
|
||||
public double Intensity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 毫米波频率(GHz)
|
||||
/// </summary>
|
||||
public double Frequency { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 毫米波告警器警报事件
|
||||
/// </summary>
|
||||
public class MillimeterWaveWarnerAlarmEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 探测到的频率(GHz)
|
||||
/// </summary>
|
||||
public double DetectedFrequency { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 毫米波告警器警报停止事件
|
||||
/// </summary>
|
||||
public class MillimeterWaveWarnerAlarmStopEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 红外干扰事件
|
||||
/// </summary>
|
||||
public class InfraredJammingEvent : SimulationEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// 目标ID
|
||||
/// </summary>
|
||||
public string? TargetId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 干扰功率(瓦特)
|
||||
/// </summary>
|
||||
public double JammingPower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小波长(微米)
|
||||
/// </summary>
|
||||
public double WavelengthMin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大波长(微米)
|
||||
/// </summary>
|
||||
public double WavelengthMax { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user