Changeset 61:7deb4cf7dd78 for src/mlx/fsuipc.py
- Timestamp:
- 04/07/12 11:03:47 (12 years ago)
- Branch:
- default
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/fsuipc.py
r59 r61 428 428 via FSUIPC.""" 429 429 # The basic data that should be queried all the time once we are connected 430 normalData = [ (0x0240, "H"), # Year 431 (0x023e, "H"), # Number of day in year 432 (0x023b, "b"), # UTC hour 433 (0x023c, "b"), # UTC minute 434 (0x023a, "b"), # seconds 435 (0x3d00, -256), # The name of the current aircraft 430 timeData = [ (0x0240, "H"), # Year 431 (0x023e, "H"), # Number of day in year 432 (0x023b, "b"), # UTC hour 433 (0x023c, "b"), # UTC minute 434 (0x023a, "b") ] # seconds 435 436 normalData = timeData + \ 437 [ (0x3d00, -256), # The name of the current aircraft 436 438 (0x3c00, -256) ] # The path of the current AIR file 437 439 … … 452 454 (0x057c, "d"), # Bank 453 455 (0x0580, "d") ] # Heading 456 457 @staticmethod 458 def _getTimestamp(data): 459 """Convert the given data into a timestamp.""" 460 timestamp = calendar.timegm(time.struct_time([data[0], 461 1, 1, 0, 0, 0, -1, 1, 0])) 462 timestamp += data[1] * 24 * 3600 463 timestamp += data[2] * 3600 464 timestamp += data[3] * 60 465 timestamp += data[4] 466 467 return timestamp 454 468 455 469 def __init__(self, connectionListener, connectAttempts = -1, … … 516 530 """Send a request for the ZFW.""" 517 531 self._handler.requestRead([(0x3bfc, "d")], self._handleZFW, extra = callback) 532 533 def requestTime(self, callback): 534 """Request the time from the simulator.""" 535 self._handler.requestRead(Simulator.timeData, self._handleTime, 536 extra = callback) 518 537 519 538 def startMonitoring(self): … … 583 602 aircraft-specific values. 584 603 """ 585 timestamp = calendar.timegm(time.struct_time([data[0], 586 1, 1, 0, 0, 0, -1, 1, 0])) 587 timestamp += data[1] * 24 * 3600 588 timestamp += data[2] * 3600 589 timestamp += data[3] * 60 590 timestamp += data[4] 604 timestamp = Simulator._getTimestamp(data) 591 605 592 606 createdNewModel = self._setAircraftName(timestamp, data[5], data[6]) … … 719 733 zfw = data[0] * const.LBSTOKG / 256.0 720 734 callback(zfw) 735 736 def _handleTime(self, data, callback): 737 """Callback for a time retrieval request.""" 738 callback(Simulator._getTimestamp(data)) 721 739 722 740 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.