ActiveProtect/SimulationEnvironment/SimulationConfig.cs

525 lines
14 KiB
C#

using System;
using System.Collections.Generic;
using ActiveProtect.Models;
using Model;
namespace ActiveProtect.SimulationEnvironment
{
/// <summary>
/// 仿真配置类,包含整个仿真所需的所有配置信息
/// </summary>
public class SimulationConfig
{
/// <summary>
/// 坦克配置列表
/// </summary>
public List<TankConfig> TankConfigs { get; set; }
/// <summary>
/// 导弹配置列表
/// </summary>
public List<MissileConfig> MissileConfigs { get; set; }
/// <summary>
/// 激光指示器配置列表
/// </summary>
public LaserDesignatorConfig LaserDesignatorConfig { get; set; }
/// <summary>
/// 激光驾束仪配置列表
/// </summary>
public LaserBeamRiderConfig LaserBeamRiderConfig { get; set; }
/// <summary>
/// 激光告警器配置
/// </summary>
public LaserWarnerConfig LaserWarnerConfig { get; set; }
/// <summary>
/// 激光干扰器配置
/// </summary>
public LaserJammerConfig LaserJammerConfig { get; set; }
/// <summary>
/// 仿真时间步长(秒)
/// </summary>
public double SimulationTimeStep { get; set; }
/// <summary>
/// 红外测角仪配置
/// </summary>
public InfraredTrackerConfig InfraredTrackerConfig { get; set; }
/// <summary>
/// 构造函数,初始化默认配置
/// </summary>
public SimulationConfig()
{
TankConfigs = new List<TankConfig>();
MissileConfigs = new List<MissileConfig>();
LaserDesignatorConfig = new LaserDesignatorConfig();
LaserBeamRiderConfig = new LaserBeamRiderConfig();
LaserWarnerConfig = new LaserWarnerConfig();
LaserJammerConfig = new LaserJammerConfig();
InfraredTrackerConfig = new InfraredTrackerConfig();
SimulationTimeStep = 0.1; // 默认时间步长为0.1秒
}
}
/// <summary>
/// 坦克配置类
/// </summary>
public class TankConfig
{
/// <summary>
/// 坦克ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 初始位置
/// </summary>
public Vector3D InitialPosition { get; set; }
/// <summary>
/// 初始朝向
/// </summary>
public Orientation InitialOrientation { get; set; }
/// <summary>
/// 初始速度(米/秒)
/// </summary>
public double InitialSpeed { get; set; }
/// <summary>
/// 最大速度(米/秒)
/// </summary>
public double MaxSpeed { get; set; }
/// <summary>
/// 最大装甲值
/// </summary>
public double MaxArmor { get; set; }
/// <summary>
/// 红外辐射强度(W/sr)
/// </summary>
public double InfraredRadiationIntensity { get; set; }
/// <summary>
/// 雷达截面积(m^2)
/// </summary>
public double RadarCrossSection { get; set; }
/// <summary>
/// 是否装备激光告警器
/// </summary>
public bool HasLaserWarner { get; set; }
/// <summary>
/// 是否装备激光干扰器
/// </summary>
public bool HasLaserJammer { get; set; }
/// <summary>
/// 构造函数,设置默认值
/// </summary>
public TankConfig()
{
SetDefaultValues();
Id = "";
InitialPosition = new Vector3D(0, 0, 0);
InitialOrientation = new Orientation(0, 0, 0);
}
public TankConfig(TankInfo tankInfo){
SetDefaultValues();
Id = $"Tank_{tankInfo.TankID}";
InitialPosition = new Vector3D(tankInfo.xp, tankInfo.yp, tankInfo.zp);
InitialOrientation = new Orientation(0, 0, 0);
}
public void SetDefaultValues(){
InitialSpeed = 0;
MaxSpeed = 0;
MaxArmor = 0;
HasLaserWarner = false;
HasLaserJammer = false;
InfraredRadiationIntensity = 0;
}
// 验证方法
public bool Validate()
{
// 实现验证逻辑
return true;
}
}
/// <summary>
/// 导弹配置类
/// </summary>
public class MissileConfig
{
/// <summary>
/// 导弹ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 初始位置
/// </summary>
public Vector3D InitialPosition { get; set; }
/// <summary>
/// 初始朝向
/// </summary>
public Orientation InitialOrientation { get; set; }
/// <summary>
/// 初始速度(米/秒)
/// </summary>
public double InitialSpeed { get; set; }
/// <summary>
/// 最大速度(米/秒)
/// </summary>
public double MaxSpeed { get; set; }
/// <summary>
/// 目标索引
/// </summary>
public int TargetIndex { get; set; }
/// <summary>
/// 最大飞行时间(秒)
/// </summary>
public double MaxFlightTime { get; set; }
/// <summary>
/// 最大飞行距离(米)
/// </summary>
public double MaxFlightDistance { get; set; }
/// <summary>
/// 最大加速度(米/秒²)
/// </summary>
public double MaxAcceleration { get; set; }
/// <summary>
/// 比例导引系数
/// </summary>
public double ProportionalNavigationCoefficient { get; set; }
/// <summary>
/// 发射推力加速度(米/秒²)
/// </summary>
public double LaunchAcceleration { get; set; }
/// <summary>
/// 最大发动机燃烧时间(秒)
/// </summary>
public double MaxEngineBurnTime { get; set; }
/// <summary>
/// 导弹质量(千克)
/// </summary>
public double Mass { get; set; }
/// <summary>
/// 爆炸半径(米)
/// </summary>
public double ExplosionRadius { get; set; }
/// <summary>
/// 导弹类型
/// </summary>
public MissileType Type { get; set; }
/// <summary>
/// 比例增益
/// </summary>
public double Kp { get; set; }
/// <summary>
/// 积分增益
/// </summary>
public double Ki { get; set; }
/// <summary>
/// 微分增益
/// </summary>
public double Kd { get; set; }
/// <summary>
/// 自适应速率
/// </summary>
public double AdaptiveRate { get; set; }
/// <summary>
/// 期望性能指标
/// </summary>
public double DesiredPerformance { get; set; }
/// <summary>
/// 构造函数,设置默认值
/// </summary>
public MissileConfig()
{
SetDefaultValues();
Id = "";
InitialPosition = new Vector3D(0, 0, 0);
InitialOrientation = new Orientation(0, 0, 0);
}
/// <summary>
/// 构造函数,根据导弹初始信息初始化导弹配置
/// </summary>
/// <param name="mIniInfo">导弹初始信息</param>
public MissileConfig(MIniInfo mIniInfo){
SetDefaultValues();
Id = $"Missile_{mIniInfo.nMisID}";
InitialPosition = new Vector3D(mIniInfo.xm, mIniInfo.ym, mIniInfo.zm);
InitialOrientation = new Orientation(mIniInfo.psi_m, mIniInfo.theta_m, 0);
InitialSpeed = mIniInfo.vm;
}
/// <summary>
/// 设置默认值
/// </summary>
public void SetDefaultValues(){
InitialSpeed = 0;
MaxSpeed = 0;
TargetIndex = 0;
MaxFlightTime = 0;
MaxFlightDistance = 0;
LaunchAcceleration = 0;
MaxEngineBurnTime = 0;
MaxAcceleration = 0;
ExplosionRadius = 0;
ProportionalNavigationCoefficient = 0;
Type = MissileType.StandardMissile;
}
}
/// <summary>
/// 激光指示器配置类
/// </summary>
public class LaserDesignatorConfig
{
/// <summary>
/// 激光指示器ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 初始位置
/// </summary>
public Vector3D InitialPosition { get; set; }
/// <summary>
/// 激光功率(瓦特)
/// </summary>
public double LaserPower { get; set; }
/// <summary>
/// 激光发散角
/// </summary>
public double LaserDivergenceAngle { get; set; }
/// <summary>
/// 构造函数,设置默认值
/// </summary>
public LaserDesignatorConfig()
{
Id = "";
InitialPosition = new Vector3D(0, 0, 0);
LaserPower = 0;
LaserDivergenceAngle = 0;
}
}
/// <summary>
/// 激光驾束仪配置类
/// </summary>
public class LaserBeamRiderConfig
{
/// <summary>
/// 激光驾束仪ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 初始位置
/// </summary>
public Vector3D InitialPosition { get; set; }
/// <summary>
/// 激光功率(瓦特)
/// </summary>
public double LaserPower { get; set; }
/// <summary>
/// 控制场直径(米)
/// </summary>
public double ControlFieldDiameter { get; set; }
/// <summary>
/// 最大导引距离(米)
/// </summary>
public double MaxGuidanceDistance { get; set; }
/// <summary>
/// 构造函数,设置默认值
/// </summary>
public LaserBeamRiderConfig()
{
Id = "";
InitialPosition = new Vector3D(0, 0, 0);
LaserPower = 0;
ControlFieldDiameter = 0;
}
}
/// <summary>
/// 导弹类型枚举
/// </summary>
public enum MissileType
{
StandardMissile, // 标准导弹
LaserSemiActiveGuidance, // 激光半主动制导
LaserBeamRiderGuidance, // 激光驾束制导
InfraredCommandGuidance, // 红外指令制导
InfraredImagingTerminalGuidance, // 红外成像末制导
MillimeterWaveTerminalGuidance, // 毫米波末制导
TerminalSensitiveMissile // 末敏弹
}
/// <summary>
/// 激光告警器配置类
/// </summary>
public class LaserWarnerConfig
{
/// <summary>
/// 激光告警器ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 警报持续时间(秒)
/// </summary>
public double AlarmDuration { get; set; }
/// <summary>
/// 构造函数,设置默认值
/// </summary>
public LaserWarnerConfig()
{
Id = "";
AlarmDuration = 5.0; // 默认警报持续5秒
}
}
/// <summary>
/// 激光干扰器配置类
/// </summary>
public class LaserJammerConfig
{
/// <summary>
/// 激光干扰器ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 最大干扰冷却时间(秒)
/// </summary>
public double MaxJammingCooldown { get; set; }
/// <summary>
/// 最大干扰功率(瓦特)
/// </summary>
public double MaxJammingPower { get; set; }
/// <summary>
/// 初始干扰功率(瓦特)
/// </summary>
public double InitialJammingPower { get; set; }
/// <summary>
/// 功率增加速率(瓦特/秒)
/// </summary>
public double PowerIncreaseRate { get; set; }
/// <summary>
/// 构造函数,设置默认值
/// </summary>
public LaserJammerConfig()
{
Id = "";
MaxJammingCooldown = 5.0;
MaxJammingPower = 10000.0;
InitialJammingPower = 4000.0;
PowerIncreaseRate = 2000.0; // 每秒增加的功率
}
}
/// <summary>
/// 红外测角仪配置类
/// </summary>
public class InfraredTrackerConfig
{
/// <summary>
/// 红外测角仪ID
/// </summary>
public string Id { get; set; }
/// <summary>
/// 初始位置
/// </summary>
public Vector3D InitialPosition { get; set; }
/// <summary>
/// 初始朝向
/// </summary>
public Orientation InitialOrientation { get; set; }
/// <summary>
/// 最大跟踪距离(米)
/// </summary>
public double MaxTrackingRange { get; set; }
/// <summary>
/// 视场角(弧度)
/// </summary>
public double FieldOfView { get; set; }
/// <summary>
/// 角度测量精度(弧度)
/// </summary>
public double AngleMeasurementAccuracy { get; set; }
/// <summary>
/// 更新频率(赫兹)
/// </summary>
public double UpdateFrequency { get; set; }
/// <summary>
/// 构造函数,设置默认值
/// </summary>
public InfraredTrackerConfig()
{
Id = "";
InitialPosition = new Vector3D(0, 0, 0);
InitialOrientation = new Orientation(0, 0, 0);
MaxTrackingRange = 10000; // 10公里
FieldOfView = Math.PI / 3; // 60度
AngleMeasurementAccuracy = 0.001; // 0.001弧度 (约0.057度)
UpdateFrequency = 10; // 10赫兹
}
}
}