ATSU: add server switching for METAR server; add ATIS subsystem. However it is not yet connected to MCDU. That comes next week.
This commit is contained in:
parent
2e5736860c
commit
c95912fa8b
3 changed files with 153 additions and 26 deletions
|
@ -879,7 +879,7 @@ var canvas_MCDU_base = {
|
|||
}
|
||||
} else if (page == "ATCMENU2") {
|
||||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me.defaultHide();
|
||||
me.defaultHideWithCenter();
|
||||
me["Simple_Title"].setText("ATC MENU");
|
||||
me["Simple_Title"].setColor(1, 1, 1);
|
||||
me["Simple_PageNum"].setText("2/2");
|
||||
|
@ -891,6 +891,8 @@ var canvas_MCDU_base = {
|
|||
me["Simple_L0S"].hide();
|
||||
me.showLeftS(-1, -1, -1, -1, -1, 1);
|
||||
me.showLeftArrow(1, 1, -1, -1, -1, 1);
|
||||
me.showCenter(-1, -1, -1, -1, -1, -1);
|
||||
me.showCenterS(1, -1, -1, -1, -1, -1);
|
||||
me.showRight(1, -1, -1, -1, -1, -1);
|
||||
me.showRightS(-1, -1, -1, -1, -1, -1);
|
||||
me.showRightArrow(1, -1, -1, -1, -1, -1);
|
||||
|
@ -898,10 +900,13 @@ var canvas_MCDU_base = {
|
|||
me["Simple_C4B"].hide();
|
||||
|
||||
me.standardFontSize();
|
||||
me.fontSizeCenter(normal, normal, normal, normal, normal, normal);
|
||||
me.standardFontColour();
|
||||
me.colorCenterS("wht", "wht", "wht", "wht", "wht", "wht");
|
||||
|
||||
me["Simple_L1"].setText(" DEPART REQ");
|
||||
me["Simple_L2"].setText(" OCEANIC REQ");
|
||||
me["Simple_C1S"].setText(" -------- ATS623 PAGE -------- ");
|
||||
me["Simple_L6S"].setText(" ATSU DLK");
|
||||
me["Simple_L6"].setText(" RETURN");
|
||||
|
||||
|
@ -1184,41 +1189,35 @@ var canvas_MCDU_base = {
|
|||
me["Simple_Title"].setText("VHF3 DATA MODE");
|
||||
me.defaultPageNumbers();
|
||||
|
||||
me.showLeft(-1, 1, 1, 1, -1, 1);
|
||||
me.showLeft(1, 1, 1, -1, -1, 1);
|
||||
me["Simple_L0S"].hide();
|
||||
me.showLeftS(1, 1, 1, 1, -1, -1);
|
||||
me.showLeftArrow(-1, 1, 1, 1, -1, 1);
|
||||
me.showLeftS(1, -1, -1, -1, -1, -1);
|
||||
me.showLeftArrow(-1, 1, 1, -1, -1, 1);
|
||||
me.showCenter(-1, -1, -1, -1, -1, -1);
|
||||
me.showCenterS(1, -1, -1, -1, -1, -1);
|
||||
me.showRight(-1, 1, 1, -1, -1, 1);
|
||||
me.showRightS(1, 1, 1, -1, -1, 1);
|
||||
me.showRight(1, 1, 1, -1, -1, 1);
|
||||
me.showRightS(1, -1, -1, -1, -1, 1);
|
||||
me.showRightArrow(-1, 1, 1, -1, -1, -1);
|
||||
me["Simple_C3B"].hide();
|
||||
me["Simple_C4B"].hide();
|
||||
|
||||
me.standardFontSize();
|
||||
|
||||
me.colorLeft("wht", "blu", "blu", "blu", "wht", "wht");
|
||||
me.colorLeftS("grn", "blu", "blu", "blu", "wht", "wht");
|
||||
me.colorLeft("grn", "blu", "blu", "blu", "wht", "wht");
|
||||
me.colorLeftS("wht", "blu", "blu", "blu", "wht", "wht");
|
||||
me.colorLeftArrow("wht", "blu", "blu", "blu", "wht", "wht");
|
||||
me.colorCenterS("grn", "wht", "wht", "wht", "wht", "wht");
|
||||
me.colorRight("wht", "blu", "blu", "wht", "wht", "blu");
|
||||
me.colorRightS("grn", "blu", "blu", "wht", "wht", "blu");
|
||||
me.colorRight("grn", "blu", "blu", "wht", "wht", "blu");
|
||||
me.colorRightS("wht", "blu", "blu", "wht", "wht", "blu");
|
||||
me.colorRightArrow("wht", "blu", "blu", "wht", "wht", "wht");
|
||||
|
||||
me["Simple_L1S"].setText(" AUTO");
|
||||
me["Simple_C1S"].setText("SITA725 ");
|
||||
me["Simple_L2S"].setText(" SITA725");
|
||||
me["Simple_L2"].setText(" EUROPE");
|
||||
me["Simple_L3S"].setText(" SITA550");
|
||||
me["Simple_L3"].setText(" ASIA/AUST");
|
||||
me["Simple_L4S"].setText(" AVICOM");
|
||||
me["Simple_L4"].setText(" JAPAN");
|
||||
me["Simple_R1S"].setText(" 131.725");
|
||||
me["Simple_R2S"].setText("ARINC ");
|
||||
me["Simple_R2"].setText("USA ");
|
||||
me["Simple_R3S"].setText("AIRCANADA ");
|
||||
me["Simple_R3"].setText("CANADA ");
|
||||
me["Simple_L1S"].setText(" ATIS");
|
||||
me["Simple_C1S"].setText("ACTIVE SERVERS");
|
||||
me["Simple_L2"].setText(" FAA");
|
||||
me["Simple_L3"].setText(" VATSIM");
|
||||
me["Simple_R1S"].setText("METAR ");
|
||||
me["Simple_R2"].setText("NOAA ");
|
||||
me["Simple_R3"].setText("VATSIM ");
|
||||
me["Simple_L6S"].setText(" RETURN TO");
|
||||
me["Simple_L6"].setText(" COMM MENU");
|
||||
me["Simple_R6S"].setText("PAGE ");
|
||||
|
@ -1226,6 +1225,25 @@ var canvas_MCDU_base = {
|
|||
|
||||
pageSwitch[i].setBoolValue(1);
|
||||
}
|
||||
if (atsu.AOC.server == 1) {
|
||||
me["Simple_R1"].setText("VATSIM ");
|
||||
me["Simple_R2_Arrow"].show();
|
||||
me["Simple_R3_Arrow"].hide();
|
||||
} elsif (atsu.AOC.server == 0) {
|
||||
me["Simple_R1"].setText("NOAA ");
|
||||
me["Simple_R2_Arrow"].hide();
|
||||
me["Simple_R3_Arrow"].show();
|
||||
}
|
||||
|
||||
if (atsu.ATIS.server == 1) {
|
||||
me["Simple_L1"].setText(" VATSIM");
|
||||
me["Simple_L2_Arrow"].show();
|
||||
me["Simple_L3_Arrow"].hide();
|
||||
} elsif (atsu.ATIS.server == 0) {
|
||||
me["Simple_L1"].setText(" FAA");
|
||||
me["Simple_L2_Arrow"].hide();
|
||||
me["Simple_L3_Arrow"].show();
|
||||
}
|
||||
} else if (page == "COMMINIT") {
|
||||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me.defaultHide();
|
||||
|
|
|
@ -355,6 +355,8 @@ var lskbutton = func(btn, i) {
|
|||
pageNode[i].setValue("DATAMODE");
|
||||
} else if (page == "RECEIVEDMSGS") {
|
||||
canvas_mcdu.myReceivedMessages[i].leftKey(2);
|
||||
} else if (page == "DATAMODE") {
|
||||
atsu.ATIS.server = 0;
|
||||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
|
@ -408,6 +410,8 @@ var lskbutton = func(btn, i) {
|
|||
pageNode[i].setValue("VOICEDIRECTORY");
|
||||
} else if (page == "RECEIVEDMSGS") {
|
||||
canvas_mcdu.myReceivedMessages[i].leftKey(3);
|
||||
} else if (page == "DATAMODE") {
|
||||
atsu.ATIS.server = 1;
|
||||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
|
@ -693,6 +697,8 @@ var rskbutton = func(btn, i) {
|
|||
pageNode[i].setValue("COMPANYCALL");
|
||||
} else if (page == "AOCMENU") {
|
||||
pageNode[i].setValue("WEATHERREQ");
|
||||
} else if (page == "DATAMODE") {
|
||||
atsu.AOC.server = 0;
|
||||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
|
@ -730,6 +736,8 @@ var rskbutton = func(btn, i) {
|
|||
canvas_mcdu.myReceivedMessages[i] = nil;
|
||||
canvas_mcdu.myReceivedMessages[i] = receivedMessagesPage.new(i);
|
||||
pageNode[i].setValue("RECEIVEDMSGS");
|
||||
} else if (page == "DATAMODE") {
|
||||
atsu.AOC.server = 1;
|
||||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
# Jonathan Redpath
|
||||
|
||||
# Copyright (c) 2020 Josh Davidson (Octal450)
|
||||
var defaultServer = "https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&mostRecent=true&hoursBeforeNow=12&stationString=";
|
||||
var serverString = "";
|
||||
var result = nil;
|
||||
|
||||
var ATSU = {
|
||||
working: 0,
|
||||
loop: func() {
|
||||
|
@ -93,13 +97,14 @@ var CompanyCall = {
|
|||
|
||||
var AOC = {
|
||||
station: nil,
|
||||
selectedType: "HOURLY WX", # 0 = METAR 1 = TAF
|
||||
selectedType: "HOURLY WX",
|
||||
lastMETAR: nil,
|
||||
lastTAF: nil,
|
||||
sent: 0,
|
||||
sentTime: nil,
|
||||
received: 0,
|
||||
receivedTime: nil,
|
||||
server: 0, # 0 = noaa, 1 = vatsim
|
||||
newStation: func(airport) {
|
||||
if (size(airport) == 3 or size(airport) == 4) {
|
||||
if (size(findAirportsByICAO(airport)) == 0) {
|
||||
|
@ -152,8 +157,19 @@ var AOC = {
|
|||
me.sent = 0;
|
||||
return 1;
|
||||
}
|
||||
http.load("https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&mostRecent=true&hoursBeforeNow=12&stationString=" ~ airport)
|
||||
.fail(func print("Download failed!"))
|
||||
|
||||
serverString = "";
|
||||
|
||||
if (me.server == 0) {
|
||||
serverString = defaultServer;
|
||||
} elsif (me.server == 1) {
|
||||
serverString = "https://api.flybywiresim.com/metar?source=vatsim&icao=";
|
||||
} else { # fall back to NOAA silently
|
||||
serverString = defaultServer;
|
||||
}
|
||||
|
||||
http.load(serverString ~ airport)
|
||||
.fail(func(r) print("Download failed; try changing your server to NOAA"))
|
||||
.done(func(r) me.processMETAR(r, i));
|
||||
return 0;
|
||||
},
|
||||
|
@ -202,3 +218,88 @@ var AOC = {
|
|||
}, math.max(rand()*6, 2.25));
|
||||
},
|
||||
};
|
||||
|
||||
var ATIS = {
|
||||
station: nil,
|
||||
lastATIS: nil,
|
||||
sent: 0,
|
||||
sentTime: nil,
|
||||
received: 0,
|
||||
receivedTime: nil,
|
||||
server: 0,
|
||||
newStation: func(airport) {
|
||||
if (size(airport) == 3 or size(airport) == 4) {
|
||||
if (size(findAirportsByICAO(airport)) == 0) {
|
||||
return 2;
|
||||
} else {
|
||||
me.station = airport;
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
},
|
||||
sendReq: func(i) {
|
||||
if (me.station == nil or (me.sent and !me.received)) {
|
||||
return 1;
|
||||
}
|
||||
me.sent = 1;
|
||||
me.received = 0;
|
||||
var sentTime = left(getprop("/sim/time/gmt-string"), 5);
|
||||
me.sentTime = split(":", sentTime)[0] ~ "." ~ split(":", sentTime)[1] ~ "Z";
|
||||
|
||||
result = me.fetchATIS(atsu.ATIS.station, i);
|
||||
if (result == 0) {
|
||||
return 0;
|
||||
} elsif (result == 1) {
|
||||
return 3;
|
||||
} elsif (result == 2) {
|
||||
return 4;
|
||||
}
|
||||
},
|
||||
fetchATIS: func(airport, i) {
|
||||
if (!ATSU.working) {
|
||||
me.sent = 0;
|
||||
return 2;
|
||||
}
|
||||
if (ecam.vhf3_voice.active) {
|
||||
me.sent = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
serverString = "";
|
||||
|
||||
if (me.server == 0) {
|
||||
serverString = "https://api.flybywiresim.com/atis?source=faa&icao=";
|
||||
} elsif (me.server == 1) {
|
||||
serverString = "https://api.flybywiresim.com/atis?source=vatsim&icao=";
|
||||
} else { # fall back to FAA silently
|
||||
serverString = "https://api.flybywiresim.com/atis?source=faa&icao=";
|
||||
}
|
||||
|
||||
http.load(serverString ~ airport)
|
||||
.fail(func(r) return 3)
|
||||
.done(func(r) me.processATIS(r, i));
|
||||
return 0;
|
||||
},
|
||||
processATIS: func(r, i) {
|
||||
var raw = r.response;
|
||||
if (find("combined", raw)) {
|
||||
raw = split('{"combined":"', raw)[1];
|
||||
raw = split('"}', raw)[0];
|
||||
} else {
|
||||
raw = split('{"arr":"', raw)[1];
|
||||
raw = split('","dep":', raw)[0];
|
||||
}
|
||||
me.lastATIS = raw;
|
||||
settimer(func() {
|
||||
me.received = 1;
|
||||
mcdu.mcdu_message(i, "WX UPLINK");
|
||||
|
||||
var receivedTime = left(getprop("/sim/time/gmt-string"), 5);
|
||||
me.receivedTime = split(":", receivedTime)[0] ~ "." ~ split(":", receivedTime)[1] ~ "Z";
|
||||
var message = mcdu.ACARSMessage.new(me.receivedTime, me.lastATIS);
|
||||
mcdu.ReceivedMessagesDatabase.addMessage(message);
|
||||
}, math.max(rand()*10, 2.25));
|
||||
},
|
||||
};
|
Loading…
Add table
Reference in a new issue