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",
"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",
"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() {
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["ATISSend4"].hide();
}
if (page != "ATISDETAIL") {
me["ATISArrows"].hide();
}
if (page == "F-PLNA" or page == "F-PLNB") {
if (!pageSwitch[i].getBoolValue()) {
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]);
}
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);
}
} else if (page == "ATIS") {

View file

@ -41,13 +41,13 @@
inkscape:window-height="705"
id="namedview371"
showgrid="true"
inkscape:zoom="17.863704"
inkscape:cx="1222.2874"
inkscape:cy="575.96236"
inkscape:zoom="3.1578866"
inkscape:cx="1122.1906"
inkscape:cy="986.92422"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="PERFAPPR"
inkscape:current-layer="svg2"
showguides="false"
inkscape:snap-global="false"
units="px"
@ -3189,64 +3189,117 @@
d="m 974.36752,294.79468 20.17349,-20.1735"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
transform="matrix(1.0807111,0,0,1.0807111,-76.462145,213.12578)"
inkscape:label="#g4324"
id="ATISSend4"
style="stroke:#179ab7;stroke-opacity:1">
<path
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 998.71909,284.70793 H 970.18944"
id="path1331"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1333"
d="m 994.54102,294.79468 -20.17351,-20.1735"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 984.45427,298.97275 -10e-6,-28.52964"
id="path1335"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1337"
d="m 974.36752,294.79468 20.17349,-20.1735"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
<g
style="stroke:#179ab7;stroke-opacity:1"
id="ATISSend3"
inkscape:label="#g4324"
transform="matrix(1.0807111,0,0,1.0807111,-76.462145,94.951839)">
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1341"
d="M 998.71909,284.70793 H 970.18944"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 994.54102,294.79468 -20.17351,-20.1735"
id="path1343"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1345"
d="m 984.45427,298.97275 -10e-6,-28.52964"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 974.36752,294.79468 20.17349,-20.1735"
id="path1347"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
</g>
<g
transform="translate(220.36572,-474.55648)"
id="ATISArrows"
inkscape:label="#WIND_UPDOWN">
<g
transform="matrix(1.0807111,0,0,1.0807111,-76.462145,213.12578)"
inkscape:label="#g4324"
id="ATISSend4"
style="stroke:#179ab7;stroke-opacity:1">
id="g1338"
inkscape:label="#g4241"
transform="matrix(0,1,1,0,667.65035,-414.17373)"
style="stroke:#ffffff;stroke-opacity:1">
<path
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 998.71909,284.70793 H 970.18944"
id="path1331"
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="path1333"
d="m 994.54102,294.79468 -20.17351,-20.1735"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 984.45427,298.97275 -10e-6,-28.52964"
id="path1335"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1337"
d="m 974.36752,294.79468 20.17349,-20.1735"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
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:#179ab7;stroke-opacity:1"
id="ATISSend3"
inkscape:label="#g4324"
transform="matrix(1.0807111,0,0,1.0807111,-76.462145,94.951839)">
style="stroke:#ffffff;stroke-opacity:1"
transform="matrix(0,-1,-1,0,801.59015,1459.2436)"
inkscape:label="#g4241"
id="g1346">
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path1341"
d="M 998.71909,284.70793 H 970.18944"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<path
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 994.54102,294.79468 -20.17351,-20.1735"
id="path1343"
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="path1345"
d="m 984.45427,298.97275 -10e-6,-28.52964"
style="fill:none;stroke:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
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:#179ab7;stroke-width:4.07999992;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="m 974.36752,294.79468 20.17349,-20.1735"
id="path1347"
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>

Before

Width:  |  Height:  |  Size: 168 KiB

After

Width:  |  Height:  |  Size: 171 KiB

View file

@ -26,33 +26,38 @@ var atisPage = {
new: func(computer, index) {
var ap = {parents:[atisPage]};
ap.computer = computer;
ap.lineOffset = 0;
ap.page = 1;
ap.index = index;
ap.message = atsu.ATISInstances[index].lastATIS;
ap._setupPageWithData();
ap._numPages = 1;
ap.update();
return ap;
},
del: func() {
return nil;
},
getNumLines: func() {
me._numLines = size(me.message) / 30;
me.lineOffset = math.ceil(me._numLines);
getNumPages: func() {
me._numPages = math.ceil(size(me.message) / 210);
return me._numPages;
},
scrollUp: func() {
me.lineOffset -= 1;
if (me.lineOffset < 0) {
me.lineOffset = me.getNumLines();
print(me.page);
me.page -= 1;
if (me.page < 1) {
me.page = me.getNumPages();
}
me.update();
print(me.page);
},
scrollDown: func() {
me.lineOffset += 1;
if (me.lineOffset > me.getNumLines()) {
me.lineOffset = 1;
print(me.page);
me.page += 1;
if (me.page > me.getNumPages()) {
me.page = 1;
}
me.update();
print(me.page);
},
_clearPage: func() {
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]];
},
_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.L6 = [" RETURN", " ATIS MENU", "wht"];
me.R6 = ["PRINT ", nil, "blu"];
@ -83,30 +87,29 @@ var atisPage = {
update: func() {
me._clearPage();
var message = atsu.ATISInstances[me.index].lastATIS;
var start = left(message, size(message) > (30 + (me.lineOffset * 30)) ? (30 + (me.lineOffset * 30)) : size(message));
start = right(start, 30);
me.L1 = [start, atsu.ATISInstances[me.index].station ~ "/" ~ (atsu.ATISInstances[me.index].type == 0 ? "ARR" : "DEP"), "wht"];
# dictionary for code
var pageMinusOne = (me.page - 1);
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.R1 = [" ",atsu.ATISInstances[me.index].receivedCode ~ " " ~ atsu.ATISInstances[me.index].receivedTime ~ "Z", "wht"];
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) {
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) {
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) {
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) {
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) {
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);
},
};

View file

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

View file

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