Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
fix ils frequencies
Browse files Browse the repository at this point in the history
  • Loading branch information
dga711 committed Nov 18, 2021
1 parent ae8eb12 commit d771dba
Showing 4 changed files with 80 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -427,7 +427,7 @@ class AirportInfo extends WayPointInfo {
this.frequencies = [];
if (data.frequencies) {
for (let i = 0; i < data.frequencies.length; i++) {
this.frequencies.push(new Frequency(data.frequencies[i].name, data.frequencies[i].freqMHz, data.frequencies[i].freqBCD16));
this.frequencies.push(new Frequency(data.frequencies[i].name, data.frequencies[i].freqMHz, data.frequencies[i].freqBCD16, data.frequencies[i].type));
}
}
this.runways = [];
@@ -941,10 +941,12 @@ class IntersectionInfo extends WayPointInfo {
IntersectionInfo.readManager = new InstrumentDataReadManager();
IntersectionInfo.longestAirway = 0;
class Frequency {
constructor(_name, _mhValue, _bcd16Value) {
constructor(_name, _mhValue, _bcd16Value, _type) {
this.name = _name;
this.mhValue = _mhValue;
this.bcd16Value = _bcd16Value;
this.bcd16Value = _bcd16Value;
this.type = _type;
}
}

Original file line number Diff line number Diff line change
@@ -8,6 +8,27 @@ class CJ4_FMC_FrequencyPage_State {

let cj4FmcFrequencyPageState = new CJ4_FMC_FrequencyPage_State();

const FacilityFrequencyType = {
"None":0,
"ATIS":1,
"Multicom":2,
"Unicom":3,
"CTAF":4,
"Ground":5,
"Tower":6,
"Clearance":7,
"Approach":8,
"Departure":9,
"Center":10,
"FSS":11,
"AWOS":12,
"ASOS":13,
/** Clearance Pre-Taxi*/
"CPT":14,
/** Remote Clearance Delivery */
"GCO":15
}

class CJ4_FMC_FrequencyPage {

static async ShowMainPage(fmc, currentPage = 1) {
@@ -21,7 +42,14 @@ class CJ4_FMC_FrequencyPage {
let pageCount;

let origin = fmc.flightPlanManager.getOrigin();
if(origin && origin.ident !== '') {
origin = await fmc.dataManager.GetAirportByIdent(origin.ident);
}

let destination = fmc.flightPlanManager.getDestination();
if(destination && destination.ident !== '') {
destination = await fmc.dataManager.GetAirportByIdent(destination.ident);
}
let alternate; // Not supported yet, flightPlanManager does not manage alternate
let pilotDefined = cj4FmcFrequencyPageState.pilotDefinedAirport;

@@ -66,16 +94,17 @@ class CJ4_FMC_FrequencyPage {
showNoDataAvailable();
} else {
fmc.setMsg("Working...");
await selectedWaypoint.infos.UpdateNamedFrequencies();
let namedFrequencies = selectedWaypoint.infos.namedFrequencies;
// await selectedWaypoint.infos.UpdateNamedFrequencies();
// let namedFrequencies = selectedWaypoint.infos.namedFrequencies;

// Group frequencies by name. For instance, an airport can have multiple Ground frequencies.
// // Group frequencies by name. For instance, an airport can have multiple Ground frequencies.
let frequenciesByName = new Map();
namedFrequencies.forEach(frequency => {
if (!frequenciesByName.has(frequency.name)) {
frequenciesByName.set(frequency.name, []);
selectedWaypoint.infos.frequencies.forEach(frequency => {
let freqName = CJ4_FMC_FrequencyPage.buildName(frequency);
if (!frequenciesByName.has(freqName)) {
frequenciesByName.set(freqName, []);
}
frequenciesByName.get(frequency.name).push(frequency.value);
frequenciesByName.get(freqName).push(frequency.mhValue);
});

let headlines = [];
@@ -200,6 +229,42 @@ class CJ4_FMC_FrequencyPage {
fmc.updateSideButtonActiveStatus();
}

static buildName(freqObj) {
switch (freqObj.type) {
case FacilityFrequencyType.ASOS:
return 'ASOS';
case FacilityFrequencyType.ATIS:
return 'ATIS';
case FacilityFrequencyType.AWOS:
return 'AWOS';
case FacilityFrequencyType.Approach:
return 'APPROACH';
case FacilityFrequencyType.CPT:
case FacilityFrequencyType.Clearance:
return 'CLEARANCE';
case FacilityFrequencyType.CTAF:
return 'CTAF';
case FacilityFrequencyType.Center:
return 'CENTER';
case FacilityFrequencyType.Departure:
return 'DEPARTURE';
case FacilityFrequencyType.FSS:
return 'FSS';
case FacilityFrequencyType.GCO:
return 'GCO';
case FacilityFrequencyType.Ground:
return 'GROUND';
case FacilityFrequencyType.Multicom:
return 'MULTICOM';
case FacilityFrequencyType.Tower:
return 'TOWER';
case FacilityFrequencyType.Unicom:
return 'UNICOM';
default:
return freqObj.name;
}
}

/*
* Shows multiple frequencies of a specific type, for instance all "Ground" frequencies of the airport.
*/
4 changes: 2 additions & 2 deletions src/wtsdk/src/flightplanning/FlightPlanManager.ts
Original file line number Diff line number Diff line change
@@ -1233,10 +1233,10 @@ export class FlightPlanManager {
const approachRunway = this.getApproach().runway.trim();

const aptInfo = destination.infos as AirportInfo;
const frequency = aptInfo.namedFrequencies.find(f => f.name.replace("RW0", "").replace("RW", "").indexOf(approachRunway) !== -1);
const frequency = aptInfo.frequencies.find(f => f.name.replace("RW0", "").replace("RW", "").indexOf(approachRunway) !== -1);

if (frequency) {
return frequency.value;
return frequency.freqMHz;
}
}

2 changes: 2 additions & 0 deletions src/wtsdk/src/flightplanning/RawDataMapper.ts
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@ export class RawDataMapper {
info.oneWayRunways = [];
facility.runways.forEach(runway => info.oneWayRunways.push(...Object.assign(new Runway(), runway).splitIfTwoWays()));

info.frequencies = facility.frequencies;

info.oneWayRunways.sort(RawDataMapper.sortRunways);
waypoint.infos = info;
}

0 comments on commit d771dba

Please sign in to comment.