Changeset 893:147633a04fda
- Timestamp:
- 03/11/18 09:02:42 (7 years ago)
- Branch:
- default
- Children:
- 894:995dccbca6ab, 901:960acab7a319
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/xplane.py
r881 r893 657 657 658 658 @staticmethod 659 def _getTimestamp(data):660 """Convert the given data into a timestamp."""661 year = datetime.date.today().year662 timestamp = calendar.timegm(time.struct_time([year,663 1, 1, 0, 0, 0, -1, 1, 0]))664 timestamp += data[0] * 24 * 3600665 timestamp += data[1]666 667 return timestamp668 669 @staticmethod670 659 def _getHotkeyCode(hotkey): 671 660 """Get the hotkey code for the given hot key.""" … … 709 698 self._nextSyncTime = -1 710 699 700 self._timestampBase = None 701 self._timestampDaysOffset = 0 702 self._lastZuluSeconds = None 703 711 704 self._normalRequestID = None 712 705 … … 931 924 self._connectionListener.disconnected() 932 925 926 def _getTimestamp(self, data): 927 """Convert the given data into a timestamp.""" 928 if self._timestampBase is None: 929 year = datetime.date.today().year 930 self._timestampBase = \ 931 calendar.timegm(time.struct_time([year, 1, 1, 0, 0, 0, -1, 1, 0])) 932 self._timestampBase += data[0] * 24 * 3600 933 self._timestampDaysOffset = 0 934 self._lastZuluSeconds = None 935 936 zuluSeconds = data[1] 937 if self._lastZuluSeconds is not None and \ 938 zuluSeconds<self._lastZuluSeconds: 939 print "xplane.Simulator._getTimestamp: Zulu seconds have gone backwards (%f -> %f), increasing day offset" % \ 940 (self._lastZuluSeconds, zuluSeconds) 941 self._timestampDaysOffset += 1 942 943 self._lastZuluSeconds = zuluSeconds 944 945 timestamp = self._timestampBase 946 timestamp += self._timestampDaysOffset * 24 * 3600 947 timestamp += zuluSeconds 948 949 return timestamp 950 933 951 def _startDefaultNormal(self): 934 952 """Start the default normal periodic request.""" 935 953 assert self._normalRequestID is None 954 self._timestampBase = None 936 955 self._normalRequestID = \ 937 956 self._handler.requestPeriodicRead(1.0, … … 953 972 aircraft-specific values. 954 973 """ 955 timestamp = Simulator._getTimestamp(data)974 timestamp = self._getTimestamp(data) 956 975 957 976 createdNewModel = self._setAircraftName(timestamp, … … 1104 1123 def _handleTime(self, data, callback): 1105 1124 """Callback for a time retrieval request.""" 1106 callback( Simulator._getTimestamp(data))1125 callback(self._getTimestamp(data)) 1107 1126 1108 1127 def _handleWeights(self, data, callback):
Note:
See TracChangeset
for help on using the changeset viewer.