source: src/mlx/flight.py@ 71:2dba0ba6cd1b

Last change on this file since 71:2dba0ba6cd1b was 71:2dba0ba6cd1b, checked in by István Váradi <ivaradi@…>, 12 years ago

Added the takeoff page.

File size: 3.4 KB
Line 
1# Module related to the high-level tracking of the flight
2
3#---------------------------------------------------------------------------------------
4
5import const
6
7import threading
8
9#---------------------------------------------------------------------------------------
10
11class Options(object):
12 """Various configuration options."""
13 def __init__(self):
14 """Construct the object with default values."""
15 self.fs2Crew = False
16 self.compensation = None
17
18#---------------------------------------------------------------------------------------
19
20class Flight(object):
21 """The object with the global flight state.
22
23 It is also the hub for the other main objects participating in the handling of
24 the flight."""
25 def __init__(self, logger, gui):
26 """Construct the flight."""
27 self._stage = None
28 self.logger = logger
29 self._gui = gui
30
31 gui.resetFlightStatus()
32
33 self.cruiseAltitude = None
34 self.flareTimeFromFS = False
35 self.entranceExam = False
36 self.zfw = None
37
38 self.options = Options()
39
40 self.aircraftType = None
41 self.aircraft = None
42 self.simulator = None
43
44 self._endCondition = threading.Condition()
45
46 self.v1 = None
47 self.vr = None
48 self.v2 = None
49
50 self._flareStart = None
51 self._flareStartFS = None
52
53 @property
54 def stage(self):
55 """Get the flight stage."""
56 return self._stage
57
58 def setStage(self, timestamp, stage):
59 """Set the flight stage.
60
61 Returns if the stage has really changed."""
62 if stage!=self._stage:
63 self._stage = stage
64 self.logger.stage(timestamp, stage)
65 self._gui.setStage(stage)
66 if stage==const.STAGE_END:
67 with self._endCondition:
68 self._endCondition.notify()
69 return True
70 else:
71 return False
72
73 def handleFault(self, faultID, timestamp, what, score):
74 """Handle the given fault.
75
76 faultID as a unique ID for the given kind of fault. If another fault of
77 this ID has been reported earlier, it will be reported again only if
78 the score is greater than last time. This ID can be, e.g. the checker
79 the report comes from."""
80 self.logger.fault(faultID, timestamp, what, score)
81 self._gui.setRating(self.logger.getRating())
82
83 def handleNoGo(self, faultID, timestamp, what, shortReason):
84 """Handle a No-Go fault."""
85 self.logger.noGo(faultID, timestamp, what)
86 self._gui.setNoGo(shortReason)
87
88 def flareStarted(self, flareStart, flareStartFS):
89 """Called when the flare time has started."""
90 self._flareStart = flareStart
91 self._flareStartFS = flareStartFS
92
93 def flareFinished(self, flareEnd, flareEndFS):
94 """Called when the flare time has ended.
95
96 Return a tuple of the following items:
97 - a boolean indicating if FS time is used
98 - the flare time
99 """
100 if self.flareTimeFromFS:
101 return (True, flareEndFS - self._flareStartFS)
102 else:
103 return (False, flareEnd - self._flareStart)
104
105 def wait(self):
106 """Wait for the flight to end."""
107 with self._endCondition:
108 while self._stage!=const.STAGE_END:
109 self._endCondition.wait(1)
110
111#---------------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.