Changeset 148:453ebaea9090 for src/mlx/fsuipc.py
- Timestamp:
- 05/03/12 18:27:13 (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
r141 r148 471 471 (0x0580, "d") ] # Heading 472 472 473 TIME_SYNC_INTERVAL = 3.0 474 473 475 @staticmethod 474 476 def _getTimestamp(data): … … 514 516 self._scroll = False 515 517 518 self._syncTime = False 519 self._nextSyncTime = -1 520 516 521 self._normalRequestID = None 517 522 … … 536 541 self._handler.connect() 537 542 if self._normalRequestID is None: 543 self._nextSyncTime = -1 538 544 self._startDefaultNormal() 539 545 … … 638 644 data.append( (offset, "u", long(level * 128.8 * 65536.0)) ) 639 645 self._handler.requestWrite(data, self._handleFuelWritten) 646 647 def enableTimeSync(self): 648 """Enable the time synchronization.""" 649 self._nextSyncTime = -1 650 self._syncTime = True 651 652 def disableTimeSync(self): 653 """Enable the time synchronization.""" 654 self._syncTime = False 655 self._nextSyncTime = -1 640 656 641 657 def disconnect(self): … … 678 694 679 695 self._scroll = data[7]!=0 696 697 self._checkTimeSync() 680 698 681 699 if self._monitoringRequested and not self._monitoring: … … 691 709 self._aircraft.handleState(aircraftState) 692 710 711 def _checkTimeSync(self): 712 """Check if we need to synchronize the FS time.""" 713 if not self._syncTime: return 714 715 now = time.time() 716 seconds = time.gmtime(now).tm_sec 717 718 if seconds>30 and seconds<59: 719 if self._nextSyncTime > (now - 0.49): 720 return 721 722 self._handler.requestWrite([(0x023a, "b", int(seconds))], 723 self._handleTimeSynced) 724 725 #print "Set the seconds to ", seconds 726 727 if self._nextSyncTime<0: 728 self._nextSyncTime = now 729 730 self._nextSyncTime += Simulator.TIME_SYNC_INTERVAL 731 else: 732 self._nextSyncTime = -1 733 734 def _handleTimeSynced(self, success, extra): 735 """Callback for the time sync result.""" 736 pass 737 693 738 def _setAircraftName(self, timestamp, name, airPath): 694 739 """Set the name of the aicraft and if it is different from the
Note:
See TracChangeset
for help on using the changeset viewer.