Alessandro Usai Posted October 21, 2019 Report Posted October 21, 2019 On 10/18/2019 at 10:35 PM, aua668 said: Hi, In the included ZIP-File I added two files: One is a definition file for the XML-functions I use with my hardware. The numbers I got from the provided utility, which calculates the hash value for the specific variable. The second file is a sample module, which toggles the TOGA button. For every button I have such a routine. In a master file, which is automatically started, I start all my modules for the Q400 with ipc.runlua("<<<modulename>>>") For reading values from the XML interface I use one single module transferring all the necessary XML-Values into global variables, which later I can use in different modules. The core of the routine can be seen here: -- initialize XML interface to HW function readXMLIF ( pFunc ) -- function to read specific IF value local lMJC_readCode local lMJC_readValue local lCount = 0 -- select function by hash code ipc.writeLvar("L:MJC_VAR_READ_CODE", pFunc) ipc.sleep(5) -- read results lMJC_readCode = ipc.readLvar("L:MJC_VAR_READ_CODE") -- wait if not ready while lMJC_readCode ~= 9991999 and lMJC_readCode ~= 9992999 and lCount < 20 do lCount = lCount + 1 ipc.sleep(10) lMJC_readCode = ipc.readLvar("L:MJC_VAR_READ_CODE") end if lMJC_readCode == 9991999 then lMJC_readValue = ipc.readLvar("L:MJC_VAR_READ_VALUE") -- success else lMJC_readValue = 9992999 -- variable not found ipc.log("Error reading MJC interface for function "..pFunc) end return lMJC_readValue -- return value or error end function readAllXMLValues() -- synchronize global variables from Q400 values -- autopilot ipc.set ("Q400_YD_LIGHT" , readXMLIF ( 31461 ) ) -- AFCS_->outputs.YD_engaged ipc.set ("Q400_AP_LIGHT" , readXMLIF ( 31281 ) ) -- AFCS_->outputs.AP_engaged -- glare shield ipc.set ("Q400_CAUTION" , readXMLIF ( 143090 ) ) -- CautionWarning_->outs_.master_caution_light_blinking ipc.set ("Q400_WARNING" , readXMLIF ( 143112 ) ) -- CautionWarning_->outs_.master_warning_light_blinking -- fuel ipc.set ("Q400_AUX_FUEL" , readXMLIF ( 59590 ) ) -- Fuel_->systems[0].AuxFuelPumplight -- Autofeather ipc.set ("Q400_AUTO_FEATHER" , readXMLIF ( 41047 ) ) -- PCU_->AutofeatherSelectLight -- Hydraulic ipc.set ("Q400_HYDRAULIC" , readXMLIF ( 91735 ) ) -- Hydraulical_->outs_.stby_hydr_ON_indicator end while 0 < 1 do readAllXMLValues() ipc.sleep(50) end The reason, why I read all the values at once in one single module is, that the interface always fetches one single value at one time. If you would call it from several independent threads, the calls could interfere. This is a limitation of the current XML interface. The training edition will include a more sophisticated interface. Luckily most of the values can be read directly out of Lvars and you can avoid the XML-Interface. So a simple ipc.readLvar("<<<variable name>>>") will provide you the value directly. If you have no programming skills, it's hard. Maybe you find some student nearby, which helps you with that part. You can offer him later some simulator hours 😉 Rgds Reinhard Hi Reinhard, just one question: when you refer to ipc.readLvar("<<<variable name>>>") is "<<<variable name>>> the variable name as is called in variablesmap.xlsx spreadsheet? Example: ipc.readLvar("AFCS_->outputs.AP_engaged") Thanks, Alessandro
aua668 Posted October 21, 2019 Report Posted October 21, 2019 Hi, No - ipc.readLvar() function reads the Lvars like L:OHD_AC_CTRL_GEN1_SW. here is a list of the variables: L:CPT_CONS_LDG_FLAP_INH_GUARD = 0 L:EFIS_ADC_SRC = 0 L:EFIS_ATTHDG_SRC = 0 L:ENG_LEFT_DOOR_POS = 0 L:ENG_RIGHT_DOOR_POS = 0 L:FC_AILERON_LEFT = -0 L:FC_AILERON_RIGHT = 0 L:FC_COLUMN_LEFT = 50.015181303024 L:FC_COLUMN_RIGHT = 50.015181303024 L:FC_ELEVATOR_LEFT = -14.99771105028 L:FC_ELEVATOR_RIGHT = -14.998748369733 L:FC_FLAPS_LEFT = 0 L:FC_FLAPS_RIGHT = 0 L:FC_GEAR_DOOR_POS_LEFT = 0.5 L:FC_GEAR_DOOR_POS_NOSE = 0.8 L:FC_GEAR_DOOR_POS_RIGHT = 0.5 L:FC_GEAR_LEFT_STRUT = 83.345882343581 L:FC_GEAR_NOSE = 100 L:FC_GEAR_NOSE_STRUT = 85.00757313897 L:FC_GEAR_POS_LEFT = 180 L:FC_GEAR_POS_RIGHT = 180 L:FC_GEAR_RIGHT_STRUT = 83.335765407711 L:FC_NOSE_WHEEL_STEERING = 100 L:FC_PEDALS_LEFT = 49.999848008156 L:FC_PEDALS_RIGHT = 49.999848008156 L:FC_RUDDER = -0 L:FC_SPOILER_LI = 0 L:FC_SPOILER_LO = 0 L:FC_SPOILER_RI = 0 L:FC_SPOILER_RO = 0 L:FC_WHEEL_LEFT = 50.414788722992 L:FC_WHEEL_RIGHT = 50.414788722992 L:Filter = 0 L:FSDT_VAR_Frozen = 0 L:GS_ALTSEL_KNOB_ANGLE = 0 L:GS_ANTISKID_SW = 0 L:GS_CLK1_ARROW_POS = 0 L:GS_CLK1_SELECTOR_POS = 2 L:GS_CLK2_ARROW_POS = 0 L:GS_CLK2_SELECTOR_POS = 2 L:GS_CRS1_KNOB_ANGLE = 100 L:GS_CRS2_KNOB_ANGLE = 100 L:GS_HDG1_KNOB_ANGLE = 0 L:GS_HDG2_KNOB_ANGLE = 0 L:GS_NAV1_KNOB_ANGLE = 14 L:GS_NAV2_KNOB_ANGLE = 21 L:GS_PITCH_WHEEL_ANGLE = 50 L:GS_SPOILERS_SW = 1 L:LastLeftPropPos = 0 L:LastRightPropPos = 0 L:LayerAirports = 0 L:LayerAirspaces = 0 L:LayerCompass = 0 L:LayerILSs = 0 L:LayerIntersections = 0 L:LayerLowAirways = 0 L:LayerNDBs = 0 L:LayerRangeRings = 0 L:LayerTags = 0 L:LayerTerrain = 0 L:LayerVORs = 0 L:MAINPANEL_PUSHBUTTONS = 0 L:MAIN_ALTERNATE_STATIC_POS = 0 L:MAIN_GEAR_HANDLE_POS = 1 L:MAIN_GEAR_HORN_SW = 0 L:MAIN_GEAR_LOCK_POS = 0 L:MAIN_GPWS_FLAP_SLCTR_POS = 0 L:MAIN_INDX1_DH_KNOB_ANGLE = 53 L:MAIN_INDX1_DH_MDA_SW = 0 L:MAIN_INDX1_QNH_KNOB_ANGLE = 59 L:MAIN_INDX1_SPDBUG_KNOB_ANGLE = 67 L:MAIN_INDX2_DH_KNOB_ANGLE = 42 L:MAIN_INDX2_DH_MDA_SW = 0 L:MAIN_INDX2_QNH_KNOB_ANGLE = 79 L:MAIN_INDX2_SPDBUG_KNOB_ANGLE = 69 L:MAIN_STBY_QNH_KNOB_ANGLE = 0 L:MapInit = 0 L:map_ZoomFactor = 0 L:map_ZoomStep = 0 L:MJC_VAR_READ_CODE = 9991999 L:MJC_VAR_READ_VALUE = 0 L:MJC_VAR_WRITE_CODE = 9991999 L:MJC_VAR_WRITE_VALUE = 19400 L:OBS_ADF1_VOL_KNOB = 0 L:OBS_ADF2_VOL_KNOB = 0 L:OBS_AUX1_PB = 0 L:OBS_AUX1_VOL_KNOB = 0 L:OBS_AUX2_PB = 0 L:OBS_AUX2_VOL_KNOB = 0 L:OBS_BOOM_MASK_SW = 0 L:OBS_DME1_VOL_KNOB = 0 L:OBS_DME2_VOL_KNOB = 0 L:OBS_HF_PB = 0 L:OBS_HF_VOL_KNOB = 0 L:OBS_INT_PB = 0 L:OBS_INT_RAD_SW = 0 L:OBS_INT_VOL_KNOB = 0 L:OBS_MKR_VOL_KNOB = 0 L:OBS_VHF1_PB = 0 L:OBS_VHF1_VOL_KNOB = 0 L:OBS_VHF2_PB = 0 L:OBS_VHF2_VOL_KNOB = 0 L:OBS_VOR1_VOL_KNOB = 0 L:OBS_VOR2_VOL_KNOB = 0 L:OBS_VOR_MLS_SW = 0 L:OHD_ACONDPNL_DUCTTEMP_IND_ANGLE = -15 L:OHD_AC_CTRL_EXT_PWR_SW = 0 L:OHD_AC_CTRL_GEN1_SW = 0 L:OHD_AC_CTRL_GEN2_SW = 0 L:OHD_AICE_AFRAME_MAN_KNOB_ANGLE = 0 L:OHD_AICE_AFRAME_MODE_KNOB_ANGLE = 0 L:OHD_AICE_AFRAME_PROPTIMER_KNOB_ANGLE = 0 L:OHD_AICE_BOOT_AIR_SW = 0 L:OHD_AICE_DOOR_PUSHBUTTONS = 0 L:OHD_AICE_ENG_INTAKE_REF_SW = 0 L:OHD_AICE_PITOT_1_SW = 0 L:OHD_AICE_PITOT_2_SW = 0 L:OHD_AICE_PITOT_STBY_SW = 0 L:OHD_AIR_COND_BLEED1_SW = 0 L:OHD_AIR_COND_BLEED2_SW = 0 L:OHD_AIR_COND_BLEED_KNOB = -1 L:OHD_AIR_COND_GAUGE_KNOB = 20 L:OHD_AIR_COND_PACKS1_SW = 0 L:OHD_AIR_COND_PACKS2_SW = 0 L:OHD_AIR_COND_RECIRC_SW = 0 L:OHD_AIR_COND_TEMP_CABIN_KNOB = 49 L:OHD_AIR_COND_TEMP_FCOMP_KNOB = 49 L:OHD_APU_PUSHBUTTONS = 0 L:OHD_CAB_ALT_FWD_OUTFLOW_KNOB = 0 L:OHD_CAB_ALT_LDG_ALT_KNOB = 52 L:OHD_CAB_ALT_MODE_SW = 0 L:OHD_CAB_MAN_OFF_SW = 0 L:OHD_DC_CNTRL_PNL_AUX_SW = 0 L:OHD_DC_CNTRL_PNL_EXTPWR_SW = 0 L:OHD_DC_CNTRL_PNL_GEN1_SW = 0 L:OHD_DC_CNTRL_PNL_GEN2_SW = 0 L:OHD_DC_CNTRL_PNL_MAIN_SW = 0 L:OHD_DC_CNTRL_PNL_MASTER_SW = 0 L:OHD_DC_CNTRL_PNL_RESET_SW = 0 L:OHD_DC_CNTRL_PNL_STB_SW = 0 L:OHD_DC_CNTRL_PNL_TIE_SW = 0 L:OHD_EMER_LT_ARM_SW = 1 L:OHD_EMER_LT_CAUT_BRT_SW = 0 L:OHD_EMER_LT_CAUT_TEST_SW = 0 L:OHD_EMER_LT_FASTEN_BELTS_SW = 0 L:OHD_EMER_LT_NO_SMOKING_SW = 1 L:OHD_ENGSTART_IGN1_KNOB_SW = 1 L:OHD_ENGSTART_IGN2_KNOB_SW = 1 L:OHD_ENGSTART_SELECT_SW = 0 L:OHD_ENG_START_BUTTON = 0 L:OHD_EXT_LIGHTS_L_APPR_SW = 0 L:OHD_EXT_LIGHTS_L_FLARE_SW = 0 L:OHD_EXT_LIGHTS_L_TAXI_SW = 0 L:OHD_EXT_LT_ACOL_SW = 0 L:OHD_EXT_LT_LOGO_SW = 0 L:OHD_EXT_LT_POS_SW = 1 L:OHD_EXT_LT_WING_SW = 0 L:OHD_FDR_GNDTEST_SW = 0 L:OHD_FDR_MODE_SW = 1 L:OHD_FIRE_BAGGAGE_TEST_SW = 0 L:OHD_FIRE_ENG1_EXTH_SW = 0 L:OHD_FIRE_ENG1_PULL_HANDLE = 0 L:OHD_FIRE_ENG2_EXTH_SW = 0 L:OHD_FIRE_ENG2_PULL_HANDLE = 0 L:OHD_FIRE_TEST_DETECTION_SW = 0 L:OHD_PFD_ALT_UNITS_SW = 0 L:OHD_PNL_LIGHTS_CENTER_KNOB_ANGLE = 0 L:OHD_PNL_LIGHTS_DOME_SW = 0 L:OHD_PNL_LIGHTS_ENGPNL_KNOB_ANGLE = 0 L:OHD_PNL_LIGHTS_GLARESHIELD_KNOB_ANGLE = 0 L:OHD_PNL_LIGHTS_OVHD_KNOB_ANGLE = 0 L:OHD_PNL_LIGHTS_STORM_SW = 0 L:OHD_PRESSCOMP_CABALT_IND_ANGLE = 7.15 L:OHD_PRESSCOMP_DIFF_IND_ANGLE = 1.0562358197914e-005 L:OHD_PRESSCOMP_RATE_IND_ANGLE = 50 L:OHD_PRESSPNL_LDGALT_IND_ANGLE = 37.136116 L:OHD_WDO_HEAT_SW = 0 L:OHD_WSHIELD_HEAT_KNOB_ANGLE = 0 L:OHD_WSHIELD_WIPER_KNOB_ANGLE = 1 L:OVH_GUARD_EXT_APU = 0 L:OVH_GUARD_EXT_BGAFT = 0 L:OVH_GUARD_EXT_BGFWD = 0 L:PEDESTAL_PUSHBUTTONS = 0 L:PED_ALT_FTHR_ONE_GUARD = 0 L:PED_ALT_FTHR_TWO_GUARD = 0 L:PED_COM1_FREQ_HI = 50 L:PED_COM1_FREQ_LOW = 40 L:PED_COM1_MODE_KNOB = 0 L:PED_CPT_MFD_BRT_KNOB = 56.250858319982 L:PED_CPT_NAV_SRC_LFT_KNOB = 4 L:PED_CPT_NAV_SRC_RGT_KNOB = 0 L:PED_CPT_PFD_BRT_KNOB = 56.250858319982 L:PED_CPT_RANGE_KNOB = 2 L:PED_CPT_WX_BRT_KNOB = 81.251239795529 L:PED_ED_BRT = 56.250858319982 L:PED_FO_MFD_BRT_KNOB = 56.250858319982 L:PED_FO_NAV_SRC_LFT_KNOB = 4 L:PED_FO_NAV_SRC_RGT_KNOB = 0 L:PED_FO_PFD_BRT_KNOB = 56.250858319982 L:PED_FO_RANGE_KNOB = 2 L:PED_FO_WX_BRT_KNOB = 81.251239795529 L:PED_FUEL_TRANSFER_SWITCH = 0 L:PED_IRS_KNOB = 1 L:PED_MFD1_MODE = 0 L:PED_PITCH_HANDLE = 0 L:PED_ROLL_DISC_HANDLE = 0 L:PED_TRIM_AILERON_SW = 0 L:PED_TRIM_RUDDER_KNOB = 0 L:PED_WR_GAIN = 0.0016212710737955 L:PED_WR_MODE = 0 L:PED_WR_TILT = 0 L:PFD_MFD2_MODE = 1 L:PLANEHEADINGDEGREESGYRO = 0 L:PROP_LEFT_BLADES_ANGLE = 43.275265038013 L:PROP_LEFT_DISK_VISUAL_ANGLE = 0.76904296875 L:PROP_LEFT_RPM = 0 L:PROP_RIGHT_BLADES_ANGLE = 43.275265038013 L:PROP_RIGHT_DISK_VISUAL_ANGLE = 0.1495361328125 L:PROP_RIGHT_RPM = 0 L:Q400_2PILOT_HEAD = -15 L:Q400_2PILOT_POS = 0 L:Q400_AILERON_TRIM_IND_ANGLE = 0 L:Q400_ALT_LG_EXT_COVER = 0 L:Q400_ALT_LG_EXT_HANDLE = 0 L:Q400_ALT_LG_FLOOR_HANDLE = 0 L:Q400_AP_DISENGAGE_KNOB = 0 L:Q400_BEACON_SPLASH = 0 L:Q400_BIRD_STRIKE = 0 L:Q400_CAMERA_PERSPECTIVE = 1 L:Q400_COND_LEVER_1 = 0 L:Q400_COND_LEVER_2 = 0 L:Q400_CONTROL_LOCK = 100 L:Q400_DOMELIGHT = 0 L:Q400_ELEVATOR_TRIM_IND_ANGLE = 99.607843137255 L:Q400_EMER_HATCH = 0 L:Q400_FIRE = 0 L:Q400_FIRE_COCKPIT = 0 L:Q400_FLAP_POS = 0 L:Q400_FLARELIGHT = 0 L:Q400_FUELFLOW_PPH_L = 0 L:Q400_FUELFLOW_PPH_R = 0 L:Q400_FWD_WHEEL = 68.006361624844 L:Q400_GEAR_LEFT_RPM = 0 L:Q400_GEAR_LOCK_PIN_IN = 1 L:Q400_GEAR_NOSE_RPM = 0 L:Q400_GEAR_RIGHT_RPM = 0 L:Q400_GFORCE_FPS = -32.144016132336 L:Q400_GPU_VISIBLE = 1 L:Q400_HUD = 0 L:Q400_HUD_BRIGHTNESS = 100 L:Q400_ICING_LEVEL_INTAKES = 0 L:Q400_ICING_LEVEL_NO_DEICE = 0 L:Q400_ICING_LEVEL_SIDE_WINDOW = 0 L:Q400_ICING_LEVEL_TAIL = 0 L:Q400_ICING_LEVEL_WINDSHIELD = 0 L:Q400_ICING_LEVEL_WINGS = 0 L:Q400_LANDLIGHT = 0 L:Q400_LAND_LTST = 0 L:Q400_LEFT_WHEEL = 18.554237379552 L:Q400_LEVER_ANTIMIST = 0 L:Q400_LG_DNLOCK_VER_SWITCH = 0 L:Q400_LG_DN_SEL_INH_GUARD = 0 L:Q400_LG_DN_SEL_INH_SWITCH = 0 L:Q400_LIGHTTAXI = 0 L:Q400_LOW_VENT_HANDLE = 0 L:Q400_LT_FUSES_LEFT_LT = 0 L:Q400_LT_FUSES_RIGHT_LT = 0 L:Q400_LT_HALL_LT = 0 L:Q400_LT_HALL_SW = 0 L:Q400_LT_MAP_LEFT_LT = 0 L:Q400_LT_MAP_LEFT_SW = 0 L:Q400_LT_MAP_RIGHT_LT = 0 L:Q400_LT_MAP_RIGHT_SW = 0 L:Q400_LT_PILOT_LEFT_LT = 0 L:Q400_LT_PILOT_LEFT_SW = 0 L:Q400_LT_PILOT_RIGHT_LT = 0 L:Q400_LT_PILOT_RIGHT_SW = 0 L:Q400_MAN_GEAR_EXT_HANDLE = 0 L:Q400_MAN_GEAR_EXT_READY = 0 L:Q400_MIST_COPILOTWIN_LEVEL = 7 L:Q400_MIST_PILOTWIN_LEVEL = 0 L:Q400_MIST_WINDSHIELD_LEVEL = 0 L:Q400_NAV_LIGHTS = 0 L:Q400_PILOT_HEAD = 0 L:Q400_PILOT_POS = 0 L:Q400_PITOT_ISOL_VALVE_GUARD = 0 L:Q400_POWER_LEVER_1 = 46.35498046875 L:Q400_POWER_LEVER_2 = 49.69623613931 L:Q400_PROP_LEFT_RPM = 0 L:Q400_PROP_RIGHT_RPM = 0 L:Q400_RAIN_FRAMES = 0 L:Q400_RIGHT_WHEEL = 18.575972976864 L:Q400_RUDDER_TRIM_IND_ANGLE = 0 L:Q400_SIDE_RIGHT_TABLET = 0 L:Q400_SIDE_TABLET = 0 L:Q400_STEERING_TILLER = 56.628936767578 L:Q400_STROBELIGHT_DN = 0 L:Q400_STROBELIGHT_UP = 0 L:Q400_SUN_SHIELD_LEFT = 0 L:Q400_SUN_SHIELD_RIGHT = 0 L:Q400_TYRE_BLOWN_LEFT = 0 L:Q400_TYRE_BLOWN_RIGHT = 0 L:Q400_WINGLIGHT = 0 L:Q400_WIPER_ANGLE = 0 L:Q400_WIPER_RIGHT_ANGLE = 0 L:Q400_YOKE_VISIBILITY = 255 L:RADIO1_ADF1_KNOB = 0 L:RADIO1_ADF2_KNOB = 0 L:RADIO1_AUX1_KNOB = 0 L:RADIO1_AUX2_KNOB = 0 L:RADIO1_BOOM_MASK_SW = 0 L:RADIO1_CENTRAL_KNOB = 0 L:RADIO1_DME1_KNOB = 0 L:RADIO1_DME2_KNOB = 0 L:RADIO1_HF_KNOB = 0 L:RADIO1_HOT_MIC_SW = 0 L:RADIO1_MKR_KNOB = 0 L:RADIO1_NORM_EMER_SW = 0 L:RADIO1_SERV_INT_KNOB = 25.001525972044 L:RADIO1_SPKR_KNOB = 0 L:RADIO1_SRC_SELECTOR = 0 L:RADIO1_TUNE_HIGH = 23 L:RADIO1_TUNE_LOW = 67 L:RADIO1_VHF1_KNOB = 0 L:RADIO1_VHF2_KNOB = 0 L:RADIO1_VOR1_KNOB = 0 L:RADIO1_VOR2_KNOB = 0 L:RADIO2_ADF1_KNOB = 0 L:RADIO2_ADF2_KNOB = 0 L:RADIO2_AUX1_KNOB = 0 L:RADIO2_AUX2_KNOB = 0 L:RADIO2_BOOM_MASK_SW = 0 L:RADIO2_CENTRAL_KNOB = 0 L:RADIO2_DME1_KNOB = 0 L:RADIO2_DME2_KNOB = 0 L:RADIO2_HF_KNOB = 0 L:RADIO2_HOT_MIC_SW = 0 L:RADIO2_MKR_KNOB = 0 L:RADIO2_NORM_EMER_SW = 0 L:RADIO2_SERV_INT_KNOB = 25.001525972044 L:RADIO2_SPKR_KNOB = 0 L:RADIO2_SRC_SELECTOR = 0 L:RADIO2_TUNE_HIGH = 50 L:RADIO2_TUNE_LOW = 50 L:RADIO2_VHF1_KNOB = 0 L:RADIO2_VHF2_KNOB = 0 L:RADIO2_VOR1_KNOB = 0 L:RADIO2_VOR2_KNOB = 0 L:seatFO = 0 L:seatKVS = 0 L:SIDE_PNL_ADC_TEST = 0 L:SIDE_PNL_CIRC_BRK_LT = 0 L:SIDE_PNL_FLT_PNL_BRT = 0 L:SIDE_PNL_FO_CIRC_BRK_LT = 0 L:SIDE_PNL_FO_DEICE1_IND_ANGLE = 0 L:SIDE_PNL_FO_DEICE2_IND_ANGLE = 0 L:SIDE_PNL_FO_FLT_PNL_BRT = 0 L:SIDE_PNL_FO_OXYGEN_IND_ANGLE = 90 L:SIDE_PNL_INPH_XMIT = 0 L:SIDE_PNL_PROP_OSG = 0 L:SIDE_PNL_STALL_WARN_TEST = 0 L:SIDE_PNL_STEERING = 0 L:SIDE_PNL_TO_WARN = 0 L:SMOKE3STATE = 0 L:SMOKE4STATE = 0 L:SMOKE59STATE = 0 L:SPNL_FORWARD_OUTFLOW_VALVE_GUARD = 0 L:SPNL_FWD_OUTFLOW_VALVE = 0 L:VehicleObjectDetail = 0 The variables in the supplied XLS-Sheet must be handled via the XML-interface. Rgds Reinhard
Alessandro Usai Posted October 22, 2019 Report Posted October 22, 2019 Reinhard, thank you. This point is now clear. Just another question: where are Q400's Lvars defined? Thanks, Alessandro
John Dowson Posted October 22, 2019 Report Posted October 22, 2019 As previously posted, you could try the log lvars.lua plugin (see the FSUIPC Lua Plug-Ins manual) which will list all lvars (and their values) available for any loaded aircraft. John
Alessandro Usai Posted October 22, 2019 Report Posted October 22, 2019 John, thanks a lot for reminding me! Alessandro
Alessandro Usai Posted December 1, 2019 Report Posted December 1, 2019 On 10/18/2019 at 10:35 PM, aua668 said: Hi, In the included ZIP-File I added two files: One is a definition file for the XML-functions I use with my hardware. The numbers I got from the provided utility, which calculates the hash value for the specific variable. The second file is a sample module, which toggles the TOGA button. For every button I have such a routine. In a master file, which is automatically started, I start all my modules for the Q400 with ipc.runlua("<<<modulename>>>") For reading values from the XML interface I use one single module transferring all the necessary XML-Values into global variables, which later I can use in different modules. The core of the routine can be seen here: -- initialize XML interface to HW function readXMLIF ( pFunc ) -- function to read specific IF value local lMJC_readCode local lMJC_readValue local lCount = 0 -- select function by hash code ipc.writeLvar("L:MJC_VAR_READ_CODE", pFunc) ipc.sleep(5) -- read results lMJC_readCode = ipc.readLvar("L:MJC_VAR_READ_CODE") -- wait if not ready while lMJC_readCode ~= 9991999 and lMJC_readCode ~= 9992999 and lCount < 20 do lCount = lCount + 1 ipc.sleep(10) lMJC_readCode = ipc.readLvar("L:MJC_VAR_READ_CODE") end if lMJC_readCode == 9991999 then lMJC_readValue = ipc.readLvar("L:MJC_VAR_READ_VALUE") -- success else lMJC_readValue = 9992999 -- variable not found ipc.log("Error reading MJC interface for function "..pFunc) end return lMJC_readValue -- return value or error end function readAllXMLValues() -- synchronize global variables from Q400 values -- autopilot ipc.set ("Q400_YD_LIGHT" , readXMLIF ( 31461 ) ) -- AFCS_->outputs.YD_engaged ipc.set ("Q400_AP_LIGHT" , readXMLIF ( 31281 ) ) -- AFCS_->outputs.AP_engaged -- glare shield ipc.set ("Q400_CAUTION" , readXMLIF ( 143090 ) ) -- CautionWarning_->outs_.master_caution_light_blinking ipc.set ("Q400_WARNING" , readXMLIF ( 143112 ) ) -- CautionWarning_->outs_.master_warning_light_blinking -- fuel ipc.set ("Q400_AUX_FUEL" , readXMLIF ( 59590 ) ) -- Fuel_->systems[0].AuxFuelPumplight -- Autofeather ipc.set ("Q400_AUTO_FEATHER" , readXMLIF ( 41047 ) ) -- PCU_->AutofeatherSelectLight -- Hydraulic ipc.set ("Q400_HYDRAULIC" , readXMLIF ( 91735 ) ) -- Hydraulical_->outs_.stby_hydr_ON_indicator end while 0 < 1 do readAllXMLValues() ipc.sleep(50) end The reason, why I read all the values at once in one single module is, that the interface always fetches one single value at one time. If you would call it from several independent threads, the calls could interfere. This is a limitation of the current XML interface. The training edition will include a more sophisticated interface. Luckily most of the values can be read directly out of Lvars and you can avoid the XML-Interface. So a simple ipc.readLvar("<<<variable name>>>") will provide you the value directly. If you have no programming skills, it's hard. Maybe you find some student nearby, which helps you with that part. You can offer him later some simulator hours 😉 Rgds Reinhard Hi Reinhard, I'm again on this post. I successfully read a Q400 variable via a LUA script and wrote it's value in a file just to see if script is working well. The LUA script is run by FSUIPC (Buttons+Switches control). Now I'm guessing if it is possible to save this value in a new variable that FSUIPC can share externally (i.e Spad.neXt). If yes how can I achieve this? Thanks in advance, Alessandro
aua668 Posted December 5, 2019 Report Posted December 5, 2019 Hi, I have no knowledge, what type of variable you can read in Spad.neXt. If you are able to read offsets there, you could use some bytes of the free offset range of FSUIPC (see offset documentation) to transfer values to your software. According to that forum topic, it should be possible: https://www.spadnext.com/forum/viewtopic.php?f=4&t=2483 Rgds Reinhard
Gmoney88 Posted December 24, 2024 Report Posted December 24, 2024 (edited) On 10/19/2019 at 4:35 AM, aua668 said: Hi, In the included ZIP-File I added two files: One is a definition file for the XML-functions I use with my hardware. The numbers I got from the provided utility, which calculates the hash value for the specific variable. The second file is a sample module, which toggles the TOGA button. For every button I have such a routine. In a master file, which is automatically started, I start all my modules for the Q400 with ipc.runlua("<<<modulename>>>") For reading values from the XML interface I use one single module transferring all the necessary XML-Values into global variables, which later I can use in different modules. The core of the routine can be seen here: -- initialize XML interface to HW function readXMLIF ( pFunc ) -- function to read specific IF value local lMJC_readCode local lMJC_readValue local lCount = 0 -- select function by hash code ipc.writeLvar("L:MJC_VAR_READ_CODE", pFunc) ipc.sleep(5) -- read results lMJC_readCode = ipc.readLvar("L:MJC_VAR_READ_CODE") -- wait if not ready while lMJC_readCode ~= 9991999 and lMJC_readCode ~= 9992999 and lCount < 20 do lCount = lCount + 1 ipc.sleep(10) lMJC_readCode = ipc.readLvar("L:MJC_VAR_READ_CODE") end if lMJC_readCode == 9991999 then lMJC_readValue = ipc.readLvar("L:MJC_VAR_READ_VALUE") -- success else lMJC_readValue = 9992999 -- variable not found ipc.log("Error reading MJC interface for function "..pFunc) end return lMJC_readValue -- return value or error end function readAllXMLValues() -- synchronize global variables from Q400 values -- autopilot ipc.set ("Q400_YD_LIGHT" , readXMLIF ( 31461 ) ) -- AFCS_->outputs.YD_engaged ipc.set ("Q400_AP_LIGHT" , readXMLIF ( 31281 ) ) -- AFCS_->outputs.AP_engaged -- glare shield ipc.set ("Q400_CAUTION" , readXMLIF ( 143090 ) ) -- CautionWarning_->outs_.master_caution_light_blinking ipc.set ("Q400_WARNING" , readXMLIF ( 143112 ) ) -- CautionWarning_->outs_.master_warning_light_blinking -- fuel ipc.set ("Q400_AUX_FUEL" , readXMLIF ( 59590 ) ) -- Fuel_->systems[0].AuxFuelPumplight -- Autofeather ipc.set ("Q400_AUTO_FEATHER" , readXMLIF ( 41047 ) ) -- PCU_->AutofeatherSelectLight -- Hydraulic ipc.set ("Q400_HYDRAULIC" , readXMLIF ( 91735 ) ) -- Hydraulical_->outs_.stby_hydr_ON_indicator end while 0 < 1 do readAllXMLValues() ipc.sleep(50) end The reason, why I read all the values at once in one single module is, that the interface always fetches one single value at one time. If you would call it from several independent threads, the calls could interfere. This is a limitation of the current XML interface. The training edition will include a more sophisticated interface. Luckily most of the values can be read directly out of Lvars and you can avoid the XML-Interface. So a simple ipc.readLvar("<<<variable name>>>") will provide you the value directly. If you have no programming skills, it's hard. Maybe you find some student nearby, which helps you with that part. You can offer him later some simulator hours 😉 Rgds Reinhard Hi guys, I am missing some pieces of the puzzle. Been searching and reading manuals for weeks going in circles. I am trying to read the YD and AP status using the XML interface with the code above so that I can light some autopilot LEDs through Mobiflight. I am using P3Dv6 and FSUIPC v6 The instrctions for the XML interface withy Q400 are very brief. 1) What directory the above code should be placed or what file extension it takes (.lua .xml etc) ? 2) Am I correct in understanding ipc.set ("Q400_YD_LIGHT" , readXMLIF ( 31461 ) syncs the q400 variable to a global varible? 3) How do I link that global variable to one of the free user offsets so that Mobilflight can read it? thanks Jason Edited December 24, 2024 by Gmoney88
John Dowson Posted December 24, 2024 Report Posted December 24, 2024 5 hours ago, Gmoney88 said: 1) What directory the above code should be placed or what file extension it takes (.lua .xml etc) ? Its a lua script so it takes the .lua extension, and should go in the FSUIPC installation folder (i.e. where the FSUIPC6.exe is located) unless you have the LuaPath ini parameter set, in which case use that folder. 5 hours ago, Gmoney88 said: 2) Am I correct in understanding ipc.set ("Q400_YD_LIGHT" , readXMLIF ( 31461 ) syncs the q400 variable to a global varible? Well, readXMLIF ( 31461 ) will just call that function and return a value, which is the value of the lvar MJC_VAR_READ_VALUE after writing 31461 to the lvar MJC_VAR_READ_CODE. So it looks like the majestic interface works by writing a code to one lvar, waiting for this to be processed and then reading the result from another lvar. 5 hours ago, Gmoney88 said: 3) How do I link that global variable to one of the free user offsets so that Mobilflight can read it? What global variable? Can't Mobiflight read lvars directly? If you want to make any variable/value available in an offset, just write it to spare/free offset with one of the ipc.writeXX lua functions. John
Gmoney88 Posted December 26, 2024 Report Posted December 26, 2024 Thanks John, On 12/24/2024 at 5:06 PM, John Dowson said: Its a lua script so it takes the .lua extension, and should go in the FSUIPC installation folder (i.e. where the FSUIPC6.exe is located) unless you have the LuaPath ini parameter set, in which case use that folder. Ok, so I have one lua file placed in the FSUIPC directory named Q400.lua (containing the code I quoted in my first post. This handles the Majestic XML writing to one LVAR and reading return from another Lvar) On 12/24/2024 at 5:06 PM, John Dowson said: So it looks like the majestic interface works by writing a code to one lvar, waiting for this to be processed and then reading the result from another lvar. The "reading result from another lvar", is that referring to Q400_YD_LIGHT ? On 12/24/2024 at 5:06 PM, John Dowson said: What global variable? Can't Mobiflight read lvars directly? If you want to make any variable/value available in an offset, just write it to spare/free offset with one of the ipc.writeXX lua functions. Global variable, I think in translation I have taken to mean another Lvar eg Q400_YD_LIGHT On 12/24/2024 at 11:05 AM, Gmoney88 said: function readAllXMLValues() -- synchronize global variables from Q400 values -- autopilot ipc.set ("Q400_YD_LIGHT" , readXMLIF ( 31461 ) ) -- AFCS_->outputs.YD_engaged I am using p3dv6 and from what I understand mobiflight only uses the WASM/sim connect module for FS2020 to be able to read Lvars in mobiflight. Either that or I can't get sim connect to work with mobiflight (get list of lvars doesnt work) So at this stage I am limited to using FSUIPC offsets for my outputs. Now to get the "Q400_YD_LIGHT into a free offset that I can read in mobiflight... I have another separete .lua in the FSUIPC directory named yd_on.lua containing this: function yd_on (var, value) ipc.writeUB ("66C0", value) end event.Lvar ("L:Q400_YD_LIGHT", 100, "yd_on", value) The idea being that then I should be able to read the 66C0 offset in mobiflight. 1) Do I also need to auto-run both lua files in the [Auto] section of fsuipc.ini? Hope I am on the right track here
John Dowson Posted December 27, 2024 Report Posted December 27, 2024 On 12/26/2024 at 4:32 AM, Gmoney88 said: On 12/24/2024 at 10:06 AM, John Dowson said: So it looks like the majestic interface works by writing a code to one lvar, waiting for this to be processed and then reading the result from another lvar. The "reading result from another lvar", is that referring to Q400_YD_LIGHT ? No - I was referring to L:MJC_VAR_READ_VALUE - the readXMLIF function writes the result to that lvar, which is then used to set the actual lvar value (Q400_YD_LIGHT, Q400_AP_LIGHT, etc) . On 12/26/2024 at 4:32 AM, Gmoney88 said: Now to get the "Q400_YD_LIGHT into a free offset that I can read in mobiflight... I have another separete .lua in the FSUIPC directory named yd_on.lua containing this: function yd_on (var, value) ipc.writeUB ("66C0", value) end event.Lvar ("L:Q400_YD_LIGHT", 100, "yd_on", value) The idea being that then I should be able to read the 66C0 offset in mobiflight. That should be fine, but better to drop the userParameter value (as its not being used (to avoid confusion) or just pass in 0: function yd_on (var, value, userParameter) ipc.writeUB ("66C0", value) end event.Lvar ("L:Q400_YD_LIGHT", 100, "yd_on", 0) On 12/26/2024 at 4:32 AM, Gmoney88 said: 1) Do I also need to auto-run both lua files in the [Auto] section of fsuipc.ini? Yes, Luas that wait for events always need to be started, and usually via the [Auto] or profile-specific [Auto.xxx] section.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now