Changeset 1118:f5aca16c252f
- Timestamp:
- 10/29/23 08:48:11 (14 months ago)
- Branch:
- python3
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r1110 r1118 2999 2999 return self._cruiseLevel.get_value_as_int() 3000 3000 3001 @filedCruiseLevel.setter 3002 def filedCruiseLevel(self, fl): 3003 """Set the filed cruise level.""" 3004 self._cruiseLevel.set_value(fl) 3005 3001 3006 @property 3002 3007 def route(self): 3003 3008 """Get the route.""" 3004 3009 return self._getRoute() 3010 3011 @route.setter 3012 def route(self, r): 3013 """Set the route.""" 3014 self._route.get_buffer().set_text(r) 3005 3015 3006 3016 @property … … 3025 3035 def _updateForwardButton(self): 3026 3036 """Update the sensitivity of the forward button.""" 3027 cruiseLevelText = self._cruiseLevel.get_text() 3028 cruiseLevel = int(cruiseLevelText) if cruiseLevelText else 0 3037 flight = self._wizard.gui.flight 3038 useSimBrief = \ 3039 flight is not None and flight.aircraft.simBriefData is not None and \ 3040 self._wizard.gui.config.useSimBrief and \ 3041 self._wizard.usingSimBrief is not False 3042 3029 3043 alternate = self._alternate.get_text() 3030 self._button.set_sensitive(cruiseLevel>=50 and self._getRoute()!="" and 3031 (len(alternate)==4 or self._wizard.entranceExam)) 3044 if useSimBrief: 3045 self._button.set_sensitive(len(alternate)==4 or self._wizard.entranceExam) 3046 else: 3047 cruiseLevelText = self._cruiseLevel.get_text() 3048 cruiseLevel = int(cruiseLevelText) if cruiseLevelText else 0 3049 self._button.set_sensitive(cruiseLevel>=50 and self._getRoute()!="" and 3050 (len(alternate)==4 or self._wizard.entranceExam)) 3032 3051 3033 3052 def _cruiseLevelChanged(self, *arg): … … 3455 3474 self._cruiseProfile.set_active(0) 3456 3475 self._descentProfile.set_active(0) 3476 self._cruiseParameter.set_text("") 3457 3477 3458 3478 self._resultTimestamp = None … … 3700 3720 plan["cargo"] = str((wizard.bagWeight + wizard.cargoWeight + wizard.mailWeight)/1000.0) 3701 3721 3702 plan["route"] = wizard.route 3703 plan["fl"] = str(wizard.filedCruiseAltitude) 3722 route = wizard.route 3723 if route: 3724 plan["route"] = route 3725 3726 filedCruiseAltitude = wizard.filedCruiseAltitude 3727 if filedCruiseAltitude>0: 3728 plan["fl"] = filedCruiseAltitude 3704 3729 plan["altn"] = wizard.alternate 3705 3730 … … 3798 3823 elif element.tag in ["files", "prefile"]: 3799 3824 availableInfo[element.tag] = element 3825 elif element.tag == "general": 3826 generalElementList = list(element) 3827 for generalElement in generalElementList: 3828 if generalElement.tag in ["initial_altitude", 3829 "route_ifps", 3830 "costindex"]: 3831 flightInfo[generalElement.tag] = generalElement.text 3832 elif element.tag == "origin": 3833 originElementList = list(element) 3834 for originElement in originElementList: 3835 if originElement.tag == "plan_rwy": 3836 flightInfo["dep_rwy"] = originElement.text 3837 elif element.tag == "destination": 3838 destinationElementList = list(element) 3839 for destinationElement in destinationElementList: 3840 if destinationElement.tag == "plan_rwy": 3841 flightInfo["arr_rwy"] = destinationElement.text 3842 elif element.tag == "fuel": 3843 fuelElementList = list(element) 3844 for fuelElement in fuelElementList: 3845 if fuelElement.tag == "extra": 3846 flightInfo["fuel_extra"] = fuelElement.text 3800 3847 else: 3801 3848 availableInfo[element.tag] = element.text … … 3884 3931 self._wizard.arrivalMETARChanged(flightInfo["dest_metar"], self, 3885 3932 fromDownload = True) 3933 3934 cruiseLevel = int(flightInfo["initial_altitude"])/100 3935 self._wizard.filedCruiseLevel = cruiseLevel 3936 3937 (route, sid, star) = self._getRouteData(flightInfo) 3938 self._wizard.route = route 3939 self._wizard.departureSID = sid 3940 self._wizard.arrivalSTAR = star 3941 3942 takeoffRunway = flightInfo["dep_rwy"] 3943 self._wizard.takeoffRunway = takeoffRunway 3944 self._takeoffRunway.set_text(takeoffRunway) 3945 3946 landingRunway = flightInfo["arr_rwy"] 3947 self._wizard.landingRunway = landingRunway 3948 self._landingRunway.set_text(landingRunway) 3949 3950 if "costindex" in flightInfo: 3951 self._setCostIndex(flightInfo["costindex"]) 3952 3953 if "fuel_extra" in flightInfo: 3954 self._extraFuel.set_text(flightInfo["fuel_extra"]) 3955 3886 3956 self._wizard.nextPage() 3887 3957 else: … … 3907 3977 self._wizard.jumpPage("fuel", fromPageShift = 1) 3908 3978 3909 3979 def _getRouteData(self, flightInfo): 3980 """Analyze the route information provided by SimBrief. 3981 3982 Returns a tuple of 3983 - the route 3984 - the SID (may be None) 3985 - the STAR (may be None)""" 3986 route = flightInfo["route_ifps"] 3987 print("route:", route) 3988 words = re.split("\\s+", route) 3989 3990 sid = None 3991 star = None 3992 3993 if len(words)>1: 3994 if words[0]=="DCT": 3995 words = words[1:] 3996 elif len(words[0])>=7 and len(words[1])==5: 3997 if words[0][:5]==words[1]: 3998 sid = words[0] 3999 words = words[1:] 4000 4001 if words[-1]=="DCT": 4002 words = words[:-1] 4003 elif len(words[-1])>=7 and len(words[-2])==5: 4004 if words[-1][:5]==words[-2]: 4005 star = words[-1] 4006 words = words[:-1] 4007 4008 if sid is not None and sid[5].isdigit(): 4009 sid = sid[:5] + " " + sid[5:] 4010 if star is not None and star[5].isdigit(): 4011 star = star[:5] + " " + star[5:] 4012 4013 return (" ".join(words), sid, star) 4014 4015 def _setCostIndex(self, costIndex): 4016 """Set the cost index, if the selected cruise profile is a CI.""" 4017 cruiseParameters = self._wizard.gui.flight.aircraft.simBriefData.cruiseParameters 4018 cruiseProfileIndex = self._cruiseProfile.get_active() 4019 if cruiseProfileIndex in cruiseParameters: 4020 if cruiseParameters[cruiseProfileIndex][1]=="civalue": 4021 self._cruiseParameter.set_text(str(costIndex)) 3910 4022 3911 4023 #----------------------------------------------------------------------------- … … 4820 4932 self._runway.set_text(self._wizard.takeoffRunway) 4821 4933 self._runway.set_sensitive(True) 4822 self._sid.set_active(0) 4934 if self._wizard.departureSID is None: 4935 self._sid.set_active(0) 4936 else: 4937 self._sid.get_child().set_text(self._wizard.departureSID) 4823 4938 self._sid.set_sensitive(True) 4824 4939 self._v1.set_int(None) … … 5359 5474 self._updatingMETAR = False 5360 5475 5361 self._star.set_active(0) 5476 if self._wizard.arrivalSTAR is None: 5477 self._star.set_active(0) 5478 else: 5479 self._star.get_child().set_text(self._wizard.arrivalSTAR) 5362 5480 self._star.set_sensitive(True) 5363 5481 … … 6349 6467 return self._routePage.filedCruiseLevel 6350 6468 6469 @filedCruiseLevel.setter 6470 def filedCruiseLevel(self, fl): 6471 """Set the filed cruise level.""" 6472 self._routePage.filedCruiseLevel = fl 6473 6351 6474 @property 6352 6475 def filedCruiseAltitude(self): … … 6374 6497 return self._routePage.route 6375 6498 6499 @route.setter 6500 def route(self, r): 6501 """Set the route.""" 6502 self._routePage.route = r 6503 6376 6504 @property 6377 6505 def alternate(self): … … 6398 6526 """Get the SID.""" 6399 6527 return self._takeoffPage.sid 6528 6529 @sid.setter 6530 def sid(self, s): 6531 """Set the SID.""" 6532 self._takeoffPage.sid = s 6400 6533 6401 6534 @property … … 6443 6576 """Get the STAR.""" 6444 6577 return self._landingPage.star 6578 6579 @star.setter 6580 def star(self, s): 6581 """Set the STAR.""" 6582 self._landingPage.star = s 6445 6583 6446 6584 @property … … 6552 6690 self._usingSimBrief = None 6553 6691 self.takeoffRunway = None 6692 self.departureSID = None 6554 6693 self.landingRunway = None 6694 self.arrivalSTAR = None 6555 6695 6556 6696 firstPage = 0 if self._loginResult is None else 1
Note:
See TracChangeset
for help on using the changeset viewer.