diff --git a/EuroscopeSIM.sln b/EuroscopeSIM.sln index 7216ee8..8967dfd 100644 --- a/EuroscopeSIM.sln +++ b/EuroscopeSIM.sln @@ -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 diff --git a/EuroscopeSIMBib/EuroscopeSIMBib.csproj b/EuroscopeSIMBib/EuroscopeSIMBib.csproj index 09200ac..0a4042f 100644 --- a/EuroscopeSIMBib/EuroscopeSIMBib.csproj +++ b/EuroscopeSIMBib/EuroscopeSIMBib.csproj @@ -51,8 +51,6 @@ - - diff --git a/EuroscopeSIMBib/ScenarioFileGenerator.cs b/EuroscopeSIMBib/ScenarioFileGenerator.cs index 6c57bfc..588c06d 100644 --- a/EuroscopeSIMBib/ScenarioFileGenerator.cs +++ b/EuroscopeSIMBib/ScenarioFileGenerator.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using Newtonsoft.Json; using System.Deployment.Internal; +using System.Xml.Linq; namespace EuroscopeSIMBib { @@ -35,14 +36,22 @@ public static void GenerateSim() InputOutput.ReadJSON(out List 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(); } @@ -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); @@ -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); @@ -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) @@ -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}"); @@ -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++) @@ -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(); @@ -243,6 +260,10 @@ private static void DistributionInput(string[][] SIDorSTARflightplanarray, strin _validEntry = true; } } + else + { + _validEntry = true; + } } while (_validEntry == false); if (_input.ToUpper() == "RANDOM") @@ -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) @@ -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; diff --git a/EuroscopeSIMBib/SimGen.cs b/EuroscopeSIMBib/SimGen.cs deleted file mode 100644 index c3754ad..0000000 --- a/EuroscopeSIMBib/SimGen.cs +++ /dev/null @@ -1,504 +0,0 @@ -using ES; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Newtonsoft.Json; -using System.IO; -using System.Security.Principal; - - -namespace EuroscopeSIMBib -{ - public class SimGen - { - private int _duration; - private int _inboundseparation; - private int _outboundseparation; - private int _groundorairstart; - private string _outboundstartposition; - private string _outboundinitialaltitude; - private int _runwaydirectionindex; - private int _selectedPseudopilot; - private List SimFile = new List(); - - private Airport _airport = new Airport(); - - private List AircraftList = new List(); - private List Outbounds = new List(); - private List Inbounds = new List(); - - private Random Random = new Random(); - private List OutboundDistribution = new List(); - private List ArrivalDistribution = new List(); - private static List CreateAircraft(List Input) - { - List AircraftList = new List(); - //Squawks SquawkAssigner = new Squawks(); not needed if static - for (int i = 1; i < Input.Count; i++) - { - string[] subs = Input[i].Split(';'); - ACFT CurrentAircraft = new ACFT(subs[0], subs[1], subs[2], subs[3], Squawks.AssignSquawk()); - AircraftList.Add(CurrentAircraft); - } - - return AircraftList; - } - - public void GenerateSIM() - { - InputOutput.CheckFolder(); - //AirportSelection(out string ICAO, out _runwaydirectionindex); - /* - string address = $"C:\\Users\\Leon\\Documents\\EuroScope\\SIMGEN\\{ICAO.ToUpper()}.json"; - if (File.Exists(address)) - { - var airport = JsonConvert.DeserializeObject(File.ReadAllText(address)); - _airport = airport; - List Listairport = new List(); - Listairport.Add(airport); - Listairport.Add(airport); - string json = JsonConvert.SerializeObject(Listairport, Formatting.Indented); - InputOutput.ExportJson(json); - } */ - - InputOutput.ReadJSON(out List Airports); - AirportSelection(Airports); - - - - AircraftList = CreateAircraft(InputOutput.ImportFlightData(ICAO)); - SplitAircraftList(ICAO, AircraftList, out Outbounds, out Inbounds); - DurationAndIntervalSelection(Outbounds.Count, Inbounds.Count, out _duration); - ESSimSettings(); - GenerateSimFileStandardText(); - GenerateOutbounds(); - GenerateInbounds(); - InputOutput.ExportSimFile(SimFile); - } - private void AirportSelection(out string ICAO, out int RunwayDirectionIndex) - { - ICAO = ""; - RunwayDirectionIndex = 0; - string _input; - do - { - Console.WriteLine("For which airport do you want to create a Euroscope Scenario file?\n 1. EDDL \n or \n 2. EDDK"); - Console.WriteLine("Input 1 or 2"); - _input = Console.ReadLine(); - } while (_input != "1" && _input != "2"); - - string _runwaydirection; - if (_input == "1") - { - ICAO = "EDDL"; - do - { - Console.WriteLine("Which runway direction?\n 23 or 05"); - _runwaydirection = Console.ReadLine(); - if(_runwaydirection == "23") - { - RunwayDirectionIndex = 0; - } - else if (_runwaydirection == "05") - { - RunwayDirectionIndex = 1; - } - - } while (RunwayDirectionIndex != 0 && RunwayDirectionIndex != 1); - } - else if(_input == "EDDK") - { - ICAO = "EDDK"; - do - { - Console.WriteLine("Which runway direction?\n 14 or 32"); - _runwaydirection = Console.ReadLine(); - if (_runwaydirection == "14") - { - RunwayDirectionIndex = 0; - } - else if (_runwaydirection == "32") - { - RunwayDirectionIndex = 1; - } - } while (RunwayDirectionIndex != 0 && RunwayDirectionIndex != 1); - } - else - { - throw new ArgumentException("ArgumentException at AirportSelection()"); - } - } - - private void SplitAircraftList(string ICAO, List AircraftList, out List Outbounds, out List Inbounds) - { - Outbounds = new List(); - Inbounds = new List(); - - for (int i = 0; i < AircraftList.Count; i++) - { - if (AircraftList[i].DEP == ICAO) - { - Outbounds.Add(AircraftList[i]); - } - else - { - Inbounds.Add(AircraftList[i]); - } - } - } - - private void DurationAndIntervalSelection(int OutboundCount, int InboundCount, out int _duration) - { - bool _limitreached; - do - { - _limitreached = false; - Console.WriteLine("Select sim duration in minutes"); - bool _durationbool = Int32.TryParse(Console.ReadLine(), out _duration); - - Console.WriteLine("Select inbound separation in minutes \nSelect 0 for none"); - bool _inboundseparationbool = Int32.TryParse(Console.ReadLine(), out _inboundseparation); - - Console.WriteLine("Select outbound separation in minutes \nSelect 0 for none"); - bool _outboundseparationbool = Int32.TryParse(Console.ReadLine(), out _outboundseparation); - - if (_durationbool && _inboundseparationbool && _outboundseparationbool) - { - if(_inboundseparation != 0) - { - int _inboundaircraftcount = _duration / _inboundseparation; - if (_inboundaircraftcount > InboundCount) - { - Console.WriteLine("You want to create more aircraft than callsigns are availabe for inbounds"); - _limitreached = true; - } - } - if(_outboundseparation != 0) - { - int _outboundaircraftcount = _duration / _outboundseparation; - if (_outboundaircraftcount > InboundCount) - { - _limitreached = true; - } - } - } - else - { - Console.WriteLine("Error: sim duration and inbound separation have to be numbers \n"); - _limitreached = true; - } - - } while (_limitreached); - - } - - private void ESSimSettings() - { - #region selection of pseudopilot - - Console.WriteLine("Which station should control the aircrafts"); - for(int i = 0; i < _airport.Pseudopilots.Count(); i++) - { - Console.WriteLine($"{i + 1}. {_airport.Pseudopilots[i]}"); - } - bool _erfolgreich; - do - { - _erfolgreich = Int32.TryParse(Console.ReadLine(), out _selectedPseudopilot); - _selectedPseudopilot--; - _erfolgreich = _erfolgreich == true && _selectedPseudopilot < _airport.Pseudopilots.Count() && _selectedPseudopilot >= 0; - } while (!_erfolgreich); - - #endregion - - if (_outboundseparation > 0) - { - #region ground or air start - do - { - Console.WriteLine("Should outbounds start on 1) ground or 2) in air"); - Int32.TryParse(Console.ReadLine(), out _groundorairstart); - } while (_groundorairstart != 1 && _groundorairstart != 2); - if(_groundorairstart == 1) - { - Console.WriteLine("Outbound aircraft are starting on ground and have to be commanded to takeoff manually"); - if (_runwaydirectionindex == 1) - { - _outboundstartposition = _airport.DeparturePositionGroundStart[1]; - } - else - { - _outboundstartposition = _airport.DeparturePositionGroundStart[0]; - } - _outboundinitialaltitude = _airport.Elevation; - } - else - { - Console.WriteLine("Outbound aircraft are starting in air"); - if (_runwaydirectionindex == 1) - { - _outboundstartposition = _airport.DeparturePositionAirStart[1]; - } - else - { - _outboundstartposition = _airport.DeparturePositionAirStart[0]; - } - _outboundinitialaltitude = "2000"; - } - #endregion - } - } - - private void GenerateSimFileStandardText() - { - #region ILS/runway definition - - for(int i = 0; i < 4; i++) - { - SimFile.Add($"{_airport.ILSDefinitions[i]}"); - } - - #endregion - - #region Holding definitions - - for(int i = 0; i < _airport.HoldingDefinitions.Length; i++) - { - SimFile.Add($"{_airport.HoldingDefinitions[i]}"); - } - - #endregion - - SimFile.Add($"AIRPORT_ALT:{_airport.Elevation}"); - } - - private string ConvertHeadingtoEuroscopeHeadingString(int heading) - { - string _headingstring = ((int)((heading * 2.88 + 0.5) * 4)).ToString(); - return _headingstring; - } - - private void GenerateOutbounds() - { - if(_outboundseparation != 0) - { - #region distribution - - OutboundDistribution = DistributionInput(_airport.SIDSflightplan, "SID"); - - - #endregion - - #region Convert airport runway heading to ES specific runway heading - string _runwayheading = ConvertHeadingtoEuroscopeHeadingString(_airport.RunwayHeadings[_runwaydirectionindex]); - #endregion - - #region generation - string simroute; - string flightplan; - for (int i = 0; i < _duration; i += _outboundseparation) - { - // Empty line for readability - SimFile.Add(""); - - #region selecting random callsign from outbound list - int CallsignNumber = Random.Next(Outbounds.Count()); - - #endregion - - SimFile.Add($"@N:{Outbounds[CallsignNumber].Callsign}:{Squawks.AssignSquawk()}:1:{_outboundstartposition}:{_airport.Elevation}:0:{_runwayheading}:0"); - - int SIDnumber = Random.Next(OutboundDistribution.Count); - SIDnumber = OutboundDistribution[SIDnumber]; - - simroute = _airport.SIDSroute[_runwaydirectionindex][SIDnumber]; - flightplan = _airport.SIDSflightplan[_runwaydirectionindex][SIDnumber]; - - SimFile.Add($"$FP{Outbounds[CallsignNumber].Callsign}:*A:I:{Outbounds[CallsignNumber].ATYP.Substring(0, Outbounds[CallsignNumber].ATYP.Length - 2)}:420:{Outbounds[CallsignNumber].DEP}:::0:{flightplan}"); - SimFile.Add($"SIMDATA:{Outbounds[CallsignNumber].Callsign}:*:*:25:1:0"); - SimFile.Add($"$ROUTE:{simroute}"); - SimFile.Add($"START:{i}"); - SimFile.Add($"DELAY:1:2"); - SimFile.Add($"REQALT:5000"); - SimFile.Add($"INITIALPSEUDOPILOT:{_airport.Pseudopilots[_selectedPseudopilot]}"); - - Outbounds.RemoveAt(CallsignNumber); - } - - #endregion - } - } - - private void GenerateInbounds() - { - if (_inboundseparation != 0) - { - #region STAR or Transition selection - bool validEntry = false; - int STARorTRANS = 0; - do - { - Console.WriteLine("Use 1. STAR or 2. TRANS?"); - - validEntry = Int32.TryParse(Console.ReadLine(), out int _selection); - validEntry = validEntry == true && _selection <= 2 && _selection >= 1; - STARorTRANS = _selection - 1; - } while (validEntry == false); - #endregion - - #region distribution selection - - string _SIDorSTAR = ""; - //int _distributionlength = 0; - string[][] RouteList = new string[1][]; - string[][] FlightplanList = new string[1][]; - string[][] AltitudeList = new string[1][]; - if (STARorTRANS == 0) - { - _SIDorSTAR = "STAR"; - //_distributionlength = _airport.STARSroute.GetLength(_runwaydirectionindex); - RouteList = _airport.STARSroute; - FlightplanList = _airport.STARSflightplan; - AltitudeList = _airport.STARSAltitude; - } - else - { - _SIDorSTAR = "TRANS"; - //_distributionlength = _airport.TRANSITIONroute.GetLength(_runwaydirectionindex); - RouteList = _airport.TRANSITIONroute; - FlightplanList = _airport.TRANSITIONflightplan; - AltitudeList = _airport.TRANSITIONAltitude; - } - - ArrivalDistribution = DistributionInput(FlightplanList, _SIDorSTAR); - - #endregion - - #region generation of inbounds - - string simroute = ""; - string fplnroute = ""; - string InboundStartPosition = ""; - string InboundAltitude = ""; - string InitialHeading = ""; - for(int i = 0; i < _duration ; i++) - { - SimFile.Add(""); - // Get random callsign from inbound list - int CallsignNumber = Random.Next(Inbounds.Count()); - // Assign random star / transition - int ArrivalSelection = Random.Next(ArrivalDistribution.Count); - ArrivalSelection = ArrivalDistribution[ArrivalSelection]; - - - simroute = RouteList[_runwaydirectionindex][ArrivalSelection]; - fplnroute = FlightplanList[_runwaydirectionindex][ArrivalSelection]; - InboundStartPosition = _airport.ArrivalStartPosition[ArrivalSelection]; - InboundAltitude = AltitudeList[_runwaydirectionindex][ArrivalSelection]; - InitialHeading = ConvertHeadingtoEuroscopeHeadingString(_airport.ArrivalInitialHeading[ArrivalSelection]); - - SimFile.Add($"@N:{Inbounds[CallsignNumber].Callsign}:{Squawks.AssignSquawk()}:1:{InboundStartPosition}:{InboundAltitude}:0:{InitialHeading}"); - SimFile.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}"); - SimFile.Add($"SIMDATA:{Inbounds[CallsignNumber].Callsign}:*:*:25:1:0"); - SimFile.Add($"$ROUTE:{simroute}"); - SimFile.Add($"START:{i}"); - SimFile.Add("DELAY:4:10"); - SimFile.Add($"REQALT:{InboundAltitude}"); - SimFile.Add($"INITIALPSEUDOPILOT:{_airport.Pseudopilots[_selectedPseudopilot]}"); - - Inbounds.RemoveAt(CallsignNumber); - } - - #endregion - } - } - - private List DistributionInput(string[][] SIDorSTARflightplanarray, string IsSIDorSTAR) - { - List _distributionkey = new List(); - List _distribution = new List(); - string _input = ""; - bool _validEntry = false; - do - { - Console.WriteLine($"Enter {IsSIDorSTAR} distribution key: i.e. 5:1:2:5"); - Console.WriteLine($"{_airport.ICAO} needs {SIDorSTARflightplanarray[_runwaydirectionindex].Length} numbers"); - Console.WriteLine("or type \"random\" for a random distribution"); - Console.WriteLine("Distribtuon numbers have to be in this order: "); - - WriteDepartureorArrivalName(SIDorSTARflightplanarray, IsSIDorSTAR); - - _input = Console.ReadLine(); - - if (_input.ToUpper() != "RANDOM") - { - string[] _subStrings = _input.Split(':'); - foreach (string substring in _subStrings) - { - bool _isNumber = Int32.TryParse(substring, out int _convertedInt); - if (_isNumber == true) - { - _distributionkey.Add(_convertedInt); - } - } - if (_distributionkey.Count != SIDorSTARflightplanarray[_runwaydirectionindex].Length) - { - _validEntry = false; - _distributionkey.Clear(); - } - else - { - _validEntry = true; - } - } - } while (_validEntry == false); - - if(_input.ToUpper() == "RANDOM") - { - // SIDorSTARflightplanarray.GetLength(_runwaydirectionindex) - for (int i = 0; i < SIDorSTARflightplanarray[_runwaydirectionindex].Length; i++) - { - _distribution.Add(1); - } - } - else - { - for (int i = 0; i < _distributionkey.Count; i++) - { - for (int j = 0; j < _distributionkey[i]; j++) - { - _distribution.Add(i); - } - } - } - - return _distribution; - } - - private void WriteDepartureorArrivalName(string[][] SIDorSTARflightplanarray, string IsSIDorSTAR) - { - string _name; - for (int i = 0; i < SIDorSTARflightplanarray[_runwaydirectionindex].Length; i++) - { - if (IsSIDorSTAR == "SID") - { - _name = SIDorSTARflightplanarray[_runwaydirectionindex][i].Split(' ').Last(); - } - else - { - _name = SIDorSTARflightplanarray[_runwaydirectionindex][i].Split(' ').First(); - } - if (i < SIDorSTARflightplanarray[_runwaydirectionindex].Length - 1) - { - Console.Write(_name + ":"); - } - else - { - Console.Write(_name + "\n"); - } - } - } - } -} diff --git a/EuroscopeSIMBib/Squawks.cs b/EuroscopeSIMBib/Squawks.cs deleted file mode 100644 index 2f3d551..0000000 --- a/EuroscopeSIMBib/Squawks.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ES -{ - internal class Squawks - { - internal List AvailableSquawks = new List(); - - internal Squawks() - { - for (int i = 2001; i <= 2577; i++) - { - AvailableSquawks.Add(i); - } - } - internal static string AssignSquawk() - { - /*Random rnd = new Random(); - int r = rnd.Next(AvailableSquawks.Count); - - Squawk = AvailableSquawks[r].ToString(); - AvailableSquawks.RemoveAt(r); */ //aircraft count exceeds squawks count, fix needed - - return "1000"; - } - } -} diff --git a/EuroscopeSIMBib/airports.json b/EuroscopeSIMBib/airports.json index 2aca9d8..8753ac8 100644 --- a/EuroscopeSIMBib/airports.json +++ b/EuroscopeSIMBib/airports.json @@ -82,7 +82,7 @@ "DEPOK DEPOK1C" ] ], - "STARSArrivalAltitude": [ + "STARSAltitude": [ [ "11000", "12000", @@ -112,16 +112,16 @@ ], "TRANSITIONflightplan": [ [ - "KOPAG KOPA1S", - "ERNEP ERNE1S", - "GULKO GULK1S", - "DEPOK DEPO1S" + "KOPAG KOPAG1S", + "ERNEP ERNEP1S", + "GULKO GULKO1S", + "DEPOK DEPOK1S" ], [ - "KOPAG KOPA1N", - "ERNEP ERNE1N", - "GULKO GULK1N", - "DEPOK DEPO1N" + "KOPAG KOPAG1N", + "ERNEP ERNEP1N", + "GULKO GULKO1N", + "DEPOK DEPOK1N" ] ], "TRANSITIONAltitude": [ @@ -304,7 +304,7 @@ "BIKMU1X BIKMU" ] ], - "STARSArrivalAltitude": [ + "STARSAltitude": [ [ "13000", "17000", @@ -354,7 +354,7 @@ "ELDAR ELDAR05" ] ], - "TRANSITIONArrivalAltitude": [ + "TRANSITIONAltitude": [ [ "13000", "17000", diff --git a/Konsole/Konsole.csproj b/Konsole/Konsole.csproj index 65cd0a4..edd59a0 100644 --- a/Konsole/Konsole.csproj +++ b/Konsole/Konsole.csproj @@ -12,6 +12,23 @@ 512 true true + false + C:\Users\Leon\Documents\EuroScope\SIMGEN\Program\ + true + Disk + false + Foreground + 7 + Days + false + false + true + publish.htm + 2 + 1.0.0.%2a + false + true + true AnyCPU @@ -32,6 +49,18 @@ prompt 4 + + 94EE458260A08B5E1A8EA612162CF4F906598BF8 + + + Konsole_TemporaryKey.pfx + + + true + + + true + @@ -49,6 +78,18 @@ + + + False + Microsoft .NET Framework 4.8 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + {c82fd8a8-095f-4591-8d88-dfec03c0ef6f}