Show ATIS code + time
This commit is contained in:
parent
66a59b90b2
commit
93cf903128
4 changed files with 225 additions and 32 deletions
|
@ -932,7 +932,7 @@ var canvas_MCDU_base = {
|
|||
}
|
||||
} else if (page == "ATIS") {
|
||||
if (!pageSwitch[i].getBoolValue()) {
|
||||
me.defaultHide();
|
||||
me.defaultHideWithCenter();
|
||||
me["Simple_Title"].setText("ATS623 ATIS MENU");
|
||||
me["Simple_Title"].setColor(1, 1, 1);
|
||||
me["Simple_PageNum"].hide();
|
||||
|
@ -943,6 +943,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);
|
||||
|
@ -954,6 +956,8 @@ var canvas_MCDU_base = {
|
|||
me.colorLeft("blu", "blu", "blu", "blu", "wht", "wht");
|
||||
me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht");
|
||||
me.colorLeftArrow("wht", "wht", "wht", "wht", "wht", "wht");
|
||||
me.colorCenter("grn", "grn", "grn", "grn", "wht", "wht");
|
||||
me.colorCenterS("wht", "wht", "wht", "wht", "wht", "wht");
|
||||
me.colorRight("wht", "wht", "wht", "wht", "wht", "wht");
|
||||
me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht");
|
||||
me.colorRightArrow("wht", "wht", "wht", "wht", "wht", "wht");
|
||||
|
@ -965,6 +969,11 @@ var canvas_MCDU_base = {
|
|||
me["Simple_L4"].setFont(symbol);
|
||||
me["Simple_L6"].setText(" RETURN");
|
||||
|
||||
me["Simple_C1"].setFontSize(small);
|
||||
me["Simple_C2"].setFontSize(small);
|
||||
me["Simple_C3"].setFontSize(small);
|
||||
me["Simple_C4"].setFontSize(small);
|
||||
|
||||
me["Simple_R1S"].setText("REQ ");
|
||||
me["Simple_R1"].setText("SEND ");
|
||||
me["Simple_R2S"].setText("REQ ");
|
||||
|
@ -980,54 +989,74 @@ var canvas_MCDU_base = {
|
|||
pageSwitch[i].setBoolValue(1);
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[0].station != nil) {
|
||||
if (atsu.ATISInstances[0].station != nil) {
|
||||
me["Simple_L1"].setText(" " ~ atsu.ATISInstances[0].station ~ "/" ~ (atsu.ATISInstances[0].type == 0 ? "ARR" : "DEP"));
|
||||
me["Simple_L1"].setFont(default);
|
||||
me["Simple_L1"].setColor(WHITE);
|
||||
me["Simple_L1_Arrow"].show();
|
||||
} else {
|
||||
me["Simple_L1"].setText(" [ ]/[ ]");
|
||||
me["Simple_L1"].setFont(symbol);
|
||||
me["Simple_L1"].setColor(BLUE);
|
||||
me["Simple_L1_Arrow"].hide();
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[0].received) {
|
||||
me["Simple_C1"].setText(" " ~ atsu.ATISInstances[0].receivedCode ~ " " ~ atsu.ATISInstances[0].receivedTime);
|
||||
me["Simple_C1"].show();
|
||||
} else {
|
||||
me["Simple_C1"].hide();
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[1].station != nil) {
|
||||
me["Simple_L2"].setText(" " ~ atsu.ATISInstances[1].station ~ "/" ~ (atsu.ATISInstances[1].type == 0 ? "ARR" : "DEP"));
|
||||
me["Simple_L2"].setFont(default);
|
||||
me["Simple_L2"].setColor(WHITE);
|
||||
me["Simple_L2_Arrow"].show();
|
||||
} else {
|
||||
me["Simple_L2"].setText(" [ ]/[ ]");
|
||||
me["Simple_L2"].setFont(symbol);
|
||||
me["Simple_L2"].setColor(BLUE);
|
||||
me["Simple_L2_Arrow"].hide();
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[1].received) {
|
||||
me["Simple_C2"].setText(" " ~ atsu.ATISInstances[1].receivedCode ~ " " ~ atsu.ATISInstances[1].receivedTime);
|
||||
me["Simple_C2"].show();
|
||||
} else {
|
||||
me["Simple_C2"].hide();
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[2].station != nil) {
|
||||
me["Simple_L3"].setText(" " ~ atsu.ATISInstances[2].station ~ "/" ~ (atsu.ATISInstances[2].type == 0 ? "ARR" : "DEP"));
|
||||
me["Simple_L3"].setFont(default);
|
||||
me["Simple_L3"].setColor(WHITE);
|
||||
me["Simple_L3_Arrow"].show();
|
||||
} else {
|
||||
me["Simple_L3"].setText(" [ ]/[ ]");
|
||||
me["Simple_L3"].setFont(symbol);
|
||||
me["Simple_L3"].setColor(BLUE);
|
||||
me["Simple_L3_Arrow"].hide();
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[2].received) {
|
||||
me["Simple_C3"].setText(" " ~ atsu.ATISInstances[2].receivedCode ~ " " ~ atsu.ATISInstances[2].receivedTime);
|
||||
me["Simple_C3"].show();
|
||||
} else {
|
||||
me["Simple_C3"].hide();
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[3].station != nil) {
|
||||
me["Simple_L4"].setText(" " ~ atsu.ATISInstances[3].station ~ "/" ~ (atsu.ATISInstances[3].type == 0 ? "ARR" : "DEP"));
|
||||
me["Simple_L4"].setFont(default);
|
||||
me["Simple_L4"].setColor(WHITE);
|
||||
me["Simple_L4_Arrow"].show();
|
||||
} else {
|
||||
me["Simple_L4"].setText(" [ ]/[ ]");
|
||||
me["Simple_L4"].setFont(symbol);
|
||||
me["Simple_L4"].setColor(BLUE);
|
||||
me["Simple_L4_Arrow"].hide();
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[3].received) {
|
||||
me["Simple_C4"].setText(" " ~ atsu.ATISInstances[3].receivedCode ~ " " ~ atsu.ATISInstances[3].receivedTime);
|
||||
me["Simple_C4"].show();
|
||||
} else {
|
||||
me["Simple_C4"].hide();
|
||||
}
|
||||
|
||||
if (atsu.ATISInstances[0].sent) {
|
||||
me["ATISSend1"].hide();
|
||||
} else {
|
||||
|
@ -1373,11 +1402,11 @@ var canvas_MCDU_base = {
|
|||
me["Simple_R3_Arrow"].show();
|
||||
}
|
||||
|
||||
if (atsu.ATIS.server == 1) {
|
||||
if (atsu.ATIS.serverSel == 1) {
|
||||
me["Simple_L1"].setText(" VATSIM");
|
||||
me["Simple_L2_Arrow"].show();
|
||||
me["Simple_L3_Arrow"].hide();
|
||||
} elsif (atsu.ATIS.server == 0) {
|
||||
} elsif (atsu.ATIS.serverSel == 0) {
|
||||
me["Simple_L1"].setText(" FAA");
|
||||
me["Simple_L2_Arrow"].hide();
|
||||
me["Simple_L3_Arrow"].show();
|
||||
|
|
124
Nasal/MCDU/ATIS.nas
Normal file
124
Nasal/MCDU/ATIS.nas
Normal file
|
@ -0,0 +1,124 @@
|
|||
var receivedMessagePage = {
|
||||
title: nil,
|
||||
fontMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]],
|
||||
arrowsMatrix: [[0, 0, 0, 0, 0, 0],[0, 0, 0, 0, 0, 0]],
|
||||
arrowsColour: [["ack", "ack", "ack", "ack", "ack", "ack"],["ack", "ack", "ack", "ack", "ack", "ack"]],
|
||||
L1: [nil, nil, "ack"], # content, title, colour
|
||||
L2: [nil, nil, "ack"],
|
||||
L3: [nil, nil, "ack"],
|
||||
L4: [nil, nil, "ack"],
|
||||
L5: [nil, nil, "ack"],
|
||||
L6: [nil, nil, "ack"],
|
||||
C1: [nil, nil, "ack"],
|
||||
C2: [nil, nil, "ack"],
|
||||
C3: [nil, nil, "ack"],
|
||||
C4: [nil, nil, "ack"],
|
||||
C5: [nil, nil, "ack"],
|
||||
C6: [nil, nil, "ack"],
|
||||
R1: [nil, nil, "ack"],
|
||||
R2: [nil, nil, "ack"],
|
||||
R3: [nil, nil, "ack"],
|
||||
R4: [nil, nil, "ack"],
|
||||
R5: [nil, nil, "ack"],
|
||||
R6: [nil, nil, "ack"],
|
||||
computer: nil,
|
||||
size: 0,
|
||||
new: func(computer, index) {
|
||||
var ap = {parents:[receivedMessagePage]};
|
||||
ap.computer = computer;
|
||||
ap.curPage = index + 1;
|
||||
ReceivedMessagesDatabase.database.vector[ap.curPage - 1].viewed = 1;
|
||||
ap._setupPageWithData();
|
||||
ap.update();
|
||||
return ap;
|
||||
},
|
||||
del: func() {
|
||||
return nil;
|
||||
},
|
||||
scrollLeft: func() {
|
||||
me.curPage -= 1;
|
||||
if (me.curPage < 1) {
|
||||
me.curPage = ReceivedMessagesDatabase.getSize();
|
||||
}
|
||||
ReceivedMessagesDatabase.database.vector[me.curPage - 1].viewed = 1;
|
||||
me.update();
|
||||
},
|
||||
scrollRight: func() {
|
||||
me.curPage += 1;
|
||||
if (me.curPage > ReceivedMessagesDatabase.getSize()) {
|
||||
me.curPage = 1;
|
||||
}
|
||||
ReceivedMessagesDatabase.database.vector[me.curPage - 1].viewed = 1;
|
||||
me.update();
|
||||
},
|
||||
_clearPage: func() {
|
||||
me.L1 = [nil, nil, "ack"];
|
||||
me.L2 = [nil, nil, "ack"];
|
||||
me.L3 = [nil, nil, "ack"];
|
||||
me.L4 = [nil, nil, "ack"];
|
||||
me.L5 = [nil, nil, "ack"];
|
||||
me.C1 = [nil, nil, "ack"];
|
||||
me.C2 = [nil, nil, "ack"];
|
||||
me.C3 = [nil, nil, "ack"];
|
||||
me.C4 = [nil, nil, "ack"];
|
||||
me.C5 = [nil, nil, "ack"];
|
||||
me.R1 = [nil, nil, "ack"];
|
||||
me.R2 = [nil, nil, "ack"];
|
||||
me.R3 = [nil, nil, "ack"];
|
||||
me.R4 = [nil, nil, "ack"];
|
||||
me.R5 = [nil, nil, "ack"];
|
||||
me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]];
|
||||
},
|
||||
_setupPageWithData: func() {
|
||||
me.title = "ACARS MESSAGE";
|
||||
me.L6 = [" RETURN", nil, "wht"];
|
||||
me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]];
|
||||
me.arrowsColour = [["blu", "blu", "blu", "blu", "blu", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]];
|
||||
me.fontMatrix = [[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]];
|
||||
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
|
||||
},
|
||||
update: func() {
|
||||
me._clearPage();
|
||||
me.size = ReceivedMessagesDatabase.getSize();
|
||||
var message = nil;
|
||||
if (me.size >= me.curPage) {
|
||||
message = ReceivedMessagesDatabase.database.vector[me.curPage - 1];
|
||||
me.L1[1] = message.time;
|
||||
me.C1[1] = "VIEWED";
|
||||
me.C1[2] = "grn";
|
||||
me.R1[1] = me.curPage ~ "/" ~ ReceivedMessagesDatabase.getSize();
|
||||
|
||||
me.L1[0] = left(message.body, size(message.body) > 30 ? 30 : size(message.body));
|
||||
me.L1[2] = "wht";
|
||||
me.L2[2] = "wht";
|
||||
me.L3[2] = "wht";
|
||||
me.L4[2] = "wht";
|
||||
me.L5[2] = "wht";
|
||||
if (size(message.body) > 30) {
|
||||
me.L2[1] = left(split(me.L1[0], message.body)[1], size(message.body) > 60 ? 30 : size(message.body) - 30);
|
||||
}
|
||||
if (size(message.body) > 60) {
|
||||
me.L2[0] = left(split(me.L2[1], message.body)[1], size(message.body) > 90 ? 30 : size(message.body) - 60);
|
||||
}
|
||||
if (size(message.body) > 90) {
|
||||
me.L3[1] = left(split(me.L2[0], message.body)[1], size(message.body) > 120 ? 30 : size(message.body) - 90);
|
||||
}
|
||||
if (size(message.body) > 120) {
|
||||
me.L3[0] = left(split(me.L3[1], message.body)[1], size(message.body) > 150 ? 30 : size(message.body) - 120);
|
||||
}
|
||||
if (size(message.body) > 150) {
|
||||
me.L4[1] = left(split(me.L3[0], message.body)[1], size(message.body) > 180 ? 30 : size(message.body) - 150);
|
||||
}
|
||||
if (size(message.body) > 180) {
|
||||
me.L4[0] = left(split(me.L4[1], message.body)[1], size(message.body) > 210 ? 30 : size(message.body) - 180);
|
||||
}
|
||||
if (size(message.body) > 210) {
|
||||
me.L5[1] = left(split(me.L4[0], message.body)[1], size(message.body) > 240 ? 30 : size(message.body) - 210);
|
||||
}
|
||||
if (size(message.body) > 240) {
|
||||
me.L5[0] = left(split(me.L5[1], message.body)[1], size(message.body) > 270 ? 30 : size(message.body) - 240);
|
||||
}
|
||||
}
|
||||
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
|
||||
},
|
||||
};
|
|
@ -318,14 +318,13 @@ var lskbutton = func(btn, i) {
|
|||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
} elsif (size(str[0]) > 0 and size(str[1]) > 0) {
|
||||
var result = atsu.ATISInstances[0].newStation(str[0]);
|
||||
if (result == 2) {
|
||||
mcdu_message(i, "NOT IN DATA BASE");
|
||||
} elsif (result == 1) {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
} elsif (result == 0) {
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
}
|
||||
if (str[1] == "DEP") {
|
||||
atsu.ATISInstances[0].type = 1;
|
||||
|
@ -334,6 +333,7 @@ var lskbutton = func(btn, i) {
|
|||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
|
@ -418,7 +418,7 @@ var lskbutton = func(btn, i) {
|
|||
} else if (page == "RECEIVEDMSGS") {
|
||||
canvas_mcdu.myReceivedMessages[i].leftKey(2);
|
||||
} else if (page == "DATAMODE") {
|
||||
atsu.ATIS.server = 0;
|
||||
atsu.ATIS.serverSel = 0;
|
||||
} else if (page == "ATIS") {
|
||||
var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad;
|
||||
if (scratchpad == "CLR") {
|
||||
|
@ -451,14 +451,13 @@ var lskbutton = func(btn, i) {
|
|||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
} elsif (size(str[0]) > 0 and size(str[1]) > 0) {
|
||||
var result = atsu.ATISInstances[1].newStation(str[0]);
|
||||
if (result == 2) {
|
||||
mcdu_message(i, "NOT IN DATA BASE");
|
||||
} elsif (result == 1) {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
} elsif (result == 0) {
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
}
|
||||
if (str[1] == "DEP") {
|
||||
atsu.ATISInstances[1].type = 1;
|
||||
|
@ -467,11 +466,12 @@ var lskbutton = func(btn, i) {
|
|||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
} else {
|
||||
var result = atsu.ATISInstances[0].newStation(scratchpad);
|
||||
var result = atsu.ATISInstances[1].newStation(scratchpad);
|
||||
if (result == 2) {
|
||||
mcdu_message(i, "NOT IN DATA BASE");
|
||||
} elsif (result == 1) {
|
||||
|
@ -534,7 +534,7 @@ var lskbutton = func(btn, i) {
|
|||
} else if (page == "RECEIVEDMSGS") {
|
||||
canvas_mcdu.myReceivedMessages[i].leftKey(3);
|
||||
} else if (page == "DATAMODE") {
|
||||
atsu.ATIS.server = 1;
|
||||
atsu.ATIS.serverSel = 1;
|
||||
} else if (page == "ATIS") {
|
||||
var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad;
|
||||
if (scratchpad == "CLR") {
|
||||
|
@ -567,14 +567,13 @@ var lskbutton = func(btn, i) {
|
|||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
} elsif (size(str[0]) > 0 and size(str[1]) > 0) {
|
||||
var result = atsu.ATISInstances[2].newStation(str[0]);
|
||||
if (result == 2) {
|
||||
mcdu_message(i, "NOT IN DATA BASE");
|
||||
} elsif (result == 1) {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
} elsif (result == 0) {
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
}
|
||||
if (str[1] == "DEP") {
|
||||
atsu.ATISInstances[2].type = 1;
|
||||
|
@ -583,6 +582,7 @@ var lskbutton = func(btn, i) {
|
|||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
|
@ -672,14 +672,13 @@ var lskbutton = func(btn, i) {
|
|||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
} elsif (size(str[0]) > 0 and size(str[1]) > 0) {
|
||||
var result = atsu.ATISInstances[3].newStation(str[0]);
|
||||
if (result == 2) {
|
||||
mcdu_message(i, "NOT IN DATA BASE");
|
||||
} elsif (result == 1) {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
} elsif (result == 0) {
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
}
|
||||
if (str[1] == "DEP") {
|
||||
atsu.ATISInstances[3].type = 1;
|
||||
|
@ -688,6 +687,7 @@ var lskbutton = func(btn, i) {
|
|||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
mcdu_scratchpad.scratchpads[i].empty();
|
||||
} else {
|
||||
mcdu_message(i, "NOT ALLOWED");
|
||||
}
|
||||
|
|
|
@ -229,6 +229,7 @@ var AOC = {
|
|||
};
|
||||
|
||||
var ATIS = {
|
||||
serverSel: 0,
|
||||
new: func() {
|
||||
var ATIS = { parents: [ATIS] };
|
||||
ATIS.station = nil;
|
||||
|
@ -237,11 +238,12 @@ var ATIS = {
|
|||
ATIS.received = 0;
|
||||
ATIS.receivedTime = nil;
|
||||
ATIS.receivedCode = nil;
|
||||
ATIS.server = 0;
|
||||
ATIS.type = 0; # 0 = arr, 1 = dep
|
||||
return ATIS;
|
||||
},
|
||||
newStation: func(airport) {
|
||||
me.sent = 0;
|
||||
me.received = 0;
|
||||
if (size(airport) == 3 or size(airport) == 4) {
|
||||
if (size(findAirportsByICAO(airport)) == 0) {
|
||||
return 2;
|
||||
|
@ -281,9 +283,9 @@ var ATIS = {
|
|||
|
||||
serverString = "";
|
||||
|
||||
if (me.server == 0) {
|
||||
if (me.serverSel == 0) {
|
||||
serverString = "https://api.flybywiresim.com/atis?source=faa&icao=";
|
||||
} elsif (me.server == 1) {
|
||||
} elsif (me.serverSel == 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=";
|
||||
|
@ -291,7 +293,15 @@ var ATIS = {
|
|||
|
||||
http.load(serverString ~ airport)
|
||||
.fail(func(r) return 3)
|
||||
.done(func(r) me.processATIS(r, i));
|
||||
.done(func(r) {
|
||||
var errs = [];
|
||||
call(me.processATIS, [r, i], me, {}, errs);
|
||||
if (size(errs) > 0) {
|
||||
print("Failed to parse ATIS for " ~ airport);
|
||||
debug.dump(r.response);
|
||||
debug.printerror(errs);
|
||||
}
|
||||
});
|
||||
return 0;
|
||||
},
|
||||
processATIS: func(r, i) {
|
||||
|
@ -314,20 +324,40 @@ var ATIS = {
|
|||
raw = split('"}', raw)[0];
|
||||
}
|
||||
}
|
||||
var code = nil;
|
||||
var code = "";
|
||||
if (find("INFO ", raw) != -1) {
|
||||
code = split("INFO ", raw)[1];
|
||||
code = split(" ", code)[0];
|
||||
me.receivedCode = code;
|
||||
} else if (find("information ", raw) != -1) {
|
||||
code = split("information ", raw)[1];
|
||||
code = split(" ", code)[0];
|
||||
me.receivedCode = code;
|
||||
} else if (find("INFORMATION ", raw) != -1) {
|
||||
code = split("INFORMATION ", raw)[1];
|
||||
code = split(" ", code)[0];
|
||||
} else if (find("ATIS ", raw) != -1) {
|
||||
code = split("ATIS ", raw)[1];
|
||||
code = split(" ", code)[0];
|
||||
} else if (find("info ", raw) != -1) {
|
||||
code = split("info ", raw)[1];
|
||||
code = split(" ", code)[0];
|
||||
} else {
|
||||
print("Failed to find a valid ATIS code for " ~ me.station);
|
||||
debug.dump(raw);
|
||||
}
|
||||
var time = nil;
|
||||
|
||||
if (find(".", code) != -1) {
|
||||
code = split(".", code)[0];
|
||||
}
|
||||
|
||||
me.receivedCode = code;
|
||||
|
||||
var time = "";
|
||||
if (find("Time ", raw) != -1) {
|
||||
time = split("Time ", raw)[1];
|
||||
time = split(" ", time)[0];
|
||||
} else if (find("time ", raw) != -1) {
|
||||
time = split("time ", raw)[1];
|
||||
time = split(" ", time)[0];
|
||||
} else if (find("TIME ", raw) != -1) {
|
||||
time = split("TIME ", raw)[1];
|
||||
time = split(" ", time)[0];
|
||||
|
@ -337,14 +367,24 @@ var ATIS = {
|
|||
} else if (find("Z SPECIAL", raw) != -1) {
|
||||
time = split("Z SPECIAL", raw)[0];
|
||||
time = right(time, 4);
|
||||
} else if (find("Z SPECIAL", raw) != -1) {
|
||||
time = split("Z SPECIAL", raw)[0];
|
||||
time = right(time, 4);
|
||||
} else if (find("metreport", raw) != -1) {
|
||||
time = split("metreport", raw)[0];
|
||||
time = right(time, 4);
|
||||
} else {
|
||||
print("Failed to find a valid ATIS time for " ~ me.station);
|
||||
debug.dump(raw);
|
||||
}
|
||||
|
||||
if (size(time) == 3) {
|
||||
time ~= " ";
|
||||
}
|
||||
settimer(func() {
|
||||
me.sent = 0;
|
||||
me.received = 1;
|
||||
me.receivedTime = time ~ "Z";
|
||||
me.receivedTime = time;
|
||||
me.lastATIS = raw;
|
||||
}, math.max(rand()*10, 4.5));
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue