MSFS SimConnect wrapper for Python
Project description
py-simcon
This 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.
Features
- Listen to system events (aircraft loaded, game paused, etc)
- Receive data updates
- Async and sync interfaces, which can work together simultaneously
Examples
Conventional (synchronous)
import pprint
from simcon import Sim, DataField, PERIOD
with Sim("asd") as sim:
data_request = sim.request_data_on_sim_object(
[
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.SIMCONNECT_PERIOD_SECOND,
)
count = 0
for data in data_request:
pprint.pprint(data)
count += 1
if count >= 10:
break
Result:
{'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):
import asyncio
import pprint
from simcon import Sim, DataField, PERIOD
async def show_data():
async with Sim("asd") as sim:
data_request = sim.request_data_on_sim_object(
[
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.SIMCONNECT_PERIOD_SECOND,
)
count = 0
async for data in data_request:
pprint.pprint(data)
count += 1
if count >= 10:
break
asyncio.run(show_data())
Results will be the same as in the example above
Release History
0.2.0
- Added
start()
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.0
- Initial release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
simcon-0.2.0.tar.gz
(13.3 kB
view hashes)
Built Distributions
simcon-0.2.0-cp39-cp39-win_amd64.whl
(495.0 kB
view hashes)
simcon-0.2.0-cp38-cp38-win_amd64.whl
(496.0 kB
view hashes)
simcon-0.2.0-cp37-cp37m-win_amd64.whl
(487.2 kB
view hashes)
Close
Hashes for simcon-0.2.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a60e7ae19b4ad9f96489e56dc426acab3a69faf799e2108dcdbd376e88c43f5 |
|
MD5 | 2a02a7cc647591892f7c92905c374298 |
|
BLAKE2b-256 | e4353f0b7c9229d5a84d281f9521b495d71e3ebe1fb61aff6df09f91c6915f0e |
Close
Hashes for simcon-0.2.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c50a9b1eaf20edebe2fc95a5333181456af8912f796b5f8c9b5552bc3c3e05e2 |
|
MD5 | f1e67781edc4a4b4e561505e9a17fa3b |
|
BLAKE2b-256 | ad55dc2dfeaf0c6eb409d9448fa944f48a25db994f4b4e28a6bb21099cef8904 |
Close
Hashes for simcon-0.2.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb21c7f933b0b6a9478c45fa6476369acaa0a90833ac16762c765d35aa2d9a81 |
|
MD5 | b66fe56a32aa7569768cbb8e93b9b726 |
|
BLAKE2b-256 | 9395d482f6a50831a50efc8e26e92c05967aed80c48257aafda6603219e797d2 |