Created
November 14, 2020 16:34
-
-
Save marvk/8cd770becb400a5bbaecb656f20d54a7 to your computer and use it in GitHub Desktop.
Crash detection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from ctypes import c_double, Structure, c_ulong | |
from pprint import pprint | |
from SimConnect import * | |
class WAYPOINT(Structure): | |
_fields_ = [ | |
("Latitude", c_double), | |
("Longitude", c_double), | |
("Altitude", c_double), | |
("Flags", c_ulong), | |
("ktsSpeed", c_double), | |
("percentThrottle", c_double) | |
] | |
class MySimConnect(SimConnect): | |
def __init__(self, auto_connect=True): | |
super().__init__(auto_connect) | |
def handle_id_event(self, event): | |
super().handle_id_event(event) | |
print(event.uEventID) | |
print('AAAA', event) | |
def run(): | |
sc = MySimConnect(auto_connect=False) | |
sc.connect() | |
sc.dll.SubscribeToSystemEvent( | |
sc.hSimConnect, | |
0x100000, | |
b'Crashed' | |
) | |
while True: | |
print(AircraftRequests(sc).MiscellaneousData.get('CRASH_FLAG')) | |
print(AircraftRequests(sc).MiscellaneousData.get('CRASH_SEQUENCE')) | |
print(AircraftRequests(sc).MiscellaneousData.get('G_FORCE')) | |
time.sleep(1) | |
# time.sleep(3) | |
# | |
# print('go') | |
# | |
# sc.set_pos(30000, 0, 0, 300) | |
# | |
# ar = AircraftRequests(sc) | |
# | |
# pprint(ar.AvionicsData.json()) | |
# | |
# print(ar.set("PLANE_ALTITUDE", 30000)) | |
# print(ar.set("PLANE_HEADING_DEGREES_MAGNETIC", 0)) | |
# print(sc.load_flight_plan('ILS_TRAINING_HAJ')) | |
# ar = AircraftRequests(sc) | |
# | |
# ar.set("PLANE_ALTITUDE", 30000) | |
# ar.set("PLANE_HEADING_DEGREES_MAGNETIC", 0) | |
# | |
# waypoint1 = WAYPOINT(52.389352, 9.767287, 2000, 0, 200, 0.5) | |
# | |
# waypoints = [waypoint1] | |
# | |
# code = sc.add_waypoints(waypoints) | |
# print(code) | |
# | |
# pprint(ar.AvionicsData.json()) | |
return | |
if __name__ == '__main__': | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment