Merge branch 'master' into mcdu

This commit is contained in:
Joshua Davidson 2017-11-21 15:29:22 -05:00
commit b02df6331f
16 changed files with 82023 additions and 60837 deletions

View file

@ -157,29 +157,6 @@
<instrumentation>
<path>Aircraft/IDG-A32X/Systems/instrumentation.xml</path>
<adirs n="0">
<ir n="0">
<aligned type="bool">false</aligned>
<display>
<status type="string"></status>
<ttn type="int">0</ttn>
</display>
</ir>
<ir n="1">
<aligned type="bool">false</aligned>
<display>
<status type="string"></status>
<ttn type="int">0</ttn>
</display>
</ir>
<ir n="2">
<aligned type="bool">false</aligned>
<display>
<status type="string"></status>
<ttn type="int">0</ttn>
</display>
</ir>
</adirs>
</instrumentation>
<alarms>

View file

@ -151,11 +151,11 @@ saveSettings();
var systemsReset = func {
fbw.fctlInit();
systems.elec_init();
systems.ADIRSreset();
systems.pneu_init();
systems.hyd_init();
systems.fuel_init();
systems.ELEC.init();
systems.PNEU.init();
systems.HYD.init();
systems.FUEL.init();
systems.ADIRS.init();
systems.eng_init();
systems.autobrake_init();
fmgc.FMGCinit();
@ -290,12 +290,9 @@ var beforestart_b = func {
setprop("controls/adirs/ir[0]/knob","2");
setprop("controls/adirs/ir[1]/knob","2");
setprop("controls/adirs/ir[2]/knob","2");
setprop("instrumentation/adirs/ir[0]/display/ttn",0);
setprop("instrumentation/adirs/ir[1]/display/ttn",0);
setprop("instrumentation/adirs/ir[2]/display/ttn",0);
setprop("instrumentation/adirs/ir[0]/aligned",1);
setprop("instrumentation/adirs/ir[1]/aligned",1);
setprop("instrumentation/adirs/ir[2]/aligned",1);
systems.ADIRS.skip(0);
systems.ADIRS.skip(1);
systems.ADIRS.skip(2);
setprop("/controls/adirs/mcducbtn", 1);
setprop("/controls/lighting/beacon", 1);
setprop("/controls/lighting/nav-lights-switch", 1);
@ -367,12 +364,9 @@ var taxi_b = func {
setprop("controls/adirs/ir[0]/knob","2");
setprop("controls/adirs/ir[1]/knob","2");
setprop("controls/adirs/ir[2]/knob","2");
setprop("instrumentation/adirs/ir[0]/display/ttn",0);
setprop("instrumentation/adirs/ir[1]/display/ttn",0);
setprop("instrumentation/adirs/ir[2]/display/ttn",0);
setprop("instrumentation/adirs/ir[0]/aligned",1);
setprop("instrumentation/adirs/ir[1]/aligned",1);
setprop("instrumentation/adirs/ir[2]/aligned",1);
systems.ADIRS.skip(0);
systems.ADIRS.skip(1);
systems.ADIRS.skip(2);
setprop("/controls/adirs/mcducbtn", 1);
setprop("/controls/lighting/beacon", 1);
setprop("/controls/lighting/nav-lights-switch", 1);

View file

@ -26,15 +26,28 @@
<animation>
<type>select</type>
<object-name>hud</object-name>
<object-name>hud_box</object-name>
<object-name>hud_brt</object-name>
<object-name>hud_brt.axis</object-name>
<object-name>hud_norm_sw</object-name>
<object-name>hud_declutter_btn</object-name>
<object-name>hud_ceiling</object-name>
<object-name>fcu_labels_hud</object-name>
<condition>
<property>options/enable-hud</property>
</condition>
</animation>
<animation>
<type>select</type>
<object-name>visor_glass_cpt</object-name>
<object-name>visor_cpt</object-name>
<object-name>cpit_lamp_cpt</object-name>
<condition>
<not><property>options/enable-hud</property></not>
</condition>
</animation>
<!-- WIP ;) -->
<!--model>
<path>Aircraft/IDG-A32X/Models/Tablet/Tablet.xml</path>
@ -337,6 +350,22 @@
<object-name>dec_low_on</object-name>
<object-name>dec_med_on</object-name>
<object-name>dec_max_on</object-name>
<object-name>ecam_apu_led</object-name>
<object-name>ecam_bleed_led</object-name>
<object-name>ecam_cond_led</object-name>
<object-name>ecam_clr_l_led</object-name>
<object-name>ecam_clr_r_led</object-name>
<object-name>ecam_c_b_led</object-name>
<object-name>ecam_door_led</object-name>
<object-name>ecam_elec_led</object-name>
<object-name>ecam_el_dc_led</object-name>
<object-name>ecam_eng_led</object-name>
<object-name>ecam_fctl_led</object-name>
<object-name>ecam_fuel_led</object-name>
<object-name>ecam_hyd_led</object-name>
<object-name>ecam_press_led</object-name>
<object-name>ecam_sts_led</object-name>
<object-name>ecam_wheel_led</object-name>
<object-name>exped_led</object-name>
<object-name>fcu_screen</object-name>
<object-name>fd1_led</object-name>
@ -392,6 +421,22 @@
<type>select</type>
<object-name>alt-text-test</object-name>
<object-name>autoland_light_on</object-name>
<object-name>ecam_apu_led</object-name>
<object-name>ecam_bleed_led</object-name>
<object-name>ecam_cond_led</object-name>
<object-name>ecam_clr_l_led</object-name>
<object-name>ecam_clr_r_led</object-name>
<object-name>ecam_c_b_led</object-name>
<object-name>ecam_door_led</object-name>
<object-name>ecam_elec_led</object-name>
<object-name>ecam_el_dc_led</object-name>
<object-name>ecam_eng_led</object-name>
<object-name>ecam_fctl_led</object-name>
<object-name>ecam_fuel_led</object-name>
<object-name>ecam_hyd_led</object-name>
<object-name>ecam_press_led</object-name>
<object-name>ecam_sts_led</object-name>
<object-name>ecam_wheel_led</object-name>
<object-name>exped_led</object-name>
<object-name>hdg-text-test</object-name>
<object-name>master_caution_on</object-name>
@ -826,7 +871,7 @@
<animation>
<type>pick</type>
<object-name>pfd_brt_cpt</object-name>
<object-name>pfd_brt_cpt_mark</object-name>
<object-name>pfd_brt_cpt.mark</object-name>
<action>
<button>0</button>
<button>3</button>
@ -853,7 +898,6 @@
<animation>
<type>rotate</type>
<object-name>pfd_brt_cpt</object-name>
<object-name>pfd_brt_cpt_mark</object-name>
<property>controls/lighting/DU/du1</property>
<interpolation>
<entry><ind>0</ind><dep>-129</dep></entry>
@ -891,7 +935,7 @@
<animation>
<type>pick</type>
<object-name>brightness_nd_2_cpt</object-name>
<object-name>brightness_nd_2_cpt_mark</object-name>
<object-name>brightness_nd_2_cpt.mark</object-name>
<action>
<button>0</button>
<button>3</button>
@ -918,7 +962,6 @@
<animation>
<type>rotate</type>
<object-name>brightness_nd_2_cpt</object-name>
<object-name>brightness_nd_2_cpt_mark</object-name>
<property>controls/lighting/DU/du2</property>
<interpolation>
<entry><ind>0</ind><dep>-129</dep></entry>
@ -933,7 +976,7 @@
<animation>
<type>pick</type>
<object-name>brightness_nd_2_fo</object-name>
<object-name>brightness_nd_2_fo_mark</object-name>
<object-name>brightness_nd_2_fo.mark</object-name>
<action>
<button>0</button>
<button>3</button>
@ -960,7 +1003,6 @@
<animation>
<type>rotate</type>
<object-name>brightness_nd_2_fo</object-name>
<object-name>brightness_nd_2_fo_mark</object-name>
<property>controls/lighting/DU/du5</property>
<interpolation>
<entry><ind>0</ind><dep>-129</dep></entry>
@ -998,7 +1040,7 @@
<animation>
<type>pick</type>
<object-name>pfd_brt_fo</object-name>
<object-name>pfd_brt_fo_mark</object-name>
<object-name>pfd_brt_fo.mark</object-name>
<action>
<button>0</button>
<button>3</button>
@ -1025,7 +1067,6 @@
<animation>
<type>rotate</type>
<object-name>pfd_brt_fo</object-name>
<object-name>pfd_brt_fo_mark</object-name>
<property>controls/lighting/DU/du6</property>
<interpolation>
<entry><ind>0</ind><dep>-129</dep></entry>
@ -1037,6 +1078,86 @@
</animation>
<!-- ECAM Controls -->
<animation>
<type>pick</type>
<object-name>ecam_brt_upper</object-name>
<object-name>ecam_brt_upper.mark</object-name>
<action>
<button>0</button>
<button>3</button>
<repeatable>true</repeatable>
<binding>
<command>property-adjust</command>
<property>controls/lighting/DU/du3</property>
<step>0.05</step>
<max>1</max>
</binding>
</action>
<action>
<button>1</button>
<button>4</button>
<repeatable>true</repeatable>
<binding>
<command>property-adjust</command>
<property>controls/lighting/DU/du3</property>
<step>-0.05</step>
<min>0</min>
</binding>
</action>
</animation>
<animation>
<type>rotate</type>
<object-name>ecam_brt_upper</object-name>
<property>controls/lighting/DU/du3</property>
<interpolation>
<entry><ind>0</ind><dep>-129</dep></entry>
<entry><ind>1</ind><dep>129</dep></entry>
</interpolation>
<axis>
<object-name>ecam_brt_upper.axis</object-name>
</axis>
</animation>
<animation>
<type>pick</type>
<object-name>ecam_brt_lower</object-name>
<object-name>ecam_brt_lower.mark</object-name>
<action>
<button>0</button>
<button>3</button>
<repeatable>true</repeatable>
<binding>
<command>property-adjust</command>
<property>controls/lighting/DU/du4</property>
<step>0.05</step>
<max>1</max>
</binding>
</action>
<action>
<button>1</button>
<button>4</button>
<repeatable>true</repeatable>
<binding>
<command>property-adjust</command>
<property>controls/lighting/DU/du4</property>
<step>-0.05</step>
<min>0</min>
</binding>
</action>
</animation>
<animation>
<type>rotate</type>
<object-name>ecam_brt_lower</object-name>
<property>controls/lighting/DU/du4</property>
<interpolation>
<entry><ind>0</ind><dep>-129</dep></entry>
<entry><ind>1</ind><dep>129</dep></entry>
</interpolation>
<axis>
<object-name>ecam_brt_lower.axis</object-name>
</axis>
</animation>
<animation>
<type>pick</type>
<object-name>ecam_sts</object-name>
@ -4784,21 +4905,15 @@
</binding>
</action>
</animation>
<!-- FIXME: Thorsten H please check these coords or create a rotate axis -->
<!--animation>
<animation>
<type>rotate</type>
<object-name>fcu_integ_knb</object-name>
<property>controls/lighting/fcu-panel-knb</property>
<factor>10</factor>
<axis>
<x1-m>-0.45533</x1-m>
<y1-m>-0.0688</y1-m>
<z1-m>0.38539</z1-m>
<x2-m>-0.45035</x2-m>
<y2-m>-0.0688</y2-m>
<z2-m>0.37494</z2-m>
<object-name>fcu_integ_knb.axis</object-name>
</axis>
</animation-->
</animation>
<animation>
<name>Main Panel lighting</name>
@ -4816,9 +4931,29 @@
<object-name>flaps_scale</object-name>
<object-name>gear_lever_label</object-name>
<object-name>flood_lt_main.mark</object-name>
<object-name>flood_lt_ped_mark</object-name>
<object-name>flood_lt_ped.mark</object-name>
<object-name>integ_lt.mark</object-name>
<object-name>eng_mode_mark</object-name>
<object-name>eng_mode.mark</object-name>
<object-name>RudderTrim.mark</object-name>
<object-name>ecam_att_hdg_sw.mark</object-name>
<object-name>ecam_air_data_sw.mark</object-name>
<object-name>ecam_brt_upper.mark</object-name>
<object-name>ecam_brt_lower.mark</object-name>
<object-name>ecam_eis_dmc_sw.mark</object-name>
<object-name>ecam_glare</object-name>
<object-name>ecam_nd_xfr_sw.mark</object-name>
<object-name>pfd_brt_cpt.mark</object-name>
<object-name>speaker_volume_cpt.mark</object-name>
<object-name>light_console_cpt_sw.mark</object-name>
<object-name>foot_warmer_cpt_sw.mark</object-name>
<object-name>brightness_nd_2_cpt.mark</object-name>
<object-name>brightness_nd_1_cpt.mark</object-name>
<object-name>pfd_brt_fo.mark</object-name>
<object-name>speaker_volume_fo.mark</object-name>
<object-name>light_console_fo_sw.mark</object-name>
<object-name>foot_warmer_fo_sw.mark</object-name>
<object-name>brightness_nd_2_fo.mark</object-name>
<object-name>brightness_nd_1_fo.mark</object-name>
<emission>
<red>1</red>
<green>0.725</green>
@ -4833,11 +4968,11 @@
<object-name>fcu_labels</object-name>
<object-name>fcu_labels_hud</object-name>
<object-name>fcu_panel_emit</object-name>
<object-name>nd_mode_mark</object-name>
<object-name>nd_range_mark</object-name>
<object-name>nd_mode_fo_mark</object-name>
<object-name>nd_range_fo_mark</object-name>
<object-name>hud_brt_mark</object-name>
<object-name>nd_mode.mark</object-name>
<object-name>nd_range.mark</object-name>
<object-name>nd_mode_fo.mark</object-name>
<object-name>nd_range_fo.mark</object-name>
<object-name>hud_brt.mark</object-name>
<emission>
<red>1</red>
<green>0.725</green>
@ -5756,40 +5891,5 @@
<blue>0.08</blue>
</emission>
</animation>
<!--effect>
<inherits-from>Models/Effects/IDG-A32X-interior</inherits-from>
<object-name>fcu_panel</object-name>
<object-name>main_panel</object-name>
<object-name>ped_labels_1</object-name>
<object-name>ped_labels_2</object-name>
<object-name>carpet</object-name>
<object-name>so.1</object-name>
<object-name>sts.002</object-name>
<object-name>Seat</object-name>
<object-name>beam_a</object-name>
<object-name>beam_f</object-name>
<object-name>wall_1</object-name>
<object-name>seat3.001</object-name>
<object-name>seat4.002</object-name>
<object-name>pedal_adjust</object-name>
<object-name>pedals_block_capt</object-name>
<object-name>ped_surface</object-name>
<object-name>ped_wf</object-name>
<object-name>pedestal1</object-name>
<object-name>pedestal2</object-name>
<object-name>pedestal3</object-name>
<object-name>sfl</object-name>
<object-name>sfl.003</object-name>
<object-name>sts</object-name>
<object-name>sfl.001</object-name>
<object-name>sts.003</object-name>
<object-name>sts.001</object-name>
<object-name>speaker_front</object-name>
<object-name>efis_box_1</object-name>
<object-name>efis_box_2</object-name>
<object-name>efis_box_3</object-name>
<object-name>efis_box_4</object-name>
</effect--><!-- Makes lag -->
</PropertyList>

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

File diff suppressed because it is too large Load diff

View file

@ -519,10 +519,9 @@
<binding>
<command>property-cycle</command>
<property>controls/adirs/ir[0]/knob</property>
<value>0</value>
<value>1</value>
<value>2</value>
<value>3</value>
<max>3</max>
</binding>
<binding>
<command>nasal</command>
@ -536,10 +535,9 @@
<binding>
<command>property-cycle</command>
<property>controls/adirs/ir[0]/knob</property>
<value>3</value>
<value>2</value>
<value>1</value>
<min>1</min>
<value>0</value>
</binding>
<binding>
<command>nasal</command>
@ -553,9 +551,9 @@
<object-name>IR1ModeKnb</object-name>
<property>controls/adirs/ir[0]/knob</property>
<interpolation>
<entry><ind>1</ind><dep>-35</dep></entry>
<entry><ind>2</ind><dep>0</dep></entry>
<entry><ind>3</ind><dep>35</dep></entry>
<entry><ind>0</ind><dep>-35</dep></entry>
<entry><ind>1</ind><dep>0</dep></entry>
<entry><ind>2</ind><dep>35</dep></entry>
</interpolation>
<axis>
<x1-m>0.01578</x1-m>
@ -611,10 +609,9 @@
<binding>
<command>property-cycle</command>
<property>controls/adirs/ir[1]/knob</property>
<value>0</value>
<value>1</value>
<value>2</value>
<value>3</value>
<max>3</max>
</binding>
<binding>
<command>nasal</command>
@ -628,10 +625,9 @@
<binding>
<command>property-cycle</command>
<property>controls/adirs/ir[1]/knob</property>
<value>3</value>
<value>2</value>
<value>1</value>
<min>1</min>
<value>0</value>
</binding>
<binding>
<command>nasal</command>
@ -645,9 +641,9 @@
<object-name>IR2ModeKnb</object-name>
<property>controls/adirs/ir[1]/knob</property>
<interpolation>
<entry><ind>1</ind><dep>-35</dep></entry>
<entry><ind>2</ind><dep>0</dep></entry>
<entry><ind>3</ind><dep>35</dep></entry>
<entry><ind>0</ind><dep>-35</dep></entry>
<entry><ind>1</ind><dep>0</dep></entry>
<entry><ind>2</ind><dep>35</dep></entry>
</interpolation>
<axis>
<x1-m>0.00444</x1-m>
@ -703,10 +699,9 @@
<binding>
<command>property-cycle</command>
<property>controls/adirs/ir[2]/knob</property>
<value>0</value>
<value>1</value>
<value>2</value>
<value>3</value>
<max>3</max>
</binding>
<binding>
<command>nasal</command>
@ -720,10 +715,9 @@
<binding>
<command>property-cycle</command>
<property>controls/adirs/ir[2]/knob</property>
<value>3</value>
<value>2</value>
<value>1</value>
<min>1</min>
<value>0</value>
</binding>
<binding>
<command>nasal</command>
@ -737,9 +731,9 @@
<object-name>IR3ModeKnb</object-name>
<property>controls/adirs/ir[2]/knob</property>
<interpolation>
<entry><ind>1</ind><dep>-35</dep></entry>
<entry><ind>2</ind><dep>0</dep></entry>
<entry><ind>3</ind><dep>35</dep></entry>
<entry><ind>0</ind><dep>-35</dep></entry>
<entry><ind>1</ind><dep>0</dep></entry>
<entry><ind>2</ind><dep>35</dep></entry>
</interpolation>
<axis>
<x1-m>0.01021</x1-m>

View file

@ -64,6 +64,9 @@ setprop("/it-autoflight/internal/vert-speed-fpm-pfd", 0);
setprop("/position/gear-agl-ft", 0);
setprop("/controls/flight/aileron-input-fast", 0);
setprop("/controls/flight/elevator-input-fast", 0);
setprop("/instrumentation/adirs/adr[0]/active", 0);
setprop("/instrumentation/adirs/adr[1]/active", 0);
setprop("/instrumentation/adirs/adr[2]/active", 0);
setprop("/instrumentation/adirs/ir[0]/aligned", 0);
setprop("/instrumentation/adirs/ir[1]/aligned", 0);
setprop("/instrumentation/adirs/ir[2]/aligned", 0);
@ -728,37 +731,41 @@ var canvas_PFD_1 = {
wow2 = getprop("/gear/gear[2]/wow");
# Errors
if (getprop("/instrumentation/adirs/ir[0]/aligned") == 1) {
if (getprop("/instrumentation/adirs/adr[0]/active") == 1) {
me["ASI_group"].show();
me["AI_group"].show();
me["ALT_group"].show();
me["ALT_group2"].show();
me["ALT_scale"].show();
me["VS_group"].show();
me["HDG_group"].show();
me["ASI_error"].hide();
me["ASI_frame"].setColor(1,1,1);
me["AI_error"].hide();
me["ALT_error"].hide();
me["ALT_frame"].setColor(1,1,1);
me["VS_error"].hide();
me["HDG_error"].hide();
me["HDG_frame"].setColor(1,1,1);
} else {
me["ASI_error"].show();
me["ASI_frame"].setColor(1,0,0);
me["AI_error"].show();
me["ALT_error"].show();
me["ALT_frame"].setColor(1,0,0);
me["VS_error"].show();
me["HDG_error"].show();
me["HDG_frame"].setColor(1,0,0);
me["ASI_group"].hide();
me["AI_group"].hide();
me["ALT_group"].hide();
me["ALT_group2"].hide();
me["ALT_scale"].hide();
me["VS_group"].hide();
}
if (getprop("/instrumentation/adirs/ir[0]/aligned") == 1) {
me["AI_group"].show();
me["HDG_group"].show();
me["AI_error"].hide();
me["HDG_error"].hide();
me["HDG_frame"].setColor(1,1,1);
} else {
me["AI_error"].show();
me["HDG_error"].show();
me["HDG_frame"].setColor(1,0,0);
me["AI_group"].hide();
me["HDG_group"].hide();
}
@ -817,37 +824,41 @@ var canvas_PFD_2 = {
wow2 = getprop("/gear/gear[2]/wow");
# Errors
if (getprop("/instrumentation/adirs/ir[1]/aligned") == 1) {
if (getprop("/instrumentation/adirs/adr[1]/active") == 1) {
me["ASI_group"].show();
me["AI_group"].show();
me["ALT_group"].show();
me["ALT_group2"].show();
me["ALT_scale"].show();
me["VS_group"].show();
me["HDG_group"].show();
me["ASI_error"].hide();
me["ASI_frame"].setColor(1,1,1);
me["AI_error"].hide();
me["ALT_error"].hide();
me["ALT_frame"].setColor(1,1,1);
me["VS_error"].hide();
me["HDG_error"].hide();
me["HDG_frame"].setColor(1,1,1);
} else {
me["ASI_error"].show();
me["ASI_frame"].setColor(1,0,0);
me["AI_error"].show();
me["ALT_error"].show();
me["ALT_frame"].setColor(1,0,0);
me["VS_error"].show();
me["HDG_error"].show();
me["HDG_frame"].setColor(1,0,0);
me["ASI_group"].hide();
me["AI_group"].hide();
me["ALT_group"].hide();
me["ALT_group2"].hide();
me["ALT_scale"].hide();
me["VS_group"].hide();
}
if (getprop("/instrumentation/adirs/ir[1]/aligned") == 1) {
me["AI_group"].show();
me["HDG_group"].show();
me["AI_error"].hide();
me["HDG_error"].hide();
me["HDG_frame"].setColor(1,1,1);
} else {
me["AI_error"].show();
me["HDG_error"].show();
me["HDG_frame"].setColor(1,0,0);
me["AI_group"].hide();
me["HDG_group"].hide();
}

View file

@ -58,7 +58,7 @@ var canvas_upperECAM_base = {
setprop("/instrumentation/du/du3-test", 0);
}
if (getprop("/systems/electrical/bus/ac1") >= 110 or getprop("/systems/electrical/bus/ac2") >= 110 and getprop("/controls/lighting/DU/du3") > 0) {
if ((getprop("/systems/electrical/bus/ac1") >= 110 or getprop("/systems/electrical/bus/ac2") >= 110) and getprop("/controls/lighting/DU/du3") > 0) {
if (getprop("/instrumentation/du/du3-test-time") + 39 >= elapsedtime) {
upperECAM_cfm_eis2.page.hide();
upperECAM_iae_eis2.page.hide();

View file

@ -1,296 +1,237 @@
# A3XX ADIRS system
# Jonathan Redpath and Joshua Davidson
# A3XX ADIRS System
# Joshua Davidson
##############################################
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
#####################
# Initializing Vars #
#####################
setprop("/systems/electrical/bus/dc1", 0);
setprop("/systems/electrical/bus/dc2", 0);
setprop("/systems/electrical/bus/dc-ess", 0);
setprop("/systems/electrical/bus/ac1", 0);
setprop("/systems/electrical/bus/ac2", 0);
setprop("/systems/electrical/bus/ac-ess", 0);
var ttn = 0;
var knob = 0;
setprop("/controls/adirs/align-time", 600);
setlistener("/sim/signals/fdm-initialized", func {
var roll = getprop("/orientation/roll-deg");
var pitch = getprop("/orientation/pitch-deg");
var gs = getprop("/velocities/groundspeed-kt");
var data_knob = getprop("/controls/adirs/display/dataknob");
var selected_ir = getprop("/controls/adirs/display/selected");
var ac1 = 0;
var ac2 = 0;
var batt1_amps = 0;
var batt2_amps = 0;
var pwr_src = "XX";
});
var adirs_init = func {
setprop("/controls/adirs/mcducbtn",0);
adirs_timer.start();
}
var ADIRS = {
init: func() {
setprop("/controls/adirs/numm", 0);
setprop("/instrumentation/adirs/adr[0]/active", 0);
setprop("/instrumentation/adirs/adr[1]/active", 0);
setprop("/instrumentation/adirs/adr[2]/active", 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/adr[0]/fault", 0);
setprop("/controls/adirs/adr[1]/fault", 0);
setprop("/controls/adirs/adr[2]/fault", 0);
setprop("/controls/adirs/adr[0]/off", 0);
setprop("/controls/adirs/adr[1]/off", 0);
setprop("/controls/adirs/adr[2]/off", 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/onbat", 0);
setprop("/controls/adirs/mcducbtn", 0);
setprop("/controls/adirs/mcdu/mode1", ""); # INVAL ALIGN NAV ATT or off (blank)
setprop("/controls/adirs/mcdu/mode2", "");
setprop("/controls/adirs/mcdu/mode3", "");
setprop("/controls/adirs/mcdu/status1", ""); # see smith thales p487
setprop("/controls/adirs/mcdu/status2", "");
setprop("/controls/adirs/mcdu/status3", "");
setprop("/controls/adirs/mcdu/hdg", ""); # only shown if in ATT mode
setprop("/controls/adirs/mcdu/avgdrift1", "");
setprop("/controls/adirs/mcdu/avgdrift2", "");
setprop("/controls/adirs/mcdu/avgdrift3", "");
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/ac1");
ac2 = getprop("/systems/electrical/bus/ac2");
batt1_amps = getprop("/systems/electrical/battery1-amps");
batt2_amps = getprop("/systems/electrical/battery2-amps");
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 batt1_amps < 120 and batt2_amps < 120)) {
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);
}
}
if (ac1 >= 110 or ac2 >= 110) {
pwr_src = "AC";
} else if (batt1_amps >= 120 or batt2_amps >= 120) {
pwr_src = "BATT";
} else {
pwr_src = "XX";
}
if (getprop("/controls/adirs/ir[0]/time") + 3 >= getprop("/sim/time/elapsed-sec") or getprop("/controls/adirs/ir[1]/time") + 3 >= getprop("/sim/time/elapsed-sec") or getprop("/controls/adirs/ir[2]/time") + 3 >= getprop("/sim/time/elapsed-sec")) {
setprop("/controls/adirs/onbat", 1);
} else if (pwr_src == "BATT") {
setprop("/controls/adirs/onbat", 1);
} else {
setprop("/controls/adirs/onbat", 0);
}
},
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/ac1");
ac2 = getprop("/systems/electrical/bus/ac2");
batt1_amps = getprop("/systems/electrical/battery1-amps");
batt2_amps = getprop("/systems/electrical/battery2-amps");
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 batt1_amps >= 120 or batt2_amps >= 120)) {
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/adr[" ~ n ~ "]/active", 0);
setprop("/instrumentation/adirs/ir[" ~ n ~ "]/aligned", 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 ADIRSreset = 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("/instrumentation/adirs/ir[0]/display/ttn",0);
setprop("/instrumentation/adirs/ir[1]/display/ttn",0);
setprop("/instrumentation/adirs/ir[2]/display/ttn",0);
setprop("/instrumentation/adirs/ir[0]/display/status","- - - - - - - - ");
setprop("/instrumentation/adirs/ir[1]/display/status","- - - - - - - - ");
setprop("/instrumentation/adirs/ir[2]/display/status","- - - - - - - - ");
setprop("/controls/adirs/adr[0]/fault",0);
setprop("/controls/adirs/adr[1]/fault",0);
setprop("/controls/adirs/adr[2]/fault",0);
setprop("/controls/adirs/adr[0]/off",0);
setprop("/controls/adirs/adr[1]/off",0);
setprop("/controls/adirs/adr[2]/off",0);
setprop("/controls/adirs/display/text","");
setprop("/controls/adirs/display/dataknob","5");
setprop("/controls/adirs/display/selected","1");
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]/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/onbat",0);
setprop("/controls/adirs/mcducbtn",0);
setprop("/controls/adirs/mcdu/mode1", ""); # INVAL ALIGN NAV ATT or off (blank)
setprop("/controls/adirs/mcdu/mode2", "");
setprop("/controls/adirs/mcdu/mode3", "");
setprop("/controls/adirs/mcdu/status1", ""); # see smith thales p487
setprop("/controls/adirs/mcdu/status2", "");
setprop("/controls/adirs/mcdu/status3", "");
setprop("/controls/adirs/mcdu/hdg", ""); # only shown if in ATT mode
setprop("/controls/adirs/mcdu/avgdrift1", "");
setprop("/controls/adirs/mcdu/avgdrift2", "");
setprop("/controls/adirs/mcdu/avgdrift3", "");
adirs_init();
}
var ir_align_loop = func(i) {
ttn = getprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/ttn");
if ((ttn >= 0) and (ttn < 0.99)) { # Make it less sensitive
ir_align_finish(i);
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 {
setprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/ttn", ttn - 1);
}
roll = getprop("/orientation/roll-deg");
pitch = getprop("/orientation/pitch-deg");
gs = getprop("/velocities/groundspeed-kt");
if (gs > 2) {
setprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/status", "STS-XCESS MOTION");
ir_align_abort(i);
}
}
var ir0_align_loop_timer = maketimer(1, func{ir_align_loop(0)});
var ir1_align_loop_timer = maketimer(1, func{ir_align_loop(1)});
var ir2_align_loop_timer = maketimer(1, func{ir_align_loop(2)});
var ir_align_start = func(i) {
if (((i == 0) and !ir0_align_loop_timer.isRunning) or
((i == 1) and !ir1_align_loop_timer.isRunning) or
((i == 2) and !ir2_align_loop_timer.isRunning)) {
setprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/ttn", (math.sin((getprop("/position/latitude-deg") / 90) * (math.pi / 2)) * 720) + 300);
if (i == 0) {
ir0_align_loop_timer.start();
} else if (i == 1) {
ir1_align_loop_timer.start();
} else if (i == 2) {
ir2_align_loop_timer.start();
if (getprop("/instrumentation/adirs/ir[0]/aligned") != 1 and getprop("/controls/adirs/mcducbtn") == 1) {
alignOne.stop();
setprop("/instrumentation/adirs/ir[0]/aligned", 1);
}
setprop("/controls/adirs/ir[" ~ i ~ "]/align", 1);
}
}
var ir_align_finish = func(i) {
setprop("/instrumentation/adirs/ir[" ~ i ~ "]/aligned", 1);
if (i == 0) {
ir0_align_loop_timer.stop();
} else if (i == 1) {
ir1_align_loop_timer.stop();
} else if (i == 2) {
ir2_align_loop_timer.stop();
}
setprop("/controls/adirs/ir[" ~ i ~ "]/align", 0);
}
var ir_align_abort = func(i) {
setprop("/controls/adirs/ir[" ~ i ~ "]/fault", 1);
if (i == 0) {
ir0_align_loop_timer.stop();
} else if (i == 1) {
ir1_align_loop_timer.stop();
} else if (i == 2) {
ir2_align_loop_timer.stop();
}
setprop("/controls/adirs/ir[" ~ i ~ "]/align", 0);
}
var ir_knob_move = func(i) {
knob = getprop("/controls/adirs/ir[" ~ i ~ "]/knob");
if (knob == 1) {
setprop("/controls/adirs/ir[" ~ i ~ "]/align", 0);
setprop("/controls/adirs/ir[" ~ i ~ "]/fault", 0);
setprop("/instrumentation/adirs/ir[" ~ i ~ "]/aligned", 0);
setprop("/instrumentation/adirs/ir[" ~ i ~ "]/display/status", "- - - - - - - - ");
if (i == 0) {
ir0_align_loop_timer.stop();
} else if (i == 1) {
ir1_align_loop_timer.stop();
} else if (i == 2) {
ir2_align_loop_timer.stop();
}
} else if (knob == 2) {
if ( !getprop("/instrumentation/adirs/ir[" ~ i ~ "]/aligned") and
(getprop("/systems/electrical/bus/ac-ess") > 9) ) {
ir_align_start(i);
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 {
ir_knob_move(0);
knobmcducheck();
ADIRS.knob(0);
});
setlistener("/controls/adirs/ir[1]/knob", func {
ir_knob_move(1);
knobmcducheck();
ADIRS.knob(1);
});
setlistener("/controls/adirs/ir[2]/knob", func {
ir_knob_move(2);
knobmcducheck();
ADIRS.knob(2);
});
var knobmcducheck = func {
if (getprop("/controls/adirs/ir[0]/knob") == 1 and getprop("/controls/adirs/ir[1]/knob") == 1 and getprop("/controls/adirs/ir[2]/knob") == 1) {
setprop("/controls/adirs/mcducbtn", 0);
}
}
var onbat_light = func {
if (((getprop("/systems/electrical/bus/dc1") > 25) or (getprop("/systems/electrical/bus/dc2") > 25)) and
((getprop("/systems/electrical/bus/ac1") < 110) and getprop("/systems/electrical/bus/ac2") < 110) and
((getprop("/controls/adirs/ir[0]/knob") > 1) or
(getprop("/controls/adirs/ir[1]/knob") > 1) or
(getprop("/controls/adirs/ir[2]/knob") > 1))) {
setprop("/controls/adirs/onbat", 1);
} else {
setprop("/controls/adirs/onbat", 0);
}
}
var onbat_light_b = func {
setprop("/controls/adirs/onbat", 1);
settimer(func {
onbat_light();
}, 4);
if (getprop("/controls/adirs/skip") == 1) {
skip_ADIRS();
}
}
setlistener("/controls/electrical/switches/gen-apu", onbat_light);
setlistener("/controls/electrical/switches/gen1", onbat_light);
setlistener("/controls/electrical/switches/gen2", onbat_light);
setlistener("/controls/electrical/switches/gen-ext", onbat_light);
setlistener("/systems/electrical/bus/ac-ess", onbat_light);
setlistener("/controls/adirs/ir[0]/knob", onbat_light_b);
setlistener("/controls/adirs/ir[1]/knob", onbat_light_b);
setlistener("/controls/adirs/ir[2]/knob", onbat_light_b);
var adirs_display = func() {
data_knob = getprop("/controls/adirs/display/dataknob");
selected_ir = getprop("/controls/adirs/display/selected");
if ( selected_ir == 1 ) {
setprop("/controls/adirs/display/text", "");
} else {
if ( data_knob == 1 ) {
setprop("/controls/adirs/display/text", "888888888888888");
} else if ( data_knob == 2 ) {
if ( ((selected_ir == 2) and getprop("/instrumentation/adirs/ir[0]/aligned")) or
((selected_ir == 3) and getprop("/instrumentation/adirs/ir[2]/aligned")) or
((selected_ir == 4) and getprop("/instrumentation/adirs/ir[1]/aligned")) ) {
setprop("/controls/adirs/display/text", sprintf(" %03i", getprop("/orientation/track-magnetic-deg")) ~ sprintf(" %03i", getprop("/velocities/groundspeed-kt")));
} else {
setprop("/controls/adirs/display/text", "- - - - - - - - ");
}
} else if ( data_knob == 3 ) {
lat = abs(getprop("/position/latitude-deg"));
lon = abs(getprop("/position/longitude-deg"));
setprop("/controls/adirs/display/text", substr(getprop("/position/latitude-string"), -1, 1) ~
sprintf("%2i", lat) ~ "'" ~
sprintf("%2.1f", (lat - math.floor(lat)) * 60) ~
substr(getprop("/position/longitude-string"), -1, 1) ~
sprintf("%3i", lon) ~ "'" ~
sprintf("%2.1f", (lon - math.floor(lon)) * 60));
} else if ( data_knob == 4 ) {
if ( ((selected_ir == 2) and getprop("/instrumentation/adirs/ir[0]/aligned")) or
((selected_ir == 3) and getprop("/instrumentation/adirs/ir[2]/aligned")) or
((selected_ir == 4) and getprop("/instrumentation/adirs/ir[1]/aligned")) ) {
setprop("/controls/adirs/display/text", sprintf(" %03i", getprop("/environment/wind-from-heading-deg")) ~ sprintf(" %03i", getprop("/environment/wind-speed-kt")));
} else {
setprop("/controls/adirs/display/text", "- - - - - - - - ");
}
} else if ( data_knob == 5 ) {
if ( ((selected_ir == 2) and getprop("/instrumentation/adirs/ir[0]/aligned")) or
((selected_ir == 3) and getprop("/instrumentation/adirs/ir[2]/aligned")) or
((selected_ir == 4) and getprop("/instrumentation/adirs/ir[1]/aligned")) ) {
lat = getprop("/position/latitude-deg");
lon = getprop("/position/longitude-deg");
if ((lat > 82) or (lat < -60) or (lon < -90 and lon > -120 and lat > 73)) {
setprop("/controls/adirs/display/text", sprintf(" %3.1f", getprop("/orientation/heading-deg")) ~ "- - - - "); # this is true heading
} else {
setprop("/controls/adirs/display/text", sprintf(" %3.1f", getprop("/orientation/heading-magnetic-deg")) ~ "- - - - ");
}
} else {
if ( (selected_ir == 2) and getprop("/controls/adirs/ir[0]/align") ) {
setprop("controls/adirs/display/text", "- - - - " ~ sprintf(" TTN %2i", (getprop("/instrumentation/adirs/ir[0]/display/ttn") / 60)));
} else if ( (selected_ir == 3) and getprop("/controls/adirs/ir[2]/align") ) {
setprop("controls/adirs/display/text", "- - - - " ~ sprintf(" TTN %2i", (getprop("/instrumentation/adirs/ir[2]/display/ttn") / 60)));
} else if ( (selected_ir == 4) and getprop("/controls/adirs/ir[1]/align") ) {
setprop("controls/adirs/display/text", "- - - - " ~ sprintf(" TTN %2i", (getprop("/instrumentation/adirs/ir[1]/display/ttn") / 60)));
} else {
setprop("/controls/adirs/display/text", "- - - - - - - - ");
}
}
} else if ( data_knob == 6 ) {
if ( selected_ir == 2 ) {
setprop("/controls/adirs/display/text","- - - - - - - - ");
} else if ( selected_ir == 3 ) {
setprop("/controls/adirs/display/text","- - - - - - - - ");
} else if ( selected_ir == 4 ) {
setprop("/controls/adirs/display/text","- - - - - - - - ");
}
}
}
}
var skip_ADIRS = func {
if (getprop("/controls/adirs/ir[0]/knob") == 2) {
setprop("/instrumentation/adirs/ir[0]/display/ttn",1); # Set it to 1 so it counts down from 1 to 0
}
if (getprop("/controls/adirs/ir[1]/knob") == 2) {
setprop("/instrumentation/adirs/ir[1]/display/ttn",1); # Set it to 1 so it counts down from 1 to 0
}
if (getprop("/controls/adirs/ir[2]/knob") == 2) {
setprop("/instrumentation/adirs/ir[2]/display/ttn",1); # Set it to 1 so it counts down from 1 to 0
}
}
var adirs_skip = setlistener("/controls/adirs/skip", func {
if (getprop("/controls/adirs/skip") == 1) {
skip_ADIRS();
}
});
var adirs_timer = maketimer(1, adirs_display);

File diff suppressed because it is too large Load diff

View file

@ -5,10 +5,6 @@
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
#############
# Init Vars #
#############
setlistener("/sim/signals/fdm-initialized", func {
var xfeed_sw = getprop("/controls/fuel/x-feed");
var tank0pump1_sw = getprop("/controls/fuel/tank0pump1");
@ -39,177 +35,164 @@ setlistener("/sim/signals/fdm-initialized", func {
var tank2pump2_fail = getprop("/systems/failures/tank2pump2");
});
var fuel_init = func {
setprop("/systems/fuel/gravityfeedL", 0);
setprop("/systems/fuel/gravityfeedR", 0);
setprop("/systems/fuel/gravityfeedL-output", 0);
setprop("/systems/fuel/gravityfeedR-output", 0);
setprop("/controls/fuel/x-feed", 0);
setprop("/controls/fuel/tank0pump1", 0);
setprop("/controls/fuel/tank0pump2", 0);
setprop("/controls/fuel/tank1pump1", 0);
setprop("/controls/fuel/tank1pump2", 0);
setprop("/controls/fuel/tank2pump1", 0);
setprop("/controls/fuel/tank2pump2", 0);
setprop("/controls/fuel/mode", 1);
setprop("/systems/fuel/x-feed", 0);
setprop("/systems/fuel/tank[0]/feed", 0);
setprop("/systems/fuel/tank[1]/feed", 0);
setprop("/systems/fuel/tank[2]/feed", 0);
setprop("/systems/fuel/only-use-ctr-tank", 0);
setprop("/systems/fuel/tank0pump1-fault", 0);
setprop("/systems/fuel/tank0pump2-fault", 0);
setprop("/systems/fuel/tank1pump1-fault", 0);
setprop("/systems/fuel/tank1pump2-fault", 0);
setprop("/systems/fuel/tank2pump1-fault", 0);
setprop("/systems/fuel/tank2pump2-fault", 0);
setprop("/systems/fuel/mode-fault", 0);
fuel_timer.start();
}
##############
# Main Loops #
##############
var master_fuel = func {
xfeed_sw = getprop("/controls/fuel/x-feed");
tank0pump1_sw = getprop("/controls/fuel/tank0pump1");
tank0pump2_sw = getprop("/controls/fuel/tank0pump2");
tank1pump1_sw = getprop("/controls/fuel/tank1pump1");
tank1pump2_sw = getprop("/controls/fuel/tank1pump2");
tank2pump1_sw = getprop("/controls/fuel/tank2pump1");
tank2pump2_sw = getprop("/controls/fuel/tank2pump2");
mode_sw = getprop("/controls/fuel/mode");
xfeed = getprop("/systems/fuel/x-feed");
ac1 = getprop("/systems/electrical/bus/ac1");
ac2 = getprop("/systems/electrical/bus/ac2");
gravityfeedL = getprop("/systems/fuel/gravityfeedL");
gravityfeedR = getprop("/systems/fuel/gravityfeedR");
gload = getprop("/accelerations/pilot-gdamped");
tank0pump1_fail = getprop("/systems/failures/tank0pump1");
tank0pump2_fail = getprop("/systems/failures/tank0pump2");
tank1pump1_fail = getprop("/systems/failures/tank1pump1");
tank1pump2_fail = getprop("/systems/failures/tank1pump2");
tank2pump1_fail = getprop("/systems/failures/tank2pump1");
tank2pump2_fail = getprop("/systems/failures/tank2pump2");
if (gload >= 0.7 and gravityfeedL) {
setprop("/systems/fuel/gravityfeedL-output", 1);
} else {
setprop("/systems/fuel/gravityfeedL-output", 0);
}
if (gload >= 0.7 and gravityfeedR) {
setprop("/systems/fuel/gravityfeedR-output", 1);
} else {
setprop("/systems/fuel/gravityfeedR-output", 0);
}
gravityfeedL_output = getprop("/systems/fuel/gravityfeedL-output");
gravityfeedR_output = getprop("/systems/fuel/gravityfeedR-output");
if ((ac1 >= 110 or ac2 >= 110) and tank0pump1_sw and !tank0pump1_fail) {
setprop("/systems/fuel/tank[0]/feed", 1);
} else if ((ac1 >= 110 or ac2 >= 110) and tank0pump2_sw and !tank0pump2_fail) {
setprop("/systems/fuel/tank[0]/feed", 1);
} else if (gravityfeedL_output) {
setprop("/systems/fuel/tank[0]/feed", 1);
} else {
setprop("/systems/fuel/tank[0]/feed", 0);
}
if ((ac1 >= 110 or ac2 >= 110) and tank1pump1_sw and !tank1pump1_fail) {
setprop("/systems/fuel/tank[1]/feed", 1);
} else if ((ac1 >= 110 or ac2 >= 110) and tank1pump2_sw and !tank1pump2_fail) {
setprop("/systems/fuel/tank[1]/feed", 1);
} else {
setprop("/systems/fuel/tank[1]/feed", 0);
}
if ((ac1 >= 110 or ac2 >= 110) and tank2pump1_sw and !tank2pump1_fail) {
setprop("/systems/fuel/tank[2]/feed", 1);
} else if ((ac1 >= 110 or ac2 >= 110) and tank2pump2_sw and !tank2pump2_fail) {
setprop("/systems/fuel/tank[2]/feed", 1);
} else if (gravityfeedR_output) {
setprop("/systems/fuel/tank[2]/feed", 1);
} else {
setprop("/systems/fuel/tank[2]/feed", 0);
}
if ((ac1 >= 110 or ac2 >= 110) and xfeed_sw) {
setprop("/systems/fuel/x-feed", 1);
} else {
setprop("/systems/fuel/x-feed", 0);
}
tank0 = getprop("/systems/fuel/tank[0]/feed");
tank1 = getprop("/systems/fuel/tank[1]/feed");
tank2 = getprop("/systems/fuel/tank[2]/feed");
if ((ac1 >= 110 or ac2 >= 110) and (tank0pump1_sw or tank0pump2_sw)) {
var FUEL = {
init: func() {
setprop("/systems/fuel/gravityfeedL", 0);
} else {
setprop("/systems/fuel/gravityfeedL", 1);
}
if ((ac1 >= 110 or ac2 >= 110) and (tank2pump1_sw or tank2pump2_sw)) {
setprop("/systems/fuel/gravityfeedR", 0);
} else {
setprop("/systems/fuel/gravityfeedR", 1);
}
gravityfeedL = getprop("/systems/fuel/gravityfeedL");
gravityfeedR = getprop("/systems/fuel/gravityfeedR");
if ((getprop("/fdm/jsbsim/propulsion/tank[1]/contents-lbs") >= 50) and (tank1pump1_sw or tank1pump2_sw) and !gravityfeedL and !gravityfeedR) {
setprop("/systems/fuel/only-use-ctr-tank", 1);
} else {
setprop("/systems/fuel/gravityfeedL-output", 0);
setprop("/systems/fuel/gravityfeedR-output", 0);
setprop("/controls/fuel/x-feed", 0);
setprop("/controls/fuel/tank0pump1", 0);
setprop("/controls/fuel/tank0pump2", 0);
setprop("/controls/fuel/tank1pump1", 0);
setprop("/controls/fuel/tank1pump2", 0);
setprop("/controls/fuel/tank2pump1", 0);
setprop("/controls/fuel/tank2pump2", 0);
setprop("/controls/fuel/mode", 1);
setprop("/systems/fuel/x-feed", 0);
setprop("/systems/fuel/tank[0]/feed", 0);
setprop("/systems/fuel/tank[1]/feed", 0);
setprop("/systems/fuel/tank[2]/feed", 0);
setprop("/systems/fuel/only-use-ctr-tank", 0);
}
# Fault lights
if (tank0pump1_sw and tank0pump1_fail) {
setprop("/systems/fuel/tank0pump1-fault", 1);
} else {
setprop("/systems/fuel/tank0pump1-fault", 0);
}
if (tank0pump2_sw and tank0pump2_fail) {
setprop("/systems/fuel/tank0pump2-fault", 1);
} else {
setprop("/systems/fuel/tank0pump2-fault", 0);
}
if (tank1pump1_sw and tank1pump1_fail) {
setprop("/systems/fuel/tank1pump1-fault", 1);
} else {
setprop("/systems/fuel/tank1pump1-fault", 0);
}
if (tank1pump2_sw and tank1pump2_fail) {
setprop("/systems/fuel/tank1pump2-fault", 1);
} else {
setprop("/systems/fuel/tank1pump2-fault", 0);
}
if (tank2pump1_sw and tank2pump1_fail) {
setprop("/systems/fuel/tank2pump1-fault", 1);
} else {
setprop("/systems/fuel/tank2pump1-fault", 0);
}
if (tank2pump2_sw and tank2pump2_fail) {
setprop("/systems/fuel/tank2pump2-fault", 1);
} else {
setprop("/systems/fuel/tank2pump2-fault", 0);
}
}
###################
# Update Function #
###################
var update_fuel = func {
master_fuel();
}
var fuel_timer = maketimer(0.2, update_fuel);
setprop("/systems/fuel/mode-fault", 0);
},
loop: func() {
xfeed_sw = getprop("/controls/fuel/x-feed");
tank0pump1_sw = getprop("/controls/fuel/tank0pump1");
tank0pump2_sw = getprop("/controls/fuel/tank0pump2");
tank1pump1_sw = getprop("/controls/fuel/tank1pump1");
tank1pump2_sw = getprop("/controls/fuel/tank1pump2");
tank2pump1_sw = getprop("/controls/fuel/tank2pump1");
tank2pump2_sw = getprop("/controls/fuel/tank2pump2");
mode_sw = getprop("/controls/fuel/mode");
xfeed = getprop("/systems/fuel/x-feed");
ac1 = getprop("/systems/electrical/bus/ac1");
ac2 = getprop("/systems/electrical/bus/ac2");
gravityfeedL = getprop("/systems/fuel/gravityfeedL");
gravityfeedR = getprop("/systems/fuel/gravityfeedR");
gload = getprop("/accelerations/pilot-gdamped");
tank0pump1_fail = getprop("/systems/failures/tank0pump1");
tank0pump2_fail = getprop("/systems/failures/tank0pump2");
tank1pump1_fail = getprop("/systems/failures/tank1pump1");
tank1pump2_fail = getprop("/systems/failures/tank1pump2");
tank2pump1_fail = getprop("/systems/failures/tank2pump1");
tank2pump2_fail = getprop("/systems/failures/tank2pump2");
if (gload >= 0.7 and gravityfeedL) {
setprop("/systems/fuel/gravityfeedL-output", 1);
} else {
setprop("/systems/fuel/gravityfeedL-output", 0);
}
if (gload >= 0.7 and gravityfeedR) {
setprop("/systems/fuel/gravityfeedR-output", 1);
} else {
setprop("/systems/fuel/gravityfeedR-output", 0);
}
gravityfeedL_output = getprop("/systems/fuel/gravityfeedL-output");
gravityfeedR_output = getprop("/systems/fuel/gravityfeedR-output");
if ((ac1 >= 110 or ac2 >= 110) and tank0pump1_sw and !tank0pump1_fail) {
setprop("/systems/fuel/tank[0]/feed", 1);
} else if ((ac1 >= 110 or ac2 >= 110) and tank0pump2_sw and !tank0pump2_fail) {
setprop("/systems/fuel/tank[0]/feed", 1);
} else if (gravityfeedL_output) {
setprop("/systems/fuel/tank[0]/feed", 1);
} else {
setprop("/systems/fuel/tank[0]/feed", 0);
}
if ((ac1 >= 110 or ac2 >= 110) and tank1pump1_sw and !tank1pump1_fail) {
setprop("/systems/fuel/tank[1]/feed", 1);
} else if ((ac1 >= 110 or ac2 >= 110) and tank1pump2_sw and !tank1pump2_fail) {
setprop("/systems/fuel/tank[1]/feed", 1);
} else {
setprop("/systems/fuel/tank[1]/feed", 0);
}
if ((ac1 >= 110 or ac2 >= 110) and tank2pump1_sw and !tank2pump1_fail) {
setprop("/systems/fuel/tank[2]/feed", 1);
} else if ((ac1 >= 110 or ac2 >= 110) and tank2pump2_sw and !tank2pump2_fail) {
setprop("/systems/fuel/tank[2]/feed", 1);
} else if (gravityfeedR_output) {
setprop("/systems/fuel/tank[2]/feed", 1);
} else {
setprop("/systems/fuel/tank[2]/feed", 0);
}
if ((ac1 >= 110 or ac2 >= 110) and xfeed_sw) {
setprop("/systems/fuel/x-feed", 1);
} else {
setprop("/systems/fuel/x-feed", 0);
}
tank0 = getprop("/systems/fuel/tank[0]/feed");
tank1 = getprop("/systems/fuel/tank[1]/feed");
tank2 = getprop("/systems/fuel/tank[2]/feed");
if ((ac1 >= 110 or ac2 >= 110) and (tank0pump1_sw or tank0pump2_sw)) {
setprop("/systems/fuel/gravityfeedL", 0);
} else {
setprop("/systems/fuel/gravityfeedL", 1);
}
if ((ac1 >= 110 or ac2 >= 110) and (tank2pump1_sw or tank2pump2_sw)) {
setprop("/systems/fuel/gravityfeedR", 0);
} else {
setprop("/systems/fuel/gravityfeedR", 1);
}
gravityfeedL = getprop("/systems/fuel/gravityfeedL");
gravityfeedR = getprop("/systems/fuel/gravityfeedR");
if ((getprop("/fdm/jsbsim/propulsion/tank[1]/contents-lbs") >= 50) and (tank1pump1_sw or tank1pump2_sw) and !gravityfeedL and !gravityfeedR) {
setprop("/systems/fuel/only-use-ctr-tank", 1);
} else {
setprop("/systems/fuel/only-use-ctr-tank", 0);
}
# Fault lights
if (tank0pump1_sw and tank0pump1_fail) {
setprop("/systems/fuel/tank0pump1-fault", 1);
} else {
setprop("/systems/fuel/tank0pump1-fault", 0);
}
if (tank0pump2_sw and tank0pump2_fail) {
setprop("/systems/fuel/tank0pump2-fault", 1);
} else {
setprop("/systems/fuel/tank0pump2-fault", 0);
}
if (tank1pump1_sw and tank1pump1_fail) {
setprop("/systems/fuel/tank1pump1-fault", 1);
} else {
setprop("/systems/fuel/tank1pump1-fault", 0);
}
if (tank1pump2_sw and tank1pump2_fail) {
setprop("/systems/fuel/tank1pump2-fault", 1);
} else {
setprop("/systems/fuel/tank1pump2-fault", 0);
}
if (tank2pump1_sw and tank2pump1_fail) {
setprop("/systems/fuel/tank2pump1-fault", 1);
} else {
setprop("/systems/fuel/tank2pump1-fault", 0);
}
if (tank2pump2_sw and tank2pump2_fail) {
setprop("/systems/fuel/tank2pump2-fault", 1);
} else {
setprop("/systems/fuel/tank2pump2-fault", 0);
}
},
};

View file

@ -5,10 +5,6 @@
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
#############
# Init Vars #
#############
setlistener("/sim/signals/fdm-initialized", func {
var eng1_pump_sw = getprop("/controls/hydraulic/eng1-pump");
var eng2_pump_sw = getprop("/controls/hydraulic/eng2-pump");
@ -51,220 +47,212 @@ setlistener("/sim/signals/fdm-initialized", func {
var down = getprop("/controls/gear/gear-down");
});
var hyd_init = func {
setprop("/controls/hydraulic/eng1-pump", 1);
setprop("/controls/hydraulic/eng2-pump", 1);
setprop("/controls/hydraulic/elec-pump-blue", 1);
setprop("/controls/hydraulic/elec-pump-yellow", 0);
setprop("/controls/hydraulic/hand-pump-yellow", 0);
setprop("/controls/hydraulic/ptu", 1);
setprop("/controls/hydraulic/rat-man", 0);
setprop("/controls/hydraulic/rat", 0);
setprop("/controls/hydraulic/rat-deployed", 0);
setprop("/systems/hydraulic/ptu-active", 0);
setprop("/systems/hydraulic/blue-psi", 0);
setprop("/systems/hydraulic/green-psi", 0);
setprop("/systems/hydraulic/yellow-psi", 0);
setprop("/controls/gear/brake-parking", 0);
setprop("/systems/hydraulic/brakes/accumulator-pressure-psi", 0);
setprop("/systems/hydraulic/brakes/pressure-left-psi", 0);
setprop("/systems/hydraulic/brakes/pressure-right-psi", 0);
setprop("/systems/hydraulic/brakes/askidnwssw", 1);
setprop("/systems/hydraulic/brakes/mode", 0);
setprop("/systems/hydraulic/brakes/lbrake", 0);
setprop("/systems/hydraulic/brakes/rbrake", 0);
setprop("/systems/hydraulic/brakes/nose-rubber", 0); # This stops the nose from spinning when you raise the gear
setprop("/systems/hydraulic/brakes/counter", 0);
setprop("/systems/hydraulic/brakes/accumulator-pressure-psi-1", 0);
setprop("/systems/hydraulic/eng1-pump-fault", 0);
setprop("/systems/hydraulic/eng2-pump-fault", 0);
setprop("/systems/hydraulic/elec-pump-b-fault", 0);
setprop("/systems/hydraulic/elec-pump-y-fault", 0);
setprop("/systems/hydraulic/ptu-fault", 0);
hyd_timer.start();
}
#######################
# Main Hydraulic Loop #
#######################
var master_hyd = func {
eng1_pump_sw = getprop("/controls/hydraulic/eng1-pump");
eng2_pump_sw = getprop("/controls/hydraulic/eng2-pump");
elec_pump_blue_sw = getprop("/controls/hydraulic/elec-pump-blue");
elec_pump_yellow_sw = getprop("/controls/hydraulic/elec-pump-yellow");
yellow_hand_pump = getprop("/controls/hydraulic/hand-pump-yellow");
ptu_sw = getprop("/controls/hydraulic/ptu");
rat_man_sw = getprop("/controls/hydraulic/rat-man");
blue_psi = getprop("/systems/hydraulic/blue-psi");
green_psi = getprop("/systems/hydraulic/green-psi");
yellow_psi = getprop("/systems/hydraulic/yellow-psi");
rpmapu = getprop("/systems/apu/rpm");
stateL = getprop("/engines/engine[0]/state");
stateR = getprop("/engines/engine[1]/state");
dc_ess = getprop("/systems/electrical/bus/dc-ess");
psi_diff = green_psi - yellow_psi;
rat = getprop("/controls/hydraulic/rat");
ratout = getprop("/controls/hydraulic/rat-deployed");
gs = getprop("/velocities/groundspeed-kt");
blue_leak = getprop("/systems/failures/hyd-blue");
green_leak = getprop("/systems/failures/hyd-green");
yellow_leak = getprop("/systems/failures/hyd-yellow");
blue_pump_fail = getprop("/systems/failures/pump-blue");
green_pump_fail = getprop("/systems/failures/pump-green");
yellow_pump_eng_fail = getprop("/systems/failures/pump-yellow-eng");
yellow_pump_elec_fail = getprop("/systems/failures/pump-yellow-elec");
ptu_fail = getprop("/systems/failures/ptu");
dc2 = getprop("/systems/electrical/bus/dc2");
if ((psi_diff > 500 or psi_diff < -500) and ptu_sw and dc2 > 25) {
setprop("/systems/hydraulic/ptu-active", 1);
} else if (psi_diff < 20 and psi_diff > -20) {
setprop("/systems/hydraulic/ptu-active", 0);
}
if ((rat_man_sw == 1 or getprop("/controls/electrical/switches/emer-gen") == 1) and (gs > 100)) {
setprop("/controls/hydraulic/rat", 1);
setprop("/controls/hydraulic/rat-deployed", 1);
} else if (gs < 100) {
var HYD = {
init: func() {
setprop("/controls/hydraulic/eng1-pump", 1);
setprop("/controls/hydraulic/eng2-pump", 1);
setprop("/controls/hydraulic/elec-pump-blue", 1);
setprop("/controls/hydraulic/elec-pump-yellow", 0);
setprop("/controls/hydraulic/hand-pump-yellow", 0);
setprop("/controls/hydraulic/ptu", 1);
setprop("/controls/hydraulic/rat-man", 0);
setprop("/controls/hydraulic/rat", 0);
}
ptu_active = getprop("/systems/hydraulic/ptu-active");
if ((elec_pump_blue_sw and dc_ess >= 25 and !blue_pump_fail) and (stateL == 3 or stateR == 3) and !blue_leak) {
if (blue_psi < 2900) {
setprop("/systems/hydraulic/blue-psi", blue_psi + 100);
} else {
setprop("/systems/hydraulic/blue-psi", 3000);
}
} else if (gs >= 100 and rat and !blue_leak) {
if (blue_psi < 2400) {
setprop("/systems/hydraulic/blue-psi", blue_psi + 100);
} else {
setprop("/systems/hydraulic/blue-psi", 2500);
}
} else {
if (blue_psi > 1) {
setprop("/systems/hydraulic/blue-psi", blue_psi - 50);
} else {
setprop("/systems/hydraulic/blue-psi", 0);
}
}
if ((eng1_pump_sw and stateL == 3 and !green_pump_fail) and !green_leak) {
if (green_psi < 2900) {
setprop("/systems/hydraulic/green-psi", green_psi + 100);
} else {
setprop("/systems/hydraulic/green-psi", 3000);
}
} else if ((ptu_active and stateL != 3 and !ptu_fail) and !green_leak) {
if (green_psi < 2900) {
setprop("/systems/hydraulic/green-psi", green_psi + 100);
} else {
setprop("/systems/hydraulic/green-psi", 3000);
}
} else {
if (green_psi > 1) {
setprop("/systems/hydraulic/green-psi", green_psi - 50);
} else {
setprop("/systems/hydraulic/green-psi", 0);
}
}
if ((eng2_pump_sw and stateR == 3 and !yellow_pump_eng_fail) and !yellow_leak) {
if (yellow_psi < 2900) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi + 100);
} else {
setprop("/systems/hydraulic/yellow-psi", 3000);
}
} else if ((elec_pump_yellow_sw and dc_ess >= 25 and !yellow_pump_elec_fail) and !yellow_leak) {
if (yellow_psi < 2900) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi + 100);
} else {
setprop("/systems/hydraulic/yellow-psi", 3000);
}
} else if ((ptu_active and stateR != 3 and !ptu_fail) and !yellow_leak) {
if (yellow_psi < 2900) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi + 100);
} else {
setprop("/systems/hydraulic/yellow-psi", 3000);
}
} else if (yellow_hand_pump and !yellow_leak and (getprop("/gear/gear[0]/wow") or getprop("/gear/gear[1]/wow") or getprop("/gear/gear[2]/wow"))) {
if (yellow_psi < 2900) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi + 50);
} else {
setprop("/systems/hydraulic/yellow-psi", 3000);
}
} else {
if (yellow_psi > 1) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi - 50);
} else {
setprop("/systems/hydraulic/yellow-psi", 0);
}
}
accum = getprop("/systems/hydraulic/brakes/accumulator-pressure-psi");
lpsi = getprop("/systems/hydraulic/brakes/pressure-left-psi");
rpsi = getprop("/systems/hydraulic/brakes/pressure-right-psi");
parking = getprop("/controls/gear/brake-parking");
askidnws_sw = getprop("/systems/hydraulic/brakes/askidnwssw");
brake_mode = getprop("/systems/hydraulic/brakes/mode");
brake_l = getprop("/systems/hydraulic/brakes/lbrake");
brake_r = getprop("/systems/hydraulic/brakes/rbrake");
brake_nose = getprop("/systems/hydraulic/brakes/nose-rubber");
counter = getprop("/systems/hydraulic/brakes/counter");
if (!parking and askidnws_sw and green_psi > 2500) {
# set mode to on
setprop("/systems/hydraulic/brakes/mode", 1);
} else if ((!parking and askidnws_sw and yellow_psi > 2500) or (!parking and askidnws_sw and accum > 0)) {
# set mode to altn
setprop("/systems/hydraulic/brakes/mode", 2);
} else {
# set mode to off
setprop("/controls/hydraulic/rat-deployed", 0);
setprop("/systems/hydraulic/ptu-active", 0);
setprop("/systems/hydraulic/blue-psi", 0);
setprop("/systems/hydraulic/green-psi", 0);
setprop("/systems/hydraulic/yellow-psi", 0);
setprop("/controls/gear/brake-parking", 0);
setprop("/systems/hydraulic/brakes/accumulator-pressure-psi", 0);
setprop("/systems/hydraulic/brakes/pressure-left-psi", 0);
setprop("/systems/hydraulic/brakes/pressure-right-psi", 0);
setprop("/systems/hydraulic/brakes/askidnwssw", 1);
setprop("/systems/hydraulic/brakes/mode", 0);
}
if (brake_mode == 2 and yellow_psi > 2500 and accum < 700) {
setprop("/systems/hydraulic/brakes/accumulator-pressure-psi", accum + 50);
}
# Fault lights
if (green_pump_fail and eng1_pump_sw) {
setprop("/systems/hydraulic/eng1-pump-fault", 1);
} else {
setprop("/systems/hydraulic/brakes/lbrake", 0);
setprop("/systems/hydraulic/brakes/rbrake", 0);
setprop("/systems/hydraulic/brakes/nose-rubber", 0);
setprop("/systems/hydraulic/brakes/counter", 0);
setprop("/systems/hydraulic/brakes/accumulator-pressure-psi-1", 0);
setprop("/systems/hydraulic/eng1-pump-fault", 0);
}
if (blue_pump_fail and elec_pump_blue_sw) {
setprop("/systems/hydraulic/elec-pump-b-fault", 1);
} else {
setprop("/systems/hydraulic/elec-pump-b-fault", 0);
}
if (ptu_fail and ptu_sw) {
setprop("/systems/hydraulic/ptu-fault", 1);
} else {
setprop("/systems/hydraulic/ptu-fault", 0);
}
if (yellow_pump_eng_fail and eng2_pump_sw) {
setprop("/systems/hydraulic/eng2-pump-fault", 1);
} else {
setprop("/systems/hydraulic/eng2-pump-fault", 0);
}
if (yellow_pump_elec_fail and elec_pump_yellow_sw) {
setprop("/systems/hydraulic/elec-pump-y-fault", 1);
} else {
setprop("/systems/hydraulic/elec-pump-b-fault", 0);
setprop("/systems/hydraulic/elec-pump-y-fault", 0);
}
}
setprop("/systems/hydraulic/ptu-fault", 0);
},
loop: func() {
eng1_pump_sw = getprop("/controls/hydraulic/eng1-pump");
eng2_pump_sw = getprop("/controls/hydraulic/eng2-pump");
elec_pump_blue_sw = getprop("/controls/hydraulic/elec-pump-blue");
elec_pump_yellow_sw = getprop("/controls/hydraulic/elec-pump-yellow");
yellow_hand_pump = getprop("/controls/hydraulic/hand-pump-yellow");
ptu_sw = getprop("/controls/hydraulic/ptu");
rat_man_sw = getprop("/controls/hydraulic/rat-man");
blue_psi = getprop("/systems/hydraulic/blue-psi");
green_psi = getprop("/systems/hydraulic/green-psi");
yellow_psi = getprop("/systems/hydraulic/yellow-psi");
rpmapu = getprop("/systems/apu/rpm");
stateL = getprop("/engines/engine[0]/state");
stateR = getprop("/engines/engine[1]/state");
dc_ess = getprop("/systems/electrical/bus/dc-ess");
psi_diff = green_psi - yellow_psi;
rat = getprop("/controls/hydraulic/rat");
ratout = getprop("/controls/hydraulic/rat-deployed");
gs = getprop("/velocities/groundspeed-kt");
blue_leak = getprop("/systems/failures/hyd-blue");
green_leak = getprop("/systems/failures/hyd-green");
yellow_leak = getprop("/systems/failures/hyd-yellow");
blue_pump_fail = getprop("/systems/failures/pump-blue");
green_pump_fail = getprop("/systems/failures/pump-green");
yellow_pump_eng_fail = getprop("/systems/failures/pump-yellow-eng");
yellow_pump_elec_fail = getprop("/systems/failures/pump-yellow-elec");
ptu_fail = getprop("/systems/failures/ptu");
dc2 = getprop("/systems/electrical/bus/dc2");
if ((psi_diff > 500 or psi_diff < -500) and ptu_sw and dc2 > 25) {
setprop("/systems/hydraulic/ptu-active", 1);
} else if (psi_diff < 20 and psi_diff > -20) {
setprop("/systems/hydraulic/ptu-active", 0);
}
#######################
# Various Other Stuff #
#######################
if ((rat_man_sw == 1 or getprop("/controls/electrical/switches/emer-gen") == 1) and (gs > 100)) {
setprop("/controls/hydraulic/rat", 1);
setprop("/controls/hydraulic/rat-deployed", 1);
} else if (gs < 100) {
setprop("/controls/hydraulic/rat", 0);
}
ptu_active = getprop("/systems/hydraulic/ptu-active");
if ((elec_pump_blue_sw and dc_ess >= 25 and !blue_pump_fail) and (stateL == 3 or stateR == 3) and !blue_leak) {
if (blue_psi < 2900) {
setprop("/systems/hydraulic/blue-psi", blue_psi + 50);
} else {
setprop("/systems/hydraulic/blue-psi", 3000);
}
} else if (gs >= 50 and rat and !blue_leak) {
if (blue_psi < 2400) {
setprop("/systems/hydraulic/blue-psi", blue_psi + 50);
} else {
setprop("/systems/hydraulic/blue-psi", 2250);
}
} else {
if (blue_psi > 1) {
setprop("/systems/hydraulic/blue-psi", blue_psi - 25);
} else {
setprop("/systems/hydraulic/blue-psi", 0);
}
}
if ((eng1_pump_sw and stateL == 3 and !green_pump_fail) and !green_leak) {
if (green_psi < 2900) {
setprop("/systems/hydraulic/green-psi", green_psi + 50);
} else {
setprop("/systems/hydraulic/green-psi", 3000);
}
} else if ((ptu_active and stateL != 3 and !ptu_fail) and !green_leak) {
if (green_psi < 2900) {
setprop("/systems/hydraulic/green-psi", green_psi + 50);
} else {
setprop("/systems/hydraulic/green-psi", 3000);
}
} else {
if (green_psi > 1) {
setprop("/systems/hydraulic/green-psi", green_psi - 25);
} else {
setprop("/systems/hydraulic/green-psi", 0);
}
}
if ((eng2_pump_sw and stateR == 3 and !yellow_pump_eng_fail) and !yellow_leak) {
if (yellow_psi < 2900) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi + 50);
} else {
setprop("/systems/hydraulic/yellow-psi", 3000);
}
} else if ((elec_pump_yellow_sw and dc_ess >= 25 and !yellow_pump_elec_fail) and !yellow_leak) {
if (yellow_psi < 2900) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi + 50);
} else {
setprop("/systems/hydraulic/yellow-psi", 3000);
}
} else if ((ptu_active and stateR != 3 and !ptu_fail) and !yellow_leak) {
if (yellow_psi < 2900) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi + 50);
} else {
setprop("/systems/hydraulic/yellow-psi", 3000);
}
} else if (yellow_hand_pump and !yellow_leak and (getprop("/gear/gear[0]/wow") or getprop("/gear/gear[1]/wow") or getprop("/gear/gear[2]/wow"))) {
if (yellow_psi < 2900) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi + 25);
} else {
setprop("/systems/hydraulic/yellow-psi", 3000);
}
} else {
if (yellow_psi > 1) {
setprop("/systems/hydraulic/yellow-psi", yellow_psi - 25);
} else {
setprop("/systems/hydraulic/yellow-psi", 0);
}
}
accum = getprop("/systems/hydraulic/brakes/accumulator-pressure-psi");
lpsi = getprop("/systems/hydraulic/brakes/pressure-left-psi");
rpsi = getprop("/systems/hydraulic/brakes/pressure-right-psi");
parking = getprop("/controls/gear/brake-parking");
askidnws_sw = getprop("/systems/hydraulic/brakes/askidnwssw");
brake_mode = getprop("/systems/hydraulic/brakes/mode");
brake_l = getprop("/systems/hydraulic/brakes/lbrake");
brake_r = getprop("/systems/hydraulic/brakes/rbrake");
brake_nose = getprop("/systems/hydraulic/brakes/nose-rubber");
counter = getprop("/systems/hydraulic/brakes/counter");
if (!parking and askidnws_sw and green_psi > 2500) {
# set mode to on
setprop("/systems/hydraulic/brakes/mode", 1);
} else if ((!parking and askidnws_sw and yellow_psi > 2500) or (!parking and askidnws_sw and accum > 0)) {
# set mode to altn
setprop("/systems/hydraulic/brakes/mode", 2);
} else {
# set mode to off
setprop("/systems/hydraulic/brakes/mode", 0);
}
if (brake_mode == 2 and yellow_psi > 2500 and accum < 700) {
setprop("/systems/hydraulic/brakes/accumulator-pressure-psi", accum + 50);
}
# Fault lights
if (green_pump_fail and eng1_pump_sw) {
setprop("/systems/hydraulic/eng1-pump-fault", 1);
} else {
setprop("/systems/hydraulic/eng1-pump-fault", 0);
}
if (blue_pump_fail and elec_pump_blue_sw) {
setprop("/systems/hydraulic/elec-pump-b-fault", 1);
} else {
setprop("/systems/hydraulic/elec-pump-b-fault", 0);
}
if (ptu_fail and ptu_sw) {
setprop("/systems/hydraulic/ptu-fault", 1);
} else {
setprop("/systems/hydraulic/ptu-fault", 0);
}
if (yellow_pump_eng_fail and eng2_pump_sw) {
setprop("/systems/hydraulic/eng2-pump-fault", 1);
} else {
setprop("/systems/hydraulic/eng2-pump-fault", 0);
}
if (yellow_pump_elec_fail and elec_pump_yellow_sw) {
setprop("/systems/hydraulic/elec-pump-y-fault", 1);
} else {
setprop("/systems/hydraulic/elec-pump-y-fault", 0);
}
},
};
setlistener("/controls/gear/gear-down", func {
down = getprop("/controls/gear/gear-down");
@ -272,22 +260,3 @@ setlistener("/controls/gear/gear-down", func {
setprop("/controls/gear/gear-down", 1);
}
});
###################
# Update Function #
###################
var update_hydraulic = func {
master_hyd();
}
var hyd_timer = maketimer(0.2, update_hydraulic);
# FIXME:
# Josh, please disable braking when:
# /systems/hydraulic/brakes/accumulator-pressure-psi is equal to 0 and when /systems/hydraulic/brakes/mode is equal to 2
# Thanks!
# Will do -JD

View file

@ -199,16 +199,16 @@ var triggerDoor = func(door, doorName, doorDesc) {
setlistener("/sim/signals/fdm-initialized", func {
fbw.fctlInit();
systems.elec_init();
systems.adirs_init();
systems.pneu_init();
systems.hyd_init();
systems.fuel_init();
systems.fire_init();
systems.ELEC.init();
systems.PNEU.init();
systems.HYD.init();
systems.FUEL.init();
systems.ADIRS.init();
systems.eng_init();
systems.fire_init();
systems.autobrake_init();
fmgc.APinit();
librariesLoop.start();
systemsLoop.start();
fmgc.FMGCinit();
mcdu1.MCDU_init();
mcdu2.MCDU_init();
@ -217,14 +217,19 @@ setlistener("/sim/signals/fdm-initialized", func {
var autopilot = gui.Dialog.new("sim/gui/dialogs/autopilot/dialog", "Aircraft/IDG-A32X/Systems/autopilot-dlg.xml");
setprop("/it-autoflight/input/fd1", 1);
setprop("/it-autoflight/input/fd2", 1);
setprop("/sim/model/lights/floor-light", 0);
libraries.ECAMinit();
libraries.variousReset();
logoTimer.start();
noseLoop.start();
});
var librariesLoop = maketimer(0.1, func {
var systemsLoop = maketimer(0.1, func {
systems.ELEC.loop();
systems.PNEU.loop();
systems.HYD.loop();
systems.FUEL.loop();
systems.ADIRS.loop();
if ((getprop("/controls/pneumatic/switches/groundair") or getprop("/controls/switches/cart")) and ((getprop("/velocities/groundspeed-kt") > 2) or getprop("/controls/gear/brake-parking") == 0)) {
setprop("/controls/switches/cart", 0);
setprop("/controls/pneumatic/switches/groundair", 0);

View file

@ -5,10 +5,6 @@
# Copyright (c) Joshua Davidson (it0uchpods) #
##############################################
#############
# Init Vars #
#############
setlistener("/sim/signals/fdm-initialized", func {
var altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
var bleed1_sw = getprop("/controls/pneumatic/switches/bleed1");
@ -78,309 +74,305 @@ setlistener("/sim/signals/fdm-initialized", func {
var guard = getprop("/controls/oxygen/masksGuard");
});
var pneu_init = func {
setprop("/controls/pneumatic/switches/bleed1", 1);
setprop("/controls/pneumatic/switches/bleed2", 1);
setprop("/controls/pneumatic/switches/bleedapu", 0);
setprop("/controls/pneumatic/switches/groundair", 0);
setprop("/controls/pneumatic/switches/pack1", 1);
setprop("/controls/pneumatic/switches/pack2", 1);
setprop("/controls/pneumatic/switches/hot-air", 1);
setprop("/controls/pneumatic/switches/ram-air", 0);
setprop("/controls/pneumatic/switches/pack-flo", 9); # LO: 7, NORM: 9, HI: 11.
setprop("/controls/pneumatic/switches/xbleed", 1); # SHUT: 0, AUTO: 1, OPEN: 2.
setprop("/systems/pneumatic/bleed1", 0);
setprop("/systems/pneumatic/bleed2", 0);
setprop("/systems/pneumatic/bleedapu", 0);
setprop("/systems/pneumatic/groundair", 0);
setprop("/systems/pneumatic/total-psi", 0);
setprop("/systems/pneumatic/start-psi", 0);
setprop("/systems/pneumatic/pack-psi", 0);
setprop("/systems/pneumatic/pack1", 0);
setprop("/systems/pneumatic/pack2", 0);
setprop("/systems/pneumatic/start-psi", 0);
setprop("/systems/pneumatic/eng1-starter", 0);
setprop("/systems/pneumatic/eng2-starter", 0);
setprop("/systems/pneumatic/bleed1-fault", 0);
setprop("/systems/pneumatic/bleed2-fault", 0);
setprop("/systems/pneumatic/bleedapu-fault", 0);
setprop("/systems/pneumatic/hotair-fault", 0);
setprop("/systems/pneumatic/pack1-fault", 0);
setprop("/systems/pneumatic/pack2-fault", 0);
setprop("/systems/pneumatic/xbleed", 0);
setprop("/FMGC/internal/dep-arpt", "");
altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
setprop("/systems/pressurization/mode", "GN");
setprop("/systems/pressurization/vs", "0");
setprop("/systems/pressurization/targetvs", "0");
setprop("/systems/pressurization/vs-norm", "0");
setprop("/systems/pressurization/auto", 1);
setprop("/systems/pressurization/deltap", "0");
setprop("/systems/pressurization/outflowpos", "0");
setprop("/systems/pressurization/deltap-norm", "0");
setprop("/systems/pressurization/outflowpos-norm", "0");
setprop("/systems/pressurization/outflowpos-man", "0.5");
setprop("/systems/pressurization/outflowpos-man-sw", "0");
setprop("/systems/pressurization/outflowpos-norm-cmd", "0");
setprop("/systems/pressurization/cabinalt", altitude);
setprop("/systems/pressurization/targetalt", altitude);
setprop("/systems/pressurization/diff-to-target", "0");
setprop("/systems/pressurization/ditchingpb", 0);
setprop("/systems/pressurization/targetvs", "0");
setprop("/systems/pressurization/ambientpsi", "0");
setprop("/systems/pressurization/cabinpsi", "0");
setprop("/systems/pressurization/manvs-cmd", "0");
setprop("/systems/ventilation/cabin/fans", 0); # aircon fans
setprop("/systems/ventilation/avionics/fan", 0);
setprop("/systems/ventilation/avionics/extractvalve", "0");
setprop("/systems/ventilation/avionics/inletvalve", "0");
setprop("/systems/ventilation/lavatory/extractfan", 0);
setprop("/systems/ventilation/lavatory/extractvalve", "0");
setprop("/controls/deice/eng1-on", 0);
setprop("/controls/deice/eng2-on", 0);
setprop("/controls/oxygen/masksDeploy", 0);
setprop("/controls/oxygen/masksDeployMan", 0);
setprop("/controls/oxygen/masksReset", 0); # this is the TMR RESET pb on the maintenance panel, needs 3D model
setprop("/controls/oxygen/masksSys", 0);
pneu_timer.start();
}
#######################
# Main Pneumatic Loop #
#######################
var master_pneu = func {
bleed1_sw = getprop("/controls/pneumatic/switches/bleed1");
bleed2_sw = getprop("/controls/pneumatic/switches/bleed2");
bleedapu_sw = getprop("/controls/pneumatic/switches/bleedapu");
pack1_sw = getprop("/controls/pneumatic/switches/pack1");
pack2_sw = getprop("/controls/pneumatic/switches/pack2");
hot_air_sw = getprop("/controls/pneumatic/switches/hot-air");
ram_air_sw = getprop("/controls/pneumatic/switches/ram-air");
pack_flo_sw = getprop("/controls/pneumatic/switches/pack-flo");
xbleed_sw = getprop("/controls/pneumatic/switches/xbleed");
eng1_starter = getprop("/systems/pneumatic/eng1-starter");
eng2_starter = getprop("/systems/pneumatic/eng2-starter");
groundair = getprop("/systems/pneumatic/groundair");
groundair_supp = getprop("/controls/pneumatic/switches/groundair");
rpmapu = getprop("/systems/apu/rpm");
stateL = getprop("/engines/engine[0]/state");
stateR = getprop("/engines/engine[1]/state");
bleedapu_fail = getprop("/systems/failures/bleed-apu");
bleedext_fail = getprop("/systems/failures/bleed-ext");
bleedeng1_fail = getprop("/systems/failures/bleed-eng1");
bleedeng2_fail = getprop("/systems/failures/bleed-eng2");
pack1_fail = getprop("/systems/failures/pack1");
pack2_fail = getprop("/systems/failures/pack2");
engantiice1 = getprop("/controls/deice/eng1-on");
engantiice2 = getprop("/controls/deice/eng2-on");
# Air Sources/PSI
if (rpmapu >= 94.9 and bleedapu_sw and !bleedapu_fail) {
setprop("/systems/pneumatic/bleedapu", 34);
} else {
setprop("/systems/pneumatic/bleedapu", 0);
}
ground = getprop("/systems/pneumatic/groundair");
bleedapu = getprop("/systems/pneumatic/bleedapu");
if (xbleed_sw == 0) {
setprop("/systems/pneumatic/xbleed", 0);
} else if (xbleed_sw == 1) {
if (bleedapu >= 11) {
setprop("/systems/pneumatic/xbleed", 1);
} else {
setprop("/systems/pneumatic/xbleed", 0);
}
} else if (xbleed_sw == 2) {
setprop("/systems/pneumatic/xbleed", 1);
}
xbleed = getprop("/systems/pneumatic/xbleed", 0);
if (stateL == 3 and bleed1_sw and !bleedeng1_fail) {
setprop("/systems/pneumatic/bleed1", 31);
} else {
var PNEU = {
init: func() {
setprop("/controls/pneumatic/switches/bleed1", 1);
setprop("/controls/pneumatic/switches/bleed2", 1);
setprop("/controls/pneumatic/switches/bleedapu", 0);
setprop("/controls/pneumatic/switches/groundair", 0);
setprop("/controls/pneumatic/switches/pack1", 1);
setprop("/controls/pneumatic/switches/pack2", 1);
setprop("/controls/pneumatic/switches/hot-air", 1);
setprop("/controls/pneumatic/switches/ram-air", 0);
setprop("/controls/pneumatic/switches/pack-flo", 9); # LO: 7, NORM: 9, HI: 11.
setprop("/controls/pneumatic/switches/xbleed", 1); # SHUT: 0, AUTO: 1, OPEN: 2.
setprop("/systems/pneumatic/bleed1", 0);
}
if (stateR == 3 and bleed2_sw and !bleedeng2_fail) {
setprop("/systems/pneumatic/bleed2", 32);
} else {
setprop("/systems/pneumatic/bleed2", 0);
}
bleed1 = getprop("/systems/pneumatic/bleed1");
bleed2 = getprop("/systems/pneumatic/bleed2");
if (bleed1 >= 11 and (stateR != 3 or !bleed2_sw or bleedeng2_fail) and xbleed == 1) {
setprop("/systems/pneumatic/bleed2", 31);
}
if (bleed2 >= 11 and (stateL != 3 or !bleed1_sw or bleedeng1_fail) and xbleed == 1) {
setprop("/systems/pneumatic/bleed1", 32);
}
bleed1 = getprop("/systems/pneumatic/bleed1");
bleed2 = getprop("/systems/pneumatic/bleed2");
if (stateL == 1 or stateR == 1) {
setprop("/systems/pneumatic/start-psi", 18);
} else {
setprop("/systems/pneumatic/start-psi", 0);
}
if (pack1_sw == 1 and (bleed1 >= 11 or bleedapu >= 11 or ground >= 11) and eng1_starter == 0 and eng2_starter == 0 and !pack1_fail) {
setprop("/systems/pneumatic/pack1", pack_flo_sw);
} else {
setprop("/systems/pneumatic/pack1", 0);
}
if (pack2_sw == 1 and (bleed2 >= 11 or (bleedapu >= 11 and xbleed == 1)) and eng1_starter == 0 and eng2_starter == 0 and !pack2_fail) {
setprop("/systems/pneumatic/pack2", pack_flo_sw);
} else {
setprop("/systems/pneumatic/pack2", 0);
}
pack1 = getprop("/systems/pneumatic/pack1");
pack2 = getprop("/systems/pneumatic/pack2");
if (pack1_sw == 1 and pack2_sw == 1) {
setprop("/systems/pneumatic/pack-psi", pack1 + pack2);
} else if (pack1_sw == 0 and pack2_sw == 0) {
setprop("/systems/pneumatic/pack-psi", 0);
} else {
setprop("/systems/pneumatic/pack-psi", pack1 + pack2 + 5);
}
pack_psi = getprop("/systems/pneumatic/pack-psi");
start_psi = getprop("/systems/pneumatic/start-psi");
if ((bleed1 + bleed2 + bleedapu) > 42) {
setprop("/systems/pneumatic/total-psi", 42);
} else {
total_psi_calc = ((bleed1 + bleed2 + bleedapu + ground) - start_psi - pack_psi);
setprop("/systems/pneumatic/total-psi", total_psi_calc);
}
if (groundair_supp) {
setprop("/systems/pneumatic/groundair", 39);
} else {
setprop("/systems/pneumatic/bleedapu", 0);
setprop("/systems/pneumatic/groundair", 0);
}
if (engantiice1 and bleed1 > 20) { # shut down anti-ice if bleed is lost else turn it on
setprop("/controls/deice/lengine", 0);
setprop("/controls/deice/eng1-on", 0);
}
if (engantiice1) { # else turn it on
setprop("/controls/deice/lengine", 1);
}
if (engantiice2 and bleed2 > 20) {
setprop("/controls/deice/rengine", 0);
setprop("/controls/deice/eng2-on", 0);
}
if (engantiice2) {
setprop("/controls/deice/rengine", 1);
}
total_psi = getprop("/systems/pneumatic/total-psi");
phase = getprop("/FMGC/status/phase");
pressmode = getprop("/systems/pressurization/mode");
state1 = getprop("/systems/thrust/state1");
state2 = getprop("/systems/thrust/state2");
wowl = getprop("/gear/gear[1]/wow");
wowr = getprop("/gear/gear[2]/wow");
deltap = getprop("/systems/pressurization/deltap");
outflow = getprop("/systems/pressurization/outflowpos");
speed = getprop("/velocities/groundspeed-kt");
altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
airport_arr_elev_ft = getprop("autopilot/route-manager/destination/field-elevation-ft");
vs = getprop("/systems/pressurization/vs-norm");
manvs = getprop("/systems/pressurization/manvs-cmd");
ditch = getprop("/systems/pressurization/ditchingpb");
outflowpos = getprop("/systems/pressurization/outflowpos");
cabinalt = getprop("/systems/pressurization/cabinalt");
targetalt = getprop("/systems/pressurization/targetalt");
targetvs = getprop("/systems/pressurization/targetvs");
ambient = getprop("/systems/pressurization/ambientpsi");
cabinpsi = getprop("/systems/pressurization/cabinpsi");
pause = getprop("/sim/freeze/master");
auto = getprop("/systems/pressurization/auto");
setprop("/systems/pressurization/diff-to-target", targetalt - cabinalt);
setprop("/systems/pressurization/deltap", cabinpsi - ambient);
if ((pressmode == "GN") and (pressmode != "CL") and (wowl and wowr) and ((state1 == "MCT") or (state1 == "TOGA")) and ((state2 == "MCT") or (state2 == "TOGA"))) {
setprop("/systems/pressurization/mode", "TO");
} else if (((!wowl) or (!wowr)) and (speed > 100) and (pressmode == "TO")) {
setprop("/systems/pressurization/mode", "CL");
}
if (vs != targetvs and !wowl and !wowr) {
setprop("/systems/pressurization/vs", targetvs);
}
if (cabinalt != targetalt and !wowl and !wowr and !pause and auto) {
setprop("/systems/pressurization/cabinalt", cabinalt + ((vs / 60) / 10));
} else if (!auto and !pause) {
setprop("/systems/pressurization/cabinalt", cabinalt + ((manvs / 60) / 10));
}
if (ditch and auto) {
setprop("/systems/pressurization/outflowpos", "1");
setprop("/systems/ventilation/avionics/extractvalve", "1");
setprop("/systems/ventilation/avionics/inletvalve", "1");
}
dcess = getprop("/systems/electrical/bus/dc-ess");
acess = getprop("/systems/electrical/bus/ac-ess");
fanon = getprop("/systems/ventilation/avionics/fan");
if ((dcess > 25) or (acess > 110)) {
setprop("/systems/ventilation/avionics/fan", 1);
setprop("/systems/ventilation/lavatory/extractfan", 1);
} else if ((dcess == 0) and (acess == 0)) {
setprop("/systems/ventilation/avionics/fan", 0);
setprop("/systems/ventilation/lavatory/extractfan", 0);
}
# Fault lights
if (bleedeng1_fail and bleed1_sw) {
setprop("/systems/pneumatic/bleed1-fault", 1);
} else {
setprop("/systems/pneumatic/total-psi", 0);
setprop("/systems/pneumatic/start-psi", 0);
setprop("/systems/pneumatic/pack-psi", 0);
setprop("/systems/pneumatic/pack1", 0);
setprop("/systems/pneumatic/pack2", 0);
setprop("/systems/pneumatic/start-psi", 0);
setprop("/systems/pneumatic/eng1-starter", 0);
setprop("/systems/pneumatic/eng2-starter", 0);
setprop("/systems/pneumatic/bleed1-fault", 0);
}
if (bleedeng2_fail and bleed2_sw) {
setprop("/systems/pneumatic/bleed2-fault", 1);
} else {
setprop("/systems/pneumatic/bleed2-fault", 0);
}
if (bleedapu_fail and bleedapu_sw) {
setprop("/systems/pneumatic/bleedapu-fault", 1);
} else {
setprop("/systems/pneumatic/bleedapu-fault", 0);
}
if ((pack1_fail and pack1_sw) or (pack1_sw and pack1 <= 5)) {
setprop("/systems/pneumatic/pack1-fault", 1);
} else {
setprop("/systems/pneumatic/hotair-fault", 0);
setprop("/systems/pneumatic/pack1-fault", 0);
}
if ((pack2_fail and pack2_sw) or (pack2_sw and pack2 <= 5)) {
setprop("/systems/pneumatic/pack2-fault", 1);
} else {
setprop("/systems/pneumatic/pack2-fault", 0);
}
}
setprop("/systems/pneumatic/xbleed", 0);
setprop("/FMGC/internal/dep-arpt", "");
altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
setprop("/systems/pressurization/mode", "GN");
setprop("/systems/pressurization/vs", "0");
setprop("/systems/pressurization/targetvs", "0");
setprop("/systems/pressurization/vs-norm", "0");
setprop("/systems/pressurization/auto", 1);
setprop("/systems/pressurization/deltap", "0");
setprop("/systems/pressurization/outflowpos", "0");
setprop("/systems/pressurization/deltap-norm", "0");
setprop("/systems/pressurization/outflowpos-norm", "0");
setprop("/systems/pressurization/outflowpos-man", "0.5");
setprop("/systems/pressurization/outflowpos-man-sw", "0");
setprop("/systems/pressurization/outflowpos-norm-cmd", "0");
setprop("/systems/pressurization/cabinalt", altitude);
setprop("/systems/pressurization/targetalt", altitude);
setprop("/systems/pressurization/diff-to-target", "0");
setprop("/systems/pressurization/ditchingpb", 0);
setprop("/systems/pressurization/targetvs", "0");
setprop("/systems/pressurization/ambientpsi", "0");
setprop("/systems/pressurization/cabinpsi", "0");
setprop("/systems/pressurization/manvs-cmd", "0");
setprop("/systems/ventilation/cabin/fans", 0); # aircon fans
setprop("/systems/ventilation/avionics/fan", 0);
setprop("/systems/ventilation/avionics/extractvalve", "0");
setprop("/systems/ventilation/avionics/inletvalve", "0");
setprop("/systems/ventilation/lavatory/extractfan", 0);
setprop("/systems/ventilation/lavatory/extractvalve", "0");
setprop("/controls/deice/eng1-on", 0);
setprop("/controls/deice/eng2-on", 0);
setprop("/controls/oxygen/masksDeploy", 0);
setprop("/controls/oxygen/masksDeployMan", 0);
setprop("/controls/oxygen/masksReset", 0); # this is the TMR RESET pb on the maintenance panel, needs 3D model
setprop("/controls/oxygen/masksSys", 0);
},
loop: func() {
bleed1_sw = getprop("/controls/pneumatic/switches/bleed1");
bleed2_sw = getprop("/controls/pneumatic/switches/bleed2");
bleedapu_sw = getprop("/controls/pneumatic/switches/bleedapu");
pack1_sw = getprop("/controls/pneumatic/switches/pack1");
pack2_sw = getprop("/controls/pneumatic/switches/pack2");
hot_air_sw = getprop("/controls/pneumatic/switches/hot-air");
ram_air_sw = getprop("/controls/pneumatic/switches/ram-air");
pack_flo_sw = getprop("/controls/pneumatic/switches/pack-flo");
xbleed_sw = getprop("/controls/pneumatic/switches/xbleed");
eng1_starter = getprop("/systems/pneumatic/eng1-starter");
eng2_starter = getprop("/systems/pneumatic/eng2-starter");
groundair = getprop("/systems/pneumatic/groundair");
groundair_supp = getprop("/controls/pneumatic/switches/groundair");
rpmapu = getprop("/systems/apu/rpm");
stateL = getprop("/engines/engine[0]/state");
stateR = getprop("/engines/engine[1]/state");
bleedapu_fail = getprop("/systems/failures/bleed-apu");
bleedext_fail = getprop("/systems/failures/bleed-ext");
bleedeng1_fail = getprop("/systems/failures/bleed-eng1");
bleedeng2_fail = getprop("/systems/failures/bleed-eng2");
pack1_fail = getprop("/systems/failures/pack1");
pack2_fail = getprop("/systems/failures/pack2");
engantiice1 = getprop("/controls/deice/eng1-on");
engantiice2 = getprop("/controls/deice/eng2-on");
# Air Sources/PSI
if (rpmapu >= 94.9 and bleedapu_sw and !bleedapu_fail) {
setprop("/systems/pneumatic/bleedapu", 34);
} else {
setprop("/systems/pneumatic/bleedapu", 0);
}
ground = getprop("/systems/pneumatic/groundair");
bleedapu = getprop("/systems/pneumatic/bleedapu");
if (xbleed_sw == 0) {
setprop("/systems/pneumatic/xbleed", 0);
} else if (xbleed_sw == 1) {
if (bleedapu >= 11) {
setprop("/systems/pneumatic/xbleed", 1);
} else {
setprop("/systems/pneumatic/xbleed", 0);
}
} else if (xbleed_sw == 2) {
setprop("/systems/pneumatic/xbleed", 1);
}
xbleed = getprop("/systems/pneumatic/xbleed", 0);
if (stateL == 3 and bleed1_sw and !bleedeng1_fail) {
setprop("/systems/pneumatic/bleed1", 31);
} else {
setprop("/systems/pneumatic/bleed1", 0);
}
if (stateR == 3 and bleed2_sw and !bleedeng2_fail) {
setprop("/systems/pneumatic/bleed2", 32);
} else {
setprop("/systems/pneumatic/bleed2", 0);
}
bleed1 = getprop("/systems/pneumatic/bleed1");
bleed2 = getprop("/systems/pneumatic/bleed2");
if (bleed1 >= 11 and (stateR != 3 or !bleed2_sw or bleedeng2_fail) and xbleed == 1) {
setprop("/systems/pneumatic/bleed2", 31);
}
if (bleed2 >= 11 and (stateL != 3 or !bleed1_sw or bleedeng1_fail) and xbleed == 1) {
setprop("/systems/pneumatic/bleed1", 32);
}
bleed1 = getprop("/systems/pneumatic/bleed1");
bleed2 = getprop("/systems/pneumatic/bleed2");
if (stateL == 1 or stateR == 1) {
setprop("/systems/pneumatic/start-psi", 18);
} else {
setprop("/systems/pneumatic/start-psi", 0);
}
if (pack1_sw == 1 and (bleed1 >= 11 or bleedapu >= 11 or ground >= 11) and eng1_starter == 0 and eng2_starter == 0 and !pack1_fail) {
setprop("/systems/pneumatic/pack1", pack_flo_sw);
} else {
setprop("/systems/pneumatic/pack1", 0);
}
if (pack2_sw == 1 and (bleed2 >= 11 or (bleedapu >= 11 and xbleed == 1)) and eng1_starter == 0 and eng2_starter == 0 and !pack2_fail) {
setprop("/systems/pneumatic/pack2", pack_flo_sw);
} else {
setprop("/systems/pneumatic/pack2", 0);
}
pack1 = getprop("/systems/pneumatic/pack1");
pack2 = getprop("/systems/pneumatic/pack2");
if (pack1_sw == 1 and pack2_sw == 1) {
setprop("/systems/pneumatic/pack-psi", pack1 + pack2);
} else if (pack1_sw == 0 and pack2_sw == 0) {
setprop("/systems/pneumatic/pack-psi", 0);
} else {
setprop("/systems/pneumatic/pack-psi", pack1 + pack2 + 5);
}
pack_psi = getprop("/systems/pneumatic/pack-psi");
start_psi = getprop("/systems/pneumatic/start-psi");
if ((bleed1 + bleed2 + bleedapu) > 42) {
setprop("/systems/pneumatic/total-psi", 42);
} else {
total_psi_calc = ((bleed1 + bleed2 + bleedapu + ground) - start_psi - pack_psi);
setprop("/systems/pneumatic/total-psi", total_psi_calc);
}
if (groundair_supp) {
setprop("/systems/pneumatic/groundair", 39);
} else {
setprop("/systems/pneumatic/groundair", 0);
}
if (engantiice1 and bleed1 > 20) { # shut down anti-ice if bleed is lost else turn it on
setprop("/controls/deice/lengine", 0);
setprop("/controls/deice/eng1-on", 0);
}
if (engantiice1) { # else turn it on
setprop("/controls/deice/lengine", 1);
}
if (engantiice2 and bleed2 > 20) {
setprop("/controls/deice/rengine", 0);
setprop("/controls/deice/eng2-on", 0);
}
if (engantiice2) {
setprop("/controls/deice/rengine", 1);
}
total_psi = getprop("/systems/pneumatic/total-psi");
phase = getprop("/FMGC/status/phase");
pressmode = getprop("/systems/pressurization/mode");
state1 = getprop("/systems/thrust/state1");
state2 = getprop("/systems/thrust/state2");
wowl = getprop("/gear/gear[1]/wow");
wowr = getprop("/gear/gear[2]/wow");
deltap = getprop("/systems/pressurization/deltap");
outflow = getprop("/systems/pressurization/outflowpos");
speed = getprop("/velocities/groundspeed-kt");
altitude = getprop("/instrumentation/altimeter/indicated-altitude-ft");
airport_arr_elev_ft = getprop("autopilot/route-manager/destination/field-elevation-ft");
vs = getprop("/systems/pressurization/vs-norm");
manvs = getprop("/systems/pressurization/manvs-cmd");
ditch = getprop("/systems/pressurization/ditchingpb");
outflowpos = getprop("/systems/pressurization/outflowpos");
cabinalt = getprop("/systems/pressurization/cabinalt");
targetalt = getprop("/systems/pressurization/targetalt");
targetvs = getprop("/systems/pressurization/targetvs");
ambient = getprop("/systems/pressurization/ambientpsi");
cabinpsi = getprop("/systems/pressurization/cabinpsi");
pause = getprop("/sim/freeze/master");
auto = getprop("/systems/pressurization/auto");
setprop("/systems/pressurization/diff-to-target", targetalt - cabinalt);
setprop("/systems/pressurization/deltap", cabinpsi - ambient);
if ((pressmode == "GN") and (pressmode != "CL") and (wowl and wowr) and ((state1 == "MCT") or (state1 == "TOGA")) and ((state2 == "MCT") or (state2 == "TOGA"))) {
setprop("/systems/pressurization/mode", "TO");
} else if (((!wowl) or (!wowr)) and (speed > 100) and (pressmode == "TO")) {
setprop("/systems/pressurization/mode", "CL");
}
if (vs != targetvs and !wowl and !wowr) {
setprop("/systems/pressurization/vs", targetvs);
}
if (cabinalt != targetalt and !wowl and !wowr and !pause and auto) {
setprop("/systems/pressurization/cabinalt", cabinalt + ((vs / 60) / 10));
} else if (!auto and !pause) {
setprop("/systems/pressurization/cabinalt", cabinalt + ((manvs / 60) / 10));
}
if (ditch and auto) {
setprop("/systems/pressurization/outflowpos", "1");
setprop("/systems/ventilation/avionics/extractvalve", "1");
setprop("/systems/ventilation/avionics/inletvalve", "1");
}
dcess = getprop("/systems/electrical/bus/dc-ess");
acess = getprop("/systems/electrical/bus/ac-ess");
fanon = getprop("/systems/ventilation/avionics/fan");
if ((dcess > 25) or (acess > 110)) {
setprop("/systems/ventilation/avionics/fan", 1);
setprop("/systems/ventilation/lavatory/extractfan", 1);
} else if ((dcess == 0) and (acess == 0)) {
setprop("/systems/ventilation/avionics/fan", 0);
setprop("/systems/ventilation/lavatory/extractfan", 0);
}
# Fault lights
if (bleedeng1_fail and bleed1_sw) {
setprop("/systems/pneumatic/bleed1-fault", 1);
} else {
setprop("/systems/pneumatic/bleed1-fault", 0);
}
if (bleedeng2_fail and bleed2_sw) {
setprop("/systems/pneumatic/bleed2-fault", 1);
} else {
setprop("/systems/pneumatic/bleed2-fault", 0);
}
if (bleedapu_fail and bleedapu_sw) {
setprop("/systems/pneumatic/bleedapu-fault", 1);
} else {
setprop("/systems/pneumatic/bleedapu-fault", 0);
}
if ((pack1_fail and pack1_sw) or (pack1_sw and pack1 <= 5)) {
setprop("/systems/pneumatic/pack1-fault", 1);
} else {
setprop("/systems/pneumatic/pack1-fault", 0);
}
if ((pack2_fail and pack2_sw) or (pack2_sw and pack2 <= 5)) {
setprop("/systems/pneumatic/pack2-fault", 1);
} else {
setprop("/systems/pneumatic/pack2-fault", 0);
}
},
};
setlistener("/controls/pneumatic/switches/pack1", func {
pack1_sw = getprop("/controls/pneumatic/switches/pack1");
@ -456,13 +448,3 @@ var flashfault2 = func {
}
});
}
###################
# Update Function #
###################
var update_pneumatic = func {
master_pneu();
}
var pneu_timer = maketimer(0.2, update_pneumatic);

View file

@ -1 +1 @@
4024
4027