Skip to content

Commit

Permalink
Option to auto fill best prefered runway.
Browse files Browse the repository at this point in the history
  • Loading branch information
daanbroekhuizen committed Feb 25, 2014
1 parent d96bb01 commit 96af4fd
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 10 deletions.
Binary file modified DutchVACCATISGenerator/DutchVACCATISGenerator.v12.suo
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ private void processMetarButton_Click(object sender, EventArgs e)
generateATISButton.Enabled = true;
runwayInfoButton.Enabled = true;

//Check if a runway info has been created before.
if (runwayInfo != null && runwayInfo.Visible)
//If runwayInfo is null, create RunwayInfo form.
if (runwayInfo == null) runwayInfo = new RunwayInfo(this, metarProcessor.metar);
else
{
//Update runway info form.
runwayInfo.metar = metarProcessor.metar;
Expand Down Expand Up @@ -1233,7 +1234,6 @@ private void runwayInfoButton_Click(object sender, EventArgs e)
if (runwayInfo == null || !runwayInfo.Visible)
{
//Initialize new RunwayInfo form.
runwayInfo = new RunwayInfo(this, metarProcessor.metar);
runwayInfoButton.Text = "<";

//Show runway info form.
Expand Down
96 changes: 96 additions & 0 deletions DutchVACCATISGenerator/DutchVACCATISGenerator/RunwayInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
Expand Down Expand Up @@ -409,6 +410,8 @@ public void checkICAOTabSelected()
//If selected ICAO tab is EHAM.
if (!(dutchVACCATISGenerator.ICAOTabControl.SelectedTab.Text.Equals("EHAM"))) ICAODirectoryToProcess(dutchVACCATISGenerator.ICAOTabControl.SelectedTab.Text);
else fillEHAMRunwayInfoDataGrids();

if (dutchVACCATISGenerator.setBestRunwaysCheckBox.Checked) setBestRunways();
}

/// <summary>
Expand All @@ -420,5 +423,98 @@ private void RunwayInfo_FormClosing(object sender, FormClosingEventArgs e)
{
if (dutchVACCATISGenerator.runwayInfoButton.Text.Equals("<")) dutchVACCATISGenerator.runwayInfoButton.Text = ">";
}

/// <summary>
/// Set best prefered runway for selected ICAO tab.
/// </summary>
private void setBestRunways()
{
if (!(dutchVACCATISGenerator.ICAOTabControl.SelectedTab.Text.Equals("EHAM"))) ICAOBestRunway(dutchVACCATISGenerator.ICAOTabControl.SelectedTab.Text);
else
{
if (nightTime())
{
dutchVACCATISGenerator.EHAMmainDepartureRunwayComboBox.SelectedIndex = dutchVACCATISGenerator.EHAMmainDepartureRunwayComboBox.Items.IndexOf(getBestRunway(EHAMdepartureRunwayInfoDataGridView, 4, 5));
dutchVACCATISGenerator.EHAMmainLandingRunwayComboBox.SelectedIndex = dutchVACCATISGenerator.EHAMmainLandingRunwayComboBox.Items.IndexOf(getBestRunway(EHAMlandingRunwayInfoDataGridView, 4, 5));
}
else
{
dutchVACCATISGenerator.EHAMmainDepartureRunwayComboBox.SelectedIndex = dutchVACCATISGenerator.EHAMmainDepartureRunwayComboBox.Items.IndexOf(getBestRunway(EHAMdepartureRunwayInfoDataGridView, 3, 5));
dutchVACCATISGenerator.EHAMmainLandingRunwayComboBox.SelectedIndex = dutchVACCATISGenerator.EHAMmainLandingRunwayComboBox.Items.IndexOf(getBestRunway(EHAMlandingRunwayInfoDataGridView, 3, 5));
}
}
}

/// <summary>
/// Check if night OPS are operational.
/// </summary>
/// <returns></returns>
private Boolean nightTime()
{
DateTime nightStart = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 22, 00, 00);
DateTime nightEnd = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 6, 00, 00);

if (DateTime.UtcNow < nightStart && DateTime.UtcNow > nightEnd) return false;
else return true;
}

/// <summary>
/// Set runway combo box with best prefered runway for selected ICAO.
/// </summary>
/// <param name="icaoTab">ICAO tab selected.</param>
private void ICAOBestRunway(String icaoTab)
{
switch (icaoTab)
{
case "EHBK":
dutchVACCATISGenerator.EHBKmainRunwayComboBox.SelectedIndex = dutchVACCATISGenerator.EHBKmainRunwayComboBox.Items.IndexOf(getBestRunway(runwayInfoDataGridView, 3, 4));
break;

case "EHRD":
dutchVACCATISGenerator.EHRDmainRunwayComboBox.SelectedIndex = dutchVACCATISGenerator.EHRDmainRunwayComboBox.Items.IndexOf(getBestRunway(runwayInfoDataGridView, 3, 4));
break;

case "EHGG":
dutchVACCATISGenerator.EHGGmainRunwayComboBox.SelectedIndex = dutchVACCATISGenerator.EHGGmainRunwayComboBox.Items.IndexOf(getBestRunway(runwayInfoDataGridView, 3, 4));
break;

case "EHEH":
dutchVACCATISGenerator.EHEHmainRunwayComboBox.SelectedIndex = dutchVACCATISGenerator.EHEHmainRunwayComboBox.Items.IndexOf(getBestRunway(runwayInfoDataGridView, 3, 4));
break;
}
}

/// <summary>
/// Get best prefered runway by DataGridView.
/// </summary>
/// <param name="runwayInfoDataGridView">DataGridView to check</param>
/// <param name="prefColumn">Array position of pref column</param>
/// <param name="OKColumn">Array position of OK column</param>
/// <returns>Best runway identifier</returns>
public String getBestRunway(DataGridView runwayInfoDataGridView, int prefColumn, int OKColumn)
{
String runwayString = String.Empty;
int runwayPref = int.MaxValue;

foreach (DataGridViewRow row in runwayInfoDataGridView.Rows)
{
if (row.Cells[OKColumn].Value.Equals("OK"))
{
if (runwayString == String.Empty)
{
runwayString = row.Cells[0].Value.ToString();
runwayPref = Convert.ToInt32(row.Cells[prefColumn].Value);
}

if (Convert.ToInt32(row.Cells[prefColumn].Value) < runwayPref)
{
runwayString = row.Cells[0].Value.ToString();
runwayPref = Convert.ToInt32(row.Cells[prefColumn].Value);
}
}
}

return runwayString;
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,3 @@ E:\Users\Daan Broekhuizen\Dropbox\GitHub\Dutch-VACC-ATIS-Generator\DutchVACCATIS
E:\Users\Daan Broekhuizen\Dropbox\GitHub\Dutch-VACC-ATIS-Generator\DutchVACCATISGenerator\DutchVACCATISGenerator\bin\Debug\NAudio.WindowsMediaFormat.dll
C:\Users\Daan\Dropbox\GitHub\Dutch-VACC-ATIS-Generator\DutchVACCATISGenerator\DutchVACCATISGenerator\bin\Debug\NAudio.dll
C:\Users\Daan\Dropbox\GitHub\Dutch-VACC-ATIS-Generator\DutchVACCATISGenerator\DutchVACCATISGenerator\bin\Debug\NAudio.WindowsMediaFormat.dll
C:\Users\Daan\Dropbox\GitHub\Dutch-VACC-ATIS-Generator\DutchVACCATISGenerator\DutchVACCATISGenerator\obj\Debug\DutchVACCATISGenerator.csprojResolveAssemblyReference.cache
Binary file not shown.

0 comments on commit 96af4fd

Please sign in to comment.