Last change
on this file since 8:85698811c70e was 8:85698811c70e, checked in by István Váradi <ivaradi@…>, 12 years ago |
The tracking of flight stages and some basic logging functionality works
|
File size:
1.4 KB
|
Rev | Line | |
---|
[8] | 1 | # Module related to the high-level tracking of the flight
|
---|
| 2 |
|
---|
| 3 | #---------------------------------------------------------------------------------------
|
---|
| 4 |
|
---|
| 5 | import const
|
---|
| 6 |
|
---|
| 7 | import threading
|
---|
| 8 |
|
---|
| 9 | #---------------------------------------------------------------------------------------
|
---|
| 10 |
|
---|
| 11 | class Flight(object):
|
---|
| 12 | """The object with the global flight state.
|
---|
| 13 |
|
---|
| 14 | It is also the hub for the other main objects participating in the handling of
|
---|
| 15 | the flight."""
|
---|
| 16 | def __init__(self, logger):
|
---|
| 17 | """Construct the flight."""
|
---|
| 18 | self._stage = None
|
---|
| 19 | self.logger = logger
|
---|
| 20 | self.cruiseAltitude = None
|
---|
| 21 | self.aircraftType = None
|
---|
| 22 | self.aircraft = None
|
---|
| 23 | self.simulator = None
|
---|
| 24 |
|
---|
| 25 | self._endCondition = threading.Condition()
|
---|
| 26 |
|
---|
| 27 | @property
|
---|
| 28 | def stage(self):
|
---|
| 29 | """Get the flight stage."""
|
---|
| 30 | return self._stage
|
---|
| 31 |
|
---|
| 32 | def setStage(self, timestamp, stage):
|
---|
| 33 | """Set the flight stage."""
|
---|
| 34 | if stage!=self._stage:
|
---|
| 35 | self._stage = stage
|
---|
| 36 | self.logger.stage(timestamp, stage)
|
---|
| 37 | if stage==const.STAGE_END:
|
---|
| 38 | with self._endCondition:
|
---|
| 39 | self._endCondition.notify()
|
---|
| 40 |
|
---|
| 41 | def wait(self):
|
---|
| 42 | """Wait for the flight to end."""
|
---|
| 43 | with self._endCondition:
|
---|
| 44 | while self._stage!=const.STAGE_END:
|
---|
| 45 | self._endCondition.wait()
|
---|
| 46 |
|
---|
| 47 | #---------------------------------------------------------------------------------------
|
---|
Note:
See
TracBrowser
for help on using the repository browser.