Ignore:
Timestamp:
03/14/22 08:46:34 (2 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Updates for the new crew and passenger handling (re #357)

File:
1 edited

Legend:

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

    r996 r1033  
    44from mlx.i18n import xstr
    55from mlx.checks import PayloadChecker
     6from mlx.rpc import BookedFlight
     7
     8import mlx.const as const
    69
    710#-------------------------------------------------------------------------------
     
    319322        self._usingHelp.set_sensitive(True)
    320323        self._weightsTable.set_sensitive(False)
    321        
    322         self._crew = -1
     324
     325        self._flightType = -1
     326        self._dowCabinCrew = -1
     327        self._cockpitCrew = -1
     328        self._cabinCrew = -1
    323329        self._pax = -1
    324         self._humanWeight = 82.0
     330        self._children = -1
     331        self._infants = -1
    325332        self._bag = -1
    326333        self._cargo = -1
     
    341348    def _setupCalculated(self):
    342349        """Setup the labels for the calculated values."""
    343         if self._crew<0:
     350        crewWeight = self._getCrewWeight()
     351        if crewWeight is None:
    344352            self._crewLabel.set_text(xstr("weighthelp_crew") % ("-",))
    345353            self._crewWeight.set_text("-")
    346354        else:
    347             self._crewLabel.set_text(xstr("weighthelp_crew") % (str(self._crew),))
    348             crewWeight = self._crew * self._humanWeight
     355            self._crewLabel.set_text(xstr("weighthelp_crew") %
     356                                    (str(self._cockpitCrew) + "+" +
     357                                     str(self._cabinCrew),))
    349358            self._crewWeight.set_text("%.0f" % (crewWeight,))
    350            
    351         if self._pax<0:
     359
     360        paxWeight = self._getPaxWeight()
     361        if paxWeight<0:
    352362            self._paxLabel.set_text(xstr("weighthelp_pax") % ("-",))
    353363            self._paxWeight.set_text("-")
    354364        else:
    355             self._paxLabel.set_text(xstr("weighthelp_pax") % (str(self._pax),))
    356             paxWeight = self._pax * self._humanWeight
     365            self._paxLabel.set_text(xstr("weighthelp_pax") %
     366                                    (str(self._pax) + "+" +
     367                                     str(self._children) + "+" +
     368                                     str(self._infants),))
    357369            self._paxWeight.set_text("%.0f" % (paxWeight,))
    358370
     
    416428        self._setWeightLabel(self._fsGross, self._fsGrossValue)
    417429
     430    def _getCrewWeight(self):
     431        """Get the crew weight for the flight."""
     432        if self._cockpitCrew>=0 and self._dowCabinCrew>=0 and self._cabinCrew>=0:
     433            return (self._cabinCrew - self._dowCabinCrew) * const.WEIGHT_CABIN_CREW
     434        else:
     435            return None
     436       
     437    def _getPaxWeight(self):
     438        """Get the passenger weight for the flight."""
     439        if self._flightType>=0 and self._pax>=0 and self._children>=0 and \
     440           self._infants>=0:
     441            return self._pax * \
     442                (const.WEIGHT_PASSENGER_CHARTER
     443                 if self._flightType==BookedFlight.FLIGHT_TYPE_CHARTER
     444                 else const.WEIGHT_PASSENGER) + \
     445                self._children * const.WEIGHT_CHILD + \
     446                self._infants * const.WEIGHT_INFANT
     447        else:
     448            return -1
     449
    418450    def _calculateWeights(self):
    419451        """Calculate the payload and the zero-fuel weight.
     
    421453        It returns a tuple with these two items. If any of the items cannot be
    422454        calculated, that is -1."""
    423         if self._crew<0 or self._pax<0 or \
     455        crewWeight = self._getCrewWeight()
     456        paxWeight = self._getPaxWeight()
     457        if crewWeight is None or paxWeight<0 or \
    424458               self._bag<0 or self._cargo<0 or self._mail<0:
    425459            payload = -1
    426460        else:
    427             payload = (self._crew + self._pax) * self._humanWeight + \
    428                       self._bag + self._cargo + self._mail
     461            payload = crewWeight + paxWeight + self._bag + self._cargo + self._mail
    429462
    430463        if payload<0 or self._dowValue<0:
     
    442475        self._gui.logger.untimedMessage("The weight calculation help function was used by the pilot")
    443476
    444         self._crew = self._gui.numCrew
     477        bookedFlight = self._gui.bookedFlight
     478        self._flightType = bookedFlight.flightType
     479        self._dowCabinCrew = bookedFlight.dowNumCabinCrew
     480        self._cockpitCrew = self._gui.numCockpitCrew
     481        self._cabinCrew = self._gui.numCabinCrew
    445482        self._pax = self._gui.numPassengers
     483        self._children = self._gui.numChildren
     484        self._infants = self._gui.numInfants
    446485        self._bag = self._gui.bagWeight
    447486        self._cargo = self._gui.cargoWeight
    448487        self._mail = self._gui.mailWeight
     488        self._dowValue = bookedFlight.dow
    449489       
    450490        aircraft = self._gui.flight.aircraft
    451         self._humanWeight = aircraft.humanWeight
    452         self._dowValue = aircraft.dow
    453491        self._mzfwValue = aircraft.mzfw
    454492        self._mtowValue = aircraft.mtow
Note: See TracChangeset for help on using the changeset viewer.