Changeset 1118:f5aca16c252f


Ignore:
Timestamp:
10/29/23 08:48:11 (6 months ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

When using SimBrief, it is not needed to enter FL and route (re #377)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r1110 r1118  
    29992999        return self._cruiseLevel.get_value_as_int()
    30003000
     3001    @filedCruiseLevel.setter
     3002    def filedCruiseLevel(self, fl):
     3003        """Set the filed cruise level."""
     3004        self._cruiseLevel.set_value(fl)
     3005
    30013006    @property
    30023007    def route(self):
    30033008        """Get the route."""
    30043009        return self._getRoute()
     3010
     3011    @route.setter
     3012    def route(self, r):
     3013        """Set the route."""
     3014        self._route.get_buffer().set_text(r)
    30053015
    30063016    @property
     
    30253035    def _updateForwardButton(self):
    30263036        """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
    30293043        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))
    30323051
    30333052    def _cruiseLevelChanged(self, *arg):
     
    34553474        self._cruiseProfile.set_active(0)
    34563475        self._descentProfile.set_active(0)
     3476        self._cruiseParameter.set_text("")
    34573477
    34583478        self._resultTimestamp = None
     
    37003720        plan["cargo"] = str((wizard.bagWeight + wizard.cargoWeight + wizard.mailWeight)/1000.0)
    37013721
    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
    37043729        plan["altn"] = wizard.alternate
    37053730
     
    37983823                elif element.tag in ["files", "prefile"]:
    37993824                    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
    38003847                else:
    38013848                    availableInfo[element.tag] = element.text
     
    38843931            self._wizard.arrivalMETARChanged(flightInfo["dest_metar"], self,
    38853932                                             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
    38863956            self._wizard.nextPage()
    38873957        else:
     
    39073977        self._wizard.jumpPage("fuel", fromPageShift = 1)
    39083978
    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))
    39104022
    39114023#-----------------------------------------------------------------------------
     
    48204932            self._runway.set_text(self._wizard.takeoffRunway)
    48214933        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)
    48234938        self._sid.set_sensitive(True)
    48244939        self._v1.set_int(None)
     
    53595474        self._updatingMETAR = False
    53605475
    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)
    53625480        self._star.set_sensitive(True)
    53635481
     
    63496467        return self._routePage.filedCruiseLevel
    63506468
     6469    @filedCruiseLevel.setter
     6470    def filedCruiseLevel(self, fl):
     6471        """Set the filed cruise level."""
     6472        self._routePage.filedCruiseLevel = fl
     6473
    63516474    @property
    63526475    def filedCruiseAltitude(self):
     
    63746497        return self._routePage.route
    63756498
     6499    @route.setter
     6500    def route(self, r):
     6501        """Set the route."""
     6502        self._routePage.route = r
     6503
    63766504    @property
    63776505    def alternate(self):
     
    63986526        """Get the SID."""
    63996527        return self._takeoffPage.sid
     6528
     6529    @sid.setter
     6530    def sid(self, s):
     6531        """Set the SID."""
     6532        self._takeoffPage.sid = s
    64006533
    64016534    @property
     
    64436576        """Get the STAR."""
    64446577        return self._landingPage.star
     6578
     6579    @star.setter
     6580    def star(self, s):
     6581        """Set the STAR."""
     6582        self._landingPage.star = s
    64456583
    64466584    @property
     
    65526690        self._usingSimBrief = None
    65536691        self.takeoffRunway = None
     6692        self.departureSID = None
    65546693        self.landingRunway = None
     6694        self.arrivalSTAR = None
    65556695
    65566696        firstPage = 0 if self._loginResult is None else 1
Note: See TracChangeset for help on using the changeset viewer.