Skip to content

Commit a67e2ca

Browse files
committed
flight_to_dic
simple parseer to get local vars form sim. Note the writing of this data is not working.
1 parent 86eb21f commit a67e2ca

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,3 +141,6 @@ dmypy.json
141141
.idea/inspectionProfiles/Project_Default.xml
142142
.idea/CodeStyles/codeStyleConfig.xml
143143
.idea/MSFS2020-cockpit-companion.iml
144+
*.FLT
145+
*.FSSAVE
146+
*.SPB

SimConnect/SimConnect.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,3 +389,40 @@ def get_paused(self):
389389
self.dll.EventID.EVENT_SIM_PAUSED,
390390
b"Sim"
391391
)
392+
393+
# not working
394+
# def dic_to_flight(self, dic):
395+
# data_folder = os.path.dirname(os.path.realpath(__file__))
396+
# file_to_open = os.path.join(data_folder, "TEMP.FLT")
397+
# if os.path.isfile(file_to_open):
398+
# os.remove(file_to_open)
399+
# with open(file_to_open, "w") as tempfile:
400+
# for root in dic:
401+
# tempfile.write("\n[%s]\n" % root)
402+
# for member in dic[root]:
403+
# tempfile.write("%s=%s\n" % (member, dic[root][member]))
404+
# if os.path.isfile(file_to_open):
405+
# self.load_flight(file_to_open)
406+
407+
def flight_to_dic(self):
408+
data_folder = os.path.dirname(os.path.realpath(__file__))
409+
file_to_open = os.path.join(data_folder, "TEMP.FLT")
410+
if os.path.isfile(file_to_open):
411+
os.remove(file_to_open)
412+
self.save_flight(file_to_open, "Flight", "Supper Cool flight")
413+
while not os.path.isfile(file_to_open):
414+
pass
415+
time.sleep(0.5)
416+
dic = {}
417+
index = ""
418+
with open(file_to_open, "r") as tempfile:
419+
for line in tempfile.readlines():
420+
if line[0] == '[':
421+
index = line[1:-2]
422+
dic[index] = {}
423+
else:
424+
if index != "" and line != '\n':
425+
temp = line.split("=")
426+
dic[index][temp[0]] = temp[1].strip()
427+
os.remove(file_to_open)
428+
return dic

SimConnect/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def int_or_str(value):
1111
return value
1212

1313

14-
__version__ = "0.4.10"
14+
__version__ = "0.4.11"
1515
VERSION = tuple(map(int_or_str, __version__.split(".")))
1616

1717
__all__ = ["SimConnect", "Request", "Event", "millis", "DWORD", "AircraftRequests", "AircraftEvents", "FacilitiesRequests"]

0 commit comments

Comments
 (0)