1
0
Fork 0

Accept MCDU input in KG

This commit is contained in:
legoboyvdlp R 2020-09-19 14:43:44 +01:00
parent 1240862693
commit 6f0114457d
4 changed files with 57 additions and 5 deletions

View file

@ -243,7 +243,7 @@
</checkbox>
<!-- TODO Comment back in, when fully implemented -->
<!-- checkbox>
<checkbox>
<label>Weight in KG</label>
<halign>left</halign>
<property>/options/system/weight-kgs</property>
@ -261,7 +261,7 @@
</script>
</binding>
<live>true</live>
</checkbox -->
</checkbox>
<checkbox>
<label>ADIRS Aligns Instantly</label>

View file

@ -159,7 +159,7 @@ var active = [props.globals.getNode("/MCDU[0]/active", 1), props.globals.getNode
var activeAtsu = [props.globals.getNode("/MCDU[0]/atsu-active", 1), props.globals.getNode("/MCDU[1]/atsu-active", 1)];
# Conversion factor pounds to kilogram
LBS2KGS = 0.4535924;
var LBS2KGS = 0.4535924;
# Create Nodes:

View file

@ -15,6 +15,9 @@ var fuelPredInput = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
} else if (fmgc.FMGCInternal.tripFuel != 0) {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs >= 2 and tfs <= 5 and find("/", scratchpad) == 0) {
var perc = num(split("/", scratchpad)[1]);
@ -52,6 +55,9 @@ var fuelPredInput = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) {
fmgc.FMGCInternal.altFuel = tf;
@ -75,6 +81,9 @@ var fuelPredInput = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) {
fmgc.FMGCInternal.finalFuel = tf;
@ -86,6 +95,9 @@ var fuelPredInput = func(key, i) {
}
} else {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs == 4 and tf != nil and ((tf >= 0 and tf <= 59) or (tf >= 100 and tf <= 130))) {
fmgc.FMGCInternal.finalTime = scratchpad;
@ -104,6 +116,9 @@ var fuelPredInput = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs >= 3 and tfs <= 5 and tf != nil and tf >= 0 and tf <= 80.0) {
fmgc.FMGCInternal.minDestFob = tf;
@ -142,6 +157,9 @@ var fuelPredInput = func(key, i) {
}
mcdu_scratchpad.scratchpads[i].empty();
} else if (find("/", scratchpad) != -1) {
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
var zfwi = split("/", scratchpad);
var zfw = num(zfwi[0]);
var zfwcg = num(zfwi[1]);
@ -180,6 +198,9 @@ var fuelPredInput = func(key, i) {
mcdu_message(i, "NOT ALLOWED");
}
} else if (num(scratchpad) != nil and size(scratchpad) > 0 and size(scratchpad) <= 5 and (find(".", scratchpad) == -1 or size(split(".", scratchpad)[1]) <= 1)) {
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
if (scratchpad >= zfw_min and scratchpad <= zfw_max) {
fmgc.FMGCInternal.zfw = scratchpad;
fmgc.FMGCInternal.zfwSet = 1;

View file

@ -2,6 +2,10 @@
# Copyright (c) 2020 Matthew Maring (mattmaring)
var acconfig_weight_kgs = props.globals.getNode("/systems/acconfig/options/weight-kgs", 1);
# Conversion factor pounds to kilogram
var LBS2KGS = 0.4535924;
var initInputB = func(key, i) {
var scratchpad = mcdu_scratchpad.scratchpads[i].scratchpad;
if (key == "L1" and !getprop("/FMGC/internal/fuel-calculating")) {
@ -14,8 +18,11 @@ var initInputB = func(key, i) {
setprop("/FMGC/internal/block-calculating", 1);
}
mcdu_scratchpad.scratchpads[i].empty();
} else {
} else {
var tfs = size(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
if (tfs >= 1 and tfs <= 4) {
if (num(scratchpad) != nil and scratchpad >= 0.0 and scratchpad <= 9.9) {
fmgc.FMGCInternal.taxiFuel = scratchpad;
@ -43,6 +50,9 @@ var initInputB = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
} else if (fmgc.FMGCInternal.tripFuel != 0) {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs >= 2 and tfs <= 5 and find("/", scratchpad) == 0) {
var perc = num(split("/", scratchpad)[1]);
@ -80,6 +90,9 @@ var initInputB = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) {
fmgc.FMGCInternal.altFuel = tf;
@ -103,6 +116,9 @@ var initInputB = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs >= 3 and tfs <= 4 and tf != nil and tf >= 0 and tf <= 10.0) {
fmgc.FMGCInternal.finalFuel = tf;
@ -132,6 +148,9 @@ var initInputB = func(key, i) {
mcdu_scratchpad.scratchpads[i].empty();
} else if (find(".", scratchpad) != -1) {
var tf = num(scratchpad);
if (acconfig_weight_kgs.getValue() == 1) {
tf = tf / LBS2KGS;
}
var tfs = size(scratchpad);
if (tfs >= 3 and tfs <= 5 and tf != nil and tf >= 0 and tf <= 80.0) {
fmgc.FMGCInternal.minDestFob = tf;
@ -153,6 +172,7 @@ var initInputB = func(key, i) {
} else {
var zfw_min = 80.6; #make based on performance
var zfw_max = 134.5; #61,000 kg, make based on performance
if (size(scratchpad) == 0) {
var zfw = getprop("/fdm/jsbsim/inertia/weight-lbs") - getprop("/consumables/fuel/total-fuel-lbs");
fmgc.FMGCInternal.zfw = sprintf("%3.1f", math.round(zfw / 1000, 0.1));
@ -170,6 +190,9 @@ var initInputB = func(key, i) {
}
mcdu_scratchpad.scratchpads[i].empty();
} else if (find("/", scratchpad) != -1) {
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
var zfwi = split("/", scratchpad);
var zfw = num(zfwi[0]);
var zfwcg = num(zfwi[1]);
@ -208,6 +231,9 @@ var initInputB = func(key, i) {
mcdu_message(i, "NOT ALLOWED");
}
} else if (num(scratchpad) != nil and size(scratchpad) > 0 and size(scratchpad) <= 5 and (find(".", scratchpad) == -1 or size(split(".", scratchpad)[1]) <= 1)) {
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
if (scratchpad >= zfw_min and scratchpad <= zfw_max) {
fmgc.FMGCInternal.zfw = scratchpad;
fmgc.FMGCInternal.zfwSet = 1;
@ -274,7 +300,8 @@ var initInputB = func(key, i) {
var tfs = size(scratchpad);
var maxblock = getprop("/options/maxblock");
if (tfs == 0) {
fmgc.FMGCInternal.block = sprintf("%3.1f", math.round(getprop("/consumables/fuel/total-fuel-lbs") / 1000, 0.1));
var block = math.round(getprop("/consumables/fuel/total-fuel-lbs") / 1000, 0.1);
fmgc.FMGCInternal.block = sprintf("%3.1f", block);
fmgc.FMGCInternal.blockSet = 1;
if (fmgc.FMGCInternal.zfwSet) {
fmgc.FMGCInternal.tow = num(fmgc.FMGCInternal.zfw + fmgc.FMGCInternal.block - fmgc.FMGCInternal.taxiFuel);
@ -284,6 +311,10 @@ var initInputB = func(key, i) {
setprop("/FMGC/internal/block-confirmed", 1);
}
} else if (tfs >= 1 and tfs <= 5) {
if (acconfig_weight_kgs.getValue() == 1) {
scratchpad = scratchpad / LBS2KGS;
}
if (num(scratchpad) != nil and scratchpad >= 1.0 and scratchpad <= maxblock) {
fmgc.FMGCInternal.block = scratchpad;
fmgc.FMGCInternal.blockSet = 1;