2017-04-09 16:46:30 +00:00
|
|
|
# Airbus A3XX FBW System by Joshua Davidson (it0uchpods/411)
|
2017-04-17 04:10:36 +00:00
|
|
|
# V0.9.6
|
2017-04-09 16:46:30 +00:00
|
|
|
|
|
|
|
########################
|
|
|
|
# Roll Update Function #
|
|
|
|
########################
|
2017-04-06 19:06:35 +00:00
|
|
|
|
|
|
|
var roll_input = func {
|
|
|
|
|
2017-04-10 23:08:55 +00:00
|
|
|
var ail = getprop("/controls/flight/aileron");
|
2017-04-06 19:06:35 +00:00
|
|
|
|
2017-04-17 04:10:36 +00:00
|
|
|
if (getprop("/it-fbw/law") == 0) {
|
|
|
|
if (ail > 0.4 or ail < -0.4) {
|
|
|
|
setprop("/it-fbw/roll-lim-max", "67");
|
|
|
|
setprop("/it-fbw/roll-lim-min", "-67");
|
|
|
|
} else {
|
|
|
|
setprop("/it-fbw/roll-lim-max", "33");
|
|
|
|
setprop("/it-fbw/roll-lim-min", "-33");
|
|
|
|
if (getprop("/it-fbw/law") > 33) {
|
2017-04-07 18:09:40 +00:00
|
|
|
setprop("/it-fbw/roll-deg", "33");
|
2017-04-17 04:10:36 +00:00
|
|
|
} else if (getprop("/it-fbw/law") < -33) {
|
2017-04-07 18:09:40 +00:00
|
|
|
setprop("/it-fbw/roll-deg", "-33");
|
2017-04-06 19:06:35 +00:00
|
|
|
}
|
|
|
|
}
|
2017-04-17 04:10:36 +00:00
|
|
|
} else {
|
|
|
|
setprop("/it-fbw/roll-lim-max", "160");
|
|
|
|
setprop("/it-fbw/roll-lim-min", "-160");
|
2017-04-06 19:06:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (getprop("/gear/gear[0]/wow") == 1) {
|
|
|
|
setprop("/it-fbw/roll-deg", "0");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-09 16:46:30 +00:00
|
|
|
#########################
|
|
|
|
# Pitch Update Function #
|
|
|
|
#########################
|
|
|
|
|
2017-04-06 19:06:35 +00:00
|
|
|
var pitch_input = func {
|
|
|
|
|
2017-04-07 18:09:40 +00:00
|
|
|
var elev = getprop("/controls/flight/elevator");
|
2017-04-06 19:06:35 +00:00
|
|
|
|
2017-04-17 04:10:36 +00:00
|
|
|
if (getprop("/it-fbw/law") == 0) {
|
|
|
|
setprop("/it-fbw/pitch-lim-max", "30");
|
|
|
|
setprop("/it-fbw/pitch-lim-min", "-15");
|
|
|
|
} else {
|
|
|
|
setprop("/it-fbw/pitch-lim-max", "160");
|
|
|
|
setprop("/it-fbw/pitch-lim-min", "-160");
|
2017-04-06 19:06:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (getprop("/gear/gear[0]/wow") == 1) {
|
2017-04-17 04:10:36 +00:00
|
|
|
if (elev > -0.05 and elev < 0.05) {
|
2017-04-06 19:06:35 +00:00
|
|
|
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-17 04:10:36 +00:00
|
|
|
###########################
|
|
|
|
# Various Other Functions #
|
|
|
|
###########################
|
|
|
|
|
2017-04-06 19:06:35 +00:00
|
|
|
setlistener("/it-autoflight/output/ap1", func {
|
|
|
|
if (getprop("/it-autoflight/output/ap1") == 0) {
|
|
|
|
setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg"));
|
|
|
|
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
setlistener("/it-autoflight/output/ap2", func {
|
|
|
|
if (getprop("/it-autoflight/output/ap2") == 0) {
|
|
|
|
setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg"));
|
|
|
|
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
setlistener("/it-fbw/law", func {
|
2017-04-17 04:10:36 +00:00
|
|
|
if (getprop("/it-fbw/law") == 0) {
|
2017-04-06 19:06:35 +00:00
|
|
|
setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg"));
|
|
|
|
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
|
2017-04-17 04:10:36 +00:00
|
|
|
} else if (getprop("/it-fbw/law") == 1) {
|
2017-04-06 19:06:35 +00:00
|
|
|
setprop("/it-fbw/roll-deg", getprop("/orientation/roll-deg"));
|
|
|
|
setprop("/it-fbw/pitch-deg", getprop("/orientation/pitch-deg"));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
setlistener("/sim/signals/fdm-initialized", func {
|
2017-04-17 04:10:36 +00:00
|
|
|
setprop("/it-fbw/law", 2);
|
2017-04-09 16:46:30 +00:00
|
|
|
update_roll.start();
|
|
|
|
update_pitch.start();
|
2017-04-07 18:09:40 +00:00
|
|
|
print("AIRBUS FBW ... OK!");
|
2017-04-06 19:06:35 +00:00
|
|
|
});
|
2017-04-07 18:24:11 +00:00
|
|
|
|
|
|
|
setlistener("/systems/electrical/bus/ac-ess", func {
|
|
|
|
if (getprop("/systems/electrical/bus/ac-ess") >= 110) {
|
2017-04-17 04:10:36 +00:00
|
|
|
if (getprop("/it-fbw/law") != 0) {
|
|
|
|
setprop("/it-fbw/law", 0);
|
2017-04-09 15:30:46 +00:00
|
|
|
}
|
2017-04-07 18:24:11 +00:00
|
|
|
} else {
|
2017-04-17 04:10:36 +00:00
|
|
|
if (getprop("/it-fbw/law") != 2) {
|
|
|
|
setprop("/it-fbw/law", 2);
|
2017-04-09 15:30:46 +00:00
|
|
|
}
|
2017-04-07 18:24:11 +00:00
|
|
|
}
|
|
|
|
});
|
2017-04-09 16:46:30 +00:00
|
|
|
|
|
|
|
##########
|
|
|
|
# Timers #
|
|
|
|
##########
|
|
|
|
var update_roll = maketimer(0.01, roll_input);
|
|
|
|
var update_pitch = maketimer(0.01, pitch_input);
|