# Basic test program for the Python client library #------------------------------------------------------------------------------ if __name__ == "__main__": from xplra import XPlane, ProtocolException xplane = XPlane() try: print "Connecting to X-Plane..." xplane.connect() print "Connected to X-Plane." print print "Querying the number of the engines..." numEngines = xplane.getInt("sim/aircraft/engine/acf_num_engines") print "The number of engines:", numEngines print try: print "Querying an invalid dataref..." xplane.getInt("sim/aircraft/engine/num_engines") print print ">>>>>>>>>>>> Succeeded!!!!!!!!!!!!!!!!!!!!!!" except ProtocolException as e: print "Exception caugth:", str(e) print print "Querying the spool time of a jet engine..." spoolTime = xplane.getFloat("sim/aircraft/engine/acf_spooltime_jet") print "The spool time:", spoolTime print print "Querying the spool time of a propeller..." spoolTime = xplane.getFloat("sim/aircraft/engine/acf_spooltime_prop") print "The spool time:", spoolTime print print "Querying the coordinates..." latitude = xplane.getDouble("sim/flightmodel/position/latitude") longitude = xplane.getDouble("sim/flightmodel/position/longitude") print "The coordinates: " + `latitude` + ", " + `longitude` print print "Querying the aircraft's description..." result = xplane.getByteArray("sim/aircraft/view/acf_descrip") print "The description:", result.tolist() print print "Querying the aircraft's description as a string, with an offset of 3..." result2 = xplane.getString("sim/aircraft/view/acf_descrip", offset = 3); print "Got: '" + result2 + "'" print print "Querying the aircraft's engine types..." result3 = xplane.getIntArray("sim/aircraft/prop/acf_en_type") print "Got:", result3.tolist() print print "Querying the aircraft's propeller directions..." result5 = xplane.getFloatArray("sim/aircraft/prop/acf_prop_dir") print "Got:", result5.tolist() print except Exception as e: print ">>>>>>>>>>>>>>>>>>>>>> Exception caught:", str(e) finally: xplane.disconnect()