Changeset 139:839016dcd0d1 for src/mlx/checks.py
- Timestamp:
- 05/01/12 08:29:24 (12 years ago)
- Branch:
- default
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r134 r139 6 6 import const 7 7 import util 8 from acars import ACARS 9 10 import time 8 11 9 12 #--------------------------------------------------------------------------------------- … … 85 88 #--------------------------------------------------------------------------------------- 86 89 90 class ACARSSender(StateChecker): 91 """Sender of online ACARS. 92 93 It sends the ACARS every 3 minutes to the MAVA website.""" 94 95 # The interval at which ACARS is sent 96 INTERVAL = 3*60.0 97 98 def __init__(self, gui): 99 """Construct the ACARS sender.""" 100 self._gui = gui 101 self._lastSent = None 102 103 def check(self, flight, aircraft, logger, oldState, state): 104 """If the time has come to send the ACARS, send it.""" 105 now = time.time() 106 107 if self._lastSent is not None and \ 108 (self._lastSent + ACARSSender.INTERVAL)>now: 109 return 110 111 acars = ACARS(self._gui, state) 112 self._gui.webHandler.sendACARS(self._acarsCallback, acars) 113 114 def _acarsCallback(self, returned, result): 115 """Callback for ACARS sending.""" 116 if returned: 117 print "Sent online ACARS" 118 self._lastSent = time.time() if self._lastSent is None \ 119 else self._lastSent + ACARSSender.INTERVAL 120 else: 121 print "Failed to send the ACARS" 122 123 #--------------------------------------------------------------------------------------- 124 87 125 class TakeOffLogger(StateChecker): 88 126 """Logger for the cruise speed."""
Note:
See TracChangeset
for help on using the changeset viewer.