2020-04-30 19:26:36 +00:00
# A3XX mCDU by Joshua Davidson (Octal450), Jonathan Redpath, and Matthew Maring (mattmaring)
2019-10-14 16:48:35 +00:00
2020-04-30 19:26:36 +00:00
# Copyright (c) 2020 Matthew Maring (mattmaring)
2020-03-23 03:02:25 +00:00
2020-09-19 13:43:44 +00:00
var acconfig_weight_kgs = props.globals.getNode("/systems/acconfig/options/weight-kgs", 1);
# Conversion factor pounds to kilogram
var LBS2KGS = 0.4535924;
2019-10-14 16:48:35 +00:00
var initInputB = func(key, i) {
2020-05-23 00:40:01 +00:00
var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad;
2020-10-03 09:59:43 +00:00
if (key == "L1" and !fmgc.FMGCInternal.fuelCalculating) {
2020-03-28 20:40:02 +00:00
if (scratchpad == "CLR") {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.taxiFuel = 0.4;
fmgc.FMGCInternal.taxiFuelSet = 0;
2020-10-03 09:59:43 +00:00
if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
} else if (fmgc.FMGCInternal.fuelRequest) {
fmgc.FMGCInternal.blockCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(1);
2020-05-02 00:26:05 +00:00
}
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-09-19 13:43:44 +00:00
} else {
2020-03-28 20:40:02 +00:00
var tfs = size(scratchpad);
2020-09-19 13:43:44 +00:00
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
2020-03-28 20:40:02 +00:00
if (tfs >= 1 and tfs <= 4) {
2020-04-14 22:12:38 +00:00
if (num(scratchpad) != nil and scratchpad >= 0.0 and scratchpad <= 9.9) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.taxiFuel = scratchpad;
fmgc.FMGCInternal.taxiFuelSet = 1;
2020-10-03 09:59:43 +00:00
if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
} else if (fmgc.FMGCInternal.fuelRequest) {
fmgc.FMGCInternal.blockCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(1);
2020-06-27 11:11:53 +00:00
}
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-03-23 03:02:25 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-03-23 03:02:25 +00:00
}
2020-03-28 20:40:02 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-08-01 13:57:19 +00:00
}
2020-03-28 20:40:02 +00:00
}
2020-10-03 09:59:43 +00:00
} else if (key == "L3" and fmgc.FMGCInternal.blockConfirmed and !fmgc.FMGCInternal.fuelCalculating) {
2020-03-28 20:40:02 +00:00
if (scratchpad == "CLR") {
2020-08-01 16:49:54 +00:00
fmgc.FMGCInternal.rteRsv = 0.05 * fmgc.FMGCInternal.tripFuel;
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.rteRsvSet = 0;
fmgc.FMGCInternal.rtePercent = 5.0;
fmgc.FMGCInternal.rtePercentSet = 0;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-08-01 13:57:19 +00:00
} else if (fmgc.FMGCInternal.tripFuel != 0) {
2020-04-14 22:12:38 +00:00
var tf = num(scratchpad);
2020-09-19 13:43:44 +00:00
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
2020-03-23 03:02:25 +00:00
var tfs = size(scratchpad);
if (tfs >= 2 and tfs <= 5 and find("/", scratchpad) == 0) {
2020-03-30 01:27:18 +00:00
var perc = num(split("/", scratchpad)[1]);
2020-04-14 22:12:38 +00:00
if (perc != nil and perc >= 0.0 and perc <= 15.0) {
2020-08-01 16:49:54 +00:00
fmgc.FMGCInternal.rteRsv = perc / 100 * fmgc.FMGCInternal.tripFuel;
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.rteRsvSet = 0;
fmgc.FMGCInternal.rtePercent = perc;
fmgc.FMGCInternal.rtePercentSet = 1;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-03-23 03:02:25 +00:00
}
2020-05-03 20:00:58 +00:00
} else if (tfs >= 1 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 21.7) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.rteRsv = scratchpad;
fmgc.FMGCInternal.rteRsvSet = 1;
2020-08-01 16:49:54 +00:00
if (scratchpad / fmgc.FMGCInternal.tripFuel * 100 <= 15.0) {
fmgc.FMGCInternal.rtePercent = scratchpad / fmgc.FMGCInternal.tripFuel * 100;
2020-05-03 20:00:58 +00:00
} else {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.rtePercent = 15.0; # need reasearch on this value
2020-05-03 20:00:58 +00:00
}
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.rtePercentSet = 0;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-03-23 03:02:25 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-03-23 03:02:25 +00:00
}
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-03-28 20:40:02 +00:00
}
2020-10-03 09:59:43 +00:00
} else if (key == "L4" and fmgc.FMGCInternal.blockConfirmed and !fmgc.FMGCInternal.fuelCalculating and fmgc.FMGCInternal.altAirportSet) {
2020-03-28 20:40:02 +00:00
if (scratchpad == "CLR") {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.altFuel = 0.0;
fmgc.FMGCInternal.altTime = "0000";
fmgc.FMGCInternal.altFuelSet = 0;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-04-14 22:12:38 +00:00
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
2020-09-19 13:43:44 +00:00
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
2020-04-14 22:12:38 +00:00
var tfs = size(scratchpad);
2020-05-02 00:26:05 +00:00
if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.altFuel = tf;
fmgc.FMGCInternal.altTime = "0000";
fmgc.FMGCInternal.altFuelSet = 1;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-04-14 22:12:38 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-04-14 22:12:38 +00:00
}
2020-03-28 20:40:02 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-03-28 20:40:02 +00:00
}
2020-10-03 09:59:43 +00:00
} else if (key == "L5" and fmgc.FMGCInternal.blockConfirmed and !fmgc.FMGCInternal.fuelCalculating) {
2020-03-28 20:40:02 +00:00
if (scratchpad == "CLR") {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.finalFuel = 0.0;
fmgc.FMGCInternal.finalTime = "0030";
fmgc.FMGCInternal.finalFuelSet = 0;
fmgc.FMGCInternal.finalTimeSet = 0;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-04-14 22:12:38 +00:00
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
2020-09-19 13:43:44 +00:00
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
2020-04-14 22:12:38 +00:00
var tfs = size(scratchpad);
2020-05-02 00:26:05 +00:00
if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.finalFuel = tf;
fmgc.FMGCInternal.finalFuelSet = 1;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-04-14 22:12:38 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-04-14 22:12:38 +00:00
}
2020-03-28 20:40:02 +00:00
} else {
2020-04-14 22:12:38 +00:00
var tf = num(scratchpad);
2020-03-28 20:40:02 +00:00
var tfs = size(scratchpad);
2020-04-14 22:12:38 +00:00
if (tfs == 4 and tf != nil and ((tf >= 0 and tf <= 59) or (tf >= 100 and tf <= 130))) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.finalTime = scratchpad;
fmgc.FMGCInternal.finalTimeSet = 1;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-03-28 20:40:02 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-03-28 20:40:02 +00:00
}
}
2020-10-03 09:59:43 +00:00
} else if (key == "L6" and fmgc.FMGCInternal.blockConfirmed and !fmgc.FMGCInternal.fuelCalculating) {
2020-05-02 00:55:22 +00:00
if (scratchpad == "CLR") {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.minDestFob = 0;
fmgc.FMGCInternal.minDestFobSet = 0;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-05-02 00:55:22 +00:00
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
2020-09-19 13:43:44 +00:00
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
2020-05-02 00:55:22 +00:00
var tfs = size(scratchpad);
if (tfs >= 3 and tfs <= 5 and tf != nil and tf >= 0 and tf <= 80.0) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.minDestFob = tf;
fmgc.FMGCInternal.minDestFobSet = 1;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-08-01 16:49:54 +00:00
if (fmgc.FMGCInternal.minDestFob < fmgc.FMGCInternal.finalFuel + fmgc.FMGCInternal.altFuel) {
2020-08-01 13:57:19 +00:00
mcdu_message(i, "CHECK MIN DEST FOB");
2020-05-02 00:55:22 +00:00
}
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-05-02 00:55:22 +00:00
}
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-05-02 00:55:22 +00:00
}
2020-10-03 09:59:43 +00:00
} else if (key == "R1" and !fmgc.FMGCInternal.fuelCalculating) {
2019-10-14 16:48:35 +00:00
if (scratchpad == "CLR") {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2019-10-14 16:48:35 +00:00
} else {
2020-06-26 21:11:27 +00:00
var zfw_min = 80.6; #make based on performance
2020-06-26 21:35:48 +00:00
var zfw_max = 134.5; #61,000 kg, make based on performance
2020-09-19 13:43:44 +00:00
2020-06-26 21:11:27 +00:00
if (size(scratchpad) == 0) {
2020-10-03 09:59:43 +00:00
var zfw = pts.Fdm.JSBsim.Inertia.weightLbs.getValue() - pts.Consumables.Fuel.totalFuelLbs.getValue();
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.zfw = sprintf("%3.1f", math.round(zfw / 1000, 0.1));
fmgc.FMGCInternal.zfwSet = 1;
2020-10-03 09:59:43 +00:00
if (!fmgc.FMGCInternal.blockConfirmed and fmgc.FMGCInternal.blockSet) {
2020-08-01 16:49:54 +00:00
fmgc.FMGCInternal.tow = fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelRequest = 1;
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockCalculating = 0;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(0);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockConfirmed = 1;
} else if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
} else if (fmgc.FMGCInternal.fuelRequest) {
fmgc.FMGCInternal.blockCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(1);
2020-05-18 18:53:42 +00:00
}
2020-06-26 21:11:27 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2022-01-25 12:30:35 +00:00
perfTOCheckVSpeedsLimitations(i);
2020-06-26 21:11:27 +00:00
} else if (find("/", scratchpad) != -1) {
2020-09-19 13:43:44 +00:00
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
2019-10-14 16:48:35 +00:00
var zfwi = split("/", scratchpad);
2020-06-26 21:11:27 +00:00
var zfw = num(zfwi[0]);
var zfwcg = num(zfwi[1]);
var zfws = size(zfwi[0]);
var zfwcgs = size(zfwi[1]);
2020-08-03 21:47:30 +00:00
if (zfw != nil and zfws > 0 and zfws <= 5 and (find(".", zfwi[0]) == -1 or size(split(".", zfwi[0])[1]) <= 1) and zfwcg != nil and zfwcgs > 0 and zfwcgs <= 4 and (find(".", zfwi[1]) == -1 or size(split(".", zfwi[1])[1]) <= 1)) {
2020-06-26 21:11:27 +00:00
if (zfw >= zfw_min and zfw <= zfw_max and zfwcg >= 8.0 and zfwcg <= 45.0) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.zfw = zfw;
fmgc.FMGCInternal.zfwSet = 1;
fmgc.FMGCInternal.zfwcg = zfwcg;
fmgc.FMGCInternal.zfwcgSet = 1;
2020-10-03 09:59:43 +00:00
if (!fmgc.FMGCInternal.blockConfirmed and fmgc.FMGCInternal.blockSet) {
2020-08-01 16:49:54 +00:00
fmgc.FMGCInternal.tow = fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelRequest = 1;
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockCalculating = 0;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(0);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockConfirmed = 1;
} else if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
} else if (fmgc.FMGCInternal.fuelRequest) {
fmgc.FMGCInternal.blockCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(1);
2020-06-26 21:11:27 +00:00
}
mcdu_scratchpad.scratchpads[i].empty();
2022-01-25 12:30:35 +00:00
perfTOCheckVSpeedsLimitations(i);
2020-06-26 21:11:27 +00:00
} else {
mcdu_message(i, "ENTRY OUT OF RANGE");
}
2020-08-03 21:47:30 +00:00
} else if (zfws == 0 and zfwcg != nil and zfwcgs > 0 and zfwcgs <= 4 and (find(".", zfwi[1]) == -1 or size(split(".", zfwi[1])[1]) <= 1)) {
2020-06-26 21:11:27 +00:00
if (zfwcg >= 8.0 and zfwcg <= 45.0) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.zfwcg = zfwcg;
fmgc.FMGCInternal.zfwcgSet = 1;
2020-06-26 21:11:27 +00:00
mcdu_scratchpad.scratchpads[i].empty();
} else {
mcdu_message(i, "ENTRY OUT OF RANGE");
}
} else {
mcdu_message(i, "NOT ALLOWED");
2019-10-14 16:48:35 +00:00
}
2020-08-03 21:47:30 +00:00
} else if (num(scratchpad) != nil and size(scratchpad) > 0 and size(scratchpad) <= 5 and (find(".", scratchpad) == -1 or size(split(".", scratchpad)[1]) <= 1)) {
2020-09-19 13:43:44 +00:00
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
2020-06-26 21:11:27 +00:00
if (scratchpad >= zfw_min and scratchpad <= zfw_max) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.zfw = scratchpad;
fmgc.FMGCInternal.zfwSet = 1;
2020-10-03 09:59:43 +00:00
if (!fmgc.FMGCInternal.blockConfirmed and fmgc.FMGCInternal.blockSet) {
2020-08-01 16:49:54 +00:00
fmgc.FMGCInternal.tow = fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel;
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelRequest = 1;
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockCalculating = 0;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(0);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockConfirmed = 1;
} else if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
} else if (fmgc.FMGCInternal.fuelRequest) {
fmgc.FMGCInternal.blockCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(1);
2020-05-02 00:26:05 +00:00
}
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2022-01-25 12:30:35 +00:00
perfTOCheckVSpeedsLimitations(i);
2019-10-14 16:48:35 +00:00
} else {
2020-06-26 21:11:27 +00:00
mcdu_message(i, "ENTRY OUT OF RANGE");
2019-10-14 16:48:35 +00:00
}
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2019-10-14 16:48:35 +00:00
}
2020-06-29 21:17:19 +00:00
2020-07-10 19:54:13 +00:00
if (!fmgc.FMGCInternal.costIndexSet and fmgc.FMGCInternal.toFromSet) {
2020-06-29 21:17:19 +00:00
mcdu_message(i, "USING COST INDEX N", getprop("/FMGC/internal/last-cost-index") or 0);
2020-07-10 19:54:13 +00:00
fmgc.FMGCInternal.costIndexSet = 1;
fmgc.FMGCInternal.costIndex = getprop("/FMGC/internal/last-cost-index") or 0;
2020-07-11 14:04:12 +00:00
fmgc.FMGCNodes.costIndex.setValue(fmgc.FMGCInternal.costIndex);
2020-06-29 21:17:19 +00:00
}
2019-10-14 16:48:35 +00:00
}
2020-10-03 09:59:43 +00:00
} else if (key == "R2" and !fmgc.FMGCInternal.fuelCalculating) {
2019-10-14 16:48:35 +00:00
if (scratchpad == "CLR") {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.block = 0.0;
fmgc.FMGCInternal.blockSet = 0;
fmgc.FMGCInternal.taxiFuel = 0.4;
fmgc.FMGCInternal.taxiFuelSet = 0;
fmgc.FMGCInternal.tripFuel = 0;
fmgc.FMGCInternal.tripTime = "0000";
fmgc.FMGCInternal.rteRsv = 0;
fmgc.FMGCInternal.rteRsvSet = 0;
fmgc.FMGCInternal.rtePercent = 5.0;
fmgc.FMGCInternal.rtePercentSet = 0;
fmgc.FMGCInternal.altFuel = 0;
fmgc.FMGCInternal.altFuelSet = 0;
fmgc.FMGCInternal.altTime = "0000";
fmgc.FMGCInternal.finalFuel = 0;
fmgc.FMGCInternal.finalFuelSet = 0;
fmgc.FMGCInternal.finalTime = "0030";
fmgc.FMGCInternal.finalTimeSet = 0;
fmgc.FMGCInternal.minDestFob = 0;
fmgc.FMGCInternal.minDestFobSet = 0;
fmgc.FMGCInternal.tow = 0;
fmgc.FMGCInternal.lw = 0;
fmgc.FMGCInternal.tripWind = "HD000";
fmgc.FMGCInternal.tripWindValue = 0;
fmgc.FMGCInternal.fffqSensor = "FF+FQ";
fmgc.FMGCInternal.extraFuel = 0;
fmgc.FMGCInternal.extraTime = "0000";
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelRequest = 0;
fmgc.FMGCInternal.fuelCalculating = 0;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(0);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockCalculating = 0;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(0);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockConfirmed = 0;
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2019-10-14 16:48:35 +00:00
} else {
var tfs = size(scratchpad);
2020-05-02 00:26:05 +00:00
var maxblock = getprop("/options/maxblock");
2019-10-14 16:48:35 +00:00
if (tfs == 0) {
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.block = sprintf("%3.1f", math.round(pts.Consumables.Fuel.totalFuelLbs.getValue() / 1000, 0.1));
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.blockSet = 1;
if (fmgc.FMGCInternal.zfwSet) {
fmgc.FMGCInternal.tow = num(fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelRequest = 1;
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockCalculating = 0;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(0);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockConfirmed = 1;
2020-05-18 18:53:42 +00:00
}
2019-10-14 16:48:35 +00:00
} else if (tfs >= 1 and tfs <= 5) {
2020-09-19 13:43:44 +00:00
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
2020-03-30 01:27:18 +00:00
if (num(scratchpad) != nil and scratchpad >= 1.0 and scratchpad <= maxblock) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.block = scratchpad;
fmgc.FMGCInternal.blockSet = 1;
if (fmgc.FMGCInternal.zfwSet) {
fmgc.FMGCInternal.tow = num(fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.fuelRequest = 1;
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockCalculating = 0;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(0);
2020-10-03 09:59:43 +00:00
fmgc.FMGCInternal.blockConfirmed = 1;
2020-05-18 18:30:43 +00:00
}
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2019-10-14 16:48:35 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2019-10-14 16:48:35 +00:00
}
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2019-10-14 16:48:35 +00:00
}
}
2020-03-23 14:59:05 +00:00
} else if (key == "R3") {
2020-10-03 09:59:43 +00:00
if (scratchpad == "" and fmgc.FMGCInternal.zfwSet and !fmgc.FMGCInternal.fuelRequest) {
fmgc.FMGCInternal.fuelRequest = 1;
fmgc.FMGCInternal.blockCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.blockCalculating.setValue(1);
2020-10-03 09:59:43 +00:00
} else if (scratchpad == "" and fmgc.FMGCInternal.zfwSet and fmgc.FMGCInternal.fuelRequest and !fmgc.FMGCInternal.blockConfirmed and !fmgc.FMGCInternal.blockCalculating) {
fmgc.FMGCInternal.blockConfirmed = 1;
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-04-20 16:18:41 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-03-28 20:40:02 +00:00
}
2020-10-03 09:59:43 +00:00
} else if (key == "R5" and !fmgc.FMGCInternal.fuelCalculating) {
2020-04-14 22:12:38 +00:00
if (scratchpad == "CLR") {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.tripWind = "HD000";
fmgc.FMGCInternal.tripWindValue = 0;
2020-10-03 09:59:43 +00:00
if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-02 00:26:05 +00:00
}
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-04-14 22:12:38 +00:00
} else {
if (find("TL", scratchpad) != -1 or find("HD", scratchpad) != -1) {
var effwind = substr(scratchpad, 2);
if (int(effwind) != nil and effwind >= 0 and effwind <= 500) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.tripWind = scratchpad;
fmgc.FMGCInternal.tripWindValue = effwind;
2020-10-03 09:59:43 +00:00
if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-02 00:26:05 +00:00
}
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-04-14 22:12:38 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-04-14 22:12:38 +00:00
}
} else if (find("-", scratchpad) != -1 or find("+", scratchpad) != -1 or find("T", scratchpad) != -1 or find("H", scratchpad) != -1) {
var effwind = substr(scratchpad, 1);
if (int(effwind) != nil and effwind >= 0 and effwind <= 500) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.tripWind = scratchpad;
fmgc.FMGCInternal.tripWindValue = effwind;
2020-10-03 09:59:43 +00:00
if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-02 00:26:05 +00:00
}
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-04-14 22:12:38 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-04-14 22:12:38 +00:00
}
} else {
if (num(scratchpad) != nil and scratchpad >= 0 and scratchpad <= 500) {
2020-08-01 13:57:19 +00:00
fmgc.FMGCInternal.tripWind = scratchpad;
fmgc.FMGCInternal.tripWindValue = scratchpad;
2020-10-03 09:59:43 +00:00
if (fmgc.FMGCInternal.blockConfirmed) {
fmgc.FMGCInternal.fuelCalculating = 1;
2020-10-03 11:34:29 +00:00
fmgc.fuelCalculating.setValue(1);
2020-05-02 00:26:05 +00:00
}
2020-05-23 11:16:20 +00:00
mcdu_scratchpad.scratchpads[i].empty();
2020-04-14 22:12:38 +00:00
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2020-04-14 22:12:38 +00:00
}
}
}
} else {
2020-05-23 11:16:20 +00:00
mcdu_message(i, "NOT ALLOWED");
2019-10-14 16:48:35 +00:00
}
}