From d771dbadc1dbf935aab42cb962495fd0ce077add Mon Sep 17 00:00:00 2001 From: dga711 Date: Thu, 18 Nov 2021 16:40:36 +0100 Subject: [PATCH] fix ils frequencies --- .../Airliners/Shared/WT/Waypoint.js | 6 +- .../CJ4/FMC/CJ4_FMC_FrequencyPage.js | 79 +++++++++++++++++-- .../src/flightplanning/FlightPlanManager.ts | 4 +- src/wtsdk/src/flightplanning/RawDataMapper.ts | 2 + 4 files changed, 80 insertions(+), 11 deletions(-) diff --git a/src/workingtitle-vcockpits-instruments-airliners/html_ui/Pages/VCockpit/Instruments/Airliners/Shared/WT/Waypoint.js b/src/workingtitle-vcockpits-instruments-airliners/html_ui/Pages/VCockpit/Instruments/Airliners/Shared/WT/Waypoint.js index 7b598ee4b6..9c3987570f 100644 --- a/src/workingtitle-vcockpits-instruments-airliners/html_ui/Pages/VCockpit/Instruments/Airliners/Shared/WT/Waypoint.js +++ b/src/workingtitle-vcockpits-instruments-airliners/html_ui/Pages/VCockpit/Instruments/Airliners/Shared/WT/Waypoint.js @@ -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; } } diff --git a/src/workingtitle-vcockpits-instruments-cj4/html_ui/Pages/VCockpit/Instruments/Airliners/CJ4/FMC/CJ4_FMC_FrequencyPage.js b/src/workingtitle-vcockpits-instruments-cj4/html_ui/Pages/VCockpit/Instruments/Airliners/CJ4/FMC/CJ4_FMC_FrequencyPage.js index a7cffa0348..3051aca4fa 100644 --- a/src/workingtitle-vcockpits-instruments-cj4/html_ui/Pages/VCockpit/Instruments/Airliners/CJ4/FMC/CJ4_FMC_FrequencyPage.js +++ b/src/workingtitle-vcockpits-instruments-cj4/html_ui/Pages/VCockpit/Instruments/Airliners/CJ4/FMC/CJ4_FMC_FrequencyPage.js @@ -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. */ diff --git a/src/wtsdk/src/flightplanning/FlightPlanManager.ts b/src/wtsdk/src/flightplanning/FlightPlanManager.ts index 91e19fbeba..a475c20c28 100644 --- a/src/wtsdk/src/flightplanning/FlightPlanManager.ts +++ b/src/wtsdk/src/flightplanning/FlightPlanManager.ts @@ -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; } } diff --git a/src/wtsdk/src/flightplanning/RawDataMapper.ts b/src/wtsdk/src/flightplanning/RawDataMapper.ts index 289bbb682c..2fbfb49e23 100644 --- a/src/wtsdk/src/flightplanning/RawDataMapper.ts +++ b/src/wtsdk/src/flightplanning/RawDataMapper.ts @@ -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; }