New IRS alignment simulation
This commit is contained in:
parent
05ba2e8757
commit
0afe84bbce
9 changed files with 133 additions and 243 deletions
|
@ -372,9 +372,9 @@ var beforestart_b = func {
|
||||||
systems.ADIRSControlPanel.irModeSw(0, 1);
|
systems.ADIRSControlPanel.irModeSw(0, 1);
|
||||||
systems.ADIRSControlPanel.irModeSw(1, 1);
|
systems.ADIRSControlPanel.irModeSw(1, 1);
|
||||||
systems.ADIRSControlPanel.irModeSw(2, 1);
|
systems.ADIRSControlPanel.irModeSw(2, 1);
|
||||||
systems.ADIRS.skip(0);
|
systems.ADIRSnew.ADIRunits[0].instAlign();
|
||||||
systems.ADIRS.skip(1);
|
systems.ADIRSnew.ADIRunits[1].instAlign();
|
||||||
systems.ADIRS.skip(2);
|
systems.ADIRSnew.ADIRunits[2].instAlign();
|
||||||
setprop("/controls/adirs/mcducbtn", 1);
|
setprop("/controls/adirs/mcducbtn", 1);
|
||||||
setprop("/controls/switches/beacon", 1);
|
setprop("/controls/switches/beacon", 1);
|
||||||
setprop("/controls/lighting/nav-lights-switch", 1);
|
setprop("/controls/lighting/nav-lights-switch", 1);
|
||||||
|
@ -463,9 +463,9 @@ var taxi_b = func {
|
||||||
systems.ADIRSControlPanel.irModeSw(0, 1);
|
systems.ADIRSControlPanel.irModeSw(0, 1);
|
||||||
systems.ADIRSControlPanel.irModeSw(1, 1);
|
systems.ADIRSControlPanel.irModeSw(1, 1);
|
||||||
systems.ADIRSControlPanel.irModeSw(2, 1);
|
systems.ADIRSControlPanel.irModeSw(2, 1);
|
||||||
systems.ADIRS.skip(0);
|
systems.ADIRSnew.ADIRunits[0].instAlign();
|
||||||
systems.ADIRS.skip(1);
|
systems.ADIRSnew.ADIRunits[1].instAlign();
|
||||||
systems.ADIRS.skip(2);
|
systems.ADIRSnew.ADIRunits[2].instAlign();
|
||||||
setprop("/controls/adirs/mcducbtn", 1);
|
setprop("/controls/adirs/mcducbtn", 1);
|
||||||
setprop("/controls/switches/beacon", 1);
|
setprop("/controls/switches/beacon", 1);
|
||||||
setprop("/controls/switches/wing-lights", 1);
|
setprop("/controls/switches/wing-lights", 1);
|
||||||
|
|
|
@ -877,7 +877,7 @@ var canvas_MCDU_base = {
|
||||||
me["Simple_R6S"].setText("TROPO");
|
me["Simple_R6S"].setText("TROPO");
|
||||||
me["Simple_R1"].setText(sprintf("%s", depArpt.getValue() ~ "/" ~ arrArpt.getValue()));
|
me["Simple_R1"].setText(sprintf("%s", depArpt.getValue() ~ "/" ~ arrArpt.getValue()));
|
||||||
me["Simple_R2"].setText("REQUEST ");
|
me["Simple_R2"].setText("REQUEST ");
|
||||||
me["Simple_R3"].setText("ALIGN IRS ");
|
me["Simple_R3"].setText("IRS INIT >");
|
||||||
me["Simple_R4"].setText("-----.--");
|
me["Simple_R4"].setText("-----.--");
|
||||||
me["Simple_R5"].setText("WIND ");
|
me["Simple_R5"].setText("WIND ");
|
||||||
me["Simple_R6"].setText(sprintf("%5.0f", tropo.getValue()));
|
me["Simple_R6"].setText(sprintf("%5.0f", tropo.getValue()));
|
||||||
|
|
|
@ -108,12 +108,6 @@ var athr = props.globals.getNode("/it-autoflight/output/athr", 1);
|
||||||
var gear_agl = props.globals.getNode("/position/gear-agl-ft", 1);
|
var gear_agl = props.globals.getNode("/position/gear-agl-ft", 1);
|
||||||
var aileron_input = props.globals.getNode("/controls/flight/aileron-input-fast", 1);
|
var aileron_input = props.globals.getNode("/controls/flight/aileron-input-fast", 1);
|
||||||
var elevator_input = props.globals.getNode("/controls/flight/elevator-input-fast", 1);
|
var elevator_input = props.globals.getNode("/controls/flight/elevator-input-fast", 1);
|
||||||
var adirs0_active = props.globals.getNode("/instrumentation/adirs/adr[0]/active", 1);
|
|
||||||
var adirs1_active = props.globals.getNode("/instrumentation/adirs/adr[1]/active", 1);
|
|
||||||
var adirs2_active = props.globals.getNode("/instrumentation/adirs/adr[2]/active", 1);
|
|
||||||
var ir0_aligned = props.globals.getNode("/instrumentation/adirs/ir[0]/aligned", 1);
|
|
||||||
var ir1_aligned = props.globals.getNode("/instrumentation/adirs/ir[1]/aligned", 1);
|
|
||||||
var ir2_aligned = props.globals.getNode("/instrumentation/adirs/ir[2]/aligned", 1);
|
|
||||||
var att_switch = props.globals.getNode("/controls/switching/ATTHDG", 1);
|
var att_switch = props.globals.getNode("/controls/switching/ATTHDG", 1);
|
||||||
var air_switch = props.globals.getNode("/controls/switching/AIRDATA", 1);
|
var air_switch = props.globals.getNode("/controls/switching/AIRDATA", 1);
|
||||||
|
|
||||||
|
@ -790,26 +784,22 @@ var canvas_PFD_1 = {
|
||||||
wow2_act = wow2.getValue();
|
wow2_act = wow2.getValue();
|
||||||
|
|
||||||
# Errors
|
# Errors
|
||||||
if ((adirs0_active.getValue() == 1) or (air_switch.getValue() == -1 and adirs2_active.getValue() == 1)) {
|
if (systems.ADIRSnew.ADIRunits[0].aligned == 1 or (systems.ADIRSnew.ADIRunits[2].aligned == 1 and att_switch.getValue() == -1)) {
|
||||||
me["VS_group"].show();
|
|
||||||
me["VS_error"].hide();
|
|
||||||
} else {
|
|
||||||
me["VS_error"].show();
|
|
||||||
me["VS_group"].hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ir0_aligned.getValue() == 1) or (ir2_aligned.getValue() == 1 and att_switch.getValue() == -1)) {
|
|
||||||
me["AI_group"].show();
|
me["AI_group"].show();
|
||||||
me["HDG_group"].show();
|
me["HDG_group"].show();
|
||||||
me["AI_error"].hide();
|
me["AI_error"].hide();
|
||||||
me["HDG_error"].hide();
|
me["HDG_error"].hide();
|
||||||
me["HDG_frame"].setColor(1,1,1);
|
me["HDG_frame"].setColor(1,1,1);
|
||||||
|
me["VS_group"].show();
|
||||||
|
me["VS_error"].hide(); # VS is inertial-sourced
|
||||||
} else {
|
} else {
|
||||||
me["AI_error"].show();
|
me["AI_error"].show();
|
||||||
me["HDG_error"].show();
|
me["HDG_error"].show();
|
||||||
me["HDG_frame"].setColor(1,0,0);
|
me["HDG_frame"].setColor(1,0,0);
|
||||||
me["AI_group"].hide();
|
me["AI_group"].hide();
|
||||||
me["HDG_group"].hide();
|
me["HDG_group"].hide();
|
||||||
|
me["VS_error"].show();
|
||||||
|
me["VS_group"].hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
# FD
|
# FD
|
||||||
|
@ -1083,37 +1073,22 @@ var canvas_PFD_2 = {
|
||||||
wow2_act = wow2.getValue();
|
wow2_act = wow2.getValue();
|
||||||
|
|
||||||
# Errors
|
# Errors
|
||||||
if ((adirs1_active.getValue() == 1) or (air_switch.getValue() == 1 and adirs2_active.getValue() == 1)) {
|
if (systems.ADIRSnew.ADIRunits[1].aligned == 1 or (systems.ADIRSnew.ADIRunits[2].aligned == 1 and att_switch.getValue() == 1)) {
|
||||||
me["ALT_group"].show();
|
|
||||||
me["ALT_group2"].show();
|
|
||||||
me["ALT_scale"].show();
|
|
||||||
me["VS_group"].show();
|
|
||||||
me["ALT_error"].hide();
|
|
||||||
me["ALT_frame"].setColor(1,1,1);
|
|
||||||
me["VS_error"].hide();
|
|
||||||
} else {
|
|
||||||
me["ALT_error"].show();
|
|
||||||
me["ALT_frame"].setColor(1,0,0);
|
|
||||||
me["VS_error"].show();
|
|
||||||
me["ASI_group"].hide();
|
|
||||||
me["ALT_group"].hide();
|
|
||||||
me["ALT_group2"].hide();
|
|
||||||
me["ALT_scale"].hide();
|
|
||||||
me["VS_group"].hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ir1_aligned.getValue() == 1) or (ir2_aligned.getValue() == 1 and att_switch.getValue() == 1)) {
|
|
||||||
me["AI_group"].show();
|
me["AI_group"].show();
|
||||||
me["HDG_group"].show();
|
me["HDG_group"].show();
|
||||||
me["AI_error"].hide();
|
me["AI_error"].hide();
|
||||||
me["HDG_error"].hide();
|
me["HDG_error"].hide();
|
||||||
me["HDG_frame"].setColor(1,1,1);
|
me["HDG_frame"].setColor(1,1,1);
|
||||||
|
me["VS_group"].show();
|
||||||
|
me["VS_error"].hide(); # VS is inertial-sourced
|
||||||
} else {
|
} else {
|
||||||
me["AI_error"].show();
|
me["AI_error"].show();
|
||||||
me["HDG_error"].show();
|
me["HDG_error"].show();
|
||||||
me["HDG_frame"].setColor(1,0,0);
|
me["HDG_frame"].setColor(1,0,0);
|
||||||
me["AI_group"].hide();
|
me["AI_group"].hide();
|
||||||
me["HDG_group"].hide();
|
me["HDG_group"].hide();
|
||||||
|
me["VS_error"].show();
|
||||||
|
me["VS_group"].hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
# FD
|
# FD
|
||||||
|
|
|
@ -96,9 +96,9 @@ var initInputA = func(key, i) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (key == "R3") {
|
} else if (key == "R3") {
|
||||||
if (getprop("/controls/adirs/mcducbtn") == 0) {
|
#if (getprop("/controls/adirs/mcducbtn") == 0) {
|
||||||
setprop("/controls/adirs/mcducbtn", 1);
|
# setprop("/controls/adirs/mcducbtn", 1);
|
||||||
}
|
#}
|
||||||
} else if (key == "R6") {
|
} else if (key == "R6") {
|
||||||
if (scratchpad == "CLR") {
|
if (scratchpad == "CLR") {
|
||||||
setprop("/FMGC/internal/tropo", 36090);
|
setprop("/FMGC/internal/tropo", 36090);
|
||||||
|
|
|
@ -233,7 +233,6 @@ var systemsLoop = maketimer(0.1, func {
|
||||||
systems.PNEU.loop();
|
systems.PNEU.loop();
|
||||||
systems.HYD.loop();
|
systems.HYD.loop();
|
||||||
systems.FUEL.loop();
|
systems.FUEL.loop();
|
||||||
systems.ADIRS.loop();
|
|
||||||
systems.ADIRSnew.loop();
|
systems.ADIRSnew.loop();
|
||||||
libraries.ECAM.loop();
|
libraries.ECAM.loop();
|
||||||
libraries.BUTTONS.update();
|
libraries.BUTTONS.update();
|
||||||
|
|
|
@ -105,8 +105,16 @@ var Options = {
|
||||||
eng: props.globals.getNode("/options/eng"),
|
eng: props.globals.getNode("/options/eng"),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var Orientation = {
|
||||||
|
pitch: props.globals.getNode("/orientation/pitch-deg"),
|
||||||
|
roll: props.globals.getNode("/orientation/roll-deg"),
|
||||||
|
yaw: props.globals.getNode("/orientation/yaw-deg"),
|
||||||
|
};
|
||||||
|
|
||||||
var Position = {
|
var Position = {
|
||||||
gearAglFt: props.globals.getNode("/position/gear-agl-ft"),
|
gearAglFt: props.globals.getNode("/position/gear-agl-ft"),
|
||||||
|
latitude: props.globals.getNode("/position/latitude-deg"),
|
||||||
|
longitude: props.globals.getNode("/position/longitude-deg"),
|
||||||
};
|
};
|
||||||
|
|
||||||
var Sim = {
|
var Sim = {
|
||||||
|
@ -119,16 +127,14 @@ var Sim = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
var Orientation = {
|
|
||||||
pitch: props.globals.getNode("/orientation/pitch-deg"),
|
|
||||||
roll: props.globals.getNode("/orientation/roll-deg"),
|
|
||||||
yaw: props.globals.getNode("/orientation/yaw-deg"),
|
|
||||||
};
|
|
||||||
|
|
||||||
var PTSSystems = {
|
var PTSSystems = {
|
||||||
Thrust: {
|
Thrust: {
|
||||||
flex: props.globals.getNode("/systems/thrust/lim-flex"),
|
flex: props.globals.getNode("/systems/thrust/lim-flex"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var Velocities = {
|
||||||
|
groundspeed: props.globals.getNode("/velocities/groundspeed-kt"),
|
||||||
|
};
|
||||||
|
|
||||||
setprop("/systems/acconfig/property-tree-setup-loaded", 1);
|
setprop("/systems/acconfig/property-tree-setup-loaded", 1);
|
||||||
|
|
|
@ -2,35 +2,8 @@
|
||||||
# Joshua Davidson (Octal450)
|
# Joshua Davidson (Octal450)
|
||||||
|
|
||||||
# Copyright (c) 2019 Joshua Davidson (Octal450)
|
# Copyright (c) 2019 Joshua Davidson (Octal450)
|
||||||
|
|
||||||
var knob = 0;
|
|
||||||
var roll = 0;
|
|
||||||
var pitch = 0;
|
|
||||||
var gs = 0;
|
|
||||||
var ac1 = 0;
|
|
||||||
var ac2 = 0;
|
|
||||||
var dcbat = 0;
|
|
||||||
var pwr_src = "XX";
|
|
||||||
setprop("/controls/adirs/align-time", 600);
|
|
||||||
|
|
||||||
var ADIRS = {
|
var ADIRS = {
|
||||||
init: func() {
|
init: func() {
|
||||||
setprop("/controls/adirs/numm", 0);
|
|
||||||
setprop("/instrumentation/adirs/ir[0]/aligned", 0);
|
|
||||||
setprop("/instrumentation/adirs/ir[1]/aligned", 0);
|
|
||||||
setprop("/instrumentation/adirs/ir[2]/aligned", 0);
|
|
||||||
setprop("/controls/adirs/ir[0]/align", 0);
|
|
||||||
setprop("/controls/adirs/ir[1]/align", 0);
|
|
||||||
setprop("/controls/adirs/ir[2]/align", 0);
|
|
||||||
setprop("/controls/adirs/ir[0]/time", 0);
|
|
||||||
setprop("/controls/adirs/ir[1]/time", 0);
|
|
||||||
setprop("/controls/adirs/ir[2]/time", 0);
|
|
||||||
setprop("/controls/adirs/ir[0]/knob", 0);
|
|
||||||
setprop("/controls/adirs/ir[1]/knob", 0);
|
|
||||||
setprop("/controls/adirs/ir[2]/knob", 0);
|
|
||||||
setprop("/controls/adirs/ir[0]/fault", 0);
|
|
||||||
setprop("/controls/adirs/ir[1]/fault", 0);
|
|
||||||
setprop("/controls/adirs/ir[2]/fault", 0);
|
|
||||||
setprop("/controls/adirs/mcdu/mode1", ""); # INVAL ALIGN NAV ATT or off (blank)
|
setprop("/controls/adirs/mcdu/mode1", ""); # INVAL ALIGN NAV ATT or off (blank)
|
||||||
setprop("/controls/adirs/mcdu/mode2", "");
|
setprop("/controls/adirs/mcdu/mode2", "");
|
||||||
setprop("/controls/adirs/mcdu/mode3", "");
|
setprop("/controls/adirs/mcdu/mode3", "");
|
||||||
|
@ -43,160 +16,4 @@ var ADIRS = {
|
||||||
setprop("/controls/adirs/mcdu/avgdrift3", "");
|
setprop("/controls/adirs/mcdu/avgdrift3", "");
|
||||||
setprop("/controls/adirs/mcducbtn", 0);
|
setprop("/controls/adirs/mcducbtn", 0);
|
||||||
},
|
},
|
||||||
loop: func() {
|
};
|
||||||
roll = getprop("/orientation/roll-deg");
|
|
||||||
pitch = getprop("/orientation/pitch-deg");
|
|
||||||
gs = getprop("/velocities/groundspeed-kt");
|
|
||||||
ac1 = getprop("/systems/electrical/bus/ac-1");
|
|
||||||
ac2 = getprop("/systems/electrical/bus/ac-2");
|
|
||||||
dcbat = getprop("/systems/electrical/bus/dc-bat");
|
|
||||||
|
|
||||||
if (getprop("/controls/adirs/skip") == 1) {
|
|
||||||
if (getprop("/controls/adirs/align-time") != 5) {
|
|
||||||
setprop("/controls/adirs/align-time", 5);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (getprop("/controls/adirs/align-time") != 600) {
|
|
||||||
setprop("/controls/adirs/align-time", 600);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (gs > 5 or pitch > 5 or pitch < -5 or roll > 10 or roll < -10 or (ac1 < 110 and ac2 < 110 and dcbat < 25)) {
|
|
||||||
if (getprop("/controls/adirs/ir[0]/align") == 1) {
|
|
||||||
me.stopAlign(0,1);
|
|
||||||
}
|
|
||||||
if (getprop("/controls/adirs/ir[1]/align") == 1) {
|
|
||||||
me.stopAlign(1,1);
|
|
||||||
}
|
|
||||||
if (getprop("/controls/adirs/ir[2]/align") == 1) {
|
|
||||||
me.stopAlign(2,1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
knob: func(k) {
|
|
||||||
knob = getprop("/controls/adirs/ir[" ~ k ~ "]/knob");
|
|
||||||
if (knob == 0) {
|
|
||||||
me.stopAlign(k,0);
|
|
||||||
} else if (knob == 1) {
|
|
||||||
me.beginAlign(k);
|
|
||||||
} else if (knob == 2) {
|
|
||||||
me.beginAlign(k);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
beginAlign: func(n) {
|
|
||||||
ac1 = getprop("/systems/electrical/bus/ac-1");
|
|
||||||
ac2 = getprop("/systems/electrical/bus/ac-2");
|
|
||||||
dcbat = getprop("/systems/electrical/bus/dc-bat");
|
|
||||||
setprop("/instrumentation/adirs/adr[" ~ n ~ "]/active", 1);
|
|
||||||
if (getprop("/controls/adirs/ir[" ~ n ~ "]/align") != 1 and getprop("/instrumentation/adirs/ir[" ~ n ~ "]/aligned") != 1 and (ac1 >= 110 or ac2 >= 110 or dcbat >= 25)) {
|
|
||||||
setprop("/controls/adirs/ir[" ~ n ~ "]/time", getprop("/sim/time/elapsed-sec"));
|
|
||||||
setprop("/controls/adirs/ir[" ~ n ~ "]/align", 1);
|
|
||||||
setprop("/controls/adirs/ir[" ~ n ~ "]/fault", 0);
|
|
||||||
if (n == 0) {
|
|
||||||
alignOne.start();
|
|
||||||
} else if (n == 1) {
|
|
||||||
alignTwo.start();
|
|
||||||
} else if (n == 2) {
|
|
||||||
alignThree.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
stopAlign: func(n,f) {
|
|
||||||
setprop("/controls/adirs/ir[" ~ n ~ "]/align", 0);
|
|
||||||
if (f == 1) {
|
|
||||||
setprop("/controls/adirs/ir[" ~ n ~ "]/fault", 1);
|
|
||||||
} else {
|
|
||||||
setprop("/controls/adirs/ir[" ~ n ~ "]/fault", 0);
|
|
||||||
}
|
|
||||||
if (n == 0) {
|
|
||||||
alignOne.stop();
|
|
||||||
} else if (n == 1) {
|
|
||||||
alignTwo.stop();
|
|
||||||
} else if (n == 2) {
|
|
||||||
alignThree.stop();
|
|
||||||
}
|
|
||||||
setprop("/instrumentation/adirs/ir[" ~ n ~ "]/aligned", 0);
|
|
||||||
setprop("/controls/adirs/mcducbtn", 0);
|
|
||||||
},
|
|
||||||
skip: func(n) {
|
|
||||||
if (n == 0) {
|
|
||||||
alignOne.stop();
|
|
||||||
} else if (n == 1) {
|
|
||||||
alignTwo.stop();
|
|
||||||
} else if (n == 2) {
|
|
||||||
alignThree.stop();
|
|
||||||
}
|
|
||||||
setprop("/controls/adirs/ir[" ~ n ~ "]/align", 0);
|
|
||||||
setprop("/controls/adirs/ir[" ~ n ~ "]/fault", 0);
|
|
||||||
setprop("/instrumentation/adirs/ir[" ~ n ~ "]/aligned", 1);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
var alignOne = maketimer(0.1, func {
|
|
||||||
if (getprop("/controls/adirs/ir[0]/time") + getprop("/controls/adirs/align-time") >= getprop("/sim/time/elapsed-sec")) {
|
|
||||||
if (getprop("/instrumentation/adirs/ir[0]/aligned") != 0) {
|
|
||||||
setprop("/instrumentation/adirs/ir[0]/aligned", 0);
|
|
||||||
}
|
|
||||||
if (getprop("/controls/adirs/ir[0]/align") != 1) {
|
|
||||||
setprop("/controls/adirs/ir[0]/align", 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (getprop("/instrumentation/adirs/ir[0]/aligned") != 1 and getprop("/controls/adirs/mcducbtn") == 1) {
|
|
||||||
alignOne.stop();
|
|
||||||
setprop("/instrumentation/adirs/ir[0]/aligned", 1);
|
|
||||||
}
|
|
||||||
if (getprop("/controls/adirs/ir[0]/align") != 0) {
|
|
||||||
setprop("/controls/adirs/ir[0]/align", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var alignTwo = maketimer(0.1, func {
|
|
||||||
if (getprop("/controls/adirs/ir[1]/time") + getprop("/controls/adirs/align-time") >= getprop("/sim/time/elapsed-sec")) {
|
|
||||||
if (getprop("/instrumentation/adirs/ir[1]/aligned") != 0) {
|
|
||||||
setprop("/instrumentation/adirs/ir[1]/aligned", 0);
|
|
||||||
}
|
|
||||||
if (getprop("/controls/adirs/ir[1]/align") != 1) {
|
|
||||||
setprop("/controls/adirs/ir[1]/align", 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (getprop("/instrumentation/adirs/ir[1]/aligned") != 1 and getprop("/controls/adirs/mcducbtn") == 1) {
|
|
||||||
alignTwo.stop();
|
|
||||||
setprop("/instrumentation/adirs/ir[1]/aligned", 1);
|
|
||||||
}
|
|
||||||
if (getprop("/controls/adirs/ir[1]/align") != 0) {
|
|
||||||
setprop("/controls/adirs/ir[1]/align", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var alignThree = maketimer(0.1, func {
|
|
||||||
if (getprop("/controls/adirs/ir[2]/time") + getprop("/controls/adirs/align-time") >= getprop("/sim/time/elapsed-sec")) {
|
|
||||||
if (getprop("/instrumentation/adirs/ir[2]/aligned") != 0) {
|
|
||||||
setprop("/instrumentation/adirs/ir[2]/aligned", 0);
|
|
||||||
}
|
|
||||||
if (getprop("/controls/adirs/ir[2]/align") != 1) {
|
|
||||||
setprop("/controls/adirs/ir[2]/align", 1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (getprop("/instrumentation/adirs/ir[2]/aligned") != 1 and getprop("/controls/adirs/mcducbtn") == 1) {
|
|
||||||
alignThree.stop();
|
|
||||||
setprop("/instrumentation/adirs/ir[2]/aligned", 1);
|
|
||||||
}
|
|
||||||
if (getprop("/controls/adirs/ir[2]/align") != 0) {
|
|
||||||
setprop("/controls/adirs/ir[2]/align", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
setlistener("/controls/adirs/ir[0]/knob", func {
|
|
||||||
ADIRS.knob(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
setlistener("/controls/adirs/ir[1]/knob", func {
|
|
||||||
ADIRS.knob(1);
|
|
||||||
});
|
|
||||||
|
|
||||||
setlistener("/controls/adirs/ir[2]/knob", func {
|
|
||||||
ADIRS.knob(2);
|
|
||||||
});
|
|
|
@ -9,17 +9,24 @@ var _selfTestTime = nil;
|
||||||
|
|
||||||
var ADIRU = {
|
var ADIRU = {
|
||||||
# local vars
|
# local vars
|
||||||
|
_alignTime: 0,
|
||||||
_voltageMain: 0,
|
_voltageMain: 0,
|
||||||
_voltageBackup: 0,
|
_voltageBackup: 0,
|
||||||
_voltageLimitedTime: 0,
|
_voltageLimitedTime: 0,
|
||||||
_noPowerTime: 0,
|
_noPowerTime: 0,
|
||||||
_timeVar: 0,
|
_timeVar: 0,
|
||||||
|
_roll: 0,
|
||||||
|
_pitch: 0,
|
||||||
|
_gs: 0,
|
||||||
|
|
||||||
num: 0,
|
num: 0,
|
||||||
|
aligned: 0,
|
||||||
|
inAlign: 0,
|
||||||
outputOn: 0, # 0 = disc, 1 = normal
|
outputOn: 0, # 0 = disc, 1 = normal
|
||||||
mode: 0, # 0 = off, 1 = nav, 2 = att
|
mode: 0, # 0 = off, 1 = nav, 2 = att
|
||||||
energised: 0, # 0 = off, 1 = on
|
energised: 0, # 0 = off, 1 = on
|
||||||
operative: 0, # 0 = off,
|
operative: 0, # 0 = off,
|
||||||
|
alignTimer: nil,
|
||||||
input: [],
|
input: [],
|
||||||
output: [],
|
output: [],
|
||||||
|
|
||||||
|
@ -27,8 +34,18 @@ var ADIRU = {
|
||||||
new: func(n) {
|
new: func(n) {
|
||||||
var adiru = { parents:[ADIRU] };
|
var adiru = { parents:[ADIRU] };
|
||||||
adiru.num = n;
|
adiru.num = n;
|
||||||
|
adiru.alignTimer = maketimer(0.1, adiru, me.alignLoop);
|
||||||
return adiru;
|
return adiru;
|
||||||
},
|
},
|
||||||
|
setOperative: func(newOperative) {
|
||||||
|
if (newOperative != me.operative) {
|
||||||
|
me.operative = newOperative;
|
||||||
|
if (newOperative) {
|
||||||
|
me.selfTest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
# Power and state
|
||||||
updateEnergised: func(mode) {
|
updateEnergised: func(mode) {
|
||||||
me.energised = mode != 0 ? 1 : 0;
|
me.energised = mode != 0 ? 1 : 0;
|
||||||
},
|
},
|
||||||
|
@ -41,6 +58,7 @@ var ADIRU = {
|
||||||
me._voltageLimitedTime = isLimited;
|
me._voltageLimitedTime = isLimited;
|
||||||
return me._voltageBackup;
|
return me._voltageBackup;
|
||||||
},
|
},
|
||||||
|
# BITE
|
||||||
selfTest: func() {
|
selfTest: func() {
|
||||||
ADIRSnew._selfTest = 1;
|
ADIRSnew._selfTest = 1;
|
||||||
_selfTestTime = pts.Sim.Time.elapsedSec.getValue();
|
_selfTestTime = pts.Sim.Time.elapsedSec.getValue();
|
||||||
|
@ -66,14 +84,67 @@ var ADIRU = {
|
||||||
|
|
||||||
ADIRSnew.selfTest();
|
ADIRSnew.selfTest();
|
||||||
},
|
},
|
||||||
setOperative: func(newOperative) {
|
# Alignment
|
||||||
if (newOperative != me.operative) {
|
align: func(time) {
|
||||||
me.operative = newOperative;
|
ADIRSnew.Lights.irFault[me.num].setBoolValue(0);
|
||||||
if (newOperative) {
|
if (!ADIRSnew.skip.getValue()) {
|
||||||
me.selfTest();
|
if (time > 0 and me.aligned == 0 and me.inAlign == 0 and me.operative == 1) {
|
||||||
|
me._alignTime = pts.Sim.Time.elapsedSec.getValue() + time;
|
||||||
|
print("Alignment Started");
|
||||||
|
me.inAlign = 1;
|
||||||
|
if (me.alignTimer != nil) {
|
||||||
|
me.alignTimer.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (me.aligned == 0 and me.inAlign == 0 and me.operative == 1) {
|
||||||
|
me._alignTime = pts.Sim.Time.elapsedSec.getValue() + 5;
|
||||||
|
print("Fast Alignment Started");
|
||||||
|
me.inAlign = 1;
|
||||||
|
if (me.alignTimer != nil) {
|
||||||
|
me.alignTimer.start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
stopAlignNoAlign: func() {
|
||||||
|
print("Stopping alignment or setting unaligned state");
|
||||||
|
me.inAlign = 0;
|
||||||
|
me.aligned = 0;
|
||||||
|
if (me.alignTimer != nil) {
|
||||||
|
me.alignTimer.stop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
stopAlignAligned: func() {
|
||||||
|
print("Aligned");
|
||||||
|
me.inAlign = 0;
|
||||||
|
me.aligned = 1;
|
||||||
|
if (me.alignTimer != nil) {
|
||||||
|
me.alignTimer.stop();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
alignLoop: func() {
|
||||||
|
me._roll = pts.Orientation.roll.getValue();
|
||||||
|
me._pitch = pts.Orientation.pitch.getValue();
|
||||||
|
me._gs = pts.Velocities.groundspeed.getValue();
|
||||||
|
|
||||||
|
# todo use IR values
|
||||||
|
if (me._gs > 5 or abs(me._pitch) > 5 or abs(me._roll) > 10) {
|
||||||
|
me.stopAlignNoAlign();
|
||||||
|
print("Excessive motion, restarting");
|
||||||
|
me.update(); # update operative
|
||||||
|
me.align(calcAlignTime(pts.Position.latitude.getValue()));
|
||||||
|
} elsif (me.operative == 0) {
|
||||||
|
print("ADIRU " ~ me.num ~ " off");
|
||||||
|
me.stopAlignNoAlign();
|
||||||
|
} elsif (pts.Sim.Time.elapsedSec.getValue() >= me._alignTime) {
|
||||||
|
me.stopAlignAligned();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
instAlign: func() {
|
||||||
|
me.stopAlignAligned();
|
||||||
|
},
|
||||||
|
# Update loop
|
||||||
update: func() {
|
update: func() {
|
||||||
me._timeVar = pts.Sim.Time.elapsedSec.getValue();
|
me._timeVar = pts.Sim.Time.elapsedSec.getValue();
|
||||||
if (me.energised and !me._voltageMain and me._voltageLimitedTime and me._noPowerTime == 0) {
|
if (me.energised and !me._voltageMain and me._voltageLimitedTime and me._noPowerTime == 0) {
|
||||||
|
@ -136,6 +207,13 @@ var ADIRSControlPanel = {
|
||||||
ADIRSnew.ADIRunits[n].mode = mode;
|
ADIRSnew.ADIRunits[n].mode = mode;
|
||||||
ADIRSnew.ADIRunits[n].updateEnergised(mode);
|
ADIRSnew.ADIRunits[n].updateEnergised(mode);
|
||||||
ADIRSnew.Switches.irModeSw[n].setValue(mode);
|
ADIRSnew.Switches.irModeSw[n].setValue(mode);
|
||||||
|
if (mode == 0) {
|
||||||
|
ADIRSnew.Lights.irFault[n].setBoolValue(0);
|
||||||
|
ADIRSnew.ADIRunits[n].stopAlignNoAlign();
|
||||||
|
} elsif (ADIRSnew.ADIRunits[n].aligned == 0) {
|
||||||
|
ADIRSnew.ADIRunits[n].update(); # update early so operative is set properly
|
||||||
|
ADIRSnew.ADIRunits[n].align(calcAlignTime(pts.Position.latitude.getValue())); # when you set NAV, it first acquires GPS position then acquires GPS. You then use IRS INIT > to set PPOS to align if you wish
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -155,7 +233,6 @@ var ADIRSnew = {
|
||||||
|
|
||||||
# ADIRS Units
|
# ADIRS Units
|
||||||
ADIRunits: [nil, nil, nil],
|
ADIRunits: [nil, nil, nil],
|
||||||
#IRunits: [nil, nil, nil],
|
|
||||||
|
|
||||||
# Electrical
|
# Electrical
|
||||||
mainSupply: [systems.ELEC.Bus.acEss, systems.ELEC.Bus.ac2, systems.ELEC.Bus.ac1],
|
mainSupply: [systems.ELEC.Bus.acEss, systems.ELEC.Bus.ac2, systems.ELEC.Bus.ac1],
|
||||||
|
@ -180,6 +257,8 @@ var ADIRSnew = {
|
||||||
|
|
||||||
# Nodes
|
# Nodes
|
||||||
overspeedVFE: props.globals.initNode("/systems/navigation/adr/computation/overspeed-vfe-spd", 0, "INT"),
|
overspeedVFE: props.globals.initNode("/systems/navigation/adr/computation/overspeed-vfe-spd", 0, "INT"),
|
||||||
|
skip: props.globals.initNode("/controls/adirs/skip", 0, "BOOL"),
|
||||||
|
mcduControl: props.globals.initNode("/controls/adirs/mcducbtn", 0, "BOOL"),
|
||||||
|
|
||||||
# System
|
# System
|
||||||
init: func() {
|
init: func() {
|
||||||
|
@ -249,12 +328,26 @@ var ADIRSnew = {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var calcAlignTime = func(latitude) {
|
||||||
|
return ((0.002 * (latitude * latitude)) + 5) * 60;
|
||||||
|
};
|
||||||
|
|
||||||
setlistener("/systems/fmgc/cas-compare/cas-reject-all", func() {
|
setlistener("/systems/fmgc/cas-compare/cas-reject-all", func() {
|
||||||
if (pts.FMGC.CasCompare.rejectAll.getBoolValue()) {
|
if (pts.FMGC.CasCompare.rejectAll.getBoolValue()) {
|
||||||
fcu.athrOff("hard");
|
fcu.athrOff("hard");
|
||||||
}
|
}
|
||||||
}, 0, 0);
|
}, 0, 0);
|
||||||
|
|
||||||
|
setlistener("/controls/adirs/skip", func() {
|
||||||
|
if (ADIRSnew.skip.getBoolValue()) {
|
||||||
|
for (i = 0; i < 3; i = i + 1) {
|
||||||
|
if (ADIRSnew.ADIRunits[i].inAlign == 1) {
|
||||||
|
ADIRSnew.ADIRunits[i].stopAlignAligned();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0, 0);
|
||||||
|
|
||||||
selfTestLoop = maketimer(0.2, func() {
|
selfTestLoop = maketimer(0.2, func() {
|
||||||
if (pts.Sim.Time.elapsedSec.getValue() > _selfTestTime + 5) {
|
if (pts.Sim.Time.elapsedSec.getValue() > _selfTestTime + 5) {
|
||||||
ADIRSnew.Lights.onBat.setBoolValue(0);
|
ADIRSnew.Lights.onBat.setBoolValue(0);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
16
|
17
|
Loading…
Add table
Reference in a new issue