Package: simcon
py-simconThis is a Python wrapper for SimConnect library which is used to talk to
Microsoft Flight Simulator. This wrapper provides natural pythonic interface.
It can be used in both synchronous and asynchronous (asyncio) applications.
In both cases it is thread safe.FeaturesListen to system events (aircraft loaded, game paused, etc)Receive data updatesAsync and sync interfaces, which can work together simultaneouslyExamplesConventional (synchronous)importpprintfromsimconimportSim,DataField,PERIODfromsimcon.dataimporttypeswithSim("MyApp")assim:data=sim.sync_request_data_once([DataField("ATC ID",None,types.STRING32),DataField("Title",None,types.STRING256),])pprint.pprint(data)data_request=sim.request_data_on_sim_object([DataField("HSI station ident",None,types.STRING8),DataField("Plane latitude","degrees"),DataField("Plane longitude","degrees"),DataField("Plane altitude","feet"),DataField("GPS ground true track","degrees"),DataField("GPS ground speed","knots"),DataField("Zulu time","seconds"),],PERIOD.SECOND,)count=0fordataindata_request:pprint.pprint(data)count+=1ifcount>=3:breakResult:{'GPS ground speed': 97.83114326014487,
 'GPS ground true track': 307.4598039853386,
 'Plane altitude': 8501.684970335986,
 'Plane latitude': 39.3924225392898,
 'Plane longitude': -125.57142850592173,
 'Zulu time': 3287.369384765625}
{'GPS ground speed': 97.83704928992589,
 'GPS ground true track': 307.45556123353225,
 'Plane altitude': 8501.840396854732,
 'Plane latitude': 39.39269706474836,
 'Plane longitude': -125.57189141562071,
 'Zulu time': 3288.369384765625}
...Asynchronous (asyncio):importasyncioimportpprintfromsimconimportSim,DataField,PERIODfromsimcon.dataimporttypesasyncdefshow_data():asyncwithSim("MyApp")assim:data=awaitsim.request_data_once([DataField("ATC ID",None,types.STRING32),DataField("Title",None,types.STRING256),])pprint.pprint(data)data_request=sim.request_data_on_sim_object([DataField("HSI station ident",None,types.STRING8),DataField("Plane latitude","degrees"),DataField("Plane longitude","degrees"),DataField("Plane altitude","feet"),DataField("GPS ground true track","degrees"),DataField("GPS ground speed","knots"),DataField("Zulu time","seconds"),],PERIOD.SECOND,)count=0asyncfordataindata_request:pprint.pprint(data)count+=1ifcount>=3:breakasyncio.run(show_data())Results will be the same as in the example aboveRelease HistoryYet to releaseNothing so far0.6.1Always release GIL before calling SimConnect (fixes freezes)0.6.0Fixed event/data cleanup exceptions when stoppingFixed iterating over changing dicts when stoppingFixed non-asyncio-friendly threading.Lock causing deadlocks (API changed!)0.5.0Added more parameters to data requests:when- either always, or only when the data changes (default: always)origin- periods to wait before first data transmission (default: 0)interval- periods between data transmissions (default: 1, i.e. every period)limit- limit the number of data transmissions (default: 0, i.e. never stop)Fixed 32-bit fields alignment0.4.0Wrapped SimConnect failures into OSError instead of a generic RuntimeErrorSim now stops when the simulator quits.Added wait_stop() to wait until Sim stopsStop Sim if it failed to start as a context manager0.3.0Added support for strings, integer, and float32 data typesAdded a helper to request data once0.2.0Addedstart()andstop()methods. All event and data listeners
will throw Closed() exception if they are still being awaited when
Sim stops, or if it is already stopped when wait() is called.0.1.0Initial release