1
0
Fork 0

Ability to get METAR in MCDU

This commit is contained in:
legoboyvdlp R 2020-07-30 21:03:25 +01:00
parent 4aa039f671
commit 76ce5deae2
3 changed files with 72 additions and 60 deletions

View file

@ -631,7 +631,6 @@ var canvas_MCDU_base = {
me["Simple_L1"].setText(" WEATHER TYPE");
me["Simple_L1S"].setText(" " ~ atsu.AOC.selectedType);
me["Simple_L6"].setText(" RETURN");
me["Simple_R1S"].setText("STA 1 ");
me["Simple_R2"].setText("[ ]");
me["Simple_R2S"].setText("STA 2 ");
@ -660,6 +659,10 @@ var canvas_MCDU_base = {
me["Simple_R1"].setText("[ ]");
me["WEATHERREQSEND"].hide();
}
me._receivedTime = left(getprop("/sim/time/gmt-string"), 5);
me.receivedTime = split(":", me._receivedTime)[0] ~ "." ~ split(":", me._receivedTime)[1] ~ "Z";
me["Simple_L6"].setText(" RETURN " ~ me.receivedTime);
} else if (page == "WEATHERTYPE") {
if (!pageSwitch[i].getBoolValue()) {
me.defaultHide();
@ -689,7 +692,7 @@ var canvas_MCDU_base = {
}
} else if (page == "RECEIVEDMSGS") {
if (!pageSwitch[i].getBoolValue()) {
me.defaultHideWithCenter();
me.defaultHide();
me["Simple_Title"].show();
me["arrowsDepArr"].hide();
me.hideAllArrowsButL6();
@ -700,8 +703,6 @@ var canvas_MCDU_base = {
me.fontLeft(default, default, default, default, default, default);
me.fontLeftS(default, default, default, default, default, default);
me.fontCenter(default, default, default, default, default, default);
me.fontCenterS(default, default, default, default, default, default);
me.fontRight(default, default, default, default, default, default);
me.fontRightS(default, default, default, default, default, default);
@ -712,14 +713,18 @@ var canvas_MCDU_base = {
me.colorLeftS("wht", "wht", "wht", "wht", "wht", "wht");
me.colorRightS("wht", "wht", "wht", "wht", "wht", "wht");
me.showRight(-1, -1, -1, -1, -1, -1);
me.showRightS(-1, -1, -1, -1, -1, -1);
me.showRightArrow(-1, -1, -1, -1, -1, -1);
if (myReceivedMessages[i] != nil) {
me["Simple_Title"].setText(sprintf("%s", myReceivedMessages[i].title));
me["Simple_L6_Arrow"].setColor(getprop("/MCDUC/colors/" ~ myReceivedMessages[i].arrowsColour[0][5] ~ "/r"), getprop("/MCDUC/colors/" ~ myReceivedMessages[i].arrowsColour[0][5] ~ "/g"), getprop("/MCDUC/colors/" ~ myReceivedMessages[i].arrowsColour[0][5] ~ "/b"));
if (mcdu.receivedMessagesDatabase.getCountPages() > 1) {
if (mcdu.ReceivedMessagesDatabase.getCountPages() > 1) {
me["Simple_PageNum"].show();
me["Simple_PageNum"].setText(myReceivedMessages.getPageNumStr());
me["Simple_PageNum"].setText(myReceivedMessages[i].getPageNumStr());
me["ArrowLeft"].show();
me["ArrowRight"].show();
} else {
@ -729,38 +734,24 @@ var canvas_MCDU_base = {
}
me.dynamicPageFontFunc(myReceivedMessages[i]);
me.dynamicPageArrowFunc(myReceivedMessages[i]);
me.dynamicPageFunc(myReceivedMessages[i].L1, "Simple_L1");
me.dynamicPageFunc(myReceivedMessages[i].L2, "Simple_L2");
me.dynamicPageFunc(myReceivedMessages[i].L3, "Simple_L3");
me.dynamicPageFunc(myReceivedMessages[i].L4, "Simple_L4");
me.dynamicPageFunc(myReceivedMessages[i].L5, "Simple_L5");
me.dynamicPageFunc(myReceivedMessages[i].L6, "Simple_L6");
me["Simple_L6"].setColor(WHITE);
me.colorLeft(myReceivedMessages[i].L1[2],myReceivedMessages[i].L2[2],myReceivedMessages[i].L3[2],myReceivedMessages[i].L4[2],myReceivedMessages[i].L5[2],myReceivedMessages[i].L6[2]);
me.dynamicPageFunc(myReceivedMessages[i].C1, "Simple_C1");
me.dynamicPageFunc(myReceivedMessages[i].C2, "Simple_C2");
me.dynamicPageFunc(myReceivedMessages[i].C3, "Simple_C3");
me.dynamicPageFunc(myReceivedMessages[i].C4, "Simple_C4");
me.dynamicPageFunc(myReceivedMessages[i].C5, "Simple_C5");
me.colorCenter(myReceivedMessages[i].C1[2],myReceivedMessages[i].C2[2],myReceivedMessages[i].C3[2],myReceivedMessages[i].C4[2],myReceivedMessages[i].C5[2],myReceivedMessages[i].C6[2]);
me["Simple_C6"].hide();
me["Simple_C6S"].hide();
me.dynamicPageFunc(myReceivedMessages[i].R1, "Simple_R1");
me.dynamicPageFunc(myReceivedMessages[i].R2, "Simple_R2");
me.dynamicPageFunc(myReceivedMessages[i].R3, "Simple_R3");
me.dynamicPageFunc(myReceivedMessages[i].R4, "Simple_R4");
me.dynamicPageFunc(myReceivedMessages[i].R5, "Simple_R5");
me.dynamicPageFunc(myReceivedMessages[i].R6, "Simple_R6");
me.colorRight(myReceivedMessages[i].R1[2],myReceivedMessages[i].R2[2],myReceivedMessages[i].R3[2],myReceivedMessages[i].R4[2],myReceivedMessages[i].R5[2],myReceivedMessages[i].R6[2]);
}
pageSwitch[i].setBoolValue(1);
}
if (myReceivedMessages[i] != nil) {
me._receivedTime = left(getprop("/sim/time/gmt-string"), 5);
me.receivedTime = split(":", me._receivedTime)[0] ~ "." ~ split(":", me._receivedTime)[1] ~ "Z";
me["Simple_L6"].setText(" RETURN " ~ me.receivedTime);
}
} else if (page == "ATCMENU") {
if (!pageSwitch[i].getBoolValue()) {
me.defaultHide();

View file

@ -18,7 +18,7 @@ var receivedMessagesPage = {
computer: nil,
size: 0,
getPageNumStr: func() {
return me.curPage ~ "/" ~ receivedMessagesDatabase.getCountPages();
return me.curPage ~ "/" ~ ReceivedMessagesDatabase.getCountPages();
},
new: func(computer) {
var ap = {parents:[receivedMessagesPage]};
@ -34,14 +34,16 @@ var receivedMessagesPage = {
scrollLeft: func() {
me.curPage -= 1;
if (me.curPage < 1) {
me.curPage = receivedMessagesDatabase.getCountPages();
me.curPage = ReceivedMessagesDatabase.getCountPages();
}
me.update();
},
scrollRight: func() {
me.curPage += 1;
if (me.curPage > receivedMessagesDatabase.getCountPages()) {
if (me.curPage > ReceivedMessagesDatabase.getCountPages()) {
me.curPage = 1;
}
me.update();
},
_clearPage: func() {
me.L1 = [nil, nil, "ack"];
@ -57,10 +59,10 @@ var receivedMessagesPage = {
me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]];
},
_setupPageWithData: func() {
me.title = "RECEIVED MESSAGES";
me.title = "RECEIVED MESSAGES ";
me.L6 = [" RETURN", nil, "wht"];
me.arrowsMatrix = [[0, 0, 0, 0, 0, 1], [0, 0, 0, 0, 0, 0]];
me.arrowsColour = [["wht", "wht", "wht", "wht", "wht", "wht"], ["ack", "ack", "ack", "ack", "ack", "ack"]];
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);
},
@ -70,64 +72,65 @@ var receivedMessagesPage = {
var message = nil;
if (me.size >= (me.curPage * 5) + -4) {
message = ReceivedMessagesDatabase.database[-5 + (me.curPage * 5)];
me.L1[0] = left(message.body, 16);
me.L1[2] = "wht";
message = ReceivedMessagesDatabase.database.vector[-5 + (me.curPage * 5)];
me.L1[0] = " " ~ left(message.body, 23);
me.L1[2] = "blu";
if (!message.viewed) {
me.L1[1] = message.time ~ " NEW";
me.L1[1] = " " ~ message.time ~ " NEW";
} else {
me.L1[1] = message.time ~ " VIEWED";
me.L1[1] = " " ~ message.time ~ " VIEWED";
}
me.arrowsMatrix[0][0] = 1;
}
if (me.size >= (me.curPage * 5) + -3) {
message = ReceivedMessagesDatabase.database[-4 + (me.curPage * 5)];
me.L2[0] = left(message.body, 16);
me.L2[2] = "wht";
message = ReceivedMessagesDatabase.database.vector[-4 + (me.curPage * 5)];
me.L2[0] = " " ~ left(message.body, 23);
me.L2[2] = "blu";
if (!message.viewed) {
me.L2[1] = message.time ~ " NEW";
me.L2[1] = " " ~ message.time ~ " NEW";
} else {
me.L2[1] = message.time ~ " VIEWED";
me.L2[1] = " " ~ message.time ~ " VIEWED";
}
me.arrowsMatrix[0][1] = 1;
}
if (me.size >= (me.curPage * 5) + -2) {
message = ReceivedMessagesDatabase.database[-3 + (me.curPage * 5)];
me.L3[0] = left(message.body, 16);
me.L3[2] = "wht";
message = ReceivedMessagesDatabase.database.vector[-3 + (me.curPage * 5)];
me.L3[0] = " " ~ left(message.body, 23);
me.L3[2] = "blu";
if (!message.viewed) {
me.L3[1] = message.time ~ " NEW";
me.L3[1] = " " ~ message.time ~ " NEW";
} else {
me.L3[1] = message.time ~ " VIEWED";
me.L3[1] = " " ~ message.time ~ " VIEWED";
}
me.arrowsMatrix[0][2] = 1;
}
if (me.size >= (me.curPage * 5) + -1) {
message = ReceivedMessagesDatabase.database[-2 + (me.curPage * 5)];
me.L4[0] = left(message.body, 16);
me.L4[2] = "wht";
message = ReceivedMessagesDatabase.database.vector[-2 + (me.curPage * 5)];
me.L4[0] = " " ~ left(message.body, 23);
me.L4[2] = "blu";
if (!message.viewed) {
me.L4[1] = message.time ~ " NEW";
me.L4[1] = " " ~ message.time ~ " NEW";
} else {
me.L4[1] = message.time ~ " VIEWED";
me.L4[1] = " " ~ message.time ~ " VIEWED";
}
me.arrowsMatrix[0][3] = 1;
}
if (me.size >= (me.curPage * 5) + 0) {
message = ReceivedMessagesDatabase.database[-1 + (me.curPage * 5)];
me.L5[0] = left(message.body, 16);
me.L5[2] = "wht";
message = ReceivedMessagesDatabase.database.vector[-1 + (me.curPage * 5)];
me.L5[0] = " " ~ left(message.body, 23);
me.L5[2] = "blu";
if (!message.viewed) {
me.L5[1] = message.time ~ " NEW";
me.L5[1] = " " ~ message.time ~ " NEW";
} else {
me.L5[1] = message.time ~ " VIEWED";
me.L5[1] = " " ~ message.time ~ " VIEWED";
}
me.arrowsMatrix[0][4] = 1;
}
canvas_mcdu.pageSwitch[me.computer].setBoolValue(0);
},
};
@ -137,16 +140,23 @@ var ACARSMessage = {
message.time = time;
message.body = body;
message.viewed = 0;
return message;
},
};
var ReceivedMessagesDatabase = {
database: std.Vector.new(),
addMessage: func(message) {
me.database.insert(message);
me.database.insert(0, message);
if (canvas_mcdu.myReceivedMessages[0] != nil) {
canvas_mcdu.myReceivedMessages[0].update();
}
if (canvas_mcdu.myReceivedMessages[1] != nil) {
canvas_mcdu.myReceivedMessages[1].update();
}
},
getCountPages: func() {
return math.ceil(me.database.size() / 4);
return math.ceil(me.database.size() / 5);
},
getSize: func() {
return me.database.size();

View file

@ -99,6 +99,7 @@ var AOC = {
sent: 0,
sentTime: nil,
received: 0,
receivedTime: nil,
newStation: func(airport) {
if (size(airport) == 3 or size(airport) == 4) {
if (size(findAirportsByICAO(airport)) == 0) {
@ -163,6 +164,11 @@ var AOC = {
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.lastMETAR);
mcdu.ReceivedMessagesDatabase.addMessage(message);
}, math.max(rand()*6, 2.25));
},
processTAF: func(r, i) {
@ -173,6 +179,11 @@ var AOC = {
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.lastTAF);
mcdu.ReceivedMessagesDatabase.addMessage(message);
}, math.max(rand()*6, 2.25));
},
};