2019-10-14 16:48:35 +00:00
# Aircraft Config Center
# Joshua Davidson (Octal450)
2021-04-23 17:21:07 +00:00
# Copyright (c) 2021 Josh Davidson (Octal450)
2019-10-14 16:48:35 +00:00
var spinning = maketimer(0.05, func {
2020-04-27 15:37:43 +00:00
var spinning = getprop("/systems/acconfig/spinning");
2019-10-14 16:48:35 +00:00
if (spinning == 0) {
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/spin", "\\");
setprop("/systems/acconfig/spinning", 1);
2019-10-14 16:48:35 +00:00
} else if (spinning == 1) {
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/spin", "|");
setprop("/systems/acconfig/spinning", 2);
2019-10-14 16:48:35 +00:00
} else if (spinning == 2) {
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/spin", "/");
setprop("/systems/acconfig/spinning", 3);
2019-10-14 16:48:35 +00:00
} else if (spinning == 3) {
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/spin", "-");
setprop("/systems/acconfig/spinning", 0);
2019-10-14 16:48:35 +00:00
}
});
var failReset = func {
2021-11-02 21:32:24 +00:00
systems.ELEC.resetFailures();
systems.PNEU.resetFailures();
fbw.FBW.resetFailures();
systems.HYD.resetFailures();
2019-10-14 16:48:35 +00:00
}
var failResetOld = func {
2020-04-27 15:37:43 +00:00
setprop("/systems/failures/aileron-left", 0);
setprop("/systems/failures/aileron-right", 0);
setprop("/systems/failures/elevator-left", 0);
setprop("/systems/failures/elevator-right", 0);
2021-01-30 21:47:32 +00:00
setprop("/systems/failures/fire/cargo-aft-fire", 0);
setprop("/systems/failures/fire/cargo-fwd-fire", 0);
setprop("/systems/failures/fire/engine-left-fire", 0);
setprop("/systems/failures/fire/apu-fire", 0);
setprop("/systems/failures/fire/engine-right-fire", 0);
setprop("/systems/failures/fire/lavatory-fire", 0);
2019-10-14 16:48:35 +00:00
}
failResetOld();
2021-06-08 15:53:09 +00:00
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/autoconfig-running", 0);
setprop("/systems/acconfig/spinning", 0);
setprop("/systems/acconfig/spin", "-");
setprop("/systems/acconfig/options/revision", 0);
setprop("/systems/acconfig/new-revision", 0);
setprop("/systems/acconfig/out-of-date", 0);
setprop("/systems/acconfig/mismatch-code", "0x000");
setprop("/systems/acconfig/mismatch-reason", "XX");
setprop("/systems/acconfig/options/keyboard-mode", 0);
2022-01-07 13:43:55 +00:00
setprop("/systems/acconfig/options/fgcamera-keys-enabled", 0);
2020-11-22 16:45:29 +00:00
setprop("/systems/acconfig/options/weight-kgs", 1);
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/options/adirs-skip", 0);
setprop("/systems/acconfig/options/allow-oil-consumption", 0);
2020-10-24 14:07:23 +00:00
setprop("/systems/acconfig/options/atis-server", "faa");
setprop("/systems/acconfig/options/wxr-server", "noaa");
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/options/welcome-skip", 0);
setprop("/systems/acconfig/options/no-rendering-warn", 0);
setprop("/systems/acconfig/options/save-state", 0);
2021-01-21 12:56:22 +00:00
setprop("/systems/acconfig/options/hide-canvas-outside", 0);
2020-05-24 18:40:06 +00:00
setprop("/systems/acconfig/options/seperate-tiller-axis", 0);
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/options/nd-rate", 1);
2020-07-25 14:16:06 +00:00
setprop("/systems/acconfig/options/dcdu-rate", 1);
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/options/autopush/show-route", 1);
setprop("/systems/acconfig/options/autopush/show-wingtip", 1);
var main_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/main/dialog", "Aircraft/A320-family/AircraftConfig/main.xml");
var welcome_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/welcome/dialog", "Aircraft/A320-family/AircraftConfig/welcome.xml");
var ps_load_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/psload/dialog", "Aircraft/A320-family/AircraftConfig/psload.xml");
var ps_loaded_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/psloaded/dialog", "Aircraft/A320-family/AircraftConfig/psloaded.xml");
var init_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/init/dialog", "Aircraft/A320-family/AircraftConfig/ac_init.xml");
var help_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/help/dialog", "Aircraft/A320-family/AircraftConfig/help.xml");
var fbw_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/fbw/dialog", "Aircraft/A320-family/AircraftConfig/fbw.xml");
var fail_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/fail/dialog", "Aircraft/A320-family/AircraftConfig/fail.xml");
var about_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/about/dialog", "Aircraft/A320-family/AircraftConfig/about.xml");
var update_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/update/dialog", "Aircraft/A320-family/AircraftConfig/update.xml");
var updated_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/updated/dialog", "Aircraft/A320-family/AircraftConfig/updated.xml");
var error_mismatch = gui.Dialog.new("/sim/gui/dialogs/acconfig/error/mismatch/dialog", "Aircraft/A320-family/AircraftConfig/error-mismatch.xml");
var fuel_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/fuel/dialog", "Aircraft/A320-family/AircraftConfig/fuel.xml");
var groundservices_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/groundsrvc/dialog", "Aircraft/A320-family/AircraftConfig/groundservices.xml");
2020-04-28 23:41:08 +00:00
var loadflightplan_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/loadfpln/dialog","Aircraft/A320-family/AircraftConfig/load-flightplan.xml");
2020-08-04 17:04:00 +00:00
var simbrief_dlg = gui.Dialog.new("/sim/gui/dialogs/acconfig/simbrief/dialog","Aircraft/A320-family/AircraftConfig/simbrief.xml");
2020-04-27 15:37:43 +00:00
var du_quality = gui.Dialog.new("/sim/gui/dialogs/acconfig/du-quality/dialog", "Aircraft/A320-family/AircraftConfig/du-quality.xml");
var rendering_dlg = gui.Dialog.new("/sim/gui/dialogs/rendering/dialog", "Aircraft/A320-family/AircraftConfig/rendering.xml");
2019-10-14 16:48:35 +00:00
spinning.start();
init_dlg.open();
2020-04-27 15:37:43 +00:00
http.load("/https://raw.githubusercontent.com/legoboyvdlp/A320-family/dev/revision.txt").done(func(r) setprop("/systems/acconfig/new-revision", r.response));
var revisionFile = (getprop("/sim/aircraft-dir") ~ "/revision.txt");
2019-10-14 16:48:35 +00:00
var current_revision = io.readfile(revisionFile);
2019-10-15 16:08:04 +00:00
print("A320-family Revision: " ~ current_revision);
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/revision", current_revision);
2021-06-08 17:16:19 +00:00
2021-11-02 21:32:24 +00:00
var SYSTEM = { # Prepare for migration to ACCONFIG V2
autoConfigRunning: props.globals.getNode("/systems/acconfig/autoconfig-running"),
};
2021-06-08 17:16:19 +00:00
var foViewNode = props.globals.initNode("/systems/acconfig/options/fo-view", 0, "BOOL");
2020-08-01 13:04:33 +00:00
setprop("/systems/acconfig/options/simbrief-username", "");
2019-10-14 16:48:35 +00:00
setlistener("/systems/acconfig/new-revision", func {
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/new-revision") > current_revision) {
setprop("/systems/acconfig/out-of-date", 1);
2019-10-14 16:48:35 +00:00
} else {
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/out-of-date", 0);
2019-10-14 16:48:35 +00:00
}
});
2021-08-01 14:31:48 +00:00
var fgfsMin = split(".", getprop("/sim/minimum-fg-version"));
var fgfsVer = split(".", getprop("/sim/version/flightgear"));
var versionCheck = func() {
if (fgfsVer[0] < fgfsMin[0] or fgfsVer[1] < fgfsMin[1]) {
return 0;
} else if (fgfsVer[1] == fgfsMin[1]) {
if (fgfsVer[2] < fgfsMin[2]) {
return 0;
} else {
return 1;
}
} else {
return 1;
}
}
2019-10-14 16:48:35 +00:00
var mismatch_chk = func {
2021-08-01 14:31:48 +00:00
if (!versionCheck()) {
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/mismatch-code", "0x121");
2021-08-01 14:31:48 +00:00
setprop("/systems/acconfig/mismatch-reason", "FGFS version is too old! Please update FlightGear to at least " ~ getprop("/sim/minimum-fg-version") ~ ".");
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/out-of-date") != 1) {
2019-10-14 16:48:35 +00:00
error_mismatch.open();
}
print("Mismatch: 0x121");
welcome_dlg.close();
2020-04-27 15:37:43 +00:00
} else if (getprop("/gear/gear[0]/wow") == 0 or getprop("/position/altitude-ft") >= 15000) {
setprop("/systems/acconfig/mismatch-code", "0x223");
setprop("/systems/acconfig/mismatch-reason", "Preposterous configuration detected for initialization. Check your position or scenery.");
if (getprop("/systems/acconfig/out-of-date") != 1) {
2019-10-14 16:48:35 +00:00
error_mismatch.open();
}
print("Mismatch: 0x223");
welcome_dlg.close();
2020-04-27 15:37:43 +00:00
} else if (getprop("/systems/acconfig/libraries-loaded") != 1) {
setprop("/systems/acconfig/mismatch-code", "0x247");
setprop("/systems/acconfig/mismatch-reason", "System files are missing or damaged. Please download a new copy of the aircraft.");
if (getprop("/systems/acconfig/out-of-date") != 1) {
2019-10-14 16:48:35 +00:00
error_mismatch.open();
}
print("Mismatch: 0x247");
welcome_dlg.close();
}
}
setlistener("/sim/signals/fdm-initialized", func {
init_dlg.close();
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/out-of-date") == 1) {
2019-10-14 16:48:35 +00:00
update_dlg.open();
print("System: The A320-family is out of date!");
}
2021-08-26 22:26:28 +00:00
#mismatch_chk();
2019-10-14 16:48:35 +00:00
readSettings();
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/out-of-date") != 1 and getprop("/systems/acconfig/options/revision") < current_revision and getprop("/systems/acconfig/mismatch-code") == "0x000") {
2019-10-14 16:48:35 +00:00
updated_dlg.open();
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/options/no-rendering-warn") != 1) {
2019-10-14 16:48:35 +00:00
renderingSettings.check();
}
2020-04-27 15:37:43 +00:00
} else if (getprop("/systems/acconfig/out-of-date") != 1 and getprop("/systems/acconfig/mismatch-code") == "0x000" and getprop("/systems/acconfig/options/welcome-skip") != 1) {
2019-10-14 16:48:35 +00:00
welcome_dlg.open();
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/options/no-rendering-warn") != 1) {
2019-10-14 16:48:35 +00:00
renderingSettings.check();
}
}
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/options/revision", current_revision);
2019-10-14 16:48:35 +00:00
writeSettings();
2020-04-27 15:37:43 +00:00
if (getprop("/options/system/save-state") == 1)
2020-02-11 16:20:05 +00:00
{
2021-06-09 16:25:17 +00:00
save.restore(save.default, pts.Sim.fgHome.getValue() ~ "/Export/" ~ pts.Sim.aircraft.getValue() ~ "-save.xml");
2020-02-11 16:20:05 +00:00
}
2020-05-06 08:42:17 +00:00
2020-05-06 09:00:21 +00:00
if (getprop("/options/system/fo-view") == 1) {
2020-05-07 20:07:35 +00:00
view.setViewByIndex(100);
2020-05-06 08:42:17 +00:00
}
2019-10-14 16:48:35 +00:00
spinning.stop();
});
2020-02-11 16:20:05 +00:00
setlistener("/sim/signals/exit", func {
2021-06-09 16:25:17 +00:00
save.save(save.default, pts.Sim.fgHome.getValue() ~ "/Export/" ~ pts.Sim.aircraft.getValue() ~ "-save.xml");
2020-02-11 16:20:05 +00:00
});
2019-10-14 16:48:35 +00:00
var renderingSettings = {
check: func() {
2020-04-27 15:37:43 +00:00
var rembrandt = getprop("/sim/rendering/rembrandt/enabled");
var ALS = getprop("/sim/rendering/shaders/skydome");
2020-12-31 20:03:47 +00:00
2020-04-27 15:37:43 +00:00
var landmass = getprop("/sim/rendering/shaders/landmass") >= 4;
var model = getprop("/sim/rendering/shaders/model") >= 2;
2020-12-31 20:03:47 +00:00
if (!rembrandt and (!ALS or !landmass or !model)) {
2019-10-14 16:48:35 +00:00
rendering_dlg.open();
}
},
fixAll: func() {
me.fixCore();
2020-04-27 15:37:43 +00:00
var landmass = getprop("/sim/rendering/shaders/landmass") >= 4;
var model = getprop("/sim/rendering/shaders/model") >= 2;
2019-10-14 16:48:35 +00:00
if (!landmass) {
2020-04-27 15:37:43 +00:00
setprop("/sim/rendering/shaders/landmass", 4);
2019-10-14 16:48:35 +00:00
}
if (!model) {
2020-04-27 15:37:43 +00:00
setprop("/sim/rendering/shaders/model", 2);
2019-10-14 16:48:35 +00:00
}
},
fixCore: func() {
2020-04-27 15:37:43 +00:00
setprop("/sim/rendering/shaders/skydome", 1); # ALS on
setprop("/sim/rendering/shaders/custom-settings", 1);
gui.popupTip("/Rendering Settings updated!");
2019-10-14 16:48:35 +00:00
},
};
var readSettings = func {
2021-06-09 16:25:17 +00:00
io.read_properties(pts.Sim.fgHome.getValue() ~ "/Export/A320-family-config.xml", "/systems/acconfig/options");
2020-04-27 15:37:43 +00:00
setprop("/options/system/keyboard-mode", getprop("/systems/acconfig/options/keyboard-mode"));
2022-01-07 13:43:55 +00:00
if (getprop("/sim/fgcamera/enable")) setprop("/options/system/fgcamera-keys-enabled", getprop("/systems/acconfig/options/fgcamera-keys-enabled")); # read only when FGCamera enabled
2020-04-27 15:37:43 +00:00
setprop("/options/system/weight-kgs", getprop("/systems/acconfig/options/weight-kgs"));
setprop("/options/system/save-state", getprop("/systems/acconfig/options/save-state"));
setprop("/controls/adirs/skip", getprop("/systems/acconfig/options/adirs-skip"));
setprop("/systems/apu/oil/allow-oil-consumption", getprop("/systems/acconfig/options/allow-oil-consumption"));
setprop("/sim/model/autopush/route/show", getprop("/systems/acconfig/options/autopush/show-route"));
setprop("/sim/model/autopush/route/show-wingtip", getprop("/systems/acconfig/options/autopush/show-wingtip"));
2021-06-08 17:16:19 +00:00
setprop("/options/system/fo-view", foViewNode.getValue());
2020-08-04 12:00:31 +00:00
setprop("/FMGC/simbrief-username", getprop("/systems/acconfig/options/simbrief-username"));
2020-10-24 14:07:23 +00:00
setprop("/systems/atsu/atis-server", getprop("/systems/acconfig/options/atis-server"));
setprop("/systems/atsu/wxr-server", getprop("/systems/acconfig/options/wxr-server"));
2021-01-21 12:56:22 +00:00
setprop("/options/hide-canvas-outside", getprop("/systems/acconfig/options/hide-canvas-outside"));
2019-10-14 16:48:35 +00:00
}
var writeSettings = func {
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/options/keyboard-mode", getprop("/options/system/keyboard-mode"));
2022-01-07 13:43:55 +00:00
setprop("/systems/acconfig/options/fgcamera-keys-enabled", getprop("/options/system/fgcamera-keys-enabled"));
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/options/weight-kgs", getprop("/options/system/weight-kgs"));
setprop("/systems/acconfig/options/save-state", getprop("/options/system/save-state"));
setprop("/systems/acconfig/options/adirs-skip", getprop("/controls/adirs/skip"));
setprop("/systems/acconfig/options/allow-oil-consumption", getprop("/systems/apu/oil/allow-oil-consumption"));
setprop("/systems/acconfig/options/autopush/show-route", getprop("/sim/model/autopush/route/show"));
setprop("/systems/acconfig/options/autopush/show-wingtip", getprop("/sim/model/autopush/route/show-wingtip"));
2021-06-08 17:16:19 +00:00
foViewNode.setValue(getprop("/options/system/fo-view"));
2020-08-01 13:04:33 +00:00
setprop("/systems/acconfig/options/simbrief-username", getprop("/FMGC/simbrief-username"));
2020-10-24 14:07:23 +00:00
setprop("/systems/acconfig/options/atis-server", getprop("/systems/atsu/atis-server"));
setprop("/systems/acconfig/options/wxr-server", getprop("/systems/atsu/wxr-server"));
2021-01-21 12:56:22 +00:00
setprop("/systems/acconfig/options/hide-canvas-outside", getprop("/options/hide-canvas-outside"));
2021-06-09 16:25:17 +00:00
io.write_properties(pts.Sim.fgHome.getValue() ~ "/Export/A320-family-config.xml", "/systems/acconfig/options");
2019-10-14 16:48:35 +00:00
}
################
# Panel States #
################
2020-12-31 20:03:47 +00:00
# Abort auto-config and close dialog
var abortPanelStates = func {
if (getprop("/systems/acconfig/autoconfig-running") == 1) {
setprop("/systems/acconfig/autoconfig-running", 0);
}
ps_load_dlg.close();
spinning.stop();
}
2019-10-14 16:48:35 +00:00
# Cold and Dark
var colddark = func {
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/mismatch-code") == "0x000") {
2019-10-14 16:48:35 +00:00
spinning.start();
ps_loaded_dlg.close();
ps_load_dlg.open();
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/autoconfig-running", 1);
setprop("/controls/gear/brake-left", 1);
setprop("/controls/gear/brake-right", 1);
2019-10-14 16:48:35 +00:00
# Initial shutdown, and reinitialization.
2021-11-02 21:32:24 +00:00
setprop("/services/chocks/enable", 1);
2020-04-27 15:37:43 +00:00
setprop("/controls/engines/engine-start-switch", 1);
setprop("/controls/engines/engine[0]/cutoff-switch", 1);
setprop("/controls/engines/engine[1]/cutoff-switch", 1);
2020-05-12 02:40:59 +00:00
setprop("/controls/flight/flaps", 0);
2021-06-12 23:24:46 +00:00
pts.Controls.Flight.speedbrakeArm.setValue(0);
2020-04-27 15:37:43 +00:00
setprop("/controls/flight/speedbrake", 0);
setprop("/controls/gear/gear-down", 1);
setprop("/controls/flight/elevator-trim", 0);
setprop("/controls/switches/beacon", 0);
setprop("/controls/switches/strobe", 0.0);
setprop("/controls/switches/wing-lights", 0);
setprop("/controls/lighting/nav-lights-switch", 0);
setprop("/controls/lighting/turnoff-light-switch", 0);
setprop("/controls/lighting/taxi-light-switch", 0.0);
setprop("/controls/switches/landing-lights-l", 0.0);
setprop("/controls/switches/landing-lights-r", 0.0);
setprop("/controls/atc/mode-knob", 0);
setprop("/controls/lighting/fcu-panel-knb", 0);
setprop("/controls/lighting/main-panel-knb", 0);
setprop("/controls/lighting/overhead-panel-knb", 0);
2019-10-14 16:48:35 +00:00
atc.transponderPanel.modeSwitch(1);
libraries.systemsInit();
2021-02-19 19:27:27 +00:00
libraries.variousReset();
2019-10-14 16:48:35 +00:00
failResetOld();
2020-04-27 15:37:43 +00:00
if (getprop("/engines/engine[1]/n2-actual") < 2) {
2019-10-14 16:48:35 +00:00
colddark_b();
} else {
var colddark_eng_off = setlistener("/engines/engine[1]/n2-actual", func {
2020-04-27 15:37:43 +00:00
if (getprop("/engines/engine[1]/n2-actual") < 2) {
2019-10-14 16:48:35 +00:00
removelistener(colddark_eng_off);
colddark_b();
}
});
}
}
}
var colddark_b = func {
# Continues the Cold and Dark script, after engines fully shutdown.
2020-04-27 15:37:43 +00:00
setprop("/controls/apu/master", 0);
2019-10-14 16:48:35 +00:00
settimer(func {
2020-04-27 15:37:43 +00:00
setprop("/controls/gear/brake-left", 0);
setprop("/controls/gear/brake-right", 0);
setprop("/systems/acconfig/autoconfig-running", 0);
2019-10-14 16:48:35 +00:00
ps_load_dlg.close();
ps_loaded_dlg.open();
spinning.stop();
}, 2);
}
# Ready to Start Eng
var beforestart = func {
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/mismatch-code") == "0x000") {
2019-10-14 16:48:35 +00:00
spinning.start();
ps_loaded_dlg.close();
ps_load_dlg.open();
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/autoconfig-running", 1);
setprop("/controls/gear/brake-left", 1);
setprop("/controls/gear/brake-right", 1);
2019-10-14 16:48:35 +00:00
# First, we set everything to cold and dark.
2021-11-02 21:32:24 +00:00
setprop("/services/chocks/enable", 1);
2020-04-27 15:37:43 +00:00
setprop("/controls/engines/engine-start-switch", 1);
setprop("/controls/engines/engine[0]/cutoff-switch", 1);
setprop("/controls/engines/engine[1]/cutoff-switch", 1);
2020-05-12 02:40:59 +00:00
setprop("/controls/flight/flaps", 0);
2021-06-12 23:24:46 +00:00
pts.Controls.Flight.speedbrakeArm.setValue(0);
2020-04-27 15:37:43 +00:00
setprop("/controls/flight/speedbrake", 0);
setprop("/controls/gear/gear-down", 1);
setprop("/controls/flight/elevator-trim", 0);
2019-10-14 16:48:35 +00:00
libraries.systemsInit();
2021-02-19 19:27:27 +00:00
libraries.variousReset();
2021-07-29 12:51:23 +00:00
setprop("/controls/oxygen/cockpit-oxygen-supply-pb", 1);
2019-10-14 16:48:35 +00:00
failResetOld();
# Now the Startup!
2020-04-27 15:37:43 +00:00
props.globals.getNode("/controls/electrical/switches/bat-1").setValue(1);
props.globals.getNode("/controls/electrical/switches/bat-2").setValue(1);
setprop("/controls/apu/master", 1);
2020-04-19 19:20:52 +00:00
settimer(func() {
systems.APUController.APU.powerOn(); # guarantee it always works
systems.APUController.APU.startCommand(1);
}, 0.1);
2020-04-17 22:41:36 +00:00
var apu_rpm_chk = setlistener("/engines/engine[2]/n1", func {
2020-04-27 15:37:43 +00:00
if (getprop("/engines/engine[2]/n1") >= 98) {
2019-10-14 16:48:35 +00:00
removelistener(apu_rpm_chk);
beforestart_b();
}
});
}
}
var beforestart_b = func {
2020-12-31 20:12:40 +00:00
if (getprop("/systems/acconfig/autoconfig-running") == 0) {
colddark();
return 0; # auto-config aborted
}
2019-10-14 16:48:35 +00:00
# Continue with engine start prep.
2019-11-16 11:59:58 +00:00
systems.FUEL.Switches.pumpLeft1.setValue(1);
systems.FUEL.Switches.pumpLeft2.setValue(1);
systems.FUEL.Switches.pumpCenter1.setValue(1);
systems.FUEL.Switches.pumpCenter2.setValue(1);
systems.FUEL.Switches.pumpRight1.setValue(1);
systems.FUEL.Switches.pumpRight2.setValue(1);
2020-04-27 15:37:43 +00:00
setprop("/controls/lighting/fcu-panel-knb", 1);
setprop("/controls/lighting/main-panel-knb", 1);
setprop("/controls/lighting/overhead-panel-knb", 1);
setprop("/controls/electrical/switches/apu", 1);
setprop("/controls/electrical/switches/galley", 1);
setprop("/controls/electrical/switches/gen-1", 1);
setprop("/controls/electrical/switches/gen-2", 1);
2020-05-10 14:37:05 +00:00
setprop("/controls/pneumatics/switches/apu", 1);
setprop("/controls/pneumatics/switches/bleed-1", 1);
setprop("/controls/pneumatics/switches/bleed-2", 1);
2020-05-06 16:05:53 +00:00
setprop("/controls/pneumatics/switches/pack-1", 1);
setprop("/controls/pneumatics/switches/pack-2", 1);
2020-04-27 15:37:43 +00:00
setprop("/controls/adirs/ir[0]/knob","1");
setprop("/controls/adirs/ir[1]/knob","1");
setprop("/controls/adirs/ir[2]/knob","1");
2020-05-01 08:41:39 +00:00
if (systems.ADIRS.Switches.adrSw[0].getValue() != 1) { systems.ADIRSControlPanel.adrSw(0); }
if (systems.ADIRS.Switches.adrSw[1].getValue() != 1) { systems.ADIRSControlPanel.adrSw(1); }
if (systems.ADIRS.Switches.adrSw[2].getValue() != 1) { systems.ADIRSControlPanel.adrSw(2); }
2019-11-21 17:27:57 +00:00
systems.ADIRSControlPanel.irModeSw(0, 1);
systems.ADIRSControlPanel.irModeSw(1, 1);
systems.ADIRSControlPanel.irModeSw(2, 1);
2020-05-01 08:41:39 +00:00
systems.ADIRS.ADIRunits[0].instAlign();
systems.ADIRS.ADIRunits[1].instAlign();
systems.ADIRS.ADIRunits[2].instAlign();
2020-04-27 15:37:43 +00:00
setprop("/controls/adirs/mcducbtn", 1);
setprop("/controls/switches/beacon", 1);
setprop("/controls/lighting/nav-lights-switch", 1);
2022-01-02 17:24:59 +00:00
pts.Controls.Switches.noSmokingSwitch.setValue(0.5);
pts.Controls.Switches.seatbeltSwitch.setValue(1.0);
pts.Controls.Switches.emerLtsSwitch.setValue(0.5);
2020-04-27 15:37:43 +00:00
setprop("/controls/radio/rmp[0]/on", 1);
setprop("/controls/radio/rmp[1]/on", 1);
setprop("/controls/radio/rmp[2]/on", 1);
setprop("/systems/fadec/power-avail", 1);
setprop("/systems/fadec/powered-time", -310);
2019-10-14 16:48:35 +00:00
settimer(func {
2020-04-27 15:37:43 +00:00
setprop("/controls/gear/brake-left", 0);
setprop("/controls/gear/brake-right", 0);
setprop("/systems/acconfig/autoconfig-running", 0);
2019-10-14 16:48:35 +00:00
ps_load_dlg.close();
ps_loaded_dlg.open();
spinning.stop();
}, 2);
}
# Ready to Taxi
var taxi = func {
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/mismatch-code") == "0x000") {
2019-10-14 16:48:35 +00:00
spinning.start();
ps_loaded_dlg.close();
ps_load_dlg.open();
2020-04-27 15:37:43 +00:00
setprop("/systems/acconfig/autoconfig-running", 1);
setprop("/controls/gear/brake-left", 1);
setprop("/controls/gear/brake-right", 1);
2019-10-14 16:48:35 +00:00
# First, we set everything to cold and dark.
2021-11-02 21:32:24 +00:00
setprop("/services/chocks/enable", 0);
2020-04-27 15:37:43 +00:00
setprop("/controls/engines/engine-start-switch", 1);
setprop("/controls/engines/engine[0]/cutoff-switch", 1);
setprop("/controls/engines/engine[1]/cutoff-switch", 1);
2020-05-12 02:40:59 +00:00
setprop("/controls/flight/flaps", 0);
2021-06-12 23:24:46 +00:00
pts.Controls.Flight.speedbrakeArm.setValue(0);
2020-04-27 15:37:43 +00:00
setprop("/controls/flight/speedbrake", 0);
setprop("/controls/gear/gear-down", 1);
setprop("/controls/flight/elevator-trim", 0);
2019-10-14 16:48:35 +00:00
libraries.systemsInit();
2021-02-19 19:27:27 +00:00
libraries.variousReset();
2021-07-29 12:51:23 +00:00
setprop("/controls/oxygen/cockpit-oxygen-supply-pb", 1);
2019-10-14 16:48:35 +00:00
failResetOld();
# Now the Startup!
2020-04-27 15:37:43 +00:00
props.globals.getNode("/controls/electrical/switches/bat-1").setValue(1);
props.globals.getNode("/controls/electrical/switches/bat-2").setValue(1);
setprop("/controls/apu/master", 1);
2020-04-19 19:20:52 +00:00
settimer(func() {
systems.APUController.APU.powerOn(); # guarantee it always works
systems.APUController.APU.startCommand(1);
}, 0.1);
2020-04-17 22:41:36 +00:00
var apu_rpm_chk = setlistener("/engines/engine[2]/n1", func {
2020-04-27 15:37:43 +00:00
if (getprop("/engines/engine[2]/n1") >= 98) {
2019-10-14 16:48:35 +00:00
removelistener(apu_rpm_chk);
taxi_b();
}
});
}
}
var taxi_b = func {
2020-12-31 20:12:40 +00:00
if (getprop("/systems/acconfig/autoconfig-running") == 0) {
colddark();
return 0; # auto-config aborted
}
2019-10-14 16:48:35 +00:00
# Continue with engine start prep, and start engines.
2019-11-16 11:59:58 +00:00
systems.FUEL.Switches.pumpLeft1.setValue(1);
systems.FUEL.Switches.pumpLeft2.setValue(1);
systems.FUEL.Switches.pumpCenter1.setValue(1);
systems.FUEL.Switches.pumpCenter2.setValue(1);
systems.FUEL.Switches.pumpRight1.setValue(1);
systems.FUEL.Switches.pumpRight2.setValue(1);
2020-04-27 15:37:43 +00:00
setprop("/controls/lighting/fcu-panel-knb", 1);
setprop("/controls/lighting/main-panel-knb", 1);
setprop("/controls/lighting/overhead-panel-knb", 1);
setprop("/controls/electrical/switches/apu", 1);
setprop("/controls/electrical/switches/galley", 1);
setprop("/controls/electrical/switches/gen-1", 1);
setprop("/controls/electrical/switches/gen-2", 1);
2020-05-10 14:37:05 +00:00
setprop("/controls/pneumatics/switches/apu", 1);
setprop("/controls/pneumatics/switches/bleed-1", 1);
setprop("/controls/pneumatics/switches/bleed-2", 1);
2020-05-06 16:05:53 +00:00
setprop("/controls/pneumatics/switches/pack-1", 1);
setprop("/controls/pneumatics/switches/pack-2", 1);
2020-04-27 15:37:43 +00:00
setprop("/controls/adirs/ir[0]/knob","1");
setprop("/controls/adirs/ir[1]/knob","1");
setprop("/controls/adirs/ir[2]/knob","1");
2020-05-01 08:41:39 +00:00
if (systems.ADIRS.Switches.adrSw[0].getValue() != 1) { systems.ADIRSControlPanel.adrSw(0); }
if (systems.ADIRS.Switches.adrSw[1].getValue() != 1) { systems.ADIRSControlPanel.adrSw(1); }
if (systems.ADIRS.Switches.adrSw[2].getValue() != 1) { systems.ADIRSControlPanel.adrSw(2); }
2019-11-21 17:27:57 +00:00
systems.ADIRSControlPanel.irModeSw(0, 1);
systems.ADIRSControlPanel.irModeSw(1, 1);
systems.ADIRSControlPanel.irModeSw(2, 1);
2020-05-01 08:41:39 +00:00
systems.ADIRS.ADIRunits[0].instAlign();
systems.ADIRS.ADIRunits[1].instAlign();
systems.ADIRS.ADIRunits[2].instAlign();
2020-04-27 15:37:43 +00:00
setprop("/controls/adirs/mcducbtn", 1);
setprop("/controls/switches/beacon", 1);
setprop("/controls/switches/wing-lights", 1);
setprop("/controls/lighting/nav-lights-switch", 1);
2022-01-02 17:24:59 +00:00
pts.Controls.Switches.noSmokingSwitch.setValue(0.5);
pts.Controls.Switches.seatbeltSwitch.setValue(1.0);
pts.Controls.Switches.emerLtsSwitch.setValue(0.5);
2020-04-27 15:37:43 +00:00
setprop("/controls/radio/rmp[0]/on", 1);
setprop("/controls/radio/rmp[1]/on", 1);
setprop("/controls/radio/rmp[2]/on", 1);
setprop("/controls/atc/mode-knob", 2);
2019-10-14 16:48:35 +00:00
atc.transponderPanel.modeSwitch(3);
2020-04-27 15:37:43 +00:00
setprop("/systems/fadec/power-avail", 1);
setprop("/systems/fadec/powered-time", -310);
setprop("/controls/lighting/turnoff-light-switch", 1);
setprop("/controls/lighting/taxi-light-switch", 0.5);
setprop("/controls/switches/landing-lights-l", 0.5);
setprop("/controls/switches/landing-lights-r", 0.5);
if (pts.Instrumentation.Altimeter.std.getBoolValue()) {
libraries.toggleSTD();
}
2020-06-29 21:17:19 +00:00
setprop("/instrumentation/altimeter[0]/setting-inhg", getprop("/environment/metar[0]/pressure-inhg") or 29.92);
2019-10-14 16:48:35 +00:00
settimer(taxi_c, 2);
}
var taxi_c = func {
2020-12-31 20:12:40 +00:00
if (getprop("/systems/acconfig/autoconfig-running") == 0) {
colddark();
return 0; # auto-config aborted
}
2020-04-27 15:37:43 +00:00
setprop("/controls/engines/engine-start-switch", 2);
setprop("/controls/engines/engine[0]/cutoff-switch", 0);
setprop("/controls/engines/engine[1]/cutoff-switch", 0);
2019-10-14 16:48:35 +00:00
settimer(func {
taxi_d();
}, 10);
}
var taxi_d = func {
2020-12-31 20:12:40 +00:00
if (getprop("/systems/acconfig/autoconfig-running") == 0) {
colddark();
return 0; # auto-config aborted
}
2019-10-14 16:48:35 +00:00
# After Start items.
2020-04-27 15:37:43 +00:00
setprop("/controls/engines/engine-start-switch", 1);
setprop("/controls/apu/master", 0);
2020-05-10 14:37:05 +00:00
setprop("/controls/pneumatics/switches/apu", 0);
2020-04-27 15:37:43 +00:00
setprop("/controls/gear/brake-left", 0);
setprop("/controls/gear/brake-right", 0);
setprop("/systems/acconfig/autoconfig-running", 0);
2019-10-14 16:48:35 +00:00
ps_load_dlg.close();
ps_loaded_dlg.open();
spinning.stop();
}
# Ready to Takeoff
var takeoff = func {
2020-04-27 15:37:43 +00:00
if (getprop("/systems/acconfig/mismatch-code") == "0x000") {
2019-10-14 16:48:35 +00:00
# The same as taxi, except we set some things afterwards.
taxi();
var eng_one_chk_c = setlistener("/engines/engine[0]/state", func {
2020-10-07 17:24:23 +00:00
if (pts.Engines.Engine.state[0].getValue() == 3) {
2019-10-14 16:48:35 +00:00
removelistener(eng_one_chk_c);
2020-04-27 15:37:43 +00:00
setprop("/controls/switches/strobe", 1.0);
setprop("/controls/lighting/taxi-light-switch", 1);
setprop("/controls/switches/landing-lights-l", 1);
setprop("/controls/switches/landing-lights-r", 1);
2021-06-12 23:24:46 +00:00
pts.Controls.Flight.speedbrakeArm.setValue(1);
2020-05-12 02:40:59 +00:00
setprop("/controls/flight/flaps", 0.2);
2020-04-27 15:37:43 +00:00
setprop("/controls/atc/mode-knob", 4);
2019-10-14 16:48:35 +00:00
atc.transponderPanel.modeSwitch(5);
2020-04-27 15:37:43 +00:00
setprop("/controls/flight/elevator-trim", -0.07);
2020-07-25 23:13:54 +00:00
systems.Autobrake.arm_autobrake(3);
2020-04-27 15:37:43 +00:00
setprop("/ECAM/to-config-test", 1);
2019-10-29 15:19:43 +00:00
settimer(func {
2020-04-27 15:37:43 +00:00
setprop("/ECAM/to-config-test", 0);
2019-10-29 15:19:43 +00:00
}, 1);
2019-10-14 16:48:35 +00:00
}
});
}
}
2021-08-26 22:26:28 +00:00
setlistener("/systems/start-up-on-start", func() {
if (getprop("/systems/start-up-on-start")) {
settimer(takeoff, 5);
}
2021-08-26 22:37:32 +00:00
}, 1, 0);