Skip to content

Commit

Permalink
Merge pull request #40 from Nikolai558/development
Browse files Browse the repository at this point in the history
Releasing v2.0.0
  • Loading branch information
Nikolai558 authored Apr 10, 2022
2 parents 2b6535d + 4d5735b commit abc34af
Show file tree
Hide file tree
Showing 43 changed files with 2,497 additions and 807 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: windows-latest
runs-on: windows-2019
permissions:
actions: read
contents: read
Expand All @@ -38,6 +38,11 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Setup .NET 6.* SDK
uses: actions/setup-dotnet@v1.9.0
with:
dotnet-version: '6.*'

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down
18 changes: 18 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
---
- ## Version 2.0.0
### FOR USERS:
- Modified menu presentation
- Fixed frequency formatting in [VOR].SCT2; All frequencies will be formatted as xxx.xx
- Added ASOS/AWOS frequencies to APT_ISR.txt
### FOR DEVELOPERS:
- Conversion from .Net Framework 4.7 to .Net Core 6
- Connected Squirrel Logging to FE-Buddy Logging
- Updater now uses Delta Nuget Packages when updating. Install will use Full Nuget Package
- New landing page and winforms added (commented out) in preparation for future feature releases.
- Backend code file and function name changes/refactoring
- Added feature-not-implemented popup
- Refactored parsing controls (backend)
- Added aircraft data alias command output (AircraftDataInfo.txt)
- Commented out until we can figure out how to get updated C/D and SRS data in an automated way
- Added Error Handling on various functions

---
- ## Version 1.0.3
- #26 KASE and many other airports were effected by a bug causing some airports and runways to be missing from the Airports.xml file.
Expand Down
4 changes: 3 additions & 1 deletion Credits.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
## Nikolas Boling - Primary Developer/Programmer
## Kyle Sanders - Concept Design; Original Author
## John Lewis - Icon/Logo Design
## Chris James - Program Name
## Chris James - Program Name
## Cian Ormond - dotNET 6 Conversion Assistance
## Caelan Sayler - dotNET 6 Conversion Assistance / Clowd.Squirrel Development
151 changes: 151 additions & 0 deletions FeBuddyLibrary/DataAccess/AircraftData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using FeBuddyLibrary.Helpers;
using FeBuddyLibrary.Models;
using Newtonsoft.Json;

namespace FeBuddyLibrary.DataAccess
{
public class AircraftData
{
AircraftDataRootObject AllAircraftData;

public void CreateAircraftDataAlias(string outputFilePath)
{
AllAircraftData = GetACDataAsync().Result;
WriteACData(outputFilePath);
}

private async Task<AircraftDataRootObject> GetACDataAsync()
{
HttpClient client = new HttpClient();

var url = "https://www4.icao.int/doc8643/External/AircraftTypes";
var values = new Dictionary<string, string>
{
{"Connection", "keep-alive" },
{"Content-Length", "0" },
{"Pragma", "no-cache" },
{"Cache-Control", "no-cache" },
{"Content-Type", "application/json" }
};

var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync(url, content);

string responseStringJson = await response.Content.ReadAsStringAsync();

responseStringJson = "{\"AllAircraftData\":" + responseStringJson + "}";

AircraftDataRootObject output = JsonConvert.DeserializeObject<AircraftDataRootObject>(responseStringJson);

return output;
}

private void WriteACData(string outputFilePath)
{
string command;

StringBuilder aliasFileSB = new StringBuilder();

Dictionary<string, AircraftDataInformation> uniqueACData = getUniqueACData(AllAircraftData);

// .acinfoc172 ->
// *** [CODE] C172 ::: [MAKE] CESSNA AIRCRAFT COMPANY ::: [MODEL] 172, P172, R172, Skyhawk, Hawk XP, Cutlass (T-41, Mescalero) ::: [ENGINE] 1/PistonProp ::: [WEIGHT] Small ::: [C/D] 600/1000 ::: [SRS] 1
//
// .ACINFOC172 .MSG FAA_ISR *** [CODE] C172 ::: [MAKE] CESSNA AIRCRAFT COMPANY ::: [MODEL] 172, P172, R172, Skyhawk, Hawk XP, Cutlass (T-41, Mescalero) ::: [ENGINE] 1/PistonProp ::: [WEIGHT] Small ::: [C/D] 600/1000 ::: [SRS] 1

Dictionary<string, string> weights = new Dictionary<string, string>()
{
{"L", "Light" },
{"M", "Medium" },
{"H", "Heavy" },
{"L/M", "Light/Medium" },
{"J", "Super" }
};

foreach (string acDesignator in uniqueACData.Keys)
{
AircraftDataInformation currentAircraftData = uniqueACData[acDesignator];
// TODO - Figure out SRS and C/D
try
{
command = $".ACINFO{acDesignator} .MSG FAA_ISR *** [CODE] {acDesignator} ::: [MAKE] {currentAircraftData.ManufacturerCode} ::: [MODEL] {currentAircraftData.ModelFullName} ::: [ENGINE] {currentAircraftData.EngineCount}/{currentAircraftData.EngineType} ::: [WEIGHT] {weights[currentAircraftData.WTC]} ::: [C/D] ???/??? ::: [SRS] ???";
}
catch (KeyNotFoundException e)
{
Logger.LogMessage("WARNING", e.Message);
command = $".ACINFO{acDesignator} .MSG FAA_ISR *** [CODE] {acDesignator} ::: [MAKE] {currentAircraftData.ManufacturerCode} ::: [MODEL] {currentAircraftData.ModelFullName} ::: [ENGINE] {currentAircraftData.EngineCount}/{currentAircraftData.EngineType} ::: [WEIGHT] {currentAircraftData.WTC} ::: [C/D] ???/??? ::: [SRS] ???";
}


aliasFileSB.AppendLine(command);
}

File.WriteAllText(outputFilePath, aliasFileSB.ToString());
File.AppendAllText($"{GlobalConfig.outputDirectory}\\ALIAS\\AliasTestFile.txt", aliasFileSB.ToString());
}

private Dictionary<string, AircraftDataInformation> getUniqueACData(AircraftDataRootObject aircraftData)
{
Dictionary<string, AircraftDataInformation> uniqueAircraftData = new Dictionary<string, AircraftDataInformation>();

foreach (AircraftDataInformation acData in aircraftData.AllAircraftData)
{
if (uniqueAircraftData.ContainsKey(acData.Designator))
{
AircraftDataInformation tempAircraftData = uniqueAircraftData[acData.Designator];

PropertyInfo[] properties = typeof(AircraftDataInformation).GetProperties();
foreach (PropertyInfo property in properties)
{
bool acDataIsNull = property.GetValue(acData) is null;
bool tempAircraftDataIsNull = property.GetValue(tempAircraftData) is null;

if (!acDataIsNull && !tempAircraftDataIsNull)
{
if (property.GetValue(tempAircraftData).ToString().Contains(","))
{
string[] propertyContains = property.GetValue(tempAircraftData).ToString().Split(",");

if (propertyContains.Length > 0 && propertyContains.Contains(property.GetValue(acData).ToString()))
{
continue;
}
}

if (property.GetValue(acData).ToString() != property.GetValue(tempAircraftData).ToString())
{
property.SetValue(uniqueAircraftData[acData.Designator], property.GetValue(acData).ToString() + ", " + property.GetValue(tempAircraftData).ToString());
}
}
else if (acDataIsNull && !tempAircraftDataIsNull)
{
property.SetValue(uniqueAircraftData[acData.Designator], property.GetValue(tempAircraftData).ToString());
}
else if (!acDataIsNull && tempAircraftDataIsNull)
{
property.SetValue(uniqueAircraftData[acData.Designator], property.GetValue(acData).ToString());
}
else
{
continue;
}
}
}
else
{
uniqueAircraftData[acData.Designator] = acData;
}
}

return uniqueAircraftData;
}
}
}
22 changes: 20 additions & 2 deletions FeBuddyLibrary/DataAccess/GetAptData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,18 @@ private void ParseAptData(string effectiveDate)
allAptModels.Add(airport);
}

GetAptWxData aptWxData = new GetAptWxData();
Dictionary<string, AptWxModel> allAptWxInfo = aptWxData.GetAptWxDataMain(effectiveDate);

foreach (string aptFaaCode in allAptWxInfo.Keys)
{
var aptModel = allAptModels.Find(x => x.Id == aptFaaCode);
if (aptModel is not null)
{
aptModel.AptWx = allAptWxInfo[aptFaaCode];
}
}

GlobalConfig.allAptModelsForCheck = allAptModels;
Logger.LogMessage("INFO", $"COMPLETED PARSING APT DATA");

Expand Down Expand Up @@ -584,11 +596,17 @@ private void WriteAptISR(string Artcc)

elvation = apt.Elv;

sb.AppendLine($".APT{apt.Id} .MSG {Artcc}_ISR *** FAA-{apt.Id} : ICAO-{icao} ___ {apt.Name} {apt.Type} ___ {elvation}'MSL ___ {tower} ___ {apt.ResArtcc}");
string aptWxString = "";
if (apt.AptWx is not null)
{
aptWxString = $" ___ {apt.AptWx.SensorType}-{apt.AptWx.StationFreq}";
}

sb.AppendLine($".APT{apt.Id} .MSG {Artcc}_ISR *** FAA-{apt.Id} : ICAO-{icao} ___ {apt.Name} {apt.Type} ___ {elvation}'MSL ___ {tower} ___ {apt.ResArtcc}{aptWxString}");

if (apt.Icao != "")
{
sb.AppendLine($".APT{apt.Icao} .MSG {Artcc}_ISR *** FAA-{apt.Id} : ICAO-{icao} ___ {apt.Name} {apt.Type} ___ {elvation}'MSL ___ {tower} ___ {apt.ResArtcc}");
sb.AppendLine($".APT{apt.Icao} .MSG {Artcc}_ISR *** FAA-{apt.Id} : ICAO-{icao} ___ {apt.Name} {apt.Type} ___ {elvation}'MSL ___ {tower} ___ {apt.ResArtcc}{aptWxString}");
}
}

Expand Down
77 changes: 77 additions & 0 deletions FeBuddyLibrary/DataAccess/GetAptWxData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using FeBuddyLibrary.Models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FeBuddyLibrary.DataAccess
{
public class GetAptWxData
{
Dictionary<string, AptWxModel> AllAptWxModels = new Dictionary<string, AptWxModel>();


public Dictionary<string, AptWxModel> GetAptWxDataMain(string effectiveDate)
{
ParseAptWxData(effectiveDate);
return AllAptWxModels;
}

private void ParseAptWxData(string effectiveDate)
{
foreach (string line in File.ReadLines($"{GlobalConfig.tempPath}\\{effectiveDate}_AWOS\\AWOS.txt"))
{
// Check to make sure we are grabbing the AWOS1 stuff

if (line.Substring(0, 5).Contains("AWOS1"))
{
AptWxModel tempModel = new AptWxModel
{
SensorIdent = line.Substring(5, 4).Trim(),
SensorType = line.Substring(9, 10).Trim(),
CommissioningStatus = line.Substring(19, 1).Trim(),
NavaidFlag = line.Substring(30, 1).Trim(),
StationLat = line.Substring(31, 14).Trim(),
StationLon = line.Substring(45, 15).Trim(),
Elevation = line.Substring(60, 7).Trim(),
StationFreq = line.Substring(68, 7).Trim(),
SecondStationFreq = line.Substring(75, 7).Trim()
};

// Grab the Sensor Type UP to the '-' if it has one.
if (tempModel.SensorType.Contains('-'))
{
tempModel.SensorType = tempModel.SensorType.Split('-')[0];
}


if (AllAptWxModels.ContainsKey(tempModel.SensorIdent))
{
if (tempModel.CommissioningStatus == "Y")
{
if (!string.IsNullOrWhiteSpace(tempModel.StationFreq))
{
// If the station does not have a frequency do not add to alias command.
AllAptWxModels[tempModel.SensorIdent] = tempModel;
}
}
}
else
{
if (!string.IsNullOrWhiteSpace(tempModel.StationFreq))
{
// If the station does not have a frequency do not add to alias command.
AllAptWxModels[tempModel.SensorIdent] = tempModel;
}
}
}
else
{
continue;
}
}
}
}
}
2 changes: 1 addition & 1 deletion FeBuddyLibrary/DataAccess/GetNavData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ private void WriteNAVSctData()
foreach (VORModel vor in allVORData)
{
// add the line with all the data into our string builder
sb.AppendLine($"{vor.Id.PadRight(4)}{vor.Freq.PadRight(8)}{vor.Lat} {vor.Lon} ;{vor.Name} {vor.Type}");
sb.AppendLine($"{vor.Id.PadRight(4)}{vor.Freq.PadRight(6, '0').PadRight(8)}{vor.Lat} {vor.Lon} ;{vor.Name} {vor.Type}");
}

// write the string builder to a file.
Expand Down
Binary file removed FeBuddyLibrary/FE_BUDDY_icon.ico
Binary file not shown.
Loading

0 comments on commit abc34af

Please sign in to comment.