180 lines
7.1 KiB
C#
180 lines
7.1 KiB
C#
using System;
|
||
using System.Threading;
|
||
using ActiveProtect.SimulationEnvironment;
|
||
using ActiveProtect.Models;
|
||
using Model;
|
||
using System.Collections.Generic;
|
||
|
||
namespace ActiveProtect
|
||
{
|
||
/// <summary>
|
||
/// 主程序
|
||
/// </summary>
|
||
class Program
|
||
{
|
||
static void Main(string[] args)
|
||
{
|
||
// 初始化坦克信息
|
||
TankInfo tankinfo = new()
|
||
{
|
||
xp = 100,
|
||
yp = 0,
|
||
zp = 100
|
||
};
|
||
|
||
// 创建仿真配置
|
||
var config = new SimulationConfig
|
||
{
|
||
// 配置坦克
|
||
TankConfigs = new List<TankConfig>
|
||
{
|
||
new(tankinfo)
|
||
{
|
||
Id = "Tank_1",
|
||
InitialOrientation = new Orientation(Math.PI/4, 0, 0),
|
||
InitialSpeed = 10,
|
||
MaxSpeed = 25,
|
||
MaxArmor = 100,
|
||
HasLaserWarner = false,
|
||
HasLaserJammer = true
|
||
}
|
||
},
|
||
// 配置激光指示器
|
||
LaserDesignatorConfig = new LaserDesignatorConfig
|
||
{
|
||
Id = "LD_1",
|
||
InitialPosition = new Vector3D(2000, 150, 100),
|
||
LaserPower = 1e6,
|
||
LaserDivergenceAngle = 0.01
|
||
},
|
||
// 配置激光告警器
|
||
LaserWarnerConfig = new LaserWarnerConfig
|
||
{
|
||
Id = "LW_1",
|
||
AlarmDuration = 5.0
|
||
},
|
||
// 配置激光干扰器
|
||
LaserJammerConfig = new LaserJammerConfig
|
||
{
|
||
Id = "LJ_1",
|
||
MaxJammingCooldown = 5.0,
|
||
MaxJammingPower = 10000.0,
|
||
InitialJammingPower = 4000.0,
|
||
PowerIncreaseRate = 2000.0
|
||
},
|
||
// 配置激光驾束仪
|
||
LaserBeamRiderConfig = new LaserBeamRiderConfig
|
||
{
|
||
Id = "LBR_1",
|
||
InitialPosition = new Vector3D(2000, 10, 100),
|
||
LaserPower = 1000,
|
||
ControlFieldDiameter = 6
|
||
},
|
||
// 配置导弹
|
||
MissileConfigs = new List<MissileConfig>
|
||
{
|
||
// 激光半主动制导导弹配置
|
||
new() {
|
||
Id = "LSGM_1",
|
||
InitialPosition = new Vector3D(2000, 100, 100),
|
||
InitialOrientation = new Orientation(Math.PI, -0.1, 0),
|
||
InitialSpeed = 700,
|
||
MaxSpeed = 800,
|
||
TargetIndex = 0,
|
||
MaxFlightTime = 10,
|
||
MaxFlightDistance = 5000,
|
||
LaunchAcceleration = 50,
|
||
MaxEngineBurnTime = 10,
|
||
MaxAcceleration = 400,
|
||
ProportionalNavigationCoefficient = 3,
|
||
ExplosionRadius = 10,
|
||
Mass = 50,
|
||
Type = MissileType.LaserSemiActiveGuidance
|
||
},
|
||
// 激光驾束制导导弹配置
|
||
new() {
|
||
Id = "LBRM_1",
|
||
InitialPosition = new Vector3D(2000, 10, 100),
|
||
InitialOrientation = new Orientation(Math.PI, 0.0, 0.0),
|
||
InitialSpeed = 300,
|
||
MaxSpeed = 400,
|
||
TargetIndex = 0,
|
||
MaxFlightTime = 10,
|
||
MaxFlightDistance = 3000,
|
||
LaunchAcceleration = 50,
|
||
MaxEngineBurnTime = 10,
|
||
MaxAcceleration = 400,
|
||
ProportionalNavigationCoefficient = 3,
|
||
ExplosionRadius = 10,
|
||
Mass = 50,
|
||
Type = MissileType.LaserBeamRiderGuidance
|
||
},
|
||
// 末敏弹配置
|
||
new() {
|
||
Id = "TSM_1",
|
||
InitialPosition = new Vector3D(4000, 0, 100), // 发射位置
|
||
InitialOrientation = new Orientation(Math.PI, Math.PI/8, 0), // 使用计算得到的发射角度
|
||
InitialSpeed = 800,
|
||
MaxSpeed = 1000,
|
||
TargetIndex = 0,
|
||
MaxFlightTime = 30,
|
||
MaxFlightDistance = 5000,
|
||
LaunchAcceleration = 0,
|
||
MaxEngineBurnTime = 0,
|
||
MaxAcceleration = 1000,
|
||
ProportionalNavigationCoefficient = 3,
|
||
Mass = 50,
|
||
Type = MissileType.TerminalSensitiveMissile
|
||
},
|
||
// 红外指令制导导弹配置
|
||
new() {
|
||
Id = "ICGM_1",
|
||
InitialPosition = new Vector3D(2000, 100, 100),
|
||
InitialOrientation = new Orientation(Math.PI, 0.0, 0),
|
||
InitialSpeed = 300,
|
||
MaxSpeed = 400,
|
||
TargetIndex = 0,
|
||
MaxFlightTime = 60,
|
||
MaxFlightDistance = 5000,
|
||
LaunchAcceleration = 50,
|
||
MaxEngineBurnTime = 10,
|
||
MaxAcceleration = 1000,
|
||
ExplosionRadius = 10,
|
||
ProportionalNavigationCoefficient = 1,
|
||
Mass = 50,
|
||
Type = MissileType.InfraredCommandGuidance
|
||
}
|
||
},
|
||
// 配置红外测角仪
|
||
InfraredTrackerConfig = new InfraredTrackerConfig
|
||
{
|
||
Id = "IT_1",
|
||
InitialPosition = new Vector3D(2500, 0, 100),
|
||
InitialOrientation = new Orientation(Math.PI, 0, 0),
|
||
MaxTrackingRange = 10000, // 10公里
|
||
FieldOfView = Math.PI / 4, // 45度
|
||
AngleMeasurementAccuracy = 0.000005, // 0.0005弧度 (约0.029度)
|
||
UpdateFrequency = 10 // 20赫兹
|
||
},
|
||
SimulationTimeStep = 0.01 // 仿真时间步长, 激光驾束制导导弹需要更小的步长,< 0.025s
|
||
};
|
||
|
||
// 创建仿真管理器
|
||
var simulationManager = new SimulationManager(config);
|
||
|
||
// 运行仿真
|
||
int maxIterations = 1000;
|
||
int iteration = 0;
|
||
while (!simulationManager.IsSimulationEnded && iteration < maxIterations)
|
||
{
|
||
simulationManager.Update();
|
||
simulationManager.PrintStatus();
|
||
Thread.Sleep(50); // 暂停100毫秒,使输出更易读
|
||
iteration++;
|
||
}
|
||
|
||
Console.WriteLine("仿真结束");
|
||
}
|
||
}
|
||
}
|