1
0
Fork 0

Load ILS frequencies into Airport pages.

This commit is contained in:
Stuart Buchanan 2018-01-13 21:48:38 +00:00
parent f6f5efe9f4
commit 42c0dd0b43
5 changed files with 52 additions and 10 deletions

View file

@ -167,6 +167,19 @@ var AirportInfo =
}
}
# Add any ILS frequencies as well
foreach(var rwy; sort(keys(apt_info.runways), string.icmp)) {
var rwy_info = apt_info.runways[rwy];
if (rwy_info.ils_frequency_mhz != nil) {
var label = "ILS " ~ rwy_info.id;
var freq = sprintf("%.3f", rwy_info.ils_frequency_mhz);
me.setTextElement("FreqLabel" ~ fcount, label);
me.setTextElement("Freq" ~ fcount, freq);
fcount += 1;
}
}
while (fcount < 9) {
# zero remaining comms channels
me.setTextElement("FreqLabel" ~ fcount, "");

View file

@ -113,7 +113,7 @@ var AirportInfoController =
var select = me.page.handleEnter();
if (select.name == "AirportInfoID") me.setAirport(select.value);
if (substr(select.name, 0, 15) == "AirportInfoFreq") {
me.page.mfd.SurroundController.setStandbyComFreq(select.value);
me.page.mfd.SurroundController.setStandbyNavComFreq(select.value);
}
return emesary.Transmitter.ReceiptStatus_Finished;

View file

@ -180,12 +180,14 @@ var NearestAirports =
}
var freqarray = [];
# Add Comm Frequencies
var apt_comms = apt.comms();
if (size(apt_comms) > 0) {
# Airport has one or more frequencies assigned to it.
var freqs = {};
foreach (var c; apt_comms) {
freqs[c.ident] = sprintf("%.3f", c.frequency);;
freqs[c.ident] = sprintf("%.3f", c.frequency);
}
foreach (var c; sort(keys(freqs), string.icmp)) {
@ -193,6 +195,16 @@ var NearestAirports =
}
}
# Add any ILS frequencies as well
foreach(var rwy; sort(keys(apt.runways), string.icmp)) {
var rwy_info = apt.runways[rwy];
if (rwy_info.ils_frequency_mhz != nil) {
var label = "ILS " ~ rwy_info.id;
var freq = sprintf("%.3f", rwy_info.ils_frequency_mhz);
append(freqarray, {FreqLabel: label, Freq: freq});
}
}
me.freqSelect.setValues(freqarray);
# Approaches

View file

@ -141,7 +141,7 @@ var NearestAirportsController =
# TODO Select the current COM frequency.
var freq = me.page.getSelectedFreq();
if (freq != nil) {
me.page.mfd.SurroundController.setStandbyComFreq(freq);
me.page.mfd.SurroundController.setStandbyNavComFreq(freq);
}
return emesary.Transmitter.ReceiptStatus_Finished;
}

View file

@ -375,10 +375,26 @@ var SurroundController =
me.transmitter = nil;
},
# Used by other pages to set the current standby COM frequency by pressing ENT
setStandbyComFreq : func(value) {
# Used by other pages to set the current standby NAV or COM frequency by pressing ENT
setStandbyNavComFreq : func(value) {
var data={};
# Determine whether this is NAV or COM based on the frequency itself
if (value < fg1000.MAX_NAV_FREQ) {
# Nav frequency
if (value > fg1000.MAX_NAV_FREQ) return;
if (value < fg1000.MIN_NAV_FREQ) return;
# TODO: If we're in approach phase then this should update the Active
# frequency
if (me._navselected == 1) {
data["Nav1StandbyFreq"] = value;
} else {
data["Nav2StandbyFreq"] = value;
}
} else {
# COM frequency
if (value > fg1000.MAX_COM_FREQ) return;
if (value < fg1000.MIN_COM_FREQ) return;
@ -387,6 +403,7 @@ var SurroundController =
} else {
data["Comm2StandbyFreq"] = value;
}
}
me.sendNavComDataNotification(data);
},