Changeset 846:d11ea8564da8 for src/mlx
- Timestamp:
- 05/10/17 17:41:17 (8 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/flight.py
r635 r846 40 40 41 41 @staticmethod 42 def getMinutesDifference(minutes1, minutes2): 43 """Get the difference in minutes between the given two time 44 instances.""" 45 diff1 = minutes1 - minutes2 46 diff2 = -1 * diff1 47 48 if diff1 < 0: diff1 += 60*24 49 else: diff2 += 60*24 50 51 diff = min(diff1, diff2) 52 53 return -1*diff if diff2<diff1 else diff 54 55 @staticmethod 42 56 def isTimeDifferenceTooMuch(scheduledTime, realTimestamp): 43 57 """Determine if the given real time differs to much from the scheduled … … 54 68 realMinute = realTime.tm_hour * 60 + realTime.tm_min 55 69 56 diff1 = scheduledMinute - realMinute 57 diff2 = -1 * diff1 58 59 if diff1 < 0: diff1 += 60*24 60 else: diff2 += 60*24 61 62 diff = min(diff1, diff2) 70 diff = abs(Flight.getMinutesDifference(scheduledMinute, realMinute)) 63 71 64 72 return (diff>Flight.TIME_WARNING_DIFFERENCE, -
src/mlx/gui/common.py
r837 r846 326 326 else: 327 327 return 0 328 329 @property 330 def minutes(self): 331 """Get the time in minutes, i.e. hour*60+minute.""" 332 return self.hour * 60 + self.minute 328 333 329 334 def setTimestamp(self, timestamp): -
src/mlx/gui/info.py
r844 r846 54 54 return (frame, comments) 55 55 56 def __init__(self, gui, mainInstance = True):56 def __init__(self, gui, callbackObject = None): 57 57 """Construct the flight info tab.""" 58 58 super(FlightInfo, self).__init__() 59 59 self._gui = gui 60 self._ mainInstance = mainInstance60 self._callbackObject = callbackObject 61 61 62 62 self._commentsAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 184 184 def delayCodesChanged(self): 185 185 """Callewd when the delay codes have changed.""" 186 if self._ mainInstance:186 if self._callbackObject is None: 187 187 self._gui.delayCodesChanged() 188 else: 189 self._callbackObject.delayCodesChanged() 188 190 189 191 def _commentsChanged(self, textbuffer): 190 192 """Called when the comments have changed.""" 191 if self._ mainInstance:193 if self._callbackObject is None: 192 194 self._gui.commentsChanged() 195 else: 196 self._callbackObject.commentsChanged() 193 197 194 198 def _faultExplanationsChanged(self, faultExplainWidget, fullyExplained): 195 199 """Called when the status of the fault explanations has changed.""" 196 if self._ mainInstance:200 if self._callbackObject is None: 197 201 self._gui.faultExplanationsChanged() 202 else: 203 self._callbackObject.faultExplanationsChanged() -
src/mlx/gui/pirep.py
r845 r846 6 6 7 7 from mlx.pirep import PIREP 8 from mlx.flight import Flight 8 9 from mlx.const import * 9 10 … … 692 693 self._gui = gui 693 694 695 self._pirep = None 696 694 697 contentArea = self.get_content_area() 695 698 … … 715 718 self._notebook.append_page(logTab, label) 716 719 720 self.add_button(xstr("button_cancel"), RESPONSETYPE_CANCEL) 721 717 722 self._okButton = self.add_button(xstr("button_ok"), RESPONSETYPE_OK) 718 723 self._okButton.set_can_default(True) … … 720 725 def setPIREP(self, pirep): 721 726 """Setup the data in the dialog from the given PIREP.""" 727 self._pirep = pirep 728 722 729 bookedFlight = pirep.bookedFlight 723 730 … … 835 842 self._okButton.grab_default() 836 843 844 self._updateButtons() 845 846 def delayCodesChanged(self): 847 """Called when the delay codes have changed.""" 848 self._updateButtons() 849 850 def commentsChanged(self): 851 """Called when the comments have changed.""" 852 self._updateButtons() 853 854 def faultExplanationsChanged(self): 855 """Called when the fault explanations have changed.""" 856 self._updateButtons() 857 837 858 def _buildDataTab(self): 838 859 """Build the data tab of the viewer.""" … … 932 953 xstr("pirepView_numPassengers"), 933 954 width = 4) 934 935 955 self._numCrew = \ 936 956 PIREPViewer.tableAttach(table, 1, 0, … … 981 1001 #self._filedCruiseLevel.set_tooltip_text(xstr("route_level_tooltip")) 982 1002 self._filedCruiseLevel.set_numeric(True) 1003 self._filedCruiseLevel.connect("value-changed", self._updateButtons) 983 1004 984 1005 levelBox.pack_start(self._filedCruiseLevel, False, False, 0) … … 995 1016 #self._modifiedCruiseLevel.set_tooltip_text(xstr("route_level_tooltip")) 996 1017 self._modifiedCruiseLevel.set_numeric(True) 1018 self._modifiedCruiseLevel.connect("value-changed", self._updateButtons) 997 1019 998 1020 levelBox.pack_start(self._modifiedCruiseLevel, False, False, 0) … … 1003 1025 PIREPViewer.getTextWindow(editable = True) 1004 1026 mainBox.pack_start(routeWindow, False, False, 0) 1027 self._userRoute.get_buffer().connect("changed", self._updateButtons) 1005 1028 1006 1029 return frame … … 1015 1038 PIREPViewer.getTextWindow(heightRequest = -1, 1016 1039 editable = True) 1040 self._departureMETAR.get_buffer().connect("changed", self._updateButtons) 1017 1041 mainBox.pack_start(metarWindow, True, True, 0) 1018 1042 … … 1062 1086 PIREPViewer.getTextWindow(heightRequest = -1, 1063 1087 editable = True) 1088 self._arrivalMETAR.get_buffer().connect("changed", self._updateButtons) 1064 1089 mainBox.pack_start(metarWindow, True, True, 0) 1065 1090 … … 1137 1162 PIREPEditor.tableAttachTimeEntry(table, 0, 0, 1138 1163 xstr("pirepView_blockTimeStart")) 1164 self._blockTimeStart.connect("changed", self._updateButtons) 1139 1165 1140 1166 self._blockTimeEnd = \ 1141 1167 PIREPEditor.tableAttachTimeEntry(table, 2, 0, 1142 1168 xstr("pirepView_blockTimeEnd")) 1169 self._blockTimeEnd.connect("changed", self._updateButtons) 1143 1170 1144 1171 self._flightTimeStart = \ 1145 1172 PIREPEditor.tableAttachTimeEntry(table, 0, 1, 1146 1173 xstr("pirepView_flightTimeStart")) 1174 self._flightTimeStart.connect("changed", self._updateButtons) 1147 1175 1148 1176 self._flightTimeEnd = \ 1149 1177 PIREPEditor.tableAttachTimeEntry(table, 2, 1, 1150 1178 xstr("pirepView_flightTimeEnd")) 1179 self._flightTimeEnd.connect("changed", self._updateButtons) 1151 1180 1152 1181 self._flownDistance = PIREPViewer.getDataLabel(width = 3) … … 1159 1188 xstr("pirepView_fuelUsed"), 1160 1189 1000000) 1161 1190 self._fuelUsed.connect("value-changed", self._updateButtons) 1162 1191 1163 1192 self._rating = PIREPViewer.getDataLabel(width = 3) … … 1181 1210 xstr("pirepView_numPassengers"), 1182 1211 300) 1212 self._flownNumPassengers.connect("value-changed", self._updateButtons) 1183 1213 1184 1214 self._flownNumCrew = \ … … 1186 1216 xstr("pirepView_numCrew"), 1187 1217 10) 1218 self._flownNumCrew.connect("value-changed", self._updateButtons) 1188 1219 1189 1220 self._flownBagWeight = \ … … 1222 1253 def _buildCommentsTab(self): 1223 1254 """Build the tab with the comments and flight defects.""" 1224 return FlightInfo(self._gui, mainInstance = False)1255 return FlightInfo(self._gui, callbackObject = self) 1225 1256 1226 1257 def _buildLogTab(self): … … 1238 1269 should be converted to uppercase.""" 1239 1270 entry.set_text(entry.get_text().upper()) 1271 self._updateButtons() 1240 1272 #self._valueChanged(entry, arg) 1241 1273 … … 1245 1277 if comboBox.get_active()==-1: 1246 1278 entry.set_text(entry.get_text().upper()) 1279 self._updateButtons() 1247 1280 #self._valueChanged(entry) 1248 1281 1282 def _updateButtons(self, *kwargs): 1283 """Update the activity state of the buttons.""" 1284 pirep = self._pirep 1285 bookedFlight = pirep.bookedFlight 1286 1287 departureMinutes = \ 1288 bookedFlight.departureTime.hour*60 + bookedFlight.departureTime.minute 1289 departureDifference = abs(Flight.getMinutesDifference(self._blockTimeStart.minutes, 1290 departureMinutes)) 1291 flightStartDifference = \ 1292 Flight.getMinutesDifference(self._flightTimeStart.minutes, 1293 self._blockTimeStart.minutes) 1294 arrivalMinutes = \ 1295 bookedFlight.arrivalTime.hour*60 + bookedFlight.arrivalTime.minute 1296 arrivalDifference = abs(Flight.getMinutesDifference(self._blockTimeEnd.minutes, 1297 arrivalMinutes)) 1298 flightEndDifference = \ 1299 Flight.getMinutesDifference(self._blockTimeEnd.minutes, 1300 self._flightTimeEnd.minutes) 1301 1302 timesOK = self._flightInfo.hasComments or \ 1303 self._flightInfo.hasDelayCode or \ 1304 (departureDifference<=Flight.TIME_ERROR_DIFFERENCE and 1305 arrivalDifference<=Flight.TIME_ERROR_DIFFERENCE and 1306 flightStartDifference>=0 and flightStartDifference<30 and 1307 flightEndDifference>=0 and flightEndDifference<30) 1308 1309 text = self._sid.get_child().get_text() 1310 sid = text if self._sid.get_active()!=0 and text and text!="N/A" \ 1311 else None 1312 1313 text = self._star.get_child().get_text() 1314 star = text if self._star.get_active()!=0 and text and text!="N/A" \ 1315 else None 1316 1317 text = self._transition.get_child().get_text() 1318 transition = text if self._transition.get_active()!=0 \ 1319 and text and text!="N/A" else None 1320 1321 1322 buffer = self._userRoute.get_buffer() 1323 route = buffer.get_text(buffer.get_start_iter(), 1324 buffer.get_end_iter(), True) 1325 1326 self._okButton.set_sensitive(timesOK and 1327 self._flightInfo.faultsFullyExplained and 1328 self._flownNumPassengers.get_value_as_int()>0 and 1329 self._flownNumCrew.get_value_as_int()>2 and 1330 self._fuelUsed.get_value_as_int()>0 and 1331 self._departureRunway.get_text_length()>0 and 1332 self._arrivalRunway.get_text_length()>0 and 1333 self._departureMETAR.get_buffer().get_char_count()>0 and 1334 self._arrivalMETAR.get_buffer().get_char_count()>0 and 1335 self._filedCruiseLevel.get_value_as_int()>=50 and 1336 self._modifiedCruiseLevel.get_value_as_int()>=50 and 1337 sid is not None and (star is not None or 1338 transition is not None) and route!="" and 1339 self._approachType.get_text()!="") 1340 1249 1341 #------------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.