defineProperty("test_data_1", globalPropertyf("sim/custom/xap/test_data_1"))
defineProperty("test_data_2", globalPropertyf("sim/custom/xap/test_data_2"))
defineProperty("test_data_3", globalPropertyf("sim/custom/xap/test_data_3"))
defineProperty("test_data_4", globalPropertyf("sim/custom/xap/test_data_4"))
defineProperty("test_data_5", globalPropertyf("sim/custom/xap/test_data_5"))

defineProperty("rel_lagear1", globalPropertyi("sim/operation/failures/rel_lagear1"))
defineProperty("rel_lagear2", globalPropertyi("sim/operation/failures/rel_lagear2"))
defineProperty("rel_lagear3", globalPropertyi("sim/operation/failures/rel_lagear3"))

defineProperty("dcp_menu1_rot", globalPropertyi("sim/custom/xap/dcp_menu1_rot"))

defineProperty("eq_ped_nobrk", globalPropertyi("sim/joystick/eq_ped_nobrk"))

defineProperty("electr_ess_p_status", globalPropertyi("sim/custom/xap/electr_ess_p_status"))
defineProperty("lan_gear_warn", globalPropertyi("sim/custom/xap/lan_gear_warn"))

defineProperty("paused", globalPropertyi("sim/time/sim_speed"))

defineProperty("heading_AHARS_deg_mag_pilot", globalPropertyf("sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot"))
defineProperty("hsi_obs_deg_mag_pilot", globalPropertyf("sim/cockpit2/radios/actuators/hsi_obs_deg_mag_pilot"))
defineProperty("crc_butt", globalPropertyi("sim/custom/xap/crc_butt"))

defineProperty("rudlim_test", globalPropertyi("sim/custom/xap/rudlim_test"))
defineProperty("taws_test_aur", globalPropertyf("sim/custom/xap/taws_test_aur"))
defineProperty("fire_test_aur", globalPropertyf("sim/custom/xap/fire_test_aur"))
defineProperty("probs_test", globalPropertyi("sim/custom/xap/probs_test"))
defineProperty("ice_test", globalPropertyi("sim/custom/xap/ice_test"))
defineProperty("annun1_aur", globalPropertyf("sim/custom/xap/annun1_aur"))
defineProperty("annun2_aur", globalPropertyf("sim/custom/xap/annun2_aur"))

defineProperty("voice_rec_test", globalPropertyi("sim/custom/xap/voice_rec_test"))
defineProperty("voice_rec_test_lt", globalPropertyi("sim/custom/xap/voice_rec_test_lt"))

defineProperty("test_rot", globalPropertyi("sim/custom/xap/test_rot"))
defineProperty("test_push", globalPropertyi("sim/custom/xap/test_push"))


defineProperty("stall_warn_test", globalPropertyi("sim/custom/xap/stall_warn_test"))


defineProperty("eicas_3d_p", globalPropertyi("sim/custom/xap/eicas_3d_p"))

defineProperty("radio_altimeter_bug_ft_pilot", globalPropertyf("sim/cockpit2/gauges/actuators/radio_altimeter_bug_ft_pilot"))
defineProperty("groundspeed", globalPropertyf("sim/flightmodel/position/groundspeed"))

defineProperty("elevator_trim", globalPropertyf("sim/cockpit2/controls/elevator_trim"))


defineProperty("refspds_v1", globalPropertyi("sim/custom/xap/refspds_v1"))
defineProperty("refspds_vr", globalPropertyi("sim/custom/xap/refspds_vr"))
defineProperty("refspds_v2", globalPropertyi("sim/custom/xap/refspds_v2"))
defineProperty("refspds_vt", globalPropertyi("sim/custom/xap/refspds_vt"))
defineProperty("refspds_vga", globalPropertyi("sim/custom/xap/refspds_vga"))
defineProperty("refspds_vref", globalPropertyi("sim/custom/xap/refspds_vref"))

defineProperty("airdat1_fault", globalPropertyi("sim/custom/xap/airdat1_fault"))
defineProperty("airdat2_fault", globalPropertyi("sim/custom/xap/airdat2_fault"))



defineProperty("HSI_source_select_pilot", globalPropertyi("sim/cockpit2/radios/actuators/HSI_source_select_pilot"))
defineProperty("dcp_navsrc", globalPropertyi("sim/custom/xap/dcp_navsrc"))
defineProperty("autop_brgsrc", globalPropertyi("sim/custom/xap/autop_brgsrc"))
defineProperty("dcp_refs", globalPropertyi("sim/custom/xap/dcp_refs"))

defineProperty("EFIS_airport_on", globalPropertyi("sim/cockpit2/EFISEFIS/EFIS_airport_on"))
defineProperty("EFIS_fix_on", globalPropertyi("sim/cockpit2/EFIS/EFIS_fix_on"))
defineProperty("EFIS_vor_on", globalPropertyi("sim/cockpit2/EFIS/EFIS_vor_on"))
defineProperty("EFIS_ndb_on", globalPropertyi("sim/cockpit2/EFIS/EFIS_ndb_on"))

defineProperty("map_mode", globalPropertyi("sim/cockpit2/EFIS/map_mode"))
defineProperty("map_range", globalPropertyi("sim/cockpit2/EFIS/map_range"))
defineProperty("dcp_range", globalPropertyi("sim/custom/xap/dcp_range"))

defineProperty("ping_pong_2", globalPropertyf("sim/graphics/animation/ping_pong_2"))
defineProperty("master_warning", globalPropertyi("sim/cockpit2/annunciators/master_warning"))
defineProperty("master_caution", globalPropertyi("sim/cockpit/warnings/annunciators/master_caution"))
defineProperty("mast_caut", globalPropertyf("sim/custom/xap/mast_caut"))
defineProperty("mast_warn", globalPropertyf("sim/custom/xap/mast_warn"))
defineProperty("red_cas", globalPropertyi("sim/custom/xap/red_cas"))
defineProperty("yellow_cas", globalPropertyi("sim/custom/xap/yellow_cas"))

defineProperty("mfd_sel_state", globalPropertyi("sim/custom/xap/mfd_sel_state"))
defineProperty("mfd_sel_state_h", globalPropertyi("sim/custom/xap/mfd_sel_state_h"))

defineProperty("rev_tune", globalPropertyi("sim/custom/xap/rev_tune"))
defineProperty("com1_freq_hz", globalPropertyi("sim/cockpit/radios/com1_freq_hz"))

defineProperty("gear_handle_status", globalPropertyi("sim/cockpit/switches/gear_handle_status"))

defineProperty("audio_selection_nav1", globalPropertyi("sim/cockpit2/radios/actuators/audio_selection_nav1"))
defineProperty("audio_selection_nav2", globalPropertyi("sim/cockpit2/radios/actuators/audio_selection_nav2"))
defineProperty("audio_selection_adf1", globalPropertyi("sim/cockpit2/radios/actuators/audio_selection_adf1"))
defineProperty("audio_selection_adf2", globalPropertyi("sim/cockpit2/radios/actuators/audio_selection_adf2"))
defineProperty("audio_dme_enabled", globalPropertyi("sim/cockpit2/radios/actuators/audio_dme_enabled"))
defineProperty("audio_marker_enabled", globalPropertyi("sim/cockpit2/radios/actuators/audio_marker_enabled"))

defineProperty("aud_vol_12_l", globalPropertyi("sim/custom/xap/aud_vol_12_l"))
defineProperty("aud_vol_12_r", globalPropertyi("sim/custom/xap/aud_vol_12_r"))
defineProperty("aud_vol_15_l", globalPropertyi("sim/custom/xap/aud_vol_15_l"))
defineProperty("aud_vol_15_r", globalPropertyi("sim/custom/xap/aud_vol_15_r"))
defineProperty("aud_vol_16_l", globalPropertyi("sim/custom/xap/aud_vol_16_l"))
defineProperty("aud_vol_16_r", globalPropertyi("sim/custom/xap/aud_vol_16_r"))


defineProperty("local_time_sec", globalPropertyf("sim/cockpit2/clock_timer/local_time_seconds")) -- local time sec

defineProperty("acf_has_fuel_all", globalPropertyi("sim/aircraft/overflow/acf_has_fuel_all"))
defineProperty("acf_has_fuel_any", globalPropertyi("sim/aircraft/overflow/acf_has_fuel_any"))
defineProperty("fuel_tank_selector", globalPropertyi("sim/cockpit2/fuel/fuel_tank_selector"))
defineProperty("fuel_tank_selector_left", globalPropertyi("sim/cockpit2/fuel/fuel_tank_selector_left"))
defineProperty("fuel_tank_selector_right", globalPropertyi("sim/cockpit2/fuel/fuel_tank_selector_right"))
defineProperty("m_fuel1", globalPropertyf("sim/flightmodel/weight/m_fuel1"))
defineProperty("m_fuel2", globalPropertyf("sim/flightmodel/weight/m_fuel2"))


defineProperty("acf_lanlite_the", globalPropertyf("sim/aircraft/view/acf_lanlite_the"))

defineProperty("pressure_diffential_psi", globalPropertyf("sim/cockpit/pressure/cabin_pressure_differential_psi"))
defineProperty("pressure_ditch_h", globalPropertyf("sim/custom/xap/pressure_ditch_h"))
defineProperty("pressure_emer_depr_h", globalPropertyi("sim/custom/xap/pressure_emer_depr_h"))
defineProperty("pressure_manrate", globalPropertyf("sim/custom/xap/pressure_manrate"))
defineProperty("barometer_setting_in_hg_copilot", globalPropertyf("sim/cockpit2/gauges/actuators/barometer_setting_in_hg_copilot"))
defineProperty("altitude_ft_copilot", globalPropertyi("sim/cockpit2/gauges/indicators/altitude_ft_copilot"))
defineProperty("altitude_ft_pilot", globalPropertyi("sim/cockpit2/gauges/indicators/altitude_ft_pilot"))

defineProperty("transparent_panel", globalPropertyi("sim/graphics/settings/transparent_panel"))

defineProperty("frame_rate_period", globalPropertyf("sim/operation/misc/frame_rate_period"))

defineProperty("dump_all", globalPropertyi("sim/cockpit/pressure/dump_all"))

defineProperty("ice_all_on", globalPropertyi("sim/cockpit2/ice/ice_all_on"))
defineProperty("ice_surfce_heat_left_on", globalPropertyi("sim/cockpit2/ice/ice_surfce_heat_left_on"))
defineProperty("ice_surfce_heat_right_on", globalPropertyi("sim/cockpit2/ice/ice_surfce_heat_right_on"))
defineProperty("ice_window_heat_on", globalPropertyi("sim/cockpit2/ice/ice_window_heat_on"))
defineProperty("ice_pitot_heat_on_pilot", globalPropertyi("sim/cockpit2/ice/ice_pitot_heat_on_pilot"))
defineProperty("ice_pitot_heat_on_copilot", globalPropertyi("sim/cockpit2/ice/ice_pitot_heat_on_copilot"))
defineProperty("ice_AOA_heat_on", globalPropertyi("sim/cockpit2/ice/ice_AOA_heat_on"))
defineProperty("ice_inlet_heat_on", globalPropertyi("sim/cockpit2/ice/ice_inlet_heat_on"))
defineProperty("ice_detect_on", globalPropertyi("sim/cockpit2/ice/ice_detect_on"))

defineProperty("machno", globalPropertyf("sim/flightmodel/misc/machno"))
defineProperty("jet_sync_mode", globalPropertyi("sim/cockpit2/switches/jet_sync_mode"))

defineProperty("altitude_hold_status", globalPropertyi("sim/cockpit2/autopilot/altitude_hold_status"))

defineProperty("autop_vvi_dial", globalPropertyi("sim/custom/xap/autop_vvi_dial"))
defineProperty("autop_crs_dial", globalPropertyi("sim/custom/xap/autop_crs_dial"))
defineProperty("autop_hdg_dial", globalPropertyi("sim/custom/xap/autop_hdg_dial"))
defineProperty("autop_spd_dial", globalPropertyi("sim/custom/xap/autop_spd_dial"))
defineProperty("autop_alt_dial", globalPropertyi("sim/custom/xap/autop_alt_dial"))

defineProperty("autopilot_mode", globalPropertyi("sim/cockpit/autopilot/autopilot_mode"))


defineProperty("timer_running", globalPropertyi("sim/cockpit2/clock_timer/timer_running"))
defineProperty("clock_timer_h", globalPropertyi("sim/custom/xap/clock_timer_h"))

defineProperty("yaw_damper_on", globalPropertyi("sim/cockpit2/switches/yaw_damper_on"))

defineProperty("autop_yd_h", globalPropertyi("sim/custom/xap/autop_yd_h"))
defineProperty("autop_xfr_h", globalPropertyi("sim/custom/xap/autop_xfr_h"))
defineProperty("autop_ap_h", globalPropertyi("sim/custom/xap/autop_ap_h"))
defineProperty("autop_alt_h", globalPropertyi("sim/custom/xap/autop_alt_h"))
defineProperty("autop_vnav_h", globalPropertyi("sim/custom/xap/autop_vnav_h"))
defineProperty("autop_vs_h", globalPropertyi("sim/custom/xap/autop_vs_h"))
defineProperty("autop_flc_h", globalPropertyi("sim/custom/xap/autop_flc_h"))
defineProperty("autop_bc_h", globalPropertyi("sim/custom/xap/autop_bc_h"))
defineProperty("autop_appr_h", globalPropertyi("sim/custom/xap/autop_appr_h"))
defineProperty("autop_hdg_h", globalPropertyi("sim/custom/xap/autop_hdg_h"))
defineProperty("autop_nav_h", globalPropertyi("sim/custom/xap/autop_nav_h"))
defineProperty("autop_fdir_h", globalPropertyi("sim/custom/xap/autop_fdir_h"))
defineProperty("half_bank_h", globalPropertyi("sim/custom/xap/half_bank_h"))
defineProperty("bank_angle_mode", globalPropertyi("sim/cockpit2/autopilot/bank_angle_mode"))
defineProperty("servos_on", globalPropertyi("sim/cockpit2/autopilot/servos_on"))

defineProperty("warn_bb", globalPropertyi("sim/operation/prefs/warn_bb"))


defineProperty("rudd_ped_l_sw", globalPropertyi("sim/custom/xap/rudd_ped_l_sw"))
defineProperty("pedals_fwd_bwd_l", globalPropertyf("sim/custom/xap/pedals_fwd_bwd_l"))
defineProperty("rudd_ped_r_sw", globalPropertyi("sim/custom/xap/rudd_ped_r_sw"))
defineProperty("pedals_fwd_bwd_r", globalPropertyf("sim/custom/xap/pedals_fwd_bwd_r"))


defineProperty("heading_AHARS_deg_mag_pilot", globalPropertyf("sim/cockpit2/gauges/indicators/heading_AHARS_deg_mag_pilot"))
defineProperty("heading_dial_deg_mag_pilot", globalPropertyf("sim/cockpit2/autopilot/heading_dial_deg_mag_pilot"))
defineProperty("fgp_s_hdg", globalPropertyi("sim/custom/xap/fgp_s_hdg"))

defineProperty("s_master_gain", globalPropertyi("sim/custom/xap/s_master_gain"))

defineProperty("aud_voice_l_sw", globalPropertyi("sim/custom/xap/aud_voice_l_sw"))
defineProperty("aud_pa_r_h", globalPropertyi("sim/custom/xap/aud_pa_r_h"))
defineProperty("aud_pa_r", globalPropertyf("sim/custom/xap/aud_pa_r"))
defineProperty("aud_cab_r_h", globalPropertyi("sim/custom/xap/aud_cab_r_h"))
defineProperty("aud_cab_r", globalPropertyf("sim/custom/xap/aud_cab_r"))
defineProperty("aud_hf2_r_h", globalPropertyi("sim/custom/xap/aud_hf2_r_h"))
defineProperty("aud_hf2_r", globalPropertyf("sim/custom/xap/aud_hf2_r"))
defineProperty("aud_hf1_r_h", globalPropertyi("sim/custom/xap/aud_hf1_r_h"))
defineProperty("aud_hf1_r", globalPropertyf("sim/custom/xap/aud_hf1_r"))
defineProperty("aud_com3_r_h", globalPropertyi("sim/custom/xap/aud_com3_r_h"))
defineProperty("aud_com3_r", globalPropertyf("sim/custom/xap/aud_com3_r"))
defineProperty("aud_com2_r_h", globalPropertyi("sim/custom/xap/aud_com2_r_h"))
defineProperty("aud_com2_r", globalPropertyf("sim/custom/xap/aud_com2_r"))
defineProperty("aud_com1_r_h", globalPropertyi("sim/custom/xap/aud_com1_r_h"))
defineProperty("aud_com1_r", globalPropertyf("sim/custom/xap/aud_com1_r"))

defineProperty("audio_com_selection", globalPropertyi("sim/cockpit2/radios/actuators/audio_com_selection"))


defineProperty("aud_pa_l_h", globalPropertyi("sim/custom/xap/aud_pa_l_h"))
defineProperty("aud_pa_l", globalPropertyf("sim/custom/xap/aud_pa_l"))
defineProperty("aud_cab_l_h", globalPropertyi("sim/custom/xap/aud_cab_l_h"))
defineProperty("aud_cab_l", globalPropertyf("sim/custom/xap/aud_cab_l"))
defineProperty("aud_hf2_l_h", globalPropertyi("sim/custom/xap/aud_hf2_l_h"))
defineProperty("aud_hf2_l", globalPropertyf("sim/custom/xap/aud_hf2_l"))
defineProperty("aud_hf1_l_h", globalPropertyi("sim/custom/xap/aud_hf1_l_h"))
defineProperty("aud_hf1_l", globalPropertyf("sim/custom/xap/aud_hf1_l"))
defineProperty("aud_com3_l_h", globalPropertyi("sim/custom/xap/aud_com3_l_h"))
defineProperty("aud_com3_l", globalPropertyf("sim/custom/xap/aud_com3_l"))
defineProperty("aud_com2_l_h", globalPropertyi("sim/custom/xap/aud_com2_l_h"))
defineProperty("aud_com2_l", globalPropertyf("sim/custom/xap/aud_com2_l"))
defineProperty("aud_com1_l_h", globalPropertyi("sim/custom/xap/aud_com1_l_h"))
defineProperty("aud_com1_l", globalPropertyf("sim/custom/xap/aud_com1_l"))



defineProperty("comps_head_l_h", globalPropertyi("sim/custom/xap/comps_head_l_h"))
defineProperty("comps_head_l", globalPropertyf("sim/custom/xap/comps_head_l"))
defineProperty("comps_head_r_h", globalPropertyi("sim/custom/xap/comps_head_r_h"))
defineProperty("comps_head_r", globalPropertyf("sim/custom/xap/comps_head_r"))

defineProperty("elt_h", globalPropertyi("sim/custom/xap/elt_h"))
defineProperty("elt", globalPropertyf("sim/custom/xap/elt"))

defineProperty("dcu_b_h", globalPropertyi("sim/custom/xap/dcu_b_h"))
defineProperty("dcu_b", globalPropertyf("sim/custom/xap/dcu_b"))
defineProperty("dcu_a_h", globalPropertyi("sim/custom/xap/dcu_a_h"))
defineProperty("dcu_a", globalPropertyf("sim/custom/xap/dcu_a"))

defineProperty("cab_ac_h", globalPropertyi("sim/custom/xap/cab_ac_h"))
defineProperty("cab_ac", globalPropertyf("sim/custom/xap/cab_ac"))
defineProperty("cab_dc_h", globalPropertyi("sim/custom/xap/cab_dc_h"))
defineProperty("cab_dc", globalPropertyf("sim/custom/xap/cab_dc"))

defineProperty("oxigen_terap_h", globalPropertyi("sim/custom/xap/oxigen_terap_h"))
defineProperty("oxigen_terap", globalPropertyf("sim/custom/xap/oxigen_terap"))

defineProperty("fire_engn_r_h", globalPropertyi("sim/custom/xap/fire_engn_r_h"))
defineProperty("fire_engn_r", globalPropertyf("sim/custom/xap/fire_engn_r"))
defineProperty("fire_engn_l_h", globalPropertyi("sim/custom/xap/fire_engn_l_h"))
defineProperty("fire_engn_l", globalPropertyf("sim/custom/xap/fire_engn_l"))
defineProperty("fire_apu_h", globalPropertyi("sim/custom/xap/fire_apu_h"))
defineProperty("fire_apu", globalPropertyf("sim/custom/xap/fire_apu"))
defineProperty("fire_ext_2_h", globalPropertyi("sim/custom/xap/fire_ext_2_h"))
defineProperty("fire_ext_2", globalPropertyf("sim/custom/xap/fire_ext_2"))
defineProperty("fire_ext_1_h", globalPropertyi("sim/custom/xap/fire_ext_1_h"))
defineProperty("fire_ext_1", globalPropertyf("sim/custom/xap/fire_ext_1"))
defineProperty("fire_autoapr_h", globalPropertyi("sim/custom/xap/fire_autoapr_h"))
defineProperty("fire_autoapr", globalPropertyf("sim/custom/xap/fire_autoapr"))
defineProperty("fire_extinguisher_on_l", globalPropertyi("sim/cockpit2/engine/actuators/fire_extinguisher_on[0]"))
defineProperty("fire_extinguisher_on_r", globalPropertyi("sim/cockpit2/engine/actuators/fire_extinguisher_on[1]"))



defineProperty("trim_pusher_h", globalPropertyi("sim/custom/xap/trim_pusher_h"))
defineProperty("trim_pusher", globalPropertyf("sim/custom/xap/trim_pusher"))

defineProperty("hydr_altn_flp_h", globalPropertyi("sim/custom/xap/hydr_altn_flp_h"))
defineProperty("hydr_altn_flp", globalPropertyf("sim/custom/xap/hydr_altn_flp"))
defineProperty("hydr_l_sov_h", globalPropertyi("sim/custom/xap/hydr_l_sov_h"))
defineProperty("hydr_l_sov", globalPropertyf("sim/custom/xap/hydr_l_sov"))
defineProperty("hydr_r_sov_h", globalPropertyi("sim/custom/xap/hydr_r_sov_h"))
defineProperty("hydr_r_sov", globalPropertyf("sim/custom/xap/hydr_r_sov"))


defineProperty("gpu_on", globalPropertyi("sim/cockpit/electrical/gpu_on"))
defineProperty("APU_generator_on", globalPropertyi("sim/cockpit2/electrical/APU_generator_on"))
defineProperty("APU_running", globalPropertyi("sim/cockpit2/electrical/APU_running"))
defineProperty("generator_on_l", globalPropertyi("sim/cockpit2/electrical/generator_on[0]"))
defineProperty("generator_on_r", globalPropertyi("sim/cockpit2/electrical/generator_on[1]"))




defineProperty("electr_apugen_h", globalPropertyi("sim/custom/xap/electr_apugen_h"))
defineProperty("electr_apugen", globalPropertyf("sim/custom/xap/electr_apugen"))
defineProperty("electr_gen_r_h", globalPropertyi("sim/custom/xap/electr_gen_r_h"))
defineProperty("electr_gen_r", globalPropertyf("sim/custom/xap/electr_gen_r"))
defineProperty("electr_gen_l_h", globalPropertyi("sim/custom/xap/electr_gen_l_h"))
defineProperty("electr_gen_l", globalPropertyf("sim/custom/xap/electr_gen_l"))
defineProperty("electr_stbi_h", globalPropertyi("sim/custom/xap/electr_stbi_h"))
defineProperty("electr_stbi", globalPropertyf("sim/custom/xap/electr_stbi"))
defineProperty("electr_extp_h", globalPropertyi("sim/custom/xap/electr_extp_h"))
defineProperty("electr_extp", globalPropertyf("sim/custom/xap/electr_extp"))
defineProperty("electr_extp_avail", globalPropertyf("sim/custom/xap/electr_extp_avail"))

defineProperty("antice_wngsource_r", globalPropertyi("sim/custom/xap/antice_wngsource_r"))
defineProperty("antice_wshld_r_h", globalPropertyi("sim/custom/xap/antice_wshld_r_h"))
defineProperty("antice_wshld_r", globalPropertyf("sim/custom/xap/antice_wshld_r"))
defineProperty("antice_wshld_l_h", globalPropertyi("sim/custom/xap/antice_wshld_l_h"))
defineProperty("antice_wshld_l", globalPropertyf("sim/custom/xap/antice_wshld_l"))
defineProperty("antice_engn_r_h", globalPropertyi("sim/custom/xap/antice_engn_r_h"))
defineProperty("antice_engn_r", globalPropertyf("sim/custom/xap/antice_engn_r"))
defineProperty("antice_engn_l_h", globalPropertyi("sim/custom/xap/antice_engn_l_h"))
defineProperty("antice_engn_l", globalPropertyf("sim/custom/xap/antice_engn_l"))
defineProperty("antice_probe_r_h", globalPropertyi("sim/custom/xap/antice_probe_r_h"))
defineProperty("antice_probe_r", globalPropertyf("sim/custom/xap/antice_probe_r"))
defineProperty("antice_probe_l_h", globalPropertyi("sim/custom/xap/antice_probe_l_h"))
defineProperty("antice_probe_l", globalPropertyf("sim/custom/xap/antice_probe_l"))
defineProperty("antice_wing_h", globalPropertyi("sim/custom/xap/antice_wing_h"))
defineProperty("antice_wing", globalPropertyf("sim/custom/xap/antice_wing"))



defineProperty("acf_hstb_trim_dn", globalPropertyi("sim/aircraft/controls/acf_hstb_trim_dn"))
defineProperty("acf_hstb_trim_up", globalPropertyi("sim/aircraft/controls/acf_hstb_trim_up"))
defineProperty("trim_stab", globalPropertyi("sim/custom/xap/trim_stab"))


defineProperty("cabin_vvi_fpm", globalPropertyf("sim/cockpit2/pressurization/actuators/cabin_vvi_fpm"))
defineProperty("cabin_altitude_ft", globalPropertyf("sim/cockpit2/pressurization/actuators/cabin_altitude_ft"))
defineProperty("pressure_man_h", globalPropertyi("sim/custom/xap/pressure_man_h"))
defineProperty("pressure_man", globalPropertyf("sim/custom/xap/pressure_man"))
defineProperty("pressure_ditch_h", globalPropertyi("sim/custom/xap/pressure_ditch_h"))
defineProperty("pressure_ditch", globalPropertyf("sim/custom/xap/pressure_ditch"))
defineProperty("pressure_emer_depr_h", globalPropertyi("sim/custom/xap/pressure_emer_depr_h"))
defineProperty("pressure_emer_depr", globalPropertyf("sim/custom/xap/pressure_emer_depr"))


defineProperty("aircond_tempr_cock_ddial", globalPropertyf("sim/custom/xap/aircond_tempr_cock_ddial"))
defineProperty("aircond_tempr_cab_ddial", globalPropertyf("sim/custom/xap/aircond_tempr_cab_ddial"))
defineProperty("aircond_cockpit_temp", globalPropertyf("sim/custom/xap/aircond_cockpit_temp"))
defineProperty("aircond_cabin_temp", globalPropertyf("sim/custom/xap/aircond_cabin_temp"))
defineProperty("aircond_man_temp_h", globalPropertyi("sim/custom/xap/aircond_man_temp_h"))
defineProperty("aircond_man_temp", globalPropertyf("sim/custom/xap/aircond_man_temp"))
defineProperty("aircond_ramair_h", globalPropertyi("sim/custom/xap/aircond_ramair_h"))
defineProperty("aircond_ramair", globalPropertyf("sim/custom/xap/aircond_ramair"))

defineProperty("taws_ter", globalPropertyf("sim/custom/xap/taws_ter"))
defineProperty("taws_flp", globalPropertyf("sim/custom/xap/taws_flp"))
defineProperty("taws_gs", globalPropertyf("sim/custom/xap/taws_gs"))
defineProperty("taws_ter_h", globalPropertyi("sim/custom/xap/taws_ter_h"))
defineProperty("taws_flp_h", globalPropertyi("sim/custom/xap/taws_flp_h"))
defineProperty("taws_gs_h", globalPropertyi("sim/custom/xap/taws_gs_h"))

defineProperty("nws_h", globalPropertyi("sim/custom/xap/nws_h"))
defineProperty("nws", globalPropertyf("sim/custom/xap/nws"))

defineProperty("fuel_xflow_up_h", globalPropertyi("sim/custom/xap/fuel_xflow_up_h"))
defineProperty("fuel_xflow_dn_h", globalPropertyi("sim/custom/xap/fuel_xflow_dn_h"))
defineProperty("fuel_xflow_up", globalPropertyf("sim/custom/xap/fuel_xflow_up"))
defineProperty("fuel_xflow_dn", globalPropertyf("sim/custom/xap/fuel_xflow_dn"))
defineProperty("fuel_xpump_r", globalPropertyi("sim/custom/xap/fuel_xpump_r"))
defineProperty("fuel_xpump_l", globalPropertyi("sim/custom/xap/fuel_xpump_l"))
defineProperty("fuel_tank_transfer_from", globalPropertyi("sim/cockpit2/fuel/fuel_tank_transfer_from"))
defineProperty("fuel_tank_transfer_to", globalPropertyi("sim/cockpit2/fuel/fuel_tank_transfer_to"))
defineProperty("fuel_balanced", globalPropertyi("sim/custom/xap/fuel_balanced"))
defineProperty("fuel_imbalanced", globalPropertyi("sim/custom/xap/fuel_imbalanced"))


defineProperty("rev_air_dat", globalPropertyi("sim/custom/xap/rev_air_dat"))
defineProperty("rev_att_hd", globalPropertyi("sim/custom/xap/rev_att_hd"))
defineProperty("rev_tune", globalPropertyi("sim/custom/xap/rev_tune"))
defineProperty("rev_pan_l", globalPropertyi("sim/custom/xap/rev_pan_l"))
defineProperty("rev_pan_r", globalPropertyi("sim/custom/xap/rev_pan_r"))






defineProperty("bleed_air_mode", globalPropertyi("sim/cockpit2/pressurization/actuators/bleed_air_mode"))
defineProperty("bleed_xbleed_h", globalPropertyi("sim/custom/xap/bleed_xbleed_h"))
defineProperty("bleed_xbleed", globalPropertyf("sim/custom/xap/bleed_xbleed"))
defineProperty("bleed_en_l_h", globalPropertyi("sim/custom/xap/bleed_en_l_h"))
defineProperty("bleed_en_l", globalPropertyf("sim/custom/xap/bleed_en_l"))
defineProperty("bleed_en_r_h", globalPropertyi("sim/custom/xap/bleed_en_r_h"))
defineProperty("bleed_en_r", globalPropertyf("sim/custom/xap/bleed_en_r"))
defineProperty("bleed_apu_h", globalPropertyi("sim/custom/xap/bleed_apu_h"))
defineProperty("bleed_apu", globalPropertyf("sim/custom/xap/bleed_apu"))

defineProperty("altitude_dial_ft", globalPropertyf("sim/cockpit2/autopilot/altitude_dial_ft"))


defineProperty("acf_face_jet", globalPropertyf("sim/aircraft/engine/acf_face_jet"))
defineProperty("ENGN_FF_l", globalPropertyf("sim/flightmodel/engine/ENGN_FF_[0]"))
defineProperty("ENGN_FF_r", globalPropertyf("sim/flightmodel/engine/ENGN_FF_[1]"))
defineProperty("fuel_pump_on_0", globalPropertyi("sim/cockpit2/engine/actuators/fuel_pump_on[0]"))
defineProperty("fuel_pump_on_1", globalPropertyi("sim/cockpit2/engine/actuators/fuel_pump_on[1]"))

defineProperty("ENGN_running_l", globalPropertyi("sim/flightmodel/engine/ENGN_running[0]"))
defineProperty("ENGN_running_r", globalPropertyi("sim/flightmodel/engine/ENGN_running[1]"))
defineProperty("engn_mach_status", globalPropertyi("sim/custom/xap/engn_mach_status"))
defineProperty("engn_mach_h", globalPropertyi("sim/custom/xap/engn_mach_h"))
defineProperty("engn_mach", globalPropertyf("sim/custom/xap/engn_mach"))
defineProperty("engn_ign_h", globalPropertyi("sim/custom/xap/engn_ign_h"))
defineProperty("engn_ign", globalPropertyf("sim/custom/xap/engn_ign"))
defineProperty("igniter_on_0", globalPropertyi("sim/cockpit2/engine/actuators/igniter_on[0]"))
defineProperty("igniter_on_1", globalPropertyi("sim/cockpit2/engine/actuators/igniter_on[1]"))
defineProperty("en_starter_l", globalPropertyi("sim/custom/xap/en_starter_l"))
defineProperty("en_starter_r", globalPropertyi("sim/custom/xap/en_starter_r"))
defineProperty("en_but_run_l", globalPropertyi("sim/custom/xap/en_but_run_l"))
defineProperty("en_but_run_r", globalPropertyi("sim/custom/xap/en_but_run_r"))

defineProperty("autop_airspeed_dial", globalPropertyf("sim/cockpit2/autopilot/airspeed_dial_kts_mach"))
defineProperty("airspeed_is_mach", globalPropertyf("sim/cockpit/autopilot/airspeed_is_mach"))

defineProperty("thrust_reverser_deploy_ratio_0", globalPropertyf("sim/flightmodel2/engines/thrust_reverser_deploy_ratio[0]"))
defineProperty("thrust_reverser_deploy_ratio_1", globalPropertyf("sim/flightmodel2/engines/thrust_reverser_deploy_ratio[1]"))



defineProperty("carets", globalPropertyi("sim/custom/xap/carets"))
defineProperty("CLB_n1", globalPropertyf("sim/custom/xap/CLB_n1"))
defineProperty("TO_n1", globalPropertyf("sim/custom/xap/TO_n1"))






defineProperty("ISA_t", globalPropertyf("sim/custom/xap/ISA_t"))
defineProperty("POINT_thrust_0", globalPropertyf("sim/flightmodel/engine/POINT_thrust[0]"))
defineProperty("POINT_thrust_1", globalPropertyf("sim/flightmodel/engine/POINT_thrust[1]"))
defineProperty("acf_tmax", globalPropertyf("sim/aircraft/engine/acf_tmax"))
defineProperty("fadec_coeff1", globalPropertyf("sim/custom/xap/fadec_coeff1"))
defineProperty("fadec_coeff2", globalPropertyf("sim/custom/xap/fadec_coeff2"))

defineProperty("onground_any", globalPropertyf("sim/flightmodel/failures/onground_any"))
defineProperty("onground_all", globalPropertyf("sim/flightmodel/failures/onground_all"))
defineProperty("radio_altimeter_height_ft_pilot", globalPropertyf("sim/cockpit2/gauges/indicators/radio_altimeter_height_ft_pilot"))

defineProperty("flaprat0", globalPropertyf("sim/flightmodel2/wing/flap1_deg[0]"))
defineProperty("flaprat1", globalPropertyf("sim/flightmodel2/wing/flap1_deg[1]"))
defineProperty("flaprat", globalPropertyf("sim/flightmodel/controls/flaprat"))
defineProperty("flaprqst", globalPropertyf("sim/flightmodel/controls/flaprqst"))

defineProperty("acf_sbrk_up", globalPropertyi("sim/aircraft/controls/acf_sbrk_up"))
defineProperty("acf_splr_up", globalPropertyi("sim/aircraft/controls/acf_splr_up"))
defineProperty("ground_sp_h", globalPropertyi("sim/custom/xap/ground_sp_h"))
defineProperty("sbrk_h", globalPropertyf("sim/custom/xap/sbrk_h"))
defineProperty("speedbrake_ratio", globalPropertyf("sim/cockpit2/controls/speedbrake_ratio"))
defineProperty("sbrkrat", globalPropertyf("sim/flightmodel/controls/sbrkrat"))
defineProperty("sbrkrqst", globalPropertyf("sim/flightmodel/controls/sbrkrqst"))
defineProperty("speedbrake1_deg0", globalPropertyf("sim/flightmodel2/wing/speedbrake1_deg[0]"))
defineProperty("speedbrake1_deg1", globalPropertyf("sim/flightmodel2/wing/speedbrake1_deg[1]"))
defineProperty("speedbrake2_deg0", globalPropertyf("sim/flightmodel2/wing/speedbrake2_deg[0]"))
defineProperty("speedbrake2_deg1", globalPropertyf("sim/flightmodel2/wing/speedbrake2_deg[1]"))


defineProperty("rel_fc_rud_L", globalPropertyf("sim/operation/failures/rel_fc_rud_L"))
defineProperty("rel_fc_rud_R", globalPropertyf("sim/operation/failures/rel_fc_rud_R"))
defineProperty("wing1r_spo2def", globalPropertyf("sim/flightmodel/controls/wing1r_spo2def"))
defineProperty("wing1l_spo2def", globalPropertyf("sim/flightmodel/controls/wing1l_spo2def"))
defineProperty("wing1r_spo1def", globalPropertyf("sim/flightmodel/controls/wing1r_spo1def"))
defineProperty("wing1l_spo1def", globalPropertyf("sim/flightmodel/controls/wing1l_spo1def"))
defineProperty("ground_spoil_h", globalPropertyi("sim/custom/xap/ground_spoil_h"))
defineProperty("flight_spoil_h", globalPropertyi("sim/custom/xap/flight_spoil_h"))
defineProperty("flight_spoil", globalPropertyf("sim/custom/xap/flight_spoil"))
defineProperty("rel_fc_ail_L", globalPropertyi("sim/operation/failures/rel_fc_ail_L"))
defineProperty("rel_fc_ail_R", globalPropertyi("sim/operation/failures/rel_fc_ail_R"))



defineProperty("barometer_current_inhg", globalPropertyf("sim/weather/barometer_current_inhg"))
defineProperty("temperature_ambient_c", globalPropertyf("sim/weather/temperature_ambient_c"))

defineProperty("rembf1", globalPropertyi("sim/custom/xap/rembf1"))
defineProperty("rembf2", globalPropertyi("sim/custom/xap/rembf2"))

defineProperty("rembf4", globalPropertyi("sim/custom/xap/rembf4"))
defineProperty("rembf5", globalPropertyi("sim/custom/xap/rembf5"))

defineProperty("rembf6", globalPropertyi("sim/custom/xap/rembf6"))
defineProperty("rembf7", globalPropertyi("sim/custom/xap/rembf7"))
defineProperty("rembf8", globalPropertyi("sim/custom/xap/rembf8"))

defineProperty("rembf11", globalPropertyi("sim/custom/xap/rembf11"))
defineProperty("rembf12", globalPropertyi("sim/custom/xap/rembf12"))

defineProperty("rembf13", globalPropertyi("sim/custom/xap/rembf13"))
defineProperty("rembf14", globalPropertyi("sim/custom/xap/rembf14"))

defineProperty("rel_AOA", globalPropertyf("sim/operation/failures/rel_AOA"))
defineProperty("rel_ice_detect", globalPropertyf("sim/operation/failures/rel_ice_detect"))
defineProperty("rel_pitot", globalPropertyf("sim/operation/failures/rel_pitot"))
defineProperty("rel_pitot2", globalPropertyf("sim/operation/failures/rel_pitot2"))
defineProperty("rel_engfai0", globalPropertyf("sim/operation/failures/rel_engfai0"))
defineProperty("rel_engfai1", globalPropertyf("sim/operation/failures/rel_engfai1"))

defineProperty("steer_handle", globalPropertyf("sim/custom/xap/steer_handle"))
defineProperty("rembf10", globalPropertyi("sim/custom/xap/rembf10"))

--controls overrides

defineProperty("dtr_s_l", globalPropertyi("sim/custom/xap/s_l"))
defineProperty("dtr_s_r", globalPropertyi("sim/custom/xap/s_r"))

defineProperty("ENGN_mixt_0", globalPropertyi("sim/flightmodel/engine/ENGN_mixt[0]"))
defineProperty("ENGN_mixt_1", globalPropertyi("sim/flightmodel/engine/ENGN_mixt[1]"))
defineProperty("ENGN_N1_L", globalPropertyf("sim/flightmodel/engine/ENGN_N1_[0]"))
defineProperty("ENGN_N1_R", globalPropertyf("sim/flightmodel/engine/ENGN_N1_[1]"))
defineProperty("ENGN_thro_0", globalPropertyf("sim/flightmodel/engine/ENGN_thro[0]"))
defineProperty("ENGN_thro_1", globalPropertyf("sim/flightmodel/engine/ENGN_thro[1]"))
defineProperty("ENGN_thro_use_0", globalPropertyf("sim/flightmodel/engine/ENGN_thro_use[0]"))
defineProperty("ENGN_thro_use_1", globalPropertyf("sim/flightmodel/engine/ENGN_thro_use[1]"))
defineProperty("override_throttles", globalPropertyi("sim/operation/override/override_throttles"))
defineProperty("override_cs", globalPropertyf("sim/operation/override/override_control_surfaces"))
defineProperty("override_fc", globalPropertyf("sim/operation/override/override_flightcontrol"))
defineProperty("override_gearbrake", globalPropertyf("sim/operation/override/override_gearbrake"))

defineProperty("parkbrake", globalPropertyf("sim/flightmodel/controls/parkbrake"))

defineProperty("hydr_pres_1", globalPropertyf("sim/cockpit2/hydraulics/indicators/hydraulic_pressure_1"))
defineProperty("hydr_pres_2", globalPropertyf("sim/cockpit2/hydraulics/indicators/hydraulic_pressure_2"))



defineProperty("acf_elev_dn", globalPropertyf("sim/aircraft/controls/acf_elev_dn"))
defineProperty("acf_elev_up", globalPropertyf("sim/aircraft/controls/acf_elev_up"))
defineProperty("hstab1_elv1def", globalPropertyf("sim/flightmodel/controls/hstab1_elv1def"))
defineProperty("hstab2_elv1def", globalPropertyf("sim/flightmodel/controls/hstab2_elv1def"))
defineProperty("elevator1_deg0", globalPropertyf("sim/flightmodel2/wing/elevator1_deg[0]"))



defineProperty("wing1l_ail1def", globalPropertyf("sim/flightmodel/controls/wing1l_ail1def"))
defineProperty("wing1r_ail1def", globalPropertyf("sim/flightmodel/controls/wing1r_ail1def"))
defineProperty("wing1l_elv1def", globalPropertyf("sim/flightmodel/controls/wing1l_elv1def"))
defineProperty("wing1r_elv1def", globalPropertyf("sim/flightmodel/controls/wing1r_elv1def"))
defineProperty("ldruddef", globalPropertyf("sim/flightmodel/controls/ldruddef"))
defineProperty("rdruddef", globalPropertyf("sim/flightmodel/controls/rdruddef"))
defineProperty("yoke_pitch_ratio", globalPropertyf("sim/cockpit2/controls/yoke_pitch_ratio"))
defineProperty("yoke_roll_ratio", globalPropertyf("sim/cockpit2/controls/yoke_roll_ratio"))
defineProperty("yoke_heading_ratio", globalPropertyf("sim/cockpit2/controls/yoke_heading_ratio"))
defineProperty("nosewheel_steer_on", globalPropertyf("sim/cockpit2/controls/nosewheel_steer_on"))

defineProperty("acf_nw_steerdeg1", globalPropertyf("sim/aircraft/gear/acf_nw_steerdeg1"))
defineProperty("acf_nw_steerdeg2", globalPropertyf("sim/aircraft/gear/acf_nw_steerdeg2"))

defineProperty("l_brake_add", globalPropertyf("sim/flightmodel/controls/l_brake_add"))
defineProperty("r_brake_add", globalPropertyf("sim/flightmodel/controls/r_brake_add"))




defineProperty("cloud_base_1", globalPropertyf("sim/weather/cloud_base_msl_m[0]"))
defineProperty("cloud_tops_1", globalPropertyf("sim/weather/cloud_tops_msl_m[0]"))

--Hydraulic
defineProperty("aux_hpump_h", globalPropertyi("sim/custom/xap/aux_hpump_h"))
defineProperty("l_hpump_h", globalPropertyi("sim/custom/xap/l_hpump_h"))
defineProperty("r_hpump_h", globalPropertyi("sim/custom/xap/r_hpump_h"))
defineProperty("ptu_h", globalPropertyi("sim/custom/xap/ptu_h"))
--

--Throttle



defineProperty("ENGN_N1_L", globalPropertyf("sim/flightmodel/engine/ENGN_N1_[0]"))
defineProperty("ENGN_N1_R", globalPropertyf("sim/flightmodel/engine/ENGN_N1_[1]"))

defineProperty("throttle_ratio_all", globalPropertyf("sim/cockpit2/engine/actuators/throttle_ratio_all"))
defineProperty("gust_lock", globalPropertyf("sim/custom/xap/gust_lock"))
defineProperty("gust_lock_anm", globalPropertyf("sim/custom/xap/gust_lock_anm"))

defineProperty("thr_anm1", globalPropertyf("sim/custom/xap/thr_anm1"))
defineProperty("thr_anm2", globalPropertyf("sim/custom/xap/thr_anm2"))

defineProperty("sim_thr_anm1", globalPropertyf("sim/cockpit2/engine/actuators/throttle_ratio[0]"))
defineProperty("sim_thr_anm2", globalPropertyf("sim/cockpit2/engine/actuators/throttle_ratio[1]"))


defineProperty("prop_mode_0", globalPropertyi("sim/cockpit2/engine/actuators/prop_mode[0]"))
defineProperty("prop_mode_1", globalPropertyi("sim/cockpit2/engine/actuators/prop_mode[1]"))
defineProperty("reverser_on_1", globalPropertyi("sim/cockpit2/annunciators/reverser_on[0]"))
defineProperty("reverser_on_2", globalPropertyi("sim/cockpit2/annunciators/reverser_on[1]"))


---


defineProperty("menu_type", globalPropertyi("sim/custom/xap/menu_type"))

defineProperty("rain_back", globalPropertyf("sim/custom/xap/rain_back"))
defineProperty("rain_scr1", globalPropertyf("sim/custom/xap/rain_scr1"))
defineProperty("rain_scr2", globalPropertyf("sim/custom/xap/rain_scr2"))
defineProperty("rain_scr3", globalPropertyf("sim/custom/xap/rain_scr3"))
defineProperty("rain_scr4", globalPropertyf("sim/custom/xap/rain_scr4"))
defineProperty("rain_drop1", globalPropertyf("sim/custom/xap/rain_drop1"))
defineProperty("rain_move1", globalPropertyf("sim/custom/xap/rain_move1"))
defineProperty("rain_move2", globalPropertyf("sim/custom/xap/rain_move2"))
defineProperty("rain_percent", globalPropertyf("sim/weather/rain_percent"))
defineProperty("airport_beacon_rot", globalPropertyf("sim/graphics/animation/airport_beacon_rotation"))

defineProperty("disp", globalPropertyf("sim/custom/xap/disp"))
defineProperty("disp2", globalPropertyf("sim/custom/xap/disp2"))
defineProperty("disp3", globalPropertyf("sim/custom/xap/disp3"))

defineProperty("ind_speed", globalPropertyf("sim/flightmodel/position/indicated_airspeed"))
defineProperty("ground_speed", globalPropertyf("sim/flightmodel/position/groundspeed"))

defineProperty("acf_hdg", globalPropertyf("sim/flightmodel/position/psi"))

defineProperty("customslider4", globalPropertyi("sim/custom/xap/customslider4"))
defineProperty("customslider4_r", globalPropertyf("sim/custom/xap/customslider4_r"))
defineProperty("customslider3", globalPropertyi("sim/custom/xap/customslider3"))
defineProperty("customslider3_r", globalPropertyf("sim/custom/xap/customslider3_r"))
defineProperty("customslider2", globalPropertyi("sim/custom/xap/customslider2"))
defineProperty("customslider2_r", globalPropertyf("sim/custom/xap/customslider2_r"))
defineProperty("customslider1", globalPropertyi("sim/custom/xap/customslider1"))
defineProperty("customslider1_r", globalPropertyf("sim/custom/xap/customslider1_r"))
defineProperty("totaltime", globalPropertyf("sim/time/total_running_time_sec"))
defineProperty("rel_depres_fast", globalPropertyi("sim/operation/failures/rel_depres_fast"))



-- electrical
defineProperty("right_bat_h", globalPropertyi("sim/custom/xap/right_bat_h"))
defineProperty("right_bat", globalPropertyf("sim/custom/xap/right_bat"))
defineProperty("left_bat_h", globalPropertyi("sim/custom/xap/left_bat_h"))
defineProperty("left_bat", globalPropertyf("sim/custom/xap/left_bat"))
defineProperty("bus_tie_h", globalPropertyf("sim/custom/xap/bus_tie_h"))
defineProperty("bus_tie", globalPropertyf("sim/custom/xap/bus_tie"))
defineProperty("cross_tie", globalPropertyf("sim/cockpit2/electrical/cross_tie"))

defineProperty("elbus1", globalPropertyf("sim/cockpit2/electrical/bus_volts[0]"))
defineProperty("elbus2", globalPropertyf("sim/cockpit2/electrical/bus_volts[1]"))
defineProperty("elbus3", globalPropertyf("sim/cockpit2/electrical/bus_volts[2]"))


defineProperty("bat_on", globalPropertyi("sim/cockpit2/electrical/battery_on[0]"))
defineProperty("bat_on2", globalPropertyi("sim/cockpit2/electrical/battery_on[1]"))
defineProperty("bat_on3", globalPropertyi("sim/cockpit2/electrical/battery_on[2]"))

defineProperty("battery_amps_0", globalPropertyi("sim/cockpit2/electrical/battery_amps[0]"))
defineProperty("battery_amps_1", globalPropertyi("sim/cockpit2/electrical/battery_amps[1]"))
defineProperty("battery_amps_2", globalPropertyi("sim/cockpit2/electrical/battery_amps[2]"))

defineProperty("APU_generator_amps", globalPropertyi("sim/cockpit2/electrical/APU_generator_amps"))
defineProperty("generator_amps_l", globalPropertyf("sim/cockpit2/electrical/generator_amps[0]"))
defineProperty("generator_amps_r", globalPropertyf("sim/cockpit2/electrical/generator_amps[1]"))
defineProperty("gpu_amps", globalPropertyf("sim/cockpit/electrical/gpu_amps"))


--lights

defineProperty("avion_lit1", globalPropertyf("sim/custom/xap/avion_lit1"))
defineProperty("avion_lit2", globalPropertyf("sim/custom/xap/avion_lit2"))
defineProperty("avion_lit3", globalPropertyf("sim/custom/xap/avion_lit3"))

defineProperty("stby_ins_lit", globalPropertyf("sim/custom/xap/stby_ins_lt"))
defineProperty("stby_ins_dim_brt", globalPropertyi("sim/custom/xap/stby_ins_dim_brt"))




defineProperty("crewlit", globalPropertyf("sim/custom/xap/crewlit"))
defineProperty("crewlit_h", globalPropertyf("sim/custom/xap/crewlit_h"))
defineProperty("crewlit2", globalPropertyf("sim/custom/xap/crewlit2"))
defineProperty("crewlit2_h", globalPropertyf("sim/custom/xap/crewlit2_h"))
defineProperty("entrlight", globalPropertyf("sim/custom/xap/entrlight"))
defineProperty("entrlight_h", globalPropertyf("sim/custom/xap/entrlight_h"))
defineProperty("cablight", globalPropertyf("sim/custom/xap/cablight"))
defineProperty("cablight_h", globalPropertyf("sim/custom/xap/cablight_h"))
defineProperty("emeright", globalPropertyf("sim/custom/xap/emeright"))
defineProperty("emeright_h", globalPropertyf("sim/custom/xap/emeright_h"))
defineProperty("landlight1", globalPropertyf("sim/custom/xap/landlight1"))
defineProperty("landlight2", globalPropertyf("sim/custom/xap/landlight2"))
defineProperty("landlight1_h", globalPropertyf("sim/custom/xap/landlight1_h"))
defineProperty("landlight2_h", globalPropertyf("sim/custom/xap/landlight2_h"))
defineProperty("xap_taxilight_h", globalPropertyf("sim/custom/xap/xap_taxilight_h"))
defineProperty("xap_taxilight", globalPropertyf("sim/custom/xap/xap_taxilight"))
defineProperty("xap_taxilight2", globalPropertyf("sim/custom/xap/xap_taxilight2"))
defineProperty("beaconlights", globalPropertyi("sim/cockpit/electrical/beacon_lights_on"))
defineProperty("stroblights", globalPropertyi("sim/cockpit/electrical/strobe_lights_on"))
defineProperty("strobe_h", globalPropertyf("sim/custom/xap/strobe_h"))
defineProperty("nav_h", globalPropertyf("sim/custom/xap/nav_h"))
defineProperty("logo", globalPropertyf("sim/custom/xap/logo"))
defineProperty("navlights", globalPropertyi("sim/cockpit/electrical/nav_lights_on"))
defineProperty("landlights", globalPropertyi("sim/cockpit/electrical/landing_lights_on"))
defineProperty("landlights_2", globalPropertyi("sim/cockpit2/switches/landing_lights_switch[0]"))
defineProperty("landlights_1", globalPropertyi("sim/cockpit2/switches/landing_lights_switch[1]"))
defineProperty("landlights_rat", globalPropertyi("sim/flightmodel2/lights/landing_lights_brightness_ratio"))


defineProperty("beac_brt_rat", globalPropertyf("sim/flightmodel2/lights/beacon_brightness_ratio"))

defineProperty("beac_brt", globalPropertyf("sim/custom/xap/beac_brt"))

defineProperty("wing_insp_h", globalPropertyf("sim/custom/xap/wing_insp_h"))
defineProperty("wing_insp", globalPropertyf("sim/custom/xap/wing_insp"))
defineProperty("wing_insp_b", globalPropertyf("sim/custom/xap/wing_insp_b"))


defineProperty("avpow", globalPropertyi("sim/cockpit2/switches/avionics_power_on"))
defineProperty("cockavl", globalPropertyf("sim/custom/xap/cockavl"))
defineProperty("cockavl_p", globalPropertyf("sim/custom/xap/cockavl_p"))
defineProperty("cockavl_m", globalPropertyf("sim/custom/xap/cockavl_m"))
defineProperty("cockavr", globalPropertyf("sim/custom/xap/cockavr"))
defineProperty("cockavr_p", globalPropertyf("sim/custom/xap/cockavr_p"))
defineProperty("cockavr_m", globalPropertyf("sim/custom/xap/cockavr_m"))

defineProperty("night_lights", globalPropertyf("sim/graphics/scenery/percent_lights_on"))

defineProperty("cmfd_h", globalPropertyf("sim/custom/xap/cmfd_h"))
defineProperty("cmfd", globalPropertyf("sim/custom/xap/cmfd"))

defineProperty("cpfd_h", globalPropertyf("sim/custom/xap/cpfd_h"))
defineProperty("cpfd", globalPropertyf("sim/custom/xap/cpfd"))

defineProperty("pmfd_h", globalPropertyf("sim/custom/xap/pmfd_h"))
defineProperty("pmfd", globalPropertyf("sim/custom/xap/pmfd"))

defineProperty("ppfd_h", globalPropertyf("sim/custom/xap/ppfd_h"))
defineProperty("ppfd", globalPropertyf("sim/custom/xap/ppfd"))


defineProperty("dome_h", globalPropertyf("sim/custom/xap/dome_h"))
defineProperty("dome", globalPropertyf("sim/custom/xap/dome"))

defineProperty("annun_h", globalPropertyf("sim/custom/xap/annun_h"))
defineProperty("annun", globalPropertyf("sim/custom/xap/annun"))

defineProperty("cbp_h", globalPropertyf("sim/custom/xap/cbp_h"))
defineProperty("cbp", globalPropertyf("sim/custom/xap/cbp"))

defineProperty("gshldr_h", globalPropertyf("sim/custom/xap/gshldr_h"))
defineProperty("gshldr", globalPropertyf("sim/custom/xap/gshldr"))

defineProperty("pedestal_h", globalPropertyf("sim/custom/xap/pedestal_h"))
defineProperty("pedestal", globalPropertyf("sim/custom/xap/pedestal"))

defineProperty("gshldl_h", globalPropertyf("sim/custom/xap/gshldl_h"))
defineProperty("gshldl", globalPropertyf("sim/custom/xap/gshldl"))

defineProperty("sunglases", globalPropertyi("sim/cockpit/electrical/sunglasses_on"))

defineProperty("view", globalPropertyf("sim/graphics/view/view_is_external"))

defineProperty("sunscreen21", globalPropertyf("sim/custom/xap/sunscreen21"))
defineProperty("sunscreen11", globalPropertyf("sim/custom/xap/sunscreen11"))

defineProperty("tire_steer_comm", globalPropertyf("sim/flightmodel2/gear/tire_steer_command_deg[0]"))
defineProperty("tire_steer_act", globalPropertyf("sim/flightmodel/parts/tire_steer_act[0]"))






defineProperty("cockpit_light_level_r", globalPropertyi("sim/graphics/misc/cockpit_light_level_r"))
defineProperty("cockpit_light_level_g", globalPropertyi("sim/graphics/misc/cockpit_light_level_g"))
defineProperty("cockpit_light_level_b", globalPropertyi("sim/graphics/misc/cockpit_light_level_b"))
defineProperty("cockpit_lights_on", globalPropertyi("sim/cockpit/electrical/cockpit_lights_on"))


defineProperty("gear_dep_0", globalPropertyf("sim/flightmodel2/gear/deploy_ratio[0]"))
defineProperty("taxi", globalPropertyf("sim/cockpit/electrical/taxi_light_on"))
defineProperty("emer_door_lit", globalPropertyf("sim/custom/xap/emer_door_lit"))
defineProperty("entry_lit", globalPropertyf("sim/cockpit2/switches/custom_slider_on[0]"))
defineProperty("cabin_lit", globalPropertyf("sim/cockpit2/switches/custom_slider_on[4]"))
defineProperty("salon_lit", globalPropertyf("sim/flightmodel2/misc/custom_slider_ratio[4]"))
defineProperty("anns_lit", globalPropertyf("sim/flightmodel2/misc/custom_slider_ratio[2]"))
defineProperty("emer_door_open", globalPropertyf("sim/custom/xap/customslider4_r"))

defineProperty("belt", globalPropertyi("sim/custom/xap/belt"))
defineProperty("smoke", globalPropertyi("sim/custom/xap/smoke"))
defineProperty("smokebelts_h", globalPropertyi("sim/custom/xap/smokebelts_h"))

defineProperty("wave_limit_n", globalPropertyi("sim/custom/xap/wave_limit_n")) -- wave limit value
defineProperty("turbulence0", globalPropertyi("sim/weather/turbulence[0]"))
defineProperty("turbulence1", globalPropertyi("sim/weather/turbulence[1]"))
defineProperty("turbulence2", globalPropertyi("sim/weather/turbulence[2]"))

defineProperty("starter_duration_l", globalPropertyi("sim/cockpit/engine/starter_duration[0]"))
defineProperty("starter_duration_r", globalPropertyi("sim/cockpit/engine/starter_duration[1]"))



starter_l = findCommand("sim/starters/engage_starter_1")
starter_r = findCommand("sim/starters/engage_starter_2")




aut_servos_toggle = findCommand("sim/autopilot/servos_toggle")
aut_altitude_hold = findCommand("sim/autopilot/altitude_hold")
aut_vnav = findCommand("sim/autopilot/vnav")
aut_vertical_speed = findCommand("sim/autopilot/vertical_speed")
aut_level_change = findCommand("sim/autopilot/level_change")
aut_back_course = findCommand("sim/autopilot/back_course")
aut_approach = findCommand("sim/autopilot/approach")
aut_heading = findCommand("sim/autopilot/heading")
aut_NAV = findCommand("sim/autopilot/NAV")
aut_fdir_toggle = findCommand("sim/autopilot/fdir_toggle")

aut_airspeed_down = findCommand("sim/autopilot/airspeed_down")
aut_airspeed_up = findCommand("sim/autopilot/airspeed_up")
aut_heading_down = findCommand("sim/autopilot/heading_down")
aut_heading_up = findCommand("sim/autopilot/heading_up")
aut_altitude_down = findCommand("sim/autopilot/altitude_down")
aut_altitude_up = findCommand("sim/autopilot/altitude_up")
aut_vertical_speed_down = findCommand("sim/autopilot/vertical_speed_down")
aut_vertical_speed_up = findCommand("sim/autopilot/vertical_speed_up")
aut_yawd = findCommand("sim/systems/yaw_damper_toggle")

defineProperty("acf_flap_deftime", globalPropertyi("sim/aircraft/controls/acf_flap_deftime"))



clock_timer_start_stop = findCommand("sim/instruments/timer_start_stop")
clock_timer_reset = findCommand("sim/instruments/timer_reset")






set(carets, 0)
set(xap_taxilight, 0)
set(emer_door_lit, 0)
--[=[
set(en_starter_l, 1)
set(en_starter_r, 1)

set(en_but_run_l, 1)
set(en_but_run_r, 1)--]=]

--set(left_bat_h, 1)
--set(right_bat_h, 1)

set(altitude_dial_ft, 5000)

--set(nws_h, 1)


set(pedals_fwd_bwd_l, 0)
set(pedals_fwd_bwd_r, 0)

set(stby_ins_dim_brt, 0)
--set(electr_stbi_h, 1)

set(clock_timer_h, 0)

set(engn_mach_status, 0)

set(ice_detect_on, 1)
--set(ice_all_on, 1)

--set(antice_wngsource_r, 1)

set(map_mode, 0)


set(EFIS_airport_on, 1)
set(EFIS_fix_on, 1)
set(EFIS_vor_on, 1)
set(EFIS_ndb_on, 1)

set(elevator_trim, -0.145)

set(radio_altimeter_bug_ft_pilot, 600)

set(warn_bb,1)




if get(timer_running) == 1 then
commandOnce(clock_timer_start_stop)
commandOnce(clock_timer_reset)
end


local gr_sp_deployed = 0
local speed_lim = get(ground_speed)
local anm_time = 0
local drop_anm_time = 0
local drop_anm_time2 = 0
local annun_coeff = 0
local gr_sp_armed = 0
local throttle_to = 0
local check_thr_rev = 0
local chek_sbrk_cond = 0

local temp_coeff = {0}
local baro_coeff = {0}

local s_l = 0
local s_r = 0

local r_cas = 0
local y_cas = 0

alt_coeff = 150

brgsrc_hide = {0,0,0}

ping_temp = {0,0,0,0}

thrust = {30363,0}

ISA_t_tmp = {get(ISA_t)}


rain_perc_tmp = {0}

thrust_temp_coeff = 0

counter_1 = 0
counter_2 = 0
counter_3 = 0
counter_4 = 0
counter_5 = 0
counter_6 = 0
counter_7 = 0
counter_8 = 0
counter_9 = 0
counter_10 = 0
counter_11 = 0
counter_12 = 0
counter_13 = 0
counter_14 = 0
counter_15 = 0
counter_16 = 0
counter_17 = 0
counter_18 = 0


time_now = {get(totaltime),get(totaltime),get(totaltime),get(totaltime),get(totaltime),get(totaltime),get(totaltime),get(totaltime)}
last_states = {get(customslider1), get(customslider2), get(customslider3), get(customslider4), get(rembf10),get(rembf11),get(rembf12), get(rembf2), get(rembf7), get(rembf1), get(rembf6), get(rembf4),get(rembf8),get(prop_mode_0),get(prop_mode_1), get(sbrk_h), gr_sp_deployed,get(en_starter_l),get(en_starter_r),get(clock_timer_h),get(engn_mach_status),get(ENGN_thro_0),get(engn_mach_h),get(onground_all), get(pressure_manrate), get(dcp_range),get(rembf5),get(rembf13),get(rembf14)}
last_states_r = {get(customslider1_r), get(customslider2_r), get(customslider3_r), get(customslider4_r)}
autop_last = {get(autop_airspeed_dial), get(autop_fdir_h), get(autop_nav_h), get(autop_hdg_h), get(autop_appr_h), get(autop_bc_h), get(autop_flc_h), get(autop_vs_h), get(autop_vnav_h), get(autop_alt_h), get(autop_ap_h), get(autop_xfr_h), get(autop_yd_h)}

mach_hold_last = {get(ENGN_thro_0), get(ENGN_N1_L),get(machno)}

coms_last = {get(aud_com1_r_h),get(aud_com2_r_h),get(aud_com3_r_h),get(aud_com1_l_h),get(aud_com2_l_h),get(aud_com3_l_h),get(autop_brgsrc),get(dcp_navsrc),get(dcp_refs),get(mfd_sel_state), get(mfd_sel_state_h)}

refspds_last = {get(refspds_v1),get(refspds_vr),get(refspds_v2),get(refspds_vt),get(refspds_vga),get(refspds_vref),get(rev_air_dat)}

caution_last = {get(red_cas),get(yellow_cas)}

systest_last = {get(test_rot),get(test_push),}

starter_last = {get(starter_duration_l),get(starter_duration_r)}

electric_last = {get(electr_extp_h),get(ENGN_running_l),get(ENGN_running_r),get(APU_running),get(dcp_menu1_rot)}









-- Commands

--[=[
cwstog = findCommand("sim/autopilot/control_wheel_steer")
 function cwstogHandler(phase)
     if 0 == phase then
	-- set(strobe_h, 2)
		if autop_last[1] - get(autop_airspeed_dial) ~= 0 then
		set(autop_airspeed_dial, autop_last[1])
		end
		else

		if get(airspeed_is_mach)== 0 and get(autop_airspeed_dial) < 2 then
		autop_last = {get(autop_airspeed_dial)}
		end
	end
     return 1
 end

 registerCommandHandler(cwstog, 1, cwstogHandler);
--]=]

bknltstog = findCommand("sim/lights/beacon_lights_toggle")
 function bknltstogHandler(phase)
     if 0 == phase then
		if get(strobe_h) == 1 then
		set(strobe_h, 2)
		elseif get(strobe_h) == 2 then set(strobe_h, 0)
		elseif get(strobe_h) == 0 then set(strobe_h, 1)
		end

     end
     return 1
 end

 registerCommandHandler(bknltstog, 1, bknltstogHandler);


strbltstog = findCommand("sim/lights/strobe_lights_toggle")
 function strbltstogHandler(phase)
     if 0 == phase then
		if get(strobe_h) == 1 then
		set(strobe_h, 2)
		elseif get(strobe_h) == 2 then set(strobe_h, 0)
		elseif get(strobe_h) == 0 then set(strobe_h, 1)
		end

     end
     return 1
 end

 registerCommandHandler(strbltstog, 1, strbltstogHandler);


navltstog = findCommand("sim/lights/nav_lights_toggle")
 function navltstogHandler(phase)
     if 0 == phase then
		if get(nav_h) == 1 then
		set(nav_h, 2)
		elseif get(nav_h) == 2 then set(nav_h, 0)
		elseif get(nav_h) == 0 then set(nav_h, 1)
		end

     end
     return 1
 end

 registerCommandHandler(navltstog, 1, navltstogHandler);



taxiltstog = findCommand("sim/lights/taxi_lights_toggle")
 function taxiltstogHandler(phase)
     if 0 == phase then
		if get(xap_taxilight_h) > 0.5 then
		set(xap_taxilight_h, 0)
		else
		set(xap_taxilight_h, 2)
		end

     end
     return 1
 end

 registerCommandHandler(taxiltstog, 1, taxiltstogHandler);



landltstog = findCommand("sim/lights/landing_lights_toggle")
 function landltstogHandler(phase)
     if 0 == phase then
		if get(landlight1_h) > 0.5 or get(landlight2_h) > 0.5 then
		set(landlight1_h, 0)
		set(landlight2_h, 0)
		else
		set(landlight1_h, 1)
		set(landlight2_h, 1)
		end
--[=[
print("ISA_T : ",ISA_t_tmp[1])
print("baro_coeff : ",baro_coeff[1])
print("thrust 1 : ,",thrust[1])
print("POINT_thrust_0 : ",get(POINT_thrust_0))
print("acf_tmax",get(acf_tmax))
--]=]
     end
     return 1
 end

 registerCommandHandler(landltstog, 1, landltstogHandler);




brakestog = findCommand("sim/flight_controls/speed_brakes_toggle")
 function brakestogHandler(phase)
     if 0 == phase then
		if get(speedbrake_ratio) > 0.5 then
			set(speedbrake_ratio, 0.03)
			else
			set(speedbrake_ratio, 0.97)
		end

     end
     return 0
 end

registerCommandHandler(brakestog, 1, brakestogHandler);

brakesdnone = findCommand("sim/flight_controls/speed_brakes_down_one")
 function brakesdnoneHandler(phase)
      if 0 == phase then
			set(speedbrake_ratio, get(speedbrake_ratio)+0.1)
			end
 end

registerCommandHandler(brakesdnone, 1, brakesdnoneHandler);

brakesupone = findCommand("sim/flight_controls/speed_brakes_up_one")
 function brakesuponeHandler(phase)
  if 0 == phase then
			set(speedbrake_ratio, get(speedbrake_ratio)-0.1)
			end
 end

registerCommandHandler(brakesupone, 1, brakesuponeHandler);

brakesdnall = findCommand("sim/flight_controls/speed_brakes_down_all")
 function brakesdnallHandler(phase)
  if 0 == phase then
			set(speedbrake_ratio, 0.97)
			end
 end

registerCommandHandler(brakesdnall, 1, brakesdnallHandler);

brakesupall = findCommand("sim/flight_controls/speed_brakes_up_all")
 function brakesupallHandler(phase)
  if 0 == phase then
			set(speedbrake_ratio, 0.03)
			end
 end --]=]

registerCommandHandler(brakesupall, 1, brakesupallHandler);

warn_butt = findCommand("sim/annunciator/clear_master_warning")
 function warn_buttHandler(phase)
     if 0 == phase then
		r_cas = 0
     end
     return 1
 end

registerCommandHandler(warn_butt, 1, warn_buttHandler);


caut_butt = findCommand("sim/annunciator/clear_master_caution")
 function caut_buttHandler(phase)
     if 0 == phase then
		y_cas = 0
     end
     return 1
 end

registerCommandHandler(caut_butt, 1, caut_buttHandler);
--//

-- apu generator
createCommand("xap/apugen_button", "APU generator toggle")
apugen_c = findCommand("xap/apugen_button")
 function apugen_cHandler(phase)
     if 0 == phase then
		if get(electr_apugen_h) > 0 then
		set(electr_apugen_h, 0)
		else
		set(electr_apugen_h, 1)
		end
     end
     return 1
 end
registerCommandHandler(apugen_c, 1, apugen_cHandler);

--
-- left generator
createCommand("xap/elec_gen_l_button", "Left generator toggle")
elec_gen_l_c = findCommand("xap/elec_gen_l_button")
 function elec_gen_l_cHandler(phase)
     if 0 == phase then
		if get(electr_gen_l_h) > 0 then
		set(electr_gen_l_h, 0)
		else
		set(electr_gen_l_h, 1)
		end
     end
     return 1
 end
registerCommandHandler(elec_gen_l_c, 1, elec_gen_l_cHandler);

--
-- right generator
createCommand("xap/elec_gen_r_button", "Right generator toggle")
elec_gen_r_c = findCommand("xap/elec_gen_r_button")
 function elec_gen_r_cHandler(phase)
     if 0 == phase then
		if get(electr_gen_r_h) > 0 then
		set(electr_gen_r_h, 0)
		else
		set(electr_gen_r_h, 1)
		end
     end
     return 1
 end
registerCommandHandler(elec_gen_r_c, 1, elec_gen_r_cHandler);

--
-- bus tie
createCommand("xap/bus_tie_h_button", "Bus tie toggle")
bus_tie_c = findCommand("xap/bus_tie_h_button")
 function bus_tie_cHandler(phase)
     if 0 == phase then
		if get(bus_tie_h) > 0 then
		set(bus_tie_h, 0)
		else
		set(bus_tie_h, 1)
		end
     end
     return 1
 end
registerCommandHandler(bus_tie_c, 1, bus_tie_cHandler);

--







function update()





--ign

if get(engn_ign_h) > 0 then
set(igniter_on_0, 1)
set(igniter_on_0, 1)
end





-- fire

if get(fire_engn_l_h) > 0 then set(fire_extinguisher_on_l, 1) else set(fire_extinguisher_on_l, 0) end
if get(fire_engn_r_h) > 0 then set(fire_extinguisher_on_r, 1) else set(fire_extinguisher_on_r, 0) end




-- RA MIN

if get(radio_altimeter_bug_ft_pilot) > 1000 then set(radio_altimeter_bug_ft_pilot, 1000) end
if get(radio_altimeter_bug_ft_pilot) < 0 then set(radio_altimeter_bug_ft_pilot, 0) end

-- trim stab disabling

if get(trim_stab) == 1 then
set(acf_hstb_trim_dn, 0)
set(acf_hstb_trim_up, 0)
else
set(acf_hstb_trim_dn, 7)
set(acf_hstb_trim_up, 15)
end


if get(flight_spoil_h) == 1 or get(trim_stab) == 1 then
if get(autopilot_mode) > 1 then set(autopilot_mode, get(autopilot_mode) - 1) end
end


if coms_last[11] - get(mfd_sel_state_h) ~= 0 then set(mfd_sel_state, 1) end



-- brgsrc refs and navsrc buttons
if coms_last[7] - get(autop_brgsrc) == 0 and get(autop_brgsrc) ~= -1 then
brgsrc_hide[1] = brgsrc_hide[1] + 0.0008*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
brgsrc_hide[1] = 0
end

if brgsrc_hide[1] > 1 then
set(autop_brgsrc, -1)
brgsrc_hide[1] = 0
end


if coms_last[8] - get(dcp_navsrc) == 0 and get(dcp_navsrc) ~= -1 then
brgsrc_hide[2] = brgsrc_hide[2] + 0.0008*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
brgsrc_hide[2] = 0
end

if brgsrc_hide[2] > 1 then
set(dcp_navsrc, -1)
brgsrc_hide[2] = 0
end



if coms_last[9] - get(dcp_refs) == 0 and refspds_last[1] - get(refspds_v1) == 0 and refspds_last[2] - get(refspds_vr) == 0 and refspds_last[3] - get(refspds_v2) == 0 and refspds_last[4] - get(refspds_vt) == 0 and refspds_last[5] - get(refspds_vga) == 0 and refspds_last[6] - get(refspds_vref) == 0 and get(dcp_refs) ~= -1 then
brgsrc_hide[3] = brgsrc_hide[3] + 0.0008*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
brgsrc_hide[3] = 0
end

if brgsrc_hide[3] > 1 then
set(dcp_refs, -1)
brgsrc_hide[3] = 0
end



if electric_last[5] - get(dcp_menu1_rot) ~= 0 and get(mfd_sel_state) > 0 then brgsrc_hide[4] = 0 end

if coms_last[10] - get(mfd_sel_state) == 0 and get(mfd_sel_state) > 0 then
brgsrc_hide[4] = brgsrc_hide[4] + 0.0008*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
brgsrc_hide[4] = 0
end

if brgsrc_hide[4] > 1 then
set(mfd_sel_state, 0)
brgsrc_hide[4] = 0
end




if get(dcp_navsrc) == 0 then
set(HSI_source_select_pilot, 2)
elseif get(dcp_navsrc) == 1 then set(HSI_source_select_pilot, 0)
elseif get(dcp_navsrc) == 2 then set(HSI_source_select_pilot, 1)
end

-- map range


if last_states[26] - get(dcp_range) > 0 and get(map_range) > 1 then
set(map_range, get(map_range) - 1)
end
if last_states[26] - get(dcp_range) < 0 and get(map_range) < 6 then
set(map_range, get(map_range) + 1)
end



-- audio panel
if coms_last[1] - get(aud_com1_r_h) ~= 0 and get(aud_com1_r_h) == 1 then
set(aud_com2_r_h, 0)
set(aud_com3_r_h, 0)
else
	if coms_last[2] - get(aud_com2_r_h) ~= 0 and get(aud_com2_r_h) == 1 then
	set(aud_com1_r_h, 0)
	set(aud_com3_r_h, 0)
	else
		if coms_last[3] - get(aud_com3_r_h) ~= 0 and get(aud_com3_r_h) == 1 then
		set(aud_com1_r_h, 0)
		set(aud_com2_r_h, 0)
		end
	end
end

if coms_last[4] - get(aud_com1_l_h) ~= 0 and get(aud_com1_l_h) == 1 then
set(aud_com2_l_h, 0)
set(aud_com3_l_h, 0)

else
	if coms_last[5] - get(aud_com2_l_h) ~= 0 and get(aud_com2_l_h) == 1 then
	set(aud_com1_l_h, 0)
	set(aud_com3_l_h, 0)

	else
		if coms_last[6] - get(aud_com3_l_h) ~= 0 and get(aud_com3_l_h) == 1 then
		set(aud_com1_l_h, 0)
		set(aud_com2_l_h, 0)
		set(audio_com_selection, 0)
		end
	end
end

if get(aud_com1_l_h) == 0 and get(aud_com2_l_h) == 0 then set(audio_com_selection, 0) end


if get(aud_com1_l_h) == 1 and get(aud_voice_l_sw) ~= 1 then set(audio_com_selection, 6) end
if get(aud_com2_l_h) == 1 and get(aud_voice_l_sw) ~= 1 then set(audio_com_selection, 7) end



if get(aud_voice_l_sw) == 1 then
set(audio_com_selection, 0)
set(audio_selection_nav1, 1)
set(audio_selection_nav2, 1)
set(audio_selection_adf1, 1)
set(audio_selection_adf2, 1)
set(audio_dme_enabled, 1)
set(audio_marker_enabled, 1)
else
	if get(aud_voice_l_sw) == 0 then
	set(audio_selection_nav1, 1)
	set(audio_selection_nav2, 1)
	set(audio_selection_adf1, 1)
	set(audio_selection_adf2, 1)
	set(audio_dme_enabled, 1)
	set(audio_marker_enabled, 1)
	else
	set(audio_selection_nav1, 0)
	set(audio_selection_nav2, 0)
	set(audio_selection_adf1, 0)
	set(audio_selection_adf2, 0)
	set(audio_dme_enabled, 0)
	set(audio_marker_enabled, 0)
	end
end

if get(aud_vol_12_l) == 0 or get(aud_vol_12_r) == 0 then
set(audio_marker_enabled, 0)
end

if get(aud_vol_15_l) == 0 or get(aud_vol_15_r) == 0 then
	set(audio_selection_nav1, 0)
end

if get(aud_vol_16_l) == 0 or get(aud_vol_16_r) == 0 then
	set(audio_selection_nav2, 0)
end

-- master warn/caut





if ping_temp[2] == 0 then ping_temp[1] = ping_temp[1] + 0.08*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end
if ping_temp[2] == 1 then ping_temp[1] = ping_temp[1] - 0.08*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end
if ping_temp[1] >= 1 then ping_temp[2] = 1 elseif ping_temp[1] <= 0 then ping_temp[2] = 0 end

if ping_temp[4] == 0 then ping_temp[3] = ping_temp[3] + 0.08*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end
if ping_temp[4] == 1 then ping_temp[3] = ping_temp[3] - 0.08*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end
if ping_temp[3] >= 1 then ping_temp[4] = 1 elseif ping_temp[3] <= 0 then ping_temp[4] = 0 end



if caution_last[1] - get(red_cas) ~= 0 and get(red_cas) > 0 then
r_cas = 1
ping_temp[1] = 0
else
	if caution_last[1] - get(red_cas) ~= 0 and get(red_cas) == 0 then
	r_cas = 0
	end
end

if caution_last[2] - get(yellow_cas) ~= 0 and get(yellow_cas) > 0 then
y_cas = 1
ping_temp[3] = 0
else
	if caution_last[2] - get(yellow_cas) ~= 0 and get(yellow_cas) == 0 then
	y_cas = 0
	end
end



if r_cas == 1 then
	if get(elbus1) >=10 or get(elbus2) >=10 then
	set(mast_warn, ping_temp[1])
	else
	set(mast_warn, 0)
	end
else
	set(mast_warn, 0)
end--

if y_cas == 1 then
	if get(elbus1) >=10 or get(elbus2) >=10 then
	set(mast_caut, ping_temp[3])
	else
	set(mast_caut, 0)
	end
else
	set(mast_caut, 0)
end



-- rev panel tune knob

if get(rev_tune) == 0 then
set(com1_freq_hz, 12150)
end







-- fuel


if get(ENGN_running_l) > 0 and get(ENGN_running_r) > 0 then
set(fuel_tank_selector, 4)
else
if get(ENGN_running_l) < 1 and get(ENGN_running_r) > 0 then set(fuel_tank_selector, 3) end
if get(ENGN_running_r) < 1 and get(ENGN_running_l) > 0 then set(fuel_tank_selector, 1) end
end

--[=[
set(fuel_tank_selector_right, 3)
set(fuel_tank_selector_left, 1)
--]=]
--set(acf_has_fuel_all, 0)
--set(acf_has_fuel_any, 0)
set(transparent_panel, 0)

-- autop panel knobs


if get(autop_hdg_dial) < 0 then
commandOnce(aut_heading_down)
end
if get(autop_hdg_dial) > 0 then
commandOnce(aut_heading_up)
end

if get(autop_spd_dial) < 0 then
commandOnce(aut_airspeed_down)
end
if get(autop_spd_dial) > 0 then
commandOnce(aut_airspeed_up)
end

if get(autop_alt_dial) < 0 then
commandOnce(aut_altitude_down)
end
if get(autop_alt_dial) > 0 then
commandOnce(aut_altitude_up)
end

if get(autop_vvi_dial) < 0 then
commandOnce(aut_vertical_speed_down)
end
if get(autop_vvi_dial) > 0 then
commandOnce(aut_vertical_speed_up)
end





-- clock reset button

if last_states[20] - get(clock_timer_h) ~= 0 and get(timer_running) == 0 and get(clock_timer_h) == 1 then
commandOnce(clock_timer_start_stop)
end

if last_states[20] - get(clock_timer_h) ~= 0 and get(timer_running) == 1 and get(clock_timer_h) == 2 then
commandOnce(clock_timer_start_stop)
end

if last_states[20] - get(clock_timer_h) ~= 0 and get(clock_timer_h) == 0 then
commandOnce(clock_timer_reset)
end




-- autopilot buttons

if autop_last[2] - get(autop_fdir_h) ~= 0 then commandOnce(aut_fdir_toggle) end
if autop_last[3] - get(autop_nav_h) ~= 0 then commandOnce(aut_NAV) end
if autop_last[4] - get(autop_hdg_h) ~= 0 then commandOnce(aut_heading) end
if autop_last[5] - get(autop_appr_h) ~= 0 then commandOnce(aut_approach) end
if autop_last[6] - get(autop_bc_h) ~= 0 then commandOnce(aut_back_course) end
if autop_last[7] - get(autop_flc_h) ~= 0 then commandOnce(aut_level_change) end
if autop_last[8] - get(autop_vs_h) ~= 0 then commandOnce(aut_vertical_speed) end
if autop_last[9] - get(autop_vnav_h) ~= 0 then commandOnce(aut_vnav) end
if autop_last[10] - get(autop_alt_h) ~= 0 then commandOnce(aut_altitude_hold) end
if autop_last[11] - get(autop_ap_h) ~= 0 then commandOnce(aut_servos_toggle) end
if autop_last[13] - get(autop_yd_h) ~= 0 then commandOnce(aut_yawd) end

if get(servos_on) == 1 then set(yaw_damper_on, 1) end



--


set(cockpit_light_level_r, 1)
set(cockpit_light_level_g, 1)
set(cockpit_light_level_b, 1)
set(cockpit_lights_on, 1)



if get(fgp_s_hdg) == 1 then
set(heading_dial_deg_mag_pilot, get(heading_AHARS_deg_mag_pilot))
end





-- pedals adjastment
if get(elbus1) >= 10 and get(rudd_ped_l_sw) == 1 and get(pedals_fwd_bwd_l) < 1 then
set(pedals_fwd_bwd_l, get(pedals_fwd_bwd_l) + 0.01*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused))
elseif get(elbus1) >= 10 and get(rudd_ped_l_sw) == -1 and get(pedals_fwd_bwd_l) > -1 then set(pedals_fwd_bwd_l, get(pedals_fwd_bwd_l) - 0.01*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused))
end

if get(elbus1) >= 10 and get(rudd_ped_r_sw) == 1 and get(pedals_fwd_bwd_r) < 1 then
set(pedals_fwd_bwd_r, get(pedals_fwd_bwd_r) + 0.01*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused))
elseif get(elbus1) >= 10 and get(rudd_ped_r_sw) == -1 and get(pedals_fwd_bwd_r) > -1 then set(pedals_fwd_bwd_r, get(pedals_fwd_bwd_r) - 0.01*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused))
end


-- Turbulence limiter

--[=[if get(wave_limit_n) > 0 then
	if get(turbulence0) > 0.125 then
		set(turbulence0, 0.125)
	end
		if get(turbulence1) > 0.125 then
		set(turbulence1, 0.125)
	end
		if get(turbulence2) > 0.125 then    starter_time[1] = get(time_now)
		set(turbulence2, 0.125)
	end
end--]=]


-- fuel
if get(en_but_run_l) > 0 then
if get(fuel_xpump_l) > 0 then
set(ENGN_mixt_0, 1)
set(fuel_pump_on_0, 1)
end
else
set(ENGN_mixt_0, 0)
set(igniter_on_0, 0)
end

if get(en_but_run_r) > 0 then
if get(fuel_xpump_r) > 0 then
set(ENGN_mixt_1, 1)
set(fuel_pump_on_1, 1)
end
else
set(ENGN_mixt_1, 0)
set(igniter_on_1, 0)
end


if get(fuel_xpump_l) == 0 then set(fuel_pump_on_0, 0) end
if get(fuel_xpump_r) == 0 then set(fuel_pump_on_1, 0) end

if get(fuel_xpump_l) < 2 and get(fuel_xpump_r) < 2 then set(fuel_tank_transfer_from, 0) end
if get(fuel_xpump_l) == 1 and get(fuel_xpump_r) == 1 then set(fuel_tank_transfer_from, 0) end
if get(fuel_xflow_dn) == 0 then set(fuel_tank_transfer_from, 0) end

if get(elbus1) >=10 or get(elbus2) >=10 then
	if get(fuel_xflow_dn) > 0 then
		if get(fuel_xpump_l) == 2 and get(fuel_xpump_r) < 2 then set(fuel_tank_transfer_from, 1) end
		if get(fuel_xpump_l) < 2 and get(fuel_xpump_r) == 2 then set(fuel_tank_transfer_from, 3) end
	end
end

if get(elbus1) >=10 or get(elbus2) >=10 then
if get(fuel_xflow_up) > 0 then
	if get(m_fuel1) - get(m_fuel2) < -1 then
	set(fuel_tank_transfer_to, 1)
	else
		if get(m_fuel1) - get(m_fuel2) > 1 then
		set(fuel_tank_transfer_to, 3)
		end
	end
else
set(fuel_tank_transfer_to, 0)
end
end

if get(m_fuel1) - get(m_fuel2) > -1 and get(m_fuel1) - get(m_fuel2) < 1 then set(fuel_tank_transfer_to, 0) end

if math.abs(get(m_fuel1)*2.20462262 - get(m_fuel2)*2.20462262) < 100 and get(fuel_xflow_dn_h) > 0 then set(fuel_balanced, 1) else set(fuel_balanced, 0) end




if get(m_fuel1)*2.20462262 + get(m_fuel2)*2.20462262 > 13700 then
	if math.abs(get(m_fuel1)*2.20462262 - get(m_fuel2)*2.20462262) > 250 then set(fuel_imbalanced, 1) else set(fuel_imbalanced, 0) end
else
	if get(m_fuel1)*2.20462262 + get(m_fuel2)*2.20462262 < 13700 and get(m_fuel1)*2.20462262 + get(m_fuel2)*2.20462262 > 10000 then
		if math.abs(get(m_fuel1)*2.20462262 - get(m_fuel2)*2.20462262) > 315 then set(fuel_imbalanced, 1) else set(fuel_imbalanced, 0) end
	else
		if get(m_fuel1)*2.20462262 + get(m_fuel2)*2.20462262 < 10000 and get(m_fuel1)*2.20462262 + get(m_fuel2)*2.20462262 > 4700 then
			if math.abs(get(m_fuel1)*2.20462262 - get(m_fuel2)*2.20462262) > 450 then set(fuel_imbalanced, 1) else set(fuel_imbalanced, 0) end
		else
			if math.abs(get(m_fuel1)*2.20462262 - get(m_fuel2)*2.20462262) > 600 then set(fuel_imbalanced, 1) else set(fuel_imbalanced, 0) end
		end
	end
end




			--





if last_states[18] - get(en_starter_l) ~= 0 and get(en_starter_l) > 1 then
s_l = 1
end

if last_states[19] - get(en_starter_r) ~= 0 and get(en_starter_r) > 1 then
s_r = 1
end


if s_l == 1 then
	if get(ENGN_N1_L) < 11 and get(ENGN_mixt_0) > 0 then
	commandOnce(starter_l)
	if get(ENGN_N1_L) > 7 then
	set(igniter_on_0, 1)
	else
	set(igniter_on_0, 0)
	end
	else
	s_l = 0
	end
end

if s_r == 1 then
	if get(ENGN_N1_R) < 11 and get(ENGN_mixt_1) > 0 then
	commandOnce(starter_r)
	if get(ENGN_N1_R) > 7 then
	set(igniter_on_1, 1)
	else
	set(igniter_on_1, 0)
	end
	else
	s_r = 0
	end
end

if get(en_starter_l) == 0 and get(ENGN_FF_l) < 0.03 then
commandOnce(starter_l)
set(igniter_on_0, 0)
end

if get(en_starter_r) == 0 and get(ENGN_FF_r) < 0.03 then
commandOnce(starter_r)
set(igniter_on_1, 0)
end


set(dtr_s_r, s_r)
set(dtr_s_l, s_l)









--]=]














--[=[
if get(rel_AOA, 6) and get(rev_air_dat) == 1 then
	set(airdat2_fault, 1)
	set(airdat1_fault, 1)
end
	--]=]

-- rem before flight ice detect failure
if get(rembf1) == 0 and get(rembf6) == 0 then
set(rel_ice_detect, 6)
else
if last_states[10] - get(rembf1) ~= 0 or last_states[11] - get(rembf6) ~= 0 then
	if get(rembf1) == 1 or get(rembf6) == 1 then
	set(rel_ice_detect, 0)
	end
end
end


-- rem before flight nose gear failure
if get(rembf5) == 0 then
set(rel_lagear1, 6)
else
if last_states[27] - get(rembf5) ~= 0 then
	if get(rembf5) == 1 then
	set(rel_lagear1, 0)
	end
end
end
-- rem before flight left gear failure
if get(rembf13) == 0 then
set(rel_lagear2, 6)
else
if last_states[28] - get(rembf13) ~= 0 then
	if get(rembf13) == 1 then
	set(rel_lagear2, 0)
	end
end
end
-- rem before flight right gear failure
if get(rembf14) == 0 then
set(rel_lagear3, 6)
else
if last_states[29] - get(rembf14) ~= 0 then
	if get(rembf14) == 1 then
	set(rel_lagear3, 0)
	end
end
end


-- rem before flight AOA detect failure

if get(rembf8) == 0 and get(rembf4) == 1 and  get(rev_air_dat) == 2 then
set(rel_AOA, 6)
end

if get(rembf8) == 1 and get(rembf4) == 0 and  get(rev_air_dat) == 0 then
set(rel_AOA, 6)
end

if get(rembf8) == 1 and get(rembf4) == 0 and  get(rev_air_dat) == 1 then
set(rel_AOA, 6)
end


--if get(rembf8) == 0 and get(rembf4) == 1 and  get(rev_air_dat) == 1 then set(rel_AOA, 6) end



if get(rembf4) == 0 and get(rembf8) == 0 then
set(rel_AOA, 6)
else
if last_states[12] - get(rembf4) ~= 0 or last_states[13] - get(rembf8) ~= 0 or refspds_last[7] - get(rev_air_dat) ~= 0 then
	if get(rembf4) == 1 or get(rembf8) == 1 then
	set(rel_AOA, 0)
	end
end
end






if get(rembf4) == 0 then set(airdat1_fault, 1) else set(airdat1_fault, 0) end
if get(rembf8) == 0 then set(airdat2_fault, 1) else set(airdat2_fault, 0) end
----[=[
if get(rembf4) == 1 and get(rembf8) == 1 then
	if get(rel_AOA) == 6 then
	set(airdat1_fault, 1)
	set(airdat2_fault, 1)
	else
		if get(rel_AOA) == 0 then
		set(airdat1_fault, 0)
		set(airdat2_fault, 0)
		end
	end
end


if get(rel_AOA) == 6 then
	if get(rembf4) == 1 and get(rembf8) == 1 then set(airdat1_fault, 1) end
	if get(rembf4) == 0 and get(rembf8) == 1 then set(airdat1_fault, 1) end
	if get(rembf4) == 1 and get(rembf8) == 0 then set(airdat1_fault, 0) end
	if get(rembf4) == 0 and get(rembf8) == 0 then set(airdat1_fault, 1) end

	if get(rembf4) == 1 and get(rembf8) == 1 then set(airdat2_fault, 1) end
	if get(rembf4) == 0 and get(rembf8) == 1 then set(airdat2_fault, 0) end
	if get(rembf4) == 1 and get(rembf8) == 0 then set(airdat2_fault, 1) end
	if get(rembf4) == 0 and get(rembf8) == 0 then set(airdat2_fault, 1) end
else
	if get(rembf4) == 1 and get(rembf8) == 1 then set(airdat1_fault, 0) end
	if get(rembf4) == 0 and get(rembf8) == 1 then set(airdat1_fault, 1) end
	if get(rembf4) == 1 and get(rembf8) == 0 then set(airdat1_fault, 0) end
	if get(rembf4) == 0 and get(rembf8) == 0 then set(airdat1_fault, 1) end

	if get(rembf4) == 1 and get(rembf8) == 1 then set(airdat2_fault, 0) end
	if get(rembf4) == 0 and get(rembf8) == 1 then set(airdat2_fault, 0) end
	if get(rembf4) == 1 and get(rembf8) == 0 then set(airdat2_fault, 1) end
	if get(rembf4) == 0 and get(rembf8) == 0 then set(airdat2_fault, 1) end
end

-- rem before flight pitot failure
if get(rembf2) == 0 then
set(rel_pitot, 6)
else
if last_states[8] - get(rembf2) ~= 0 then
set(rel_pitot, 0)
end
end

if get(rembf7) == 0 then
set(rel_pitot2, 6)
else
if last_states[9] - get(rembf7) ~= 0 then
set(rel_pitot2, 0)
end
end










-- rem before flight engine failure
if get(rembf11) == 0 then
set(rel_engfai1, 6)
else
if last_states[6] - get(rembf11) ~= 0 then
set(rel_engfai1, 0)
end
end



if get(rembf12) == 0 then
set(rel_engfai0, 6)
else
if last_states[7] - get(rembf12) ~= 0 then
set(rel_engfai0, 0)
end
end















-- steer handle

if get(ground_speed) < 22 then
set(steer_handle, get(tire_steer_act))
else
set(steer_handle, 0)
end



-- spoilers and speedbrakes
if get(speedbrake_ratio) < 0.97 and get(speedbrake_ratio) > 0.03 then
set(sbrk_h, get(speedbrake_ratio))
end

if get(speedbrake_ratio) > 0.97 and gr_sp_deployed ~= 1 then
set(sbrk_h, 0.97)
elseif get(speedbrake_ratio) < 0.03 and gr_sp_deployed ~= 1 then set(sbrk_h, 0.030000)
end




if get(throttle_ratio_all) > 0.8 and get(reverser_on_2) ~= 1 then
throttle_to = 1
end

if get(throttle_ratio_all) < 0.02 and get(reverser_on_2) ~= 1 then
check_thr_rev = 1
elseif get(throttle_ratio_all) > 0.02 and get(reverser_on_2) == 1 then check_thr_rev = 1
elseif get(throttle_ratio_all) > 0.02 and get(reverser_on_2) ~= 1 then check_thr_rev = 0
end


if get(ground_sp_h) == 1 then
	set(speedbrake_ratio , get(sbrk_h))
	if throttle_to == 1 and gr_sp_deployed == 0 then
	gr_sp_armed = 1

	end



elseif get(ground_sp_h) == 2 then gr_sp_armed = 1
else
	if get(ground_sp_h) == 0 then
	gr_sp_armed = 0
	throttle_to = 0
	set(speedbrake_ratio , get(sbrk_h))
	end
end

if gr_sp_armed == 1 then
	if check_thr_rev == 1 and get(ground_speed) > 8.3 and get(onground_all) == 1 then
	set(speedbrake_ratio , 1)
	gr_sp_deployed = 1
	chek_sbrk_cond = 1
	else
		if check_thr_rev == 1 and get(ground_speed) > 8.3 and get(radio_altimeter_height_ft_pilot) < 7 then
		set(speedbrake_ratio , 1)
		gr_sp_deployed = 1
		chek_sbrk_cond = 1
		else
			if check_thr_rev == 1 and get(radio_altimeter_height_ft_pilot) < 7 and get(onground_all) == 1 then
			set(speedbrake_ratio , 1)
			gr_sp_deployed = 1
			chek_sbrk_cond = 1
			else
			chek_sbrk_cond = 0

--[=[				if check_thr_rev == 1 and get(ground_speed) > 8.3 and get(radio_altimeter_height_ft_pilot) < 7 and get(onground_all) == 1 then
				set(speedbrake_ratio , 1)
				gr_sp_deployed = 1
	end ]=]
			end
		end
	end






    if  gr_sp_deployed == 1 and chek_sbrk_cond == 0 then
	gr_sp_deployed = 0
	gr_sp_armed = 0
	throttle_to = 0
	end

else
	gr_sp_deployed = 0
	if last_states[17] - gr_sp_deployed ~= 0 then
	set(speedbrake_ratio ,get(sbrk_h))
	end
end

--[=[
if gr_sp_deployed == 0 and last_states[17] - gr_sp_deployed ~= 0 then
gr_sp_armed = 0
throttle_to = 0
end
]=]



if last_states[17] - gr_sp_deployed ~= 0 then
time_now[8] = get(totaltime)
end


if gr_sp_armed == 1 and gr_sp_deployed == 1 and get(totaltime) - time_now[8] > 30 then
gr_sp_deployed = 0
gr_sp_armed = 0
throttle_to = 0
set(speedbrake_ratio , 0)

end







-- hydr (fl_contr etc)

if get(hydr_pres_1) < 2100 then
set(acf_elev_dn,12)
set(acf_elev_up,17)
set(tire_steer_comm, 0)
set(prop_mode_0, 1)
else
set(acf_elev_dn,20)
set(acf_elev_up,25)
end


if get(hydr_pres_2) < 2100 and get(hydr_pres_1) < 2100 then
set(acf_splr_up, 0)
set(acf_sbrk_up, 0)
set(speedbrake_ratio , 0)
set(acf_splr_up, 30)
	if get(flight_spoil_h) == 0 then
	set(acf_splr_up, 30)
	else

	set(acf_splr_up, 0)
	end
end

if get(hydr_pres_2) < 2100 then set(prop_mode_1, 1) end



if get(eq_ped_nobrk) ~= 0 then
-- brakes with chocks

	if get(rembf10) == 0 then
	set(override_gearbrake, 1)
	set(r_brake_add, 0.9)
	set(l_brake_add, 0.9)
	else
		if last_states[5] - get(rembf10) ~= 0 then
		set(override_gearbrake, 1)
		set(r_brake_add, 0)
		set(l_brake_add, 0)
		set(override_gearbrake, 0)
		end
	end





	-- brakes when steer



	if get(parkbrake) < 0.2 then
		if get(yoke_heading_ratio) > 0.85 and get(rembf10) == 1 then
		set(override_gearbrake, 1)
		set(r_brake_add, 0)
		end
			if get(yoke_heading_ratio) < -0.85 and get(rembf10) == 1 then
			set(override_gearbrake, 1)
			set(l_brake_add, 0)
			end
	else
		if get(rembf10) == 1 then
		set(override_gearbrake, 0)
		end
	end

else
set(override_gearbrake, 0)
if get(rembf10) == 0 then
set(l_brake_add, 0.9)
set(r_brake_add, 0.9)
end
if last_states[5] - get(rembf10) ~= 0 and get(rembf10) == 1 then
set(l_brake_add, 0)
set(r_brake_add, 0)
end
end



--]=]


-------------------
-------------------
--FADEC
-------------------
-------------------

set(acf_face_jet, (get(barometer_current_inhg)+38.9)*0.0409026)

-- Throttle override

if get(gust_lock) == 0 and get(ENGN_thro_0) > 0.1 and get(ENGN_thro_0) < 0.85 then
set(carets, 1)
else
if get(gust_lock) == 0 and get(ENGN_thro_0) >= 0 and get(ENGN_thro_0) < 0.1 then
set(carets, 0)
end
if get(gust_lock) == 0 and get(ENGN_thro_0) > 0.85 and get(ENGN_thro_0) < 0.9 then
set(carets, 2)
end
if get(gust_lock) == 0 and get(ENGN_thro_0) > 0.9 and get(ENGN_thro_0) < 0.95 then
set(carets, 3)
end
if get(gust_lock) == 0 and get(ENGN_thro_0) > 0.95 and get(ENGN_thro_0) < 1 then
set(carets, 4)
end
if get(gust_lock) == 1 then
set(carets, 5)
end
end





if  get(gust_lock_anm) < get(gust_lock) then
set(gust_lock_anm, get(gust_lock_anm) + 0.02*((get(frame_rate_period)-0.02)*25 + 0.5))
end
if  get(gust_lock_anm) > get(gust_lock) then
set(gust_lock_anm, get(gust_lock_anm) - 0.02*((get(frame_rate_period)-0.02)*25 + 0.5))
end

if get(gust_lock_anm) < 0 then set(gust_lock_anm, 0) end
if get(gust_lock_anm) > 1 then set(gust_lock_anm, 1) end




--[=[
if  get(gust_lock_anm) < get(gust_lock) then
set(gust_lock_anm, get(gust_lock_anm) + 0.2*((get(frame_rate_period)-0.02)*25))
else
set(gust_lock_anm, get(gust_lock_anm) - 0.2*((get(frame_rate_period)-0.02)*25))
end
--]=]




set(override_throttles, 1)

if ISA_t_tmp[1] < get(ISA_t) then ISA_t_tmp[1] = ISA_t_tmp[1] + 0.005 end
if ISA_t_tmp[1] > get(ISA_t) then ISA_t_tmp[1] = ISA_t_tmp[1] - 0.005 end

temp_coeff[1] = 0.2242*get(temperature_ambient_c) + 23.193

--0.3950  --0.6510 -- 0.203 --0.420
if get(carets) == 3 then
	if ISA_t_tmp[1] < 15 then
		baro_coeff[1] = -(get(barometer_current_inhg)-4.1)*((-(ISA_t_tmp[1]+55)*0.0064) + 0.651) + 94.1 -- (-get(ISA_t)*0.16 - 2.4)
	else
		baro_coeff[1] = -(get(barometer_current_inhg)-4.1)*((ISA_t_tmp[1]-15)*0.01085+0.203) + 94.1

	end
else
	if get(carets) > 3 then
		if ISA_t_tmp[1] < 20 then
		baro_coeff[1] = -(get(barometer_current_inhg)-4.1)*((-(ISA_t_tmp[1]+55)*0.0064) + 0.651) + 94.1 +0.2-- (-get(ISA_t)*0.16 - 2.4)
		else
		baro_coeff[1] = -(get(barometer_current_inhg)-4.1)*((ISA_t_tmp[1]-15)*0.01085+0.203) + 94.1 + 0.2

		end
	end

	if get(carets) == 2 then
		if ISA_t_tmp[1] < 20 then
		baro_coeff[1] = -(get(barometer_current_inhg)-4.1)*((-(ISA_t_tmp[1]+55)*0.0064) + 0.651) + 94.1 -0.3-- (-get(ISA_t)*0.16 - 2.4)
		else
		baro_coeff[1] = -(get(barometer_current_inhg)-4.1)*((ISA_t_tmp[1]-15)*0.01085+0.203) + 94.1 -0.3

		end
	end

	if get(carets) <= 1 then
		if ISA_t_tmp[1] < 15 then
		baro_coeff[1] = -(get(barometer_current_inhg)-4.1)*((-(ISA_t_tmp[1]+55)*0.0064) + 0.651) + 94.1 -0.3-- (-get(ISA_t)*0.16 - 2.4)
		else
		baro_coeff[1] = -(get(barometer_current_inhg)-4.1)*((ISA_t_tmp[1]-15)*0.01085+0.203) + 94.1 -0.3

		end
	end


end

set(TO_n1, baro_coeff[1])

if get(ISA_t) > 0 then
thrust_temp_coeff =  get(ISA_t)*80
else
thrust_temp_coeff = 0
end

alt_coeff = 25
delta_thrust = -300

if get(barometer_current_inhg) >= 29.92 and ISA_t_tmp[1] <= 15 then
thrust[1] = 30363 --+ 5550
elseif get(barometer_current_inhg) >= 29.92 and ISA_t_tmp[1] > 15 then thrust[1] = 30363 - (get(ISA_t)*30-450)  - (get(altitude_ft_pilot) / alt_coeff) - thrust_temp_coeff + delta_thrust
elseif get(barometer_current_inhg) < 29.92 and ISA_t_tmp[1] <= 15 and ISA_t_tmp[1] > 0 then thrust[1] = (get(barometer_current_inhg)+4.63)*879.086 - (get(altitude_ft_pilot) / alt_coeff) - thrust_temp_coeff  + delta_thrust
elseif get(barometer_current_inhg) < 29.92 and ISA_t_tmp[1] <= 0 then thrust[1] = (get(barometer_current_inhg)+4.63)*879.086 + (-ISA_t_tmp[1]*26.5) - (get(altitude_ft_pilot) / alt_coeff) - thrust_temp_coeff  + delta_thrust
elseif get(barometer_current_inhg) < 29.92 and ISA_t_tmp[1] > 15 then thrust[1] = (get(barometer_current_inhg)+4.63)*879.086 - (ISA_t_tmp[1]*30-450) - (get(altitude_ft_pilot) / alt_coeff) - thrust_temp_coeff  + delta_thrust


end

--[=[
if get(barometer_current_inhg) >= 29.92 and get(ISA_t) <= 15 then
thrust[1] = 30363
elseif get(barometer_current_inhg) >= 29.92 and get(ISA_t) > 15 then thrust[1] = 30363 - (get(ISA_t)*30-450)
elseif get(barometer_current_inhg) < 29.92 and get(ISA_t) <= 15 and get(ISA_t) > 0 then thrust[1] = get(barometer_current_inhg)*905.086+3282.829
elseif get(barometer_current_inhg) < 29.92 and get(ISA_t) <= 15 and get(ISA_t) <= 0 then thrust[1] = get(barometer_current_inhg)*905.086+3282.829 + (-get(ISA_t)*26.5)
elseif get(barometer_current_inhg) < 29.92 and get(ISA_t) > 15 then thrust[1] = get(barometer_current_inhg)*905.086+3282.829 - (get(ISA_t)*30-450)
end
--]=]


if   get(gust_lock) == 0 and get(ENGN_thro_0) > 0.85 and get(ENGN_thro_0) <= 1 and get(ENGN_thro_1) > 0.85 and get(ENGN_thro_1) <= 1 and get(thrust_reverser_deploy_ratio_0) < 0.1 then

--set(ENGN_thro_use_0, 0.87)
--set(ENGN_thro_use_1, 0.87)

	if get(ENGN_N1_L) < baro_coeff[1] then
	set(ENGN_thro_use_0, get(ENGN_thro_use_0) + ((baro_coeff[1]- get(ENGN_N1_L))*0.02))
	set(ENGN_thro_use_1, get(ENGN_thro_use_1) + ((baro_coeff[1] - get(ENGN_N1_R))*0.02))
	else

	if get(ENGN_N1_L) > baro_coeff[1] then
	set(ENGN_thro_use_0, get(ENGN_thro_use_0) - ((get(ENGN_N1_L) - baro_coeff[1])*0.02))
	set(ENGN_thro_use_1, get(ENGN_thro_use_1) - ((get(ENGN_N1_R) - baro_coeff[1])*0.02))
	end

	end



	if get(POINT_thrust_0) < thrust[1] and get(POINT_thrust_0) > 0 then
	set(acf_tmax, get(acf_tmax) + (thrust[1] - get(POINT_thrust_0))*0.5)
	end
	if get(POINT_thrust_0) >= thrust[1] and get(POINT_thrust_0) > 0 then
	set(acf_tmax, get(acf_tmax) - (get(POINT_thrust_0)-thrust[1])*0.5)
	end


	--else
end

-- crz + mach hold




if last_states[23] - get(engn_mach_h) ~= 0 and get(engn_mach_h) == 1 and get(carets) == 1 and get(jet_sync_mode) > 0 and get(altitude_hold_status) == 2 and math.abs(get(ENGN_N1_L) - get(ENGN_N1_R)) <= 0.15 then
set(engn_mach_status, 1)
else
if get(engn_mach_h) == 0  or get(carets) ~= 1 and get(jet_sync_mode) <= 0 and get(altitude_hold_status) ~= 2 and math.abs(get(ENGN_N1_L) - get(ENGN_N1_R)) > 0.15 then
set(engn_mach_status, 0)
end
end



if get(engn_mach_status) == 1 and  last_states[21] - get(engn_mach_status) ~= 0 then--  last_states[22] - get(ENGN_thro_0) ~= 0
mach_hold_last = {get(ENGN_thro_0), get(ENGN_N1_L),get(machno)}
end


if  get(gust_lock) == 0 and  get(engn_mach_status) == 0 and get(ENGN_thro_0) >= 0 and get(ENGN_thro_0) < 0.85 and get(ENGN_thro_1) >= 0 and get(ENGN_thro_1) < 0.85 and get(thrust_reverser_deploy_ratio_0) < 0.1 then

	if get(onground_all) == 1 then
		set(ENGN_thro_use_0, get(ENGN_thro_0)*0.01*baro_coeff[1]*1.14)
		set(ENGN_thro_use_1, get(ENGN_thro_1)*0.01*baro_coeff[1]*1.14)
	else
		set(ENGN_thro_use_0, get(ENGN_thro_0)*0.01*baro_coeff[1]*1.14 + ((0.85 - get(ENGN_thro_0))*0.13)*(get(altitude_ft_pilot)/15846 + 1))
		set(ENGN_thro_use_1, get(ENGN_thro_1)*0.01*baro_coeff[1]*1.14 + ((0.85 - get(ENGN_thro_1))*0.13)*(get(altitude_ft_pilot)/15846 + 1))
	end

			if get(POINT_thrust_0) < thrust[1]*get(ENGN_thro_use_0)*0.8 and get(POINT_thrust_0) > 0 and get(thrust_reverser_deploy_ratio_0) < 0.1 then
			set(acf_tmax, get(acf_tmax) + (thrust[1]*get(ENGN_thro_use_0) - get(POINT_thrust_0))*0.5)
			end

			if get(POINT_thrust_0) > thrust[1]*get(ENGN_thro_use_0)*0.8 and get(POINT_thrust_0) > 0 and get(thrust_reverser_deploy_ratio_0) < 0.1 then
			set(acf_tmax, get(acf_tmax) - (get(POINT_thrust_0)-thrust[1]*get(ENGN_thro_use_0))*0.5)
			end

			--]=]
	--		set(acf_tmax, 53363)


	else

	if  get(gust_lock) == 0 and get(engn_mach_status) == 1 and get(ENGN_thro_0) > 0 and get(ENGN_thro_0) < 0.85 and get(ENGN_thro_1) > 0 and get(ENGN_thro_1) < 0.85 and get(thrust_reverser_deploy_ratio_0) < 0.1 then

		set(ENGN_thro_use_0, get(ENGN_thro_0)*0.01*baro_coeff[1]*1.12)
		set(ENGN_thro_use_1, get(ENGN_thro_1)*0.01*baro_coeff[1]*1.12)

		if math.abs(last_states[22] - get(ENGN_thro_0)) < 0.02 then
			if get(machno) < mach_hold_last[3] then
			set(ENGN_thro_use_0, get(ENGN_thro_use_0) + (mach_hold_last[3]-get(machno))*1000)
			set(ENGN_thro_use_1, get(ENGN_thro_use_1) + (mach_hold_last[3]-get(machno))*1000)
			end

			if get(machno) > mach_hold_last[3] then
			set(ENGN_thro_use_0, get(ENGN_thro_use_0) - (get(machno)-mach_hold_last[3])*1000)
			set(ENGN_thro_use_1, get(ENGN_thro_use_1) - (get(machno)-mach_hold_last[3])*1000)
			end
		else
			set(engn_mach_status, 0)
		end


		if get(engn_mach_status) == 1 and mach_hold_last[2] + 3 < get(ENGN_N1_L) then
		set(engn_mach_status, 0)
		end

		if get(engn_mach_status) == 1 and mach_hold_last[2] - 3 > get(ENGN_N1_L) then
		set(engn_mach_status, 0)
		end



		--set(acf_tmax, 53363)

		if get(POINT_thrust_0) < thrust[1]*get(ENGN_thro_use_0)*0.79 and get(POINT_thrust_0) > 0 and get(thrust_reverser_deploy_ratio_0) < 0.1 then
	    set(acf_tmax, get(acf_tmax) + (thrust[1]*get(ENGN_thro_use_0) - get(POINT_thrust_0))*0.5)
		end

		if get(POINT_thrust_0) >= thrust[1]*get(ENGN_thro_use_0)*0.79 and get(POINT_thrust_0) > 0 and get(thrust_reverser_deploy_ratio_0) < 0.1 then
		set(acf_tmax, get(acf_tmax) - (get(POINT_thrust_0)-thrust[1]*get(ENGN_thro_use_0))*0.5)
		end
--]=]


	end





	if get(thrust_reverser_deploy_ratio_0) > 0.9 or get(thrust_reverser_deploy_ratio_1)> 0.9 then
	set(ENGN_thro_use_0, get(ENGN_thro_0)*0.55)
	set(ENGN_thro_use_1, get(ENGN_thro_1)*0.55)
	end

--	set(override_throttles, 0)




end

if get(ENGN_thro_use_0) > 0.951 then set(ENGN_thro_use_0, 0.951) end
if get(ENGN_thro_use_1) > 0.951 then set(ENGN_thro_use_1, 0.951) end
if get(ENGN_thro_use_0) <= 0 then set(ENGN_thro_use_0, 0) end
if get(ENGN_thro_use_1) <= 0 then set(ENGN_thro_use_1, 0) end

if get(acf_tmax) <= 6000 then set(acf_tmax, 6000) end
if get(acf_tmax) > 53363 then set(acf_tmax, 53363) end

if  get(gust_lock) == 1 and get(thrust_reverser_deploy_ratio_1) < 0.9  and get(thrust_reverser_deploy_ratio_1) < 0.9 then
set(ENGN_thro_use_0, 0)
set(ENGN_thro_use_1, 0)
end



if get(gust_lock) == 1 then
set(prop_mode_0, last_states[14])
set(prop_mode_1, last_states[15])
	if get(reverser_on_1) ~= 1 and get(reverser_on_2) ~= 1 then
	set(throttle_ratio_all, 0)
	end
end

if get(reverser_on_1) == 1 then
set(thr_anm1, (-get(sim_thr_anm1)*0.24)+0.24)
else
	if get(gust_lock) == 0 then
		if get(sim_thr_anm1) > 0.85 and get(sim_thr_anm1) < 0.9 then
		set(thr_anm1, 0.75)
		elseif get(sim_thr_anm1) > 0.9 and get(sim_thr_anm1) < 0.95 then set(thr_anm1, 0.85)
		elseif get(sim_thr_anm1) > 0.95 and get(sim_thr_anm1) < 1.1 then set(thr_anm1, 1)
		elseif get(sim_thr_anm1) < 0.85 then set(thr_anm1, ((get(sim_thr_anm1)*0.62)+0.38)*0.80)
		end
	else
	set(thr_anm1, 0.3)
	end
end

if get(reverser_on_2) == 1 then
set(thr_anm2, (-get(sim_thr_anm2)*0.24)+0.24)
else
if get(gust_lock) == 0 then
	if get(sim_thr_anm2) > 0.85 and get(sim_thr_anm2) < 0.9 then
	set(thr_anm2, 0.75)
	elseif get(sim_thr_anm2) > 0.9 and get(sim_thr_anm2) < 0.95 then set(thr_anm2, 0.85)
	elseif get(sim_thr_anm2) > 0.95 and get(sim_thr_anm2) < 1.1 then set(thr_anm2, 1)
	elseif get(sim_thr_anm2) < 0.85 then set(thr_anm2, ((get(sim_thr_anm2)*0.62)+0.38)*0.80)
	end
else
set(thr_anm2, 0.3)
end
end


if get(onground_any) == 0 then
set(prop_mode_0, 1)
set(prop_mode_1, 1)
end



set(test_data_1, ISA_t_tmp[1])
set(test_data_2, baro_coeff[1])
set(test_data_3, thrust[1])
set(test_data_4, get(POINT_thrust_0))
set(test_data_5, get(acf_tmax))
--]=]

if starter_last[1] - get(starter_duration_l) ~= 0 or starter_last[2] - get(starter_duration_r) ~= 0 then set(acf_tmax, 33363) end



if get(thrust_reverser_deploy_ratio_0) > 0.9 or get(thrust_reverser_deploy_ratio_1)> 0.9 then set(acf_tmax, 53363) end






--//rain animations

if rain_perc_tmp[1] < get(rain_percent) then
rain_perc_tmp[1] = rain_perc_tmp[1] + 0.0008
end

if rain_perc_tmp[1] > get(rain_percent) then
rain_perc_tmp[1] = rain_perc_tmp[1] - 0.0008
end

if get(ground_speed) < 80 then
speed_lim = get(ground_speed)
else
speed_lim = 80
end

if get(totaltime) - time_now[5] < 10-rain_perc_tmp[1]*6 then
anm_time = ((get(totaltime) - time_now[5])/(10-rain_perc_tmp[1]*6))*360
else
time_now[5] = get(totaltime)
end




if get(totaltime) - time_now[6] < 14-rain_perc_tmp[1]*11 then
drop_anm_time = ((get(totaltime) - time_now[6])/(14-rain_perc_tmp[1]*11))*360
else
time_now[6] = get(totaltime)
end

if get(totaltime) - time_now[7] < 20-rain_perc_tmp[1]*15 then
drop_anm_time2 = ((get(totaltime) - time_now[7])/(20-rain_perc_tmp[1]*15))*360
else
time_now[7] = get(totaltime)
end

set(rain_move1, drop_anm_time)
set(rain_move2, drop_anm_time2)

set(rain_drop1, ((1-(0.1/(rain_perc_tmp[1]+0.1)))+0.9*rain_perc_tmp[1])*(1- 0.00015625*speed_lim*speed_lim)*1.5)

set(rain_back, ((1-(0.1/(rain_perc_tmp[1]+0.1)))+0.9*rain_perc_tmp[1])*(1- 0.00015625*speed_lim*speed_lim))



if anm_time > 90 and  anm_time < 270 then
set(rain_scr1, (1.5-(anm_time*1.5/270))*(1-(0.11/(rain_perc_tmp[1]+0.095))-0.15)*(1- 0.00015625*speed_lim*speed_lim))
else
set(rain_scr1, 0)
end


if anm_time > 180 and  anm_time < 360 then
set(rain_scr2, (2-((anm_time*2)/360))*(1-(0.11/(rain_perc_tmp[1]+0.095))-0.15)*(1- 0.00015625*speed_lim*speed_lim))
else
set(rain_scr2, 0)
end

if anm_time > 0 and  anm_time < 180 then
set(rain_scr3, (1-(anm_time*1/180))*(1-(0.11/(rain_perc_tmp[1]+0.095))-0.15)*(1- 0.00015625*speed_lim*speed_lim))
else
set(rain_scr3, 0)
end


if anm_time > 270 and  anm_time <= 360 then
set(rain_scr4, (3-((2*anm_time+180)/360))*(1-(0.11/(rain_perc_tmp[1]+0.095))-0.15)*(1- 0.00015625*speed_lim*speed_lim))
else
	if anm_time >= 0 and  anm_time < 90 then
	set(rain_scr4, (1-((anm_time+90)*1/180))*(1-(0.11/(rain_perc_tmp[1]+0.095))-0.15)*(1- 0.00015625*speed_lim*speed_lim))
	else
	--set(rain_scr4, 0)
	end
--set(rain_scr4, 0)
end



--// custom sliders

if last_states[1]-get(customslider1) ~= 0 then
time_now[1] = get(totaltime)
last_states_r[1] = get(customslider1_r)
end
if last_states[2]-get(customslider2) ~= 0 then
time_now[2] = get(totaltime)
last_states_r[2] = get(customslider2_r)
end
if last_states[3]-get(customslider3) ~= 0 then
time_now[3] = get(totaltime)
last_states_r[3] = get(customslider3_r)
end
if last_states[4]-get(customslider4) ~= 0 then
time_now[4] = get(totaltime)
last_states_r[4] = get(customslider4_r)
end

--custstomslider1
if get(customslider1) == 1 and get(customslider1_r) < 1 then
set(customslider1_r, ((get(totaltime) - time_now[1]) / 0.5)+last_states_r[1])
if get(customslider1_r) > 1 then
set(customslider1_r, 1)
end
end

if get(customslider1) == 0 and get(customslider1_r) > 0 then
set(customslider1_r, (last_states_r[1]*0.5 - (get(totaltime) - time_now[1])) / 0.5)
if get(customslider1_r) < 0 then
set(customslider1_r, 0)
end
end

--custstomslider2
if get(customslider2) == 1 and get(customslider2_r) < 1 then
set(customslider2_r, ((get(totaltime) - time_now[2]) / 8)+last_states_r[2])
if get(customslider2_r) > 1 then
set(customslider2_r, 1)
end
end

if get(customslider2) == 0 and get(customslider2_r) > 0 then
set(customslider2_r, (last_states_r[2]*8 - (get(totaltime) - time_now[2])) / 8)
if get(customslider2_r) < 0 then
set(customslider2_r, 0)
end
end

--custstomslider3
if get(customslider3) == 1 and get(customslider3_r) < 1 then
set(customslider3_r, ((get(totaltime) - time_now[3]) / 4)+last_states_r[3])
if get(customslider3_r) > 1 then
set(customslider3_r, 1)
end
end

if get(customslider3) == 0 and get(customslider3_r) > 0 then
set(customslider3_r, (last_states_r[3]*4 - (get(totaltime) - time_now[3])) / 4)
if get(customslider3_r) < 0 then
set(customslider3_r, 0)
end
end

--custstomslider4 - emergency exit
if get(customslider4) == 1 and get(customslider4_r) < 1 then
set(customslider4_r, ((get(totaltime) - time_now[4]) / 4)+last_states_r[4])
if get(customslider4_r) > 1 then
set(customslider4_r, 1)
end
end

if get(customslider4) == 0 and get(customslider4_r) > 0 then
set(customslider4_r, (last_states_r[4]*4 - (get(totaltime) - time_now[4])) / 4)
if get(customslider4_r) < 0 then
set(customslider4_r, 0)
end
end

--// electrical

set(bat_on, get(left_bat_h))
set(bat_on2, get(right_bat_h))







if get(bat_on) > 0 or get(bat_on2) > 0 or get(generator_on_l) > 0 or get(generator_on_r) > 0 then
set(cross_tie, get(bus_tie_h))
end

if get(gpu_on) == 1 then
set(cross_tie, 1)
end

if get(APU_generator_on) == 1 and get(APU_running) > 0 then
set(cross_tie, 1)
end








if get(APU_generator_amps) == 0 and get(battery_amps_0) == 0 and get(battery_amps_1) == 0 and get(generator_amps_l) == 0 and get(generator_amps_r) == 0 and get(gpu_on) < 1 then
--	if get(bat_on3) > 0 then
	set(cross_tie, 0)
--	end
end



if get(electr_apugen_h) == 1 then set(APU_generator_on, 1) else set(APU_generator_on, 0) end
if get(electr_gen_l_h) == 1 then set(generator_on_l, 1) else set(generator_on_l, 0) end
if get(electr_gen_r_h) == 1 then set(generator_on_r, 1) else set(generator_on_r, 0) end



if electric_last[1] - get(electr_extp_h) ~= 0 and get(electr_extp_h) == 1 then set(bus_tie_h, 1) end
if electric_last[1] - get(electr_extp_h) ~= 0 and get(electr_extp_h) == 0 then set(bus_tie_h, 0) end


if get(onground_all) == 1 and get(groundspeed) < 0.5 then
set(electr_extp_avail, 0.7)
	if get(bus_tie_h) == 1 then
	set(gpu_on, get(electr_extp_h))
	else
	set(gpu_on, 0)
	end
else
set(electr_extp_avail, 0)
set(electr_extp_h, 0)
set(gpu_on, 0)
end

if get(electr_extp_avail) > 0 then
set(electr_extp, get(electr_extp_h))
else
set(electr_extp, 0)
end

--[=[
if get(bat_on) < 1 and get(bat_on2) < 1 and get(APU_generator_on) < 1 then
set(cross_tie, 0)
else
end

if get(elbus1) >=10 or get(elbus2) >=10 then
set(cross_tie, get(bus_tie_h))
end



if get(elbus1) < 10 or get(elbus2) < 10 then

end
--]=]




set(bat_on3, get(electr_stbi_h))








if get(bleed_apu_h) > 0.5 then
	if get(APU_running) > 0 then
	set(bleed_air_mode, 4)
	else
	set(bleed_air_mode, 2)
	end
else
if get(bleed_en_l_h) < 0.5 and get(bleed_en_r_h) < 0.5 then set(bleed_air_mode, 0) end
if get(bleed_en_l_h) > 0.5 and get(bleed_en_r_h) > 0.5 and get(bleed_xbleed_h) < 0.5 then set(bleed_air_mode, 2) end
if get(bleed_en_l_h) > 0.5 and get(bleed_en_r_h) < 0.5 and get(bleed_xbleed_h) < 0.5 then set(bleed_air_mode, 1) end
if get(bleed_en_l_h) < 0.5 and get(bleed_en_r_h) > 0.5 and get(bleed_xbleed_h) < 0.5 then set(bleed_air_mode, 3) end

if get(bleed_en_l_h) > 0.5 and get(bleed_en_r_h) > 0.5  and get(bleed_xbleed_h) > 0.5 then
set(bleed_air_mode, 2)
else
if get(bleed_en_l_h) > 0.5 and get(bleed_en_r_h) < 0.5  and get(bleed_xbleed_h) > 0.5 then set(bleed_air_mode, 2) end
if get(bleed_en_l_h) < 0.5 and get(bleed_en_r_h) > 0.5  and get(bleed_xbleed_h) > 0.5 then set(bleed_air_mode, 2) end
end

end


if get(bleed_en_l_h) < 0.5 and get(bleed_en_r_h) < 0.5 and get(APU_running) < 1 then set(bleed_air_mode, 0) end



--// Annuns lightning

local night_coeff = (get(night_lights)*get(night_lights)*0.8)+0.2
local night_coeff2 = (get(night_lights)*0.4)+0.6

if get(elbus1) >=10 or get(elbus2) >=10 then
annun_coeff = (get(annun_h)*0.3)+0.7
elseif get(elbus1) >= 10 and get(elbus2) >= 10 then annun_coeff = (get(annun_h)*0.3)+0.7
elseif get(elbus1) < 10 and get(elbus2) < 10 then annun_coeff = 0
end



set(bleed_apu, get(bleed_apu_h)*annun_coeff)



set(bleed_en_l, (1-get(bleed_en_l_h))*annun_coeff)
set(bleed_en_r, (1-get(bleed_en_r_h))*annun_coeff)
set(bleed_xbleed, get(bleed_xbleed_h)*annun_coeff)

if s_l == 1 or s_r == 1 then set(bleed_xbleed, annun_coeff) end

set(annun, get(anns_lit)*annun_coeff)
set(entrlight, get(entrlight_h)*annun_coeff)
set(cablight, get(cablight_h)*annun_coeff)
set(right_bat, (1-get(right_bat_h))*annun_coeff)
set(left_bat, (1-get(left_bat_h))*annun_coeff)
set(bus_tie, get(bus_tie_h)*annun_coeff)

set(flight_spoil, get(flight_spoil_h)*annun_coeff)

set(fuel_xflow_up, get(fuel_xflow_up_h)*annun_coeff)
set(fuel_xflow_dn, get(fuel_xflow_dn_h)*annun_coeff)

set(nws, (1-get(nws_h))*annun_coeff)


set(taws_ter, (1-get(taws_ter_h))*annun_coeff)
set(taws_flp, (1-get(taws_flp_h))*annun_coeff)
set(taws_gs, (1-get(taws_gs_h))*annun_coeff)

set(aircond_man_temp, get(aircond_man_temp_h)*annun_coeff)
set(aircond_ramair, get(aircond_ramair_h)*annun_coeff)

set(pressure_man, get(pressure_man_h)*annun_coeff)
set(pressure_ditch, get(pressure_ditch_h)*annun_coeff)
set(pressure_emer_depr, get(pressure_emer_depr_h)*annun_coeff)





-- atni ice system
set(antice_wshld_r, (1-get(antice_wshld_r_h))*annun_coeff)
set(antice_wshld_l, (1-get(antice_wshld_l_h))*annun_coeff)
if (get(antice_wshld_l_h)) > 0 then set(ice_window_heat_on, 1) end
if (get(antice_wshld_r_h)) > 0 then set(ice_window_heat_on, 1) end
if (get(antice_wshld_l_h)) < 1 and (get(antice_wshld_r_h)) < 1 then set(ice_window_heat_on, 0) end
if (get(antice_wshld_l_h)) > 1 and (get(antice_wshld_r_h)) > 1 then set(ice_window_heat_on, 1) end

set(antice_engn_r, get(antice_engn_r_h)*annun_coeff)
set(antice_engn_l, get(antice_engn_l_h)*annun_coeff)
if get(antice_engn_r_h) > 0 then set(ice_inlet_heat_on, 1) end
if get(antice_engn_l_h) > 0 then set(ice_inlet_heat_on, 1) end
if get(antice_engn_l_h) < 1 and get(antice_engn_r_h) < 1 then set(ice_inlet_heat_on, 0) end




set(antice_probe_r, (1-get(antice_probe_r_h))*annun_coeff)
set(antice_probe_l, (1-get(antice_probe_l_h))*annun_coeff)

if get(antice_probe_l_h) > 0 then
set(ice_pitot_heat_on_pilot, 1)
set(ice_AOA_heat_on, 1)
else
set(ice_pitot_heat_on_pilot, 0)
end

if get(antice_probe_r_h) > 0 then
set(ice_pitot_heat_on_copilot, 1)
set(ice_AOA_heat_on, 1)
else
set(ice_pitot_heat_on_copilot, 0)
end

if get(antice_probe_r_h) < 1 and get(antice_probe_l_h) < 1 then set(ice_AOA_heat_on, 0) end





--
set(antice_wing, get(antice_wing_h)*annun_coeff)

if get(antice_wing_h) > 0 and get(ENGN_running_l) > 0 then
set(ice_surfce_heat_left_on, 1)
else
if get(antice_wing_h) > 0 and get(antice_wngsource_r) < 2 and get(ENGN_running_l) < 1 then
set(ice_surfce_heat_left_on, 0)
end
end

if get(antice_wing_h) > 0 and get(ENGN_running_r) > 0 then
set(ice_surfce_heat_right_on, 1)
else
if get(antice_wing_h) > 0 and get(antice_wngsource_r) > 0 and get(ENGN_running_r) < 1 then
set(ice_surfce_heat_right_on, 0)
end
end

if get(antice_wngsource_r) == 0 and get(ENGN_running_l) < 1 then
set(ice_surfce_heat_left_on, 0)
set(ice_surfce_heat_right_on, 0)
end
if get(antice_wngsource_r) == 2 and get(ENGN_running_r) < 1 then
set(ice_surfce_heat_left_on, 0)
set(ice_surfce_heat_right_on, 0)
end



if get(antice_wing_h) < 1 then
set(ice_surfce_heat_left_on, 0)
set(ice_surfce_heat_right_on, 0)
end


--]=]
--------





set(electr_apugen, get(electr_apugen_h)*annun_coeff)

set(electr_gen_r, (1-get(generator_on_r))*annun_coeff)
set(electr_gen_l, (1-get(generator_on_l))*annun_coeff)




set(electr_stbi, (1-get(electr_stbi_h))*annun_coeff)








set(hydr_altn_flp, get(hydr_altn_flp_h)*annun_coeff)
set(hydr_l_sov, (1-get(hydr_l_sov_h))*annun_coeff)
set(hydr_r_sov, (1-get(hydr_r_sov_h))*annun_coeff)

set(trim_pusher, (1-get(trim_pusher_h))*annun_coeff)


set(fire_engn_r, (get(fire_engn_r_h))*annun_coeff)
set(fire_engn_l, (get(fire_engn_l_h))*annun_coeff)
set(fire_apu, (get(fire_apu_h))*annun_coeff)
set(fire_ext_2, (get(fire_ext_2_h))*annun_coeff)
set(fire_ext_1, (get(fire_ext_1_h))*annun_coeff)
set(fire_autoapr, (1-get(fire_autoapr_h))*annun_coeff)

set(engn_ign, (get(engn_ign_h))*annun_coeff)

set(oxigen_terap, (get(oxigen_terap_h))*annun_coeff)

set(cab_ac, (1-get(cab_ac_h))*annun_coeff)
set(cab_dc, (1-get(cab_dc_h))*annun_coeff)

set(dcu_b, (1-get(dcu_b_h))*annun_coeff)
set(dcu_a, (1-get(dcu_a_h))*annun_coeff)

set(elt, (get(elt_h)))

set(comps_head_r, (get(comps_head_r_h))*annun_coeff)
set(comps_head_l, (get(comps_head_l_h))*annun_coeff)

set(aud_pa_l, (get(aud_pa_l_h)))
set(aud_cab_l, (get(aud_cab_l_h)))
set(aud_hf2_l, (get(aud_hf2_l_h)))
set(aud_hf1_l, (get(aud_hf1_l_h)))
set(aud_com3_l, (get(aud_com3_l_h)))
set(aud_com2_l, (get(aud_com2_l_h)))
set(aud_com1_l,(get(aud_com1_l_h)))

set(aud_pa_r, (get(aud_pa_r_h)))
set(aud_cab_r, (get(aud_cab_r_h)))
set(aud_hf2_r, (get(aud_hf2_r_h)))
set(aud_hf1_r, (get(aud_hf1_r_h)))
set(aud_com3_r, (get(aud_com3_r_h)))
set(aud_com2_r, (get(aud_com2_r_h)))
set(aud_com1_r,(get(aud_com1_r_h)))

set(engn_mach, (get(engn_mach_h))*annun_coeff)


-- aircond

if get(aircond_man_temp_h) > 0 then
set(aircond_tempr_cock_ddial, 40 + get(aircond_cockpit_temp)*30)
set(aircond_tempr_cab_ddial, 40 + get(aircond_cabin_temp)*30)
else
set(aircond_tempr_cock_ddial, 25 + get(aircond_cockpit_temp)*10)
set(aircond_tempr_cab_ddial, 25 + get(aircond_cabin_temp)*10)
end







-- to blank avionics when power is off

if get(elbus2) >=10 then
	if get(electr_ess_p_status) == 0 then
	set(avion_lit2, 1)
	set(cockavr, 1 - ((get(cmfd)*0.125) + (get(cpfd)*0.125) + (get(pmfd)*0.125) + (get(ppfd)*0.125)) )
	else
	set(avion_lit2, 0)
	set(cockavr, 0)
	end
else
set(avion_lit2, 0)
set(cockavr, 0)
end


if get(elbus3) >=10 and get(bat_on3) > 0 then
set(avion_lit3, 1)
else
set(avion_lit3, 0)
end

if get(rev_pan_l) == 1 then
if get(electr_ess_p_status) == 0 then set(cockavl_p, get(cockavl)) else set(cockavl_p, 0) end
set(cockavl_m, get(cockavl))
else
	if get(rev_pan_l) == 0 then
	if get(electr_ess_p_status) == 0 then set(cockavl_p, get(cockavl)) else set(cockavl_p, 0) end
	set(cockavl_m, 0)
	else
	set(cockavl_p, 0)
	set(cockavl_m, get(cockavl))
	end
end

if get(rev_pan_r) == 1 then
set(cockavr_p, get(cockavr))
set(cockavr_m, get(cockavr))
else
	if get(rev_pan_r) == 0 then
	set(cockavr_p, get(cockavr))
	set(cockavr_m, 0)
	else
	set(cockavr_p, 0)
	set(cockavr_m, get(cockavr))
	end
end

-- left electric bus


if get(elbus1) >=10 then

	set(gshldl, get(gshldl_h))
	set(pedestal, get(pedestal_h))
	set(ppfd, 1-get(ppfd_h))
	set(pmfd, 1-get(pmfd_h))
	set(wing_insp, get(wing_insp_h)*night_coeff)
	set(wing_insp_b, get(wing_insp_h))
	set(beac_brt, get(beac_brt_rat)*night_coeff)
	set(entry_lit, get(entrlight_h))

	set(crewlit, get(crewlit_h)*night_coeff2)
	set(crewlit2, get(crewlit2_h)*night_coeff2)

   if get(rembf10) == 1 and get(nws_h) == 1 and get(hydr_pres_1) > 2100 then
    set(acf_nw_steerdeg1, 35)
    set(acf_nw_steerdeg2, 5)
	else
	set(acf_nw_steerdeg1, 0.1)
    set(acf_nw_steerdeg2, 0.1)
    end




		if get(strobe_h) == 2 then
		set(beaconlights, 1)
--		set(stroblights, 1)
		end
		if get(strobe_h) == 1 then
		set(beaconlights, 1)
--		set(stroblights, 0)
		end
		if get(strobe_h) == 0 then
		set(beaconlights, 0)
--		set(stroblights, 0)
		end

		set(avion_lit1, 1)
		set(cockavl, 1 - ((get(cmfd)*0.125) + (get(cpfd)*0.125) + (get(pmfd)*0.125) + (get(ppfd)*0.125)) )

-- left landing lights
		if get(landlight1_h) == 1 then
		--set(landlights, 1)
		set(landlights_1, 1)
		set(landlight1, 1)
		--set(landlight1, get(landlights_rat))
		else
		set(landlight1, 0)
		end




else

set(beac_brt, 0)
set(gshldl, 0)
set(pedestal, 0)
set(ppfd, 0)
set(pmfd, 0)
set(cockavl, 0)
set(wing_insp, 0)
set(wing_insp_b, 0)

set(beaconlights, 0)

set(cabin_lit, 0)
set(entrlight, 0)
set(entry_lit, 0)
set(crewlit, 0)
set(landlight1, 0)

set(avion_lit1, 0)

set(acf_nw_steerdeg1, 0.1)
set(acf_nw_steerdeg2, 0.1)

end


-- right electric bus
if get(elbus2) >=10 then

	set(cabin_lit, get(cablight_h))
	set(dome, get(dome_h)*night_coeff2)
	set(cbp, get(cbp_h))
	set(cpfd, 1-get(cpfd_h))
	set(cmfd, 1-get(cmfd_h))
	set(gshldr, get(gshldr_h))

	if get(strobe_h) == 2 then
		set(stroblights, 1)
	end
	if get(strobe_h) == 1 then
	set(stroblights, 0)
	end
	if get(strobe_h) == 0 then
	set(stroblights, 0)
	end

		if get(nav_h) == 2 then
		set(logo, night_coeff)
		set(navlights, 1)
		end
		if get(nav_h) == 1 then
		set(logo, 0)
		set(navlights, 1)
		end
		if get(nav_h) == 0 then
		set(logo, 0)
		set(navlights, 0)
		end

	-- taxilight
		if get(xap_taxilight_h) > 0 and get(gear_dep_0) > 0.6 then
		set(xap_taxilight2, 1)
		set(taxi, 1)
			if get(xap_taxilight_h) > 1 then
			set(xap_taxilight, 1)
			else
			set(xap_taxilight, 0)
			end
		else
		set(taxi, 0)
		set(xap_taxilight, 0)
		set(xap_taxilight2, 0)
		end

		if get(gear_dep_0) > 0.6 and get(xap_taxilight) == 2 then
		set(xap_taxilight2, 1)
		set(taxi, 1)
		elseif get(gear_dep_0) <= 0.6 then set(xap_taxilight2, 0)
		end
-- right landing light
		if get(landlight2_h) == 1 then
		--set(landlights, 1)
	    set(landlights_2, 1)
		--set(landlight2, get(landlights_rat))
		set(landlight2, 1)
		else
		set(landlight2, 0)
		end

else
set(stroblights, 0)
set(dome, 0)
set(cbp, 0)
set(gshldr, 0)
set(cpfd, 0)
set(cmfd, 0)
set(xap_taxilight, 0)
set(xap_taxilight2, 0)
set(landlight2, 0)
set(logo, 0)
set(navlights, 0)
set(cablight, 0)
end

if get(landlight1_h) == 1 and get(landlight2_h) == 1 then
set(acf_lanlite_the, -9)
elseif get(landlight1_h) == 1 or get(landlight2_h) == 1 then set(acf_lanlite_the, -9.5)
else
if get(xap_taxilight_h) < 2 then
set(acf_lanlite_the, -7)
else
set(acf_lanlite_the, -5.5)
end
end


--disabling eicas 3d
if get(avion_lit1) == 0 and get(avion_lit2) == 0 then set(eicas_3d_p,0) end





-- stby el logic
if get(elbus3) >=10 and get(bat_on3) > 0 and get(avion_lit3) ~= 0 then
set(stby_ins_lit, 0.5*get(stby_ins_dim_brt))
else
if get(elbus3) < 10 or get(avion_lit3) == 0 then set(stby_ins_lit, 1) end
end


if get(landlight1_h) == 0 then
set(landlights_1, 0)
end

if get(landlight2_h) == 0 then
set(landlights_2, 0)
--set(landlights, 0)
end

-- emer lightning

if get(emeright_h) == 1 then
   if get(elbus2) <=10 then
   set(emeright, 1)
   else
   set(emeright, 0)
   end
end

if get(emeright_h) == 2 then
set(emeright, 1)
end

if get(emeright_h) == 0 then
set(emeright, 0)
end

-- sunscreen
 if get(view) == 0 then
    if get(sunscreen11) > 0.5 or get(sunscreen21) > 0.5 then
     set(sunglases, 1)
	 elseif get(sunscreen11) <= 0.5 and get(sunscreen21) <= 0.5 then set(sunglases, 0)
 end
else
set(sunglases, 0)
end




--//Emergency door light logic



if get(emer_door_open) > 0.001 and get(salon_lit) > 0.2 then
	set(emer_door_lit, get(emer_door_open))
else
	set(emer_door_lit, 0)
end

--//Cabin signs
if get(smokebelts_h) == 1 and get(elbus1) >= 10 then
   set(belt, 1)
   set(smoke, 0)
   else
       if get(smokebelts_h) == 2 and get(elbus1) >= 10 then
	   set(smoke, 1)
	   set(belt, 1)
	   else
	   if get(smokebelts_h) == 0 or get(elbus1) < 10 then
	   set(smoke, 0)
	   set(belt, 0)
	   end
   end
end

-- depress when on ground



-- depress with opened doors
if get(customslider2_r) > 0.1  or get(customslider4_r) > 0.1 or get(customslider3_r) > 0.1 then
set(dump_all, 1)
set(rel_depres_fast, 6)
else
	if last_states_r[2] -get(customslider2_r) ~= 0 or last_states_r[3] -get(customslider3_r) ~= 0 or last_states_r[4] -get(customslider4_r) ~= 0 then
		if get(customslider2_r) == 0 and get(customslider4_r) == 0 and get(customslider3_r) == 0 then
		set(dump_all, 0)
		set(rel_depres_fast, 0)
		end
	end
end



-- automatic pressurization
set(barometer_setting_in_hg_copilot, 29.92)
if get(pressure_man_h) < 1 then
set(cabin_vvi_fpm, 650)
	if get(onground_all) == 1 then set(dump_all, 1) end
	if last_states[24] - get (onground_all) ~= 0 and get(onground_all) == 0 then set(dump_all, 0) end
set(cabin_altitude_ft, 2.7858*(get(altitude_ft_copilot)/1000)*(get(altitude_ft_copilot)/1000)+53.968*(get(altitude_ft_copilot)/1000)-219.85)
else
	if get(customslider2_r) == 0 and get(customslider4_r) == 0 and get(customslider3_r) == 0 and get(pressure_emer_depr_h) == 0 and get(pressure_ditch_h) == 0 then
	set(dump_all, 0)
	end

set(cabin_vvi_fpm, math.abs(get(pressure_manrate)*get(pressure_manrate))*2500)
if get(pressure_manrate) < -0.14 then
set(cabin_altitude_ft, 0)
elseif get(pressure_manrate) > 0.14 then set(cabin_altitude_ft, 7850)
--(1+get(pressure_manrate))*(1+get(pressure_manrate))*4102-350)
end

end

if get(pressure_manrate) < 0.14 and get(pressure_manrate) > -0.14 then
set(pressure_manrate,0)
end

if get(pressure_emer_depr_h) == 1 then
set(dump_all, 1)
end

if get(pressure_ditch_h) == 1 then
set(dump_all, 1)
end


-- blocking doors with pressure
if get(pressure_diffential_psi) > 0.5 then
if get(customslider2_r) < 0.1 then
set(customslider2, 0)
set(customslider2_r, 0)
end
if get(customslider3_r) < 0.1 then
set(customslider3, 0)
set(customslider3_r, 0)
end
if get(customslider4_r) < 0.1 then
set(customslider4, 0)
set(customslider4_r, 0)

end
end


-- systems test
--systest_last = {get(test_rot),get(test_push)}




if get(test_rot) == 1 and  get(test_push) == 1 then
counter_1 = counter_1 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
	if get(test_rot) ~= 1 then
	counter_1 = 0
	end
end

if get(test_rot) == 2 and  get(test_push) == 1 then
counter_3 = counter_3 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
	if get(test_rot) ~= 2 then
	counter_3 = 0
	end
end

if counter_1 > 5 then counter_2 = counter_2 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end
if counter_3 > 5 then counter_4 = counter_4 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end

if counter_2 > 20 or counter_1 == 0 then
counter_1 = 0
counter_2 = 0
end


if counter_4 > 20 or counter_3 == 0 then
counter_3 = 0
counter_4 = 0
end

set(annun1_aur, counter_2)
set(annun2_aur, counter_4)

if counter_2 > 0 or counter_4 > 0 then
set(bleed_apu, annun_coeff)
set(bleed_en_l, annun_coeff)
set(bleed_en_r, annun_coeff)
set(bleed_xbleed, annun_coeff)
set(annun, annun_coeff)
set(entrlight, annun_coeff)
set(cablight, annun_coeff)
set(right_bat, annun_coeff)
set(left_bat, annun_coeff)
set(bus_tie, annun_coeff)
set(flight_spoil, annun_coeff)
set(fuel_xflow_up, annun_coeff)
set(fuel_xflow_dn, annun_coeff)
set(nws, annun_coeff)
set(taws_ter, annun_coeff)
set(taws_flp, annun_coeff)
set(taws_gs, annun_coeff)
set(aircond_man_temp, annun_coeff)
set(aircond_ramair, annun_coeff)
set(pressure_man, annun_coeff)
set(pressure_ditch, annun_coeff)
set(pressure_emer_depr, annun_coeff)
set(antice_wshld_r, annun_coeff)
set(antice_wshld_l, annun_coeff)
set(antice_probe_r, annun_coeff)
set(antice_probe_l, annun_coeff)
set(antice_engn_r, annun_coeff)
set(antice_engn_l, annun_coeff)
set(antice_wing, annun_coeff)
set(electr_apugen, annun_coeff)
set(electr_gen_r, annun_coeff)
set(electr_gen_l, annun_coeff)
set(electr_stbi, annun_coeff)
set(hydr_altn_flp, annun_coeff)
set(hydr_l_sov, annun_coeff)
set(hydr_r_sov, annun_coeff)
set(trim_pusher, annun_coeff)
set(fire_engn_r, annun_coeff)
set(fire_engn_l, annun_coeff)
set(fire_apu, annun_coeff)
set(fire_ext_2, annun_coeff)
set(fire_ext_1, annun_coeff)
set(fire_autoapr, annun_coeff)
set(engn_ign, annun_coeff)
set(oxigen_terap, annun_coeff)
set(cab_ac, annun_coeff)
set(cab_dc, annun_coeff)
set(dcu_b, annun_coeff)
set(dcu_a, annun_coeff)
set(comps_head_r, annun_coeff)
set(comps_head_l, annun_coeff)
set(engn_mach, annun_coeff)

set(mast_warn, 1)
set(mast_caut, 1)


end








-- probe det
if get(test_rot) == 3 and  get(test_push) == 1 then
counter_5 = counter_5 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
	if get(test_rot) ~= 3 then
	counter_5 = 0
	end
end

if counter_5 > 5 then counter_6 = counter_6 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end

if counter_6 > 18 or counter_5 == 0 then
counter_5 = 0
counter_6 = 0
end

set(probs_test, 0)
if counter_6 > 7 then
set(probs_test, 1)
end



-- ice det
if get(test_rot) == 5 and  get(test_push) == 1 then
counter_13 = counter_13 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
	if get(test_rot) ~= 5 then
	counter_13 = 0
	end
end

if counter_13 > 5 then counter_14 = counter_14 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end

if counter_14 > 18 or counter_13 == 0 then
counter_13 = 0
counter_14 = 0
end

set(ice_test, 0)
if counter_14 > 7 then
set(ice_test, 1)
end





--fire det test
if get(test_rot) == 6 and  get(test_push) == 1 then
counter_7 = counter_7 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
	if get(test_rot) ~= 6 then
	counter_7 = 0
	end
end

if counter_7 > 5 then counter_8 = counter_8 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end

if counter_8 > 10 or counter_7 == 0 then
counter_7 = 0
counter_8 = 0
end


set(fire_test_aur, counter_8)

--taws test
if get(test_rot) == 7 and  get(test_push) == 1 then
counter_9 = counter_9 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
	if get(test_rot) ~= 7 then
	counter_9 = 0
	end
end

if counter_9 > 5 then counter_10 = counter_10 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end

if counter_10 > 12 or counter_9 == 0 then
counter_9 = 0
counter_10 = 0
end


set(taws_test_aur, counter_10)


--rudd lim test
if get(test_rot) == 4 and  get(test_push) == 1 then
counter_11 = counter_11 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
else
	if get(test_rot) ~= 4 then
	counter_11 = 0
	end
end

if counter_11 > 5 then counter_12 = counter_12 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end

if counter_12 > 10 or counter_11 == 0 then
counter_11 = 0
counter_12 = 0
end

set(rudlim_test, 0)
if counter_12 > 0 then
set(rudlim_test, 1)
end

set(stall_warn_test, 0)
if counter_12 > 8 and counter_12 < 9 then
set(stall_warn_test, 1)
end


--voice rec test
if get(elbus1) >=10 or get(elbus2) >=10 then
	if get(voice_rec_test) == 1 then
	counter_15 = counter_15 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused)
	else
	--counter_15 = 0
	end

	if counter_15 > 5 then counter_16 = counter_16 + 0.05*((get(frame_rate_period)-0.02)*25 + 0.5)*get(paused) end

	if counter_16 > 7 then
	counter_15 = 0
	counter_16 = 0
	end

else
counter_15 = 0
counter_16 = 0
end

if counter_16 > 0 then
set(voice_rec_test_lt, 1)
else
set(voice_rec_test_lt, 0)
end

if get(crc_butt) == 1 then
set(hsi_obs_deg_mag_pilot, get(heading_AHARS_deg_mag_pilot))
end

--

-- landing gear warn

if get(onground_all) == 0 and get(gear_handle_status) == 0 and get(flaprqst) > 0.67 then
set(lan_gear_warn, 1)
else
set(lan_gear_warn, 0)
end



-- auto gens



if electric_last[2] - get(ENGN_running_l) ~= 0 then
	if get(ENGN_running_l) == 1 then
	set(electr_gen_l_h, 1)
	else
	set(electr_gen_l_h, 0)
	end
end

if electric_last[3] - get(ENGN_running_r) ~= 0 then
	if get(ENGN_running_r) == 1 then
	set(electr_gen_r_h, 1)
	else
	set(electr_gen_r_h, 0)
	end
end

if electric_last[4] - get(APU_running) ~= 0 then
	if get(APU_running) == 1 then
	set(electr_apugen_h, 1)
	else
	set(electr_apugen_h, 0)
	end
end

if get(gust_lock) == 1 then
set(rel_fc_ail_L, 6)
set(rel_fc_ail_R, 6)
else
set(rel_fc_ail_L, 0)
set(rel_fc_ail_R, 0)
end







set(disp, get(gust_lock_anm))
set(disp2, get(gust_lock))
last_states = {get(customslider1), get(customslider2), get(customslider3), get(customslider4), get(rembf10),get(rembf11),get(rembf12), get(rembf2), get(rembf7), get(rembf1), get(rembf6), get(rembf4),get(rembf8),get(prop_mode_0),get(prop_mode_1), get(sbrk_h), gr_sp_deployed,get(en_starter_l),get(en_starter_r),get(clock_timer_h),get(engn_mach_status),get(ENGN_thro_0),get(engn_mach_h),get(onground_all), get(pressure_manrate), get(dcp_range),get(rembf5),get(rembf13),get(rembf14)}
--					1						2					3					4				5				6			7			8				9			10			11			12			13			14					15				16			17					18				19					20					21					22				23				24					25					26				27			28			29
autop_last = {get(autop_airspeed_dial), get(autop_fdir_h), get(autop_nav_h), get(autop_hdg_h), get(autop_appr_h), get(autop_bc_h), get(autop_flc_h), get(autop_vs_h), get(autop_vnav_h), get(autop_alt_h), get(autop_ap_h), get(autop_xfr_h), get(autop_yd_h)}
--						1						2					3				4					5					6				7				8					9					10				11				12				13
coms_last = {get(aud_com1_r_h),get(aud_com2_r_h),get(aud_com3_r_h),get(aud_com1_l_h),get(aud_com2_l_h),get(aud_com3_l_h),get(autop_brgsrc),get(dcp_navsrc),get(dcp_refs),get(mfd_sel_state), get(mfd_sel_state_h)}
--						1				2					3				4					5				6				7					8			9				10						11
refspds_last = {get(refspds_v1),get(refspds_vr),get(refspds_v2),get(refspds_vt),get(refspds_vga),get(refspds_vref),get(rev_air_dat)}
--						1				2				3				4				5					6				7
caution_last = {get(red_cas),get(yellow_cas)}
--
systest_last = {get(test_rot),get(test_push)}
--
starter_last = {get(starter_duration_l),get(starter_duration_r)}
--
electric_last = {get(electr_extp_h),get(ENGN_running_l),get(ENGN_running_r),get(APU_running),get(dcp_menu1_rot)}
--						1						2				3					4					5
end
