1
0
Fork 0

MCDU: add working ATIS fetcher

This commit is contained in:
legoboyvdlp R 2020-10-24 14:07:15 +01:00
parent 5c60cafb68
commit d599e1ffc5
5 changed files with 149 additions and 72 deletions

View file

@ -232,7 +232,8 @@ var canvas_MCDU_base = {
"PERFAPPR_FE","PERFAPPR_SE","PERFAPPR_OE","PERFAPPR_LDG_3","PERFAPPR_LDG_F","PERFGA","PERFGA_FE","PERFGA_SE","PERFGA_OE","FPLN","FPLN_From", "PERFAPPR_FE","PERFAPPR_SE","PERFAPPR_OE","PERFAPPR_LDG_3","PERFAPPR_LDG_F","PERFGA","PERFGA_FE","PERFGA_SE","PERFGA_OE","FPLN","FPLN_From",
"FPLN_TMPY_group","FPLN_FROM","FPLN_Callsign","departureTMPY", "arrowsDepArr","arrow1L","arrow2L","arrow3L","arrow4L","arrow5L","arrow1R","arrow2R", "FPLN_TMPY_group","FPLN_FROM","FPLN_Callsign","departureTMPY", "arrowsDepArr","arrow1L","arrow2L","arrow3L","arrow4L","arrow5L","arrow1R","arrow2R",
"arrow3R","arrow4R","arrow5R","DIRTO_TMPY_group","IRSINIT","IRSINIT_1","IRSINIT_2","IRSINIT_star","NOTIFY","NOTIFY_FLTNBR","NOTIFY_AIRPORT","WEATHERREQSEND", "arrow3R","arrow4R","arrow5R","DIRTO_TMPY_group","IRSINIT","IRSINIT_1","IRSINIT_2","IRSINIT_star","NOTIFY","NOTIFY_FLTNBR","NOTIFY_AIRPORT","WEATHERREQSEND",
"WIND","WIND_CANCEL","WIND_INSERT_star","WIND_UPDOWN","MODEVHF3","PRINTPAGE","COMM-ADS","COCALL","COCALLTUNE","ATISSend1","ATISSend2","ATISSend3","ATISSend4"]; "WIND","WIND_CANCEL","WIND_INSERT_star","WIND_UPDOWN","MODEVHF3","PRINTPAGE","COMM-ADS","COCALL","COCALLTUNE","ATISSend1","ATISSend2","ATISSend3","ATISSend4",
"ATISArrows"];
}, },
update: func() { update: func() {
if (systems.ELEC.Bus.ac1.getValue() >= 110 and mcdu1_lgt.getValue() > 0.01) { if (systems.ELEC.Bus.ac1.getValue() >= 110 and mcdu1_lgt.getValue() > 0.01) {
@ -369,6 +370,9 @@ var canvas_MCDU_base = {
me["ATISSend3"].hide(); me["ATISSend3"].hide();
me["ATISSend4"].hide(); me["ATISSend4"].hide();
} }
if (page != "ATISDETAIL") {
me["ATISArrows"].hide();
}
if (page == "F-PLNA" or page == "F-PLNB") { if (page == "F-PLNA" or page == "F-PLNB") {
if (!pageSwitch[i].getBoolValue()) { if (!pageSwitch[i].getBoolValue()) {
me["Simple"].show(); me["Simple"].show();
@ -980,6 +984,17 @@ var canvas_MCDU_base = {
me.colorRight(myAtis[i].R1[2],myAtis[i].R2[2],myAtis[i].R3[2],myAtis[i].R4[2],myAtis[i].R5[2],myAtis[i].R6[2]); me.colorRight(myAtis[i].R1[2],myAtis[i].R2[2],myAtis[i].R3[2],myAtis[i].R4[2],myAtis[i].R5[2],myAtis[i].R6[2]);
} }
if (myAtis[i].getNumPages() > 1) {
me["Simple_PageNum"].show();
me["ATISArrows"].show();
print(myAtis[i].page);
me["Simple_PageNum"].setText(myAtis[i].page ~ "/" ~ myAtis[i].getNumPages());
} else {
me["Simple_PageNum"].hide();
me["ATISArrows"].hide();
}
pageSwitch[i].setBoolValue(1); pageSwitch[i].setBoolValue(1);
} }
} else if (page == "ATIS") { } else if (page == "ATIS") {

View file

@ -41,13 +41,13 @@
inkscape:window-height="705" inkscape:window-height="705"
id="namedview371" id="namedview371"
showgrid="true" showgrid="true"
inkscape:zoom="17.863704" inkscape:zoom="3.1578866"
inkscape:cx="1222.2874" inkscape:cx="1122.1906"
inkscape:cy="575.96236" inkscape:cy="986.92422"
inkscape:window-x="-8" inkscape:window-x="-8"
inkscape:window-y="-8" inkscape:window-y="-8"
inkscape:window-maximized="1" inkscape:window-maximized="1"
inkscape:current-layer="PERFAPPR" inkscape:current-layer="svg2"
showguides="false" showguides="false"
inkscape:snap-global="false" inkscape:snap-global="false"
units="px" units="px"
@ -3249,4 +3249,57 @@
inkscape:connector-curvature="0" inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" /> sodipodi:nodetypes="cc" />
</g> </g>
<g
transform="translate(220.36572,-474.55648)"
id="ATISArrows"
inkscape:label="#WIND_UPDOWN">
<g
id="g1338"
inkscape:label="#g4241"
transform="matrix(0,1,1,0,667.65035,-414.17373)"
style="stroke:#ffffff;stroke-opacity:1">
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1332"
d="M 952.4036,47.432743 H 923.87395"
style="fill:none;stroke:#ffffff;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#ffffff;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 936.70791,32.6968 921.8587,47.4328"
id="path1334"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1336"
d="M 936.70791,62.1688 921.8587,47.4328"
style="fill:none;stroke:#ffffff;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
style="stroke:#ffffff;stroke-opacity:1"
transform="matrix(0,-1,-1,0,801.59015,1459.2436)"
inkscape:label="#g4241"
id="g1346">
<path
style="fill:none;stroke:#ffffff;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 952.4036,47.432743 H 923.87395"
id="path1340"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1342"
d="M 936.70791,32.6968 921.8587,47.4328"
style="fill:none;stroke:#ffffff;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#ffffff;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 936.70791,62.1688 921.8587,47.4328"
id="path1344"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
</g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 171 KiB

View file

@ -26,33 +26,38 @@ var atisPage = {
new: func(computer, index) { new: func(computer, index) {
var ap = {parents:[atisPage]}; var ap = {parents:[atisPage]};
ap.computer = computer; ap.computer = computer;
ap.lineOffset = 0; ap.page = 1;
ap.index = index; ap.index = index;
ap.message = atsu.ATISInstances[index].lastATIS; ap.message = atsu.ATISInstances[index].lastATIS;
ap._setupPageWithData(); ap._setupPageWithData();
ap._numPages = 1;
ap.update(); ap.update();
return ap; return ap;
}, },
del: func() { del: func() {
return nil; return nil;
}, },
getNumLines: func() { getNumPages: func() {
me._numLines = size(me.message) / 30; me._numPages = math.ceil(size(me.message) / 210);
me.lineOffset = math.ceil(me._numLines); return me._numPages;
}, },
scrollUp: func() { scrollUp: func() {
me.lineOffset -= 1; print(me.page);
if (me.lineOffset < 0) { me.page -= 1;
me.lineOffset = me.getNumLines(); if (me.page < 1) {
me.page = me.getNumPages();
} }
me.update(); me.update();
print(me.page);
}, },
scrollDown: func() { scrollDown: func() {
me.lineOffset += 1; print(me.page);
if (me.lineOffset > me.getNumLines()) { me.page += 1;
me.lineOffset = 1; if (me.page > me.getNumPages()) {
me.page = 1;
} }
me.update(); me.update();
print(me.page);
}, },
_clearPage: func() { _clearPage: func() {
me.L2 = [nil, nil, "wht"]; me.L2 = [nil, nil, "wht"];
@ -70,8 +75,7 @@ var atisPage = {
me.arrowsMatrix = [[0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0]]; me.arrowsMatrix = [[0, 0, 0, 0, 1, 1], [0, 0, 0, 0, 0, 0]];
}, },
_setupPageWithData: func() { _setupPageWithData: func() {
me.title = atsu.ATISInstances[me.index].station ~ "/" ~ (atsu.ATISInstances[me.index].type == 0 ? "ARR" : "DEP") ~ " ATIS"; me.title = atsu.ATISInstances[me.index].station ~ "/" ~ (atsu.ATISInstances[me.index].type == 0 ? "ARR" : "DEP") ~ " ATIS ";
me.title = atsu.ATISInstances[me.index].station ~ "/" ~ (atsu.ATISInstances[me.index].type == 0 ? "ARR" : "DEP") ~ " ATIS";
me.L5 = [" PREV ATIS", nil, "wht"]; me.L5 = [" PREV ATIS", nil, "wht"];
me.L6 = [" RETURN", " ATIS MENU", "wht"]; me.L6 = [" RETURN", " ATIS MENU", "wht"];
me.R6 = ["PRINT ", nil, "blu"]; me.R6 = ["PRINT ", nil, "blu"];
@ -83,30 +87,29 @@ var atisPage = {
update: func() { update: func() {
me._clearPage(); me._clearPage();
var message = atsu.ATISInstances[me.index].lastATIS; var message = atsu.ATISInstances[me.index].lastATIS;
var start = left(message, size(message) > (30 + (me.lineOffset * 30)) ? (30 + (me.lineOffset * 30)) : size(message)); var pageMinusOne = (me.page - 1);
start = right(start, 30); var numberExtraChar = pageMinusOne * 210;
me.L1 = [substr(message, numberExtraChar, 30), atsu.ATISInstances[me.index].station ~ "/" ~ (atsu.ATISInstances[me.index].type == 0 ? "ARR" : "DEP"), "wht"];
me.L1 = [start, atsu.ATISInstances[me.index].station ~ "/" ~ (atsu.ATISInstances[me.index].type == 0 ? "ARR" : "DEP"), "wht"];
# dictionary for code
me.R1 = [" ",atsu.ATISInstances[me.index].receivedCode ~ " " ~ atsu.ATISInstances[me.index].receivedTime ~ "Z", "wht"]; me.R1 = [" ",atsu.ATISInstances[me.index].receivedCode ~ " " ~ atsu.ATISInstances[me.index].receivedTime ~ "Z", "wht"];
if (size(message) > 30) { if (size(message) > 30) {
me.L2[1] = left(split(me.L1[0], message)[1], size(message) > (60 + (me.lineOffset * 30)) ? 30 : size(message) - (30 + (me.lineOffset * 30))); me.L2[1] = substr(message, numberExtraChar + 30, 30);
} }
if (size(message) > 60) { if (size(message) > 60) {
me.L2[0] = left(split(me.L2[1], message)[1], size(message) > (90 + (me.lineOffset * 30)) ? 30 : size(message) - (60 + (me.lineOffset * 30))); me.L2[0] = substr(message, numberExtraChar + 60, 30);
} }
if (size(message) > 90) { if (size(message) > 90) {
me.L3[1] = left(split(me.L2[0], message)[1], size(message) > (120 + (me.lineOffset * 30)) ? 30 : size(message) - (90 + (me.lineOffset * 30))); me.L3[1] = substr(message, numberExtraChar + 90, 30);
} }
if (size(message) > 120) { if (size(message) > 120) {
me.L3[0] = left(split(me.L3[1], message)[1], size(message) > (150 + (me.lineOffset * 30)) ? 30 : size(message) - (120 + (me.lineOffset * 30))); me.L3[0] = substr(message, numberExtraChar + 120, 30);
} }
if (size(message) > 150) { if (size(message) > 150) {
me.L4[1] = left(split(me.L3[0], message)[1], size(message) > (180 + (me.lineOffset * 30)) ? 30 : size(message) - (150 + (me.lineOffset * 30))); me.L4[1] = substr(message, numberExtraChar + 150, 30);
} }
if (size(message) > 180) { if (size(message) > 180) {
me.L4[0] = left(split(me.L4[1], message)[1], size(message) > (210 + (me.lineOffset * 30)) ? 30 : size(message) - (180 + (me.lineOffset * 30))); me.L4[0] = substr(message, numberExtraChar + 180, 30);
} }
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0); canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
}, },
}; };

View file

@ -856,6 +856,8 @@ var lskbutton = func(btn, i) {
pageNode[i].setValue("COMMMENU"); pageNode[i].setValue("COMMMENU");
} else if (page == "ATIS") { } else if (page == "ATIS") {
pageNode[i].setValue("ATCMENU2"); pageNode[i].setValue("ATCMENU2");
} else if (page == "ATISDETAIL") {
pageNode[i].setValue("ATIS");
} else { } else {
mcdu_message(i, "NOT ALLOWED"); mcdu_message(i, "NOT ALLOWED");
} }

View file

@ -324,6 +324,7 @@ var ATIS = {
raw = split('"}', raw)[0]; raw = split('"}', raw)[0];
} }
} }
var code = ""; var code = "";
if (find("INFO ", raw) != -1) { if (find("INFO ", raw) != -1) {
code = split("INFO ", raw)[1]; code = split("INFO ", raw)[1];
@ -367,12 +368,13 @@ var ATIS = {
} else if (find("Z SPECIAL", raw) != -1) { } else if (find("Z SPECIAL", raw) != -1) {
time = split("Z SPECIAL", raw)[0]; time = split("Z SPECIAL", raw)[0];
time = right(time, 4); 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) { } else if (find("metreport", raw) != -1) {
time = split("metreport", raw)[0]; time = split("metreport", raw)[0];
time = right(time, 4); time = right(time, 4);
} else if (find((code ~ " "), raw) != -1) {
if (size(split(" ",split(code ~ " ", raw)[1])[0]) == 4) {
time = split(" ",split(code ~ " ", raw)[1])[0];
}
} else { } else {
print("Failed to find a valid ATIS time for " ~ me.station); print("Failed to find a valid ATIS time for " ~ me.station);
debug.dump(raw); debug.dump(raw);
@ -381,6 +383,8 @@ var ATIS = {
if (size(time) == 3) { if (size(time) == 3) {
time ~= " "; time ~= " ";
} }
debug.dump(code);
debug.dump(time);
settimer(func() { settimer(func() {
me.sent = 0; me.sent = 0;
me.received = 1; me.received = 1;