Skip to content

Commit

Permalink
Restructure of SimGen -> ScenarioFileGenerator
Browse files Browse the repository at this point in the history
deleted "Squawk" assigner class
  • Loading branch information
LeoKle committed Sep 21, 2022
1 parent 0828a2e commit deeeac4
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 562 deletions.
40 changes: 40 additions & 0 deletions EuroscopeSIM.sln
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,57 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|ARM.ActiveCfg = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|ARM.Build.0 = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|ARM64.Build.0 = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|x64.ActiveCfg = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|x64.Build.0 = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|x86.ActiveCfg = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Debug|x86.Build.0 = Debug|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|Any CPU.Build.0 = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|ARM.ActiveCfg = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|ARM.Build.0 = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|ARM64.ActiveCfg = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|ARM64.Build.0 = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|x64.ActiveCfg = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|x64.Build.0 = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|x86.ActiveCfg = Release|Any CPU
{C82FD8A8-095F-4591-8D88-DFEC03C0EF6F}.Release|x86.Build.0 = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|ARM.ActiveCfg = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|ARM.Build.0 = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|ARM64.Build.0 = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|x64.ActiveCfg = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|x64.Build.0 = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|x86.ActiveCfg = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Debug|x86.Build.0 = Debug|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|Any CPU.Build.0 = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|ARM.ActiveCfg = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|ARM.Build.0 = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|ARM64.ActiveCfg = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|ARM64.Build.0 = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|x64.ActiveCfg = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|x64.Build.0 = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|x86.ActiveCfg = Release|Any CPU
{7633C68D-009D-40F1-B498-14D5892BEF57}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 0 additions & 2 deletions EuroscopeSIMBib/EuroscopeSIMBib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
<Compile Include="InputOutput.cs" />
<Compile Include="Airport.cs" />
<Compile Include="ScenarioFileGenerator.cs" />
<Compile Include="SimGen.cs" />
<Compile Include="Squawks.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
Expand Down
49 changes: 35 additions & 14 deletions EuroscopeSIMBib/ScenarioFileGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Deployment.Internal;
using System.Xml.Linq;

namespace EuroscopeSIMBib
{
Expand Down Expand Up @@ -35,14 +36,22 @@ public static void GenerateSim()
InputOutput.ReadJSON(out List<Airport> airports);

PresentandSelectAirport(airports);
Console.WriteLine();
SelectAirportConfig(_selectedairport);
Console.WriteLine();
CreateAircraft();
DurationAndIntervalSelection();
Console.WriteLine();
EuroScopeScenarioSettings();
Console.WriteLine();
GenerateScenarioFileStandardText();
Console.WriteLine();
GenerateOutbounds();
Console.WriteLine();
GenerateInbounds();

Console.WriteLine();
InputOutput.ExportSimFile(ScenarioFile);
Console.WriteLine("Program end");
Console.ReadLine();
}

Expand All @@ -58,6 +67,7 @@ private static void GenerateInbounds()
Console.WriteLine("Use 1. STAR or 2. TRANS?");

validEntry = Int32.TryParse(Console.ReadLine(), out int _selection);
Console.WriteLine();
validEntry = validEntry == true && _selection <= 2 && _selection >= 1;
STARorTRANS = _selection - 1;
} while (validEntry == false);
Expand Down Expand Up @@ -113,14 +123,15 @@ private static void GenerateInbounds()
InboundStartPosition = _selectedairport.ArrivalStartPosition[ArrivalSelection];
InboundAltitude = AltitudeList[_runwaydirectionindex][ArrivalSelection];
InitialHeading = ConvertHeadingtoEuroscopeHeadingString(_selectedairport.ArrivalInitialHeading[ArrivalSelection]);
string firstSIDpointname = GetFirstPointofArrival(fplnroute);

ScenarioFile.Add($"@N:{Inbounds[CallsignNumber].Callsign}:{Squawks.AssignSquawk()}:1:{InboundStartPosition}:{InboundAltitude}:0:{InitialHeading}");
ScenarioFile.Add($"$FP{Inbounds[CallsignNumber].Callsign}:*:I:{Inbounds[CallsignNumber].ATYP.Substring(0, Inbounds[CallsignNumber].ATYP.Length - 2)}:420{Inbounds[CallsignNumber].DEST}:00:00:0:0:::{fplnroute}");
ScenarioFile.Add($"@N:{Inbounds[CallsignNumber].Callsign}:1000:1:{InboundStartPosition}:{InboundAltitude}:0:{InitialHeading}:0");
ScenarioFile.Add($"$FP{Inbounds[CallsignNumber].Callsign}:*A:I:{Inbounds[CallsignNumber].ATYP.Substring(0, Inbounds[CallsignNumber].ATYP.Length - 2)}:420:{Inbounds[CallsignNumber].DEP}:::350:{Inbounds[CallsignNumber].DEST}:00:00:0:0:::{fplnroute}");
ScenarioFile.Add($"SIMDATA:{Inbounds[CallsignNumber].Callsign}:*:*:25:1:0");
ScenarioFile.Add($"$ROUTE:{simroute}");
ScenarioFile.Add($"START:{i}");
ScenarioFile.Add("DELAY:4:10");
ScenarioFile.Add($"REQALT:{InboundAltitude}");
ScenarioFile.Add($"REQALT:{firstSIDpointname}:{InboundAltitude}");
ScenarioFile.Add($"INITIALPSEUDOPILOT:{_selectedairport.Pseudopilots[_selectedPseudopilot]}");

Inbounds.RemoveAt(CallsignNumber);
Expand All @@ -130,6 +141,12 @@ private static void GenerateInbounds()
}
}

private static string GetFirstPointofArrival(string fplnroute)
{
string _name = fplnroute.Split(' ').First();
return _name;
}

private static void GenerateOutbounds()
{
if(_outboundseparation != 0)
Expand Down Expand Up @@ -157,16 +174,16 @@ private static void GenerateOutbounds()
int CallsignNumber = Random.Next(Outbounds.Count());

#endregion

ScenarioFile.Add($"@N:{Outbounds[CallsignNumber].Callsign}:{Squawks.AssignSquawk()}:1:{_outboundstartposition}:{_selectedairport.Elevation}:0:{_runwayheading}:0");
// ScenarioFile.Add($"@N:{Outbounds[CallsignNumber].Callsign}:1000:1:{_outboundstartposition}:{_selectedairport.Elevation}:0:{_runwayheading}:0");
ScenarioFile.Add($"@N:{Outbounds[CallsignNumber].Callsign}:1000:1:{_outboundstartposition}:2000:0:{_runwayheading}:0");

int SIDnumber = Random.Next(_distribution.Count);
SIDnumber = _distribution[SIDnumber];

simroute = _selectedairport.SIDSroute[_runwaydirectionindex][SIDnumber];
flightplan = _selectedairport.SIDSflightplan[_runwaydirectionindex][SIDnumber];

ScenarioFile.Add($"$FP{Outbounds[CallsignNumber].Callsign}:*A:I:{Outbounds[CallsignNumber].ATYP.Substring(0, Outbounds[CallsignNumber].ATYP.Length - 2)}:420:{Outbounds[CallsignNumber].DEP}:::0:{flightplan}");
ScenarioFile.Add($"$FP{Outbounds[CallsignNumber].Callsign}:*A:I:{Outbounds[CallsignNumber].ATYP.Substring(0, Outbounds[CallsignNumber].ATYP.Length - 2)}:420:{Outbounds[CallsignNumber].DEP}:::350:{Outbounds[CallsignNumber].DEST}:00:00:0:0:::{flightplan}");
ScenarioFile.Add($"SIMDATA:{Outbounds[CallsignNumber].Callsign}:*:*:25:1:0");
ScenarioFile.Add($"$ROUTE:{simroute}");
ScenarioFile.Add($"START:{i}");
Expand All @@ -181,7 +198,7 @@ private static void GenerateOutbounds()
}
}

private static void WriteDepartureorArrivalName(string[][] SIDorSTARflightplanarray, string IsSIDorSTAR)
private static void WriteDepartureorArrivalNames(string[][] SIDorSTARflightplanarray, string IsSIDorSTAR)
{
string _name;
for (int i = 0; i < SIDorSTARflightplanarray[_runwaydirectionindex].Length; i++)
Expand Down Expand Up @@ -218,7 +235,7 @@ private static void DistributionInput(string[][] SIDorSTARflightplanarray, strin
Console.WriteLine("or type \"random\" for a random distribution");
Console.WriteLine("Distribtuon numbers have to be in this order: ");

WriteDepartureorArrivalName(SIDorSTARflightplanarray, IsSIDorSTAR);
WriteDepartureorArrivalNames(SIDorSTARflightplanarray, IsSIDorSTAR);

_input = Console.ReadLine();

Expand All @@ -243,6 +260,10 @@ private static void DistributionInput(string[][] SIDorSTARflightplanarray, strin
_validEntry = true;
}
}
else
{
_validEntry = true;
}
} while (_validEntry == false);

if (_input.ToUpper() == "RANDOM")
Expand Down Expand Up @@ -365,13 +386,13 @@ private static void DurationAndIntervalSelection()
_limitreached = false;
Console.WriteLine("Select sim duration in minutes");
bool _durationbool = Int32.TryParse(Console.ReadLine(), out _duration);

Console.WriteLine();
Console.WriteLine("Select inbound separation in minutes \nSelect 0 for none");
bool _inboundseparationbool = Int32.TryParse(Console.ReadLine(), out _inboundseparation);

Console.WriteLine();
Console.WriteLine("Select outbound separation in minutes \nSelect 0 for none");
bool _outboundseparationbool = Int32.TryParse(Console.ReadLine(), out _outboundseparation);

Console.WriteLine();
if (_durationbool && _inboundseparationbool && _outboundseparationbool)
{
if (_inboundseparation != 0)
Expand Down Expand Up @@ -461,7 +482,7 @@ private static void SelectAirportConfig(Airport airport)
Console.WriteLine($"{i}. {config}");
i++;
}
Console.WriteLine("Select airport:");
Console.WriteLine("Select config:");
Int32.TryParse(Console.ReadLine(), out _input);
} while (_input > airport.RunwayConfigText.Length || _input < 1);
_runwaydirectionindex = _input - 1;
Expand Down
Loading

0 comments on commit deeeac4

Please sign in to comment.