Changeset 148:453ebaea9090
- Timestamp:
- 05/03/12 18:27:13 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/config.py
r147 r148 41 41 self._onlineACARS = True 42 42 self._flareTimeFromFS = False 43 self._syncFSTime = False 43 44 44 45 self._autoUpdate = True … … 145 146 if flareTimeFromFS!=self._flareTimeFromFS: 146 147 self._flareTimeFromFS = flareTimeFromFS 148 self._modified = True 149 150 @property 151 def syncFSTime(self): 152 """Get whether the simulator's time should be synchronized with the 153 machine's clock.""" 154 return self._syncFSTime 155 156 @syncFSTime.setter 157 def syncFSTime(self, syncFSTime): 158 """Set whether the simulator's time should be synchronized with the 159 machine's clock.""" 160 if syncFSTime!=self._syncFSTime: 161 self._syncFSTime = syncFSTime 147 162 self._modified = True 148 163 … … 213 228 "flareTimeFromFS", 214 229 False) 230 self._syncFSTime = self._getBoolean(config, "general", 231 "syncFSTime", 232 False) 215 233 216 234 self._messageTypeLevels = {} … … 249 267 config.set("general", "flareTimeFromFS", 250 268 "yes" if self._flareTimeFromFS else "no") 269 config.set("general", "syncFSTime", 270 "yes" if self._syncFSTime else "no") 251 271 252 272 config.add_section(Config._messageTypesSection) -
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 -
src/mlx/gui/gui.py
r147 r148 699 699 self._simulator = fs.createSimulator(const.SIM_MSFS9, self) 700 700 fs.setupMessageSending(self.config, self._simulator) 701 701 self._setupTimeSync() 702 702 703 self._flight.simulator = self._simulator 703 704 … … 853 854 """Callback for editing the preferences.""" 854 855 self._preferences.run(self.config) 856 self._setupTimeSync() 857 858 def _setupTimeSync(self): 859 """Enable or disable the simulator time synchronization based on the 860 configuration.""" 861 simulator = self._simulator 862 if simulator is not None: 863 if self.config.syncFSTime: 864 simulator.enableTimeSync() 865 else: 866 simulator.disableTimeSync() -
src/mlx/gui/prefs.py
r147 r148 71 71 self._onlineACARS.set_active(config.onlineACARS) 72 72 self._flareTimeFromFS.set_active(config.flareTimeFromFS) 73 self._syncFSTime.set_active(config.syncFSTime) 73 74 74 75 for messageType in const.messageTypes: … … 96 97 config.onlineACARS = self._onlineACARS.get_active() 97 98 config.flareTimeFromFS = self._flareTimeFromFS.get_active() 99 config.syncFSTime = self._syncFSTime.get_active() 98 100 99 101 for messageType in const.messageTypes: … … 167 169 self._flareTimeFromFS.set_tooltip_text(xstr("prefs_flaretimeFromFS_tooltip")) 168 170 mainBox.pack_start(self._flareTimeFromFS, False, False, 4) 171 172 self._syncFSTime = gtk.CheckButton(xstr("prefs_syncFSTime")) 173 self._syncFSTime.set_use_underline(True) 174 self._syncFSTime.set_tooltip_text(xstr("prefs_syncFSTime_tooltip")) 175 mainBox.pack_start(self._syncFSTime, False, False, 4) 169 176 170 177 return mainAlignment -
src/mlx/i18n.py
r147 r148 616 616 "If this is checked, the time of the flare will be calculated " 617 617 "from timestamps returned by the simulator.") 618 self.add("prefs_syncFSTime", 619 "_Synchronize the time in FS with the computer's clock") 620 self.add("prefs_syncFSTime_tooltip", 621 "If this is checked the flight simulator's internal clock " 622 "will always be synchronized to the computer's clock.") 618 623 self.add("prefs_update_auto", "Update the program auto_matically") 619 624 self.add("prefs_update_auto_tooltip", … … 1164 1169 "Ha ezt bejelölöd, a kilebegtetés idejét a szimulátor " 1165 1170 "által visszaadott időbélyegek alapján számolja a program.") 1171 self.add("prefs_syncFSTime", 1172 "_Szinkronizáld a szimulátor idéjét a számítógépével") 1173 self.add("prefs_syncFSTime_tooltip", 1174 "Ha ez bejelölöd, a szimulátor belső óráját a program " 1175 "szinkronban tartja a számítógép órájával.") 1166 1176 self.add("prefs_update_auto", 1167 1177 "Frissítsd a programot _automatikusan")
Note:
See TracChangeset
for help on using the changeset viewer.