-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPI_pyACARS.py
100 lines (81 loc) · 2.81 KB
/
PI_pyACARS.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
'''
pyACARS - X-plane ACARS plugin.
Copyright (C) 2020 Pedro Monteiro
---
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
'''
# X-plane includes
from XPLMDefs import *
from XPLMProcessing import *
from XPLMDataAccess import *
from XPLMUtilities import *
from XPLMPlanes import *
from XPLMNavigation import *
from SandyBarbourUtilities import *
from PythonScriptMessaging import *
from XPLMPlugin import *
from XPLMMenus import *
from XPWidgetDefs import *
from XPWidgets import *
from XPStandardWidgets import *
import ctypes
import cPickle
import socket
import threading
import subprocess
import os
import signal
from datetime import datetime
from random import random
from pyacars import Conf
from pyacars import Recorder
from pyacars import DataRef
from pyacars import Logger
class PythonInterface:
'''
Xplane plugin
'''
def XPluginStart(self):
self.syspath = []
path = XPLMGetSystemPath(self.syspath)[:-1]
self.conf = Conf(path)
self.recorder = Recorder(self.conf)
self.Name = "pyACARS - " + self.conf.__VERSION__
self.Sig = "python.pyACARS"
self.Desc = "ACARS, PIREP and Flight Data for Virtual Airlines"
# floop
self.floop = self.floopCallback
XPLMRegisterFlightLoopCallback(self, self.floop, -1, 0)
# Menu / About
self.mPluginItem = XPLMAppendMenuItem(XPLMFindPluginsMenu(), 'pyACARS', 0, 1)
self.mMain = XPLMCreateMenu(self, 'pyACARS', XPLMFindPluginsMenu(), self.mPluginItem, self.mainMenuCB, 0)
return self.Name, self.Sig, self.Desc
def mainMenuCB(self, menuRef, menuItem):
'''
Main menu Callback
'''
Logger.log("mainMenuCB got menuRref: %d, menuItem: %d" % (menuRef, menuItem))
def floopCallback(self, elapsedMe, elapsedSim, counter, refcon):
if DataRef.get_i("sim/time/paused"):
return -1
if DataRef.get_i('sim/operation/prefs/replay_mode'):
return -1
self.recorder.loop_callback()
return -1
def XPluginStop(self):
XPLMUnregisterFlightLoopCallback(self, self.floop, 0)
XPLMDestroyMenu(self, self.mMain)
self.conf.pluginSave()
def XPluginEnable(self):
return 1
def XPluginDisable(self):
pass
def XPluginReceiveMessage(self, inFromWho, inMessage, inParam):
Logger.log("Received message %d from %d with param %d " % (inFromWho, inMessage, inParam))