Ignore:
Timestamp:
03/14/22 08:46:34 (3 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
Message:

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

Location:
src/mlx/gui
Files:
5 edited

Legend:

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

    r1008 r1033  
    1515from mlx.i18n import xstr, getLanguage
    1616from mlx.sound import startSound
     17from mlx.rpc import BookedFlight
    1718import mlx.web as web
    1819
     
    21052106        super(PayloadPage, self).__init__(wizard, "payload",
    21062107                                          xstr("payload_title"),
    2107                                           xstr("payload_help"),
     2108                                          xstr("payload_help") + "\n\n \n \n",
    21082109                                          completedHelp = xstr("payload_chelp"))
    21092110
     
    21182119        self.setMainWidget(alignment)
    21192120
    2120         label = Gtk.Label(xstr("payload_crew"))
     2121        self._crewLabel = label = Gtk.Label(xstr("payload_crew"))
    21212122        label.set_use_underline(True)
    21222123        label.set_alignment(0.0, 0.5)
    21232124        table.attach(label, 0, 1, 0, 1)
    21242125
    2125         self._numCrew = IntegerEntry(defaultValue = 0)
    2126         self._numCrew.set_width_chars(6)
    2127         self._numCrew.connect("integer-changed", self._weightChanged)
    2128         self._numCrew.set_tooltip_text(xstr("payload_crew_tooltip"))
    2129         table.attach(self._numCrew, 1, 2, 0, 1)
    2130         label.set_mnemonic_widget(self._numCrew)
    2131 
    2132         label = Gtk.Label(xstr("payload_pax"))
     2126        self._numCockpitCrew = Gtk.Label()
     2127
     2128        self._numCabinCrew = IntegerEntry(defaultValue = 0)
     2129        self._numCabinCrew.set_width_chars(6)
     2130        self._numCabinCrew.connect("integer-changed", self._weightChanged)
     2131        self._numCabinCrew.set_tooltip_text(xstr("payload_crew_tooltip"))
     2132
     2133        crewBox = Gtk.HBox()
     2134        crewBox.pack_start(self._numCockpitCrew, False, False, 0)
     2135        crewBox.pack_start(Gtk.Label("+"), False, False, 4)
     2136        crewBox.pack_start(self._numCabinCrew, False, False, 0)
     2137        crewBox.set_halign(Gtk.Align.END)
     2138
     2139        table.attach(crewBox, 1, 2, 0, 1)
     2140        label.set_mnemonic_widget(self._numCabinCrew)
     2141
     2142        label = Gtk.Label(xstr("payload_crew_info"))
     2143        label.set_halign(Gtk.Align.START)
     2144        table.attach(label, 2, 3, 0, 1)
     2145
     2146        self._paxLabel = label = Gtk.Label(xstr("payload_pax"))
    21332147        label.set_use_underline(True)
    21342148        label.set_alignment(0.0, 0.5)
     
    21392153        self._numPassengers.connect("integer-changed", self._weightChanged)
    21402154        self._numPassengers.set_tooltip_text(xstr("payload_pax_tooltip"))
    2141         table.attach(self._numPassengers, 1, 2, 1, 2)
     2155
     2156        self._numChildren = IntegerEntry(defaultValue = 0)
     2157        self._numChildren.set_width_chars(6)
     2158        self._numChildren.connect("integer-changed", self._weightChanged)
     2159        self._numChildren.set_tooltip_text(xstr("payload_pax_children_tooltip"))
     2160
     2161        self._numInfants = IntegerEntry(defaultValue = 0)
     2162        self._numInfants.set_width_chars(6)
     2163        self._numInfants.connect("integer-changed", self._weightChanged)
     2164        self._numInfants.set_tooltip_text(xstr("payload_pax_infants_tooltip"))
     2165
     2166        paxBox = Gtk.HBox()
     2167        paxBox.pack_start(self._numPassengers, False, False, 0)
     2168        paxBox.pack_start(Gtk.Label("+"), False, False, 4)
     2169        paxBox.pack_start(self._numChildren, False, False, 0)
     2170        paxBox.pack_start(Gtk.Label("+"), False, False, 4)
     2171        paxBox.pack_start(self._numInfants, False, False, 0)
     2172
     2173        table.attach(paxBox, 1, 2, 1, 2)
    21422174        label.set_mnemonic_widget(self._numPassengers)
     2175
     2176        label = Gtk.Label(xstr("payload_pax_info"))
     2177        label.set_halign(Gtk.Align.START)
     2178        table.attach(label, 2, 3, 1, 2)
    21432179
    21442180        label = Gtk.Label(xstr("payload_bag"))
     
    21512187        self._bagWeight.connect("integer-changed", self._weightChanged)
    21522188        self._bagWeight.set_tooltip_text(xstr("payload_bag_tooltip"))
     2189        self._bagWeight.set_hexpand(False)
     2190        self._bagWeight.set_halign(Gtk.Align.END)
    21532191        table.attach(self._bagWeight, 1, 2, 2, 3)
    21542192        label.set_mnemonic_widget(self._bagWeight)
    21552193
    2156         table.attach(Gtk.Label("kg"), 2, 3, 2, 3)
     2194        label = Gtk.Label("kg")
     2195        label.set_halign(Gtk.Align.START)
     2196        table.attach(label, 2, 3, 2, 3)
    21572197
    21582198        label = Gtk.Label(xstr("payload_cargo"))
     
    21652205        self._cargoWeight.connect("integer-changed", self._weightChanged)
    21662206        self._cargoWeight.set_tooltip_text(xstr("payload_cargo_tooltip"))
     2207        self._cargoWeight.set_hexpand(False)
     2208        self._cargoWeight.set_halign(Gtk.Align.END)
    21672209        table.attach(self._cargoWeight, 1, 2, 3, 4)
    21682210        label.set_mnemonic_widget(self._cargoWeight)
    21692211
    2170         table.attach(Gtk.Label("kg"), 2, 3, 3, 4)
     2212        label = Gtk.Label("kg")
     2213        label.set_halign(Gtk.Align.START)
     2214        table.attach(label, 2, 3, 3, 4)
    21712215
    21722216        label = Gtk.Label(xstr("payload_mail"))
     
    21792223        self._mailWeight.connect("integer-changed", self._weightChanged)
    21802224        self._mailWeight.set_tooltip_text(xstr("payload_mail_tooltip"))
     2225        self._mailWeight.set_hexpand(False)
     2226        self._mailWeight.set_halign(Gtk.Align.END)
    21812227        table.attach(self._mailWeight, 1, 2, 4, 5)
    21822228        label.set_mnemonic_widget(self._mailWeight)
    21832229
    2184         table.attach(Gtk.Label("kg"), 2, 3, 4, 5)
     2230        label = Gtk.Label("kg")
     2231        label.set_halign(Gtk.Align.START)
     2232        table.attach(label, 2, 3, 4, 5)
    21852233
    21862234        label = Gtk.Label("<b>" + xstr("payload_zfw") + "</b>")
     
    21942242        table.attach(self._calculatedZFW, 1, 2, 5, 6)
    21952243
    2196         table.attach(Gtk.Label("kg"), 2, 3, 5, 6)
     2244        label = Gtk.Label("kg")
     2245        label.set_halign(Gtk.Align.START)
     2246        table.attach(label, 2, 3, 5, 6)
    21972247
    21982248        self._zfwButton = Gtk.Button(xstr("payload_fszfw"))
     
    22082258        self._simulatorZFWValue = None
    22092259
    2210         table.attach(Gtk.Label("kg"), 2, 3, 6, 7)
     2260        label = Gtk.Label("kg")
     2261        label.set_halign(Gtk.Align.START)
     2262        table.attach(label, 2, 3, 6, 7)
    22112263
    22122264        self.addCancelFlightButton()
     
    22152267
    22162268    @property
    2217     def numCrew(self):
    2218         """The number of the crew members on the flight."""
    2219         return self._numCrew.get_int()
     2269    def numCockpitCrew(self):
     2270        """The number of the cockpit crew members on the flight."""
     2271        return self._wizard._bookedFlight.numCockpitCrew
     2272
     2273    @property
     2274    def numCabinCrew(self):
     2275        """The number of the cabin members on the flight."""
     2276        return self._numCabinCrew.get_int()
    22202277
    22212278    @property
    22222279    def numPassengers(self):
    2223         """The number of the passengers on the flight."""
     2280        """The number of the adult passengers on the flight."""
    22242281        return self._numPassengers.get_int()
     2282
     2283    @property
     2284    def numChildren(self):
     2285        """The number of the child passengers on the flight."""
     2286        return self._numChildren.get_int()
     2287
     2288    @property
     2289    def numInfants(self):
     2290        """The number of the infant passengers on the flight."""
     2291        return self._numInfants.get_int()
    22252292
    22262293    @property
     
    22432310        bookedFlight = self._wizard._bookedFlight
    22442311
    2245         self._numCrew.set_int(bookedFlight.numCrew)
    2246         self._numCrew.set_sensitive(True)
     2312        self._numCockpitCrew.set_markup("<b>" +
     2313                                        str(bookedFlight.numCockpitCrew) +
     2314                                        "</b>")
     2315        self._numCabinCrew.set_int(bookedFlight.numCabinCrew)
     2316        self._numCabinCrew.set_sensitive(True)
     2317
     2318
    22472319        self._numPassengers.set_int(bookedFlight.numPassengers)
    22482320        self._numPassengers.set_sensitive(True)
    22492321
     2322        self._numChildren.set_int(bookedFlight.numChildren)
     2323        self._numChildren.set_sensitive(True)
     2324
     2325        self._numInfants.set_int(bookedFlight.numInfants)
     2326        self._numInfants.set_sensitive(True)
     2327
    22502328        self._bagWeight.set_int(bookedFlight.bagWeight)
    22512329        self._bagWeight.set_sensitive(True)
    2252         self._cargoWeight.set_int(bookedFlight.cargoWeight)
    2253         self._cargoWeight.set_sensitive(True)
    2254         self._mailWeight.set_int(bookedFlight.mailWeight)
    2255         self._mailWeight.set_sensitive(True)
     2330
     2331        if bookedFlight.flightType==BookedFlight.FLIGHT_TYPE_CHARTER:
     2332            self._cargoWeight.set_int(0)
     2333            self._cargoWeight.set_sensitive(False)
     2334            self._mailWeight.set_int(0)
     2335            self._mailWeight.set_sensitive(False)
     2336        else:
     2337            self._cargoWeight.set_int(bookedFlight.cargoWeight)
     2338            self._cargoWeight.set_sensitive(True)
     2339            self._mailWeight.set_int(bookedFlight.mailWeight)
     2340            self._mailWeight.set_sensitive(True)
    22562341
    22572342        self._simulatorZFW.set_text("-")
     
    22622347    def finalize(self):
    22632348        """Finalize the payload page."""
    2264         self._numCrew.set_sensitive(False)
     2349        self._numCabinCrew.set_sensitive(False)
    22652350        self._numPassengers.set_sensitive(False)
     2351        self._numChildren.set_sensitive(False)
     2352        self._numInfants.set_sensitive(False)
    22662353        self._bagWeight.set_sensitive(False)
    22672354        self._cargoWeight.set_sensitive(False)
     
    22712358    def calculateZFW(self):
    22722359        """Calculate the ZFW value."""
    2273         zfw = self._wizard.gui._flight.aircraft.dow
    2274         zfw += (self._numCrew.get_int() + self._numPassengers.get_int()) * 82
     2360        bookedFlight = self._wizard._bookedFlight
     2361
     2362        zfw = bookedFlight.dow
     2363        zfw += (self._numCabinCrew.get_int() - bookedFlight.dowNumCabinCrew) *  \
     2364            const.WEIGHT_CABIN_CREW
     2365        zfw += self._numPassengers.get_int() * \
     2366            (const.WEIGHT_PASSENGER_CHARTER
     2367             if bookedFlight.flightType==BookedFlight.FLIGHT_TYPE_CHARTER
     2368             else const.WEIGHT_PASSENGER)
     2369        zfw += self._numChildren.get_int() * const.WEIGHT_CHILD
     2370        zfw += self._numInfants.get_int() * const.WEIGHT_INFANT
    22752371        zfw += self._bagWeight.get_int()
    22762372        zfw += self._cargoWeight.get_int()
     
    22912387
    22922388    def _weightChanged(self, entry, weight):
    2293         """Called when one of the weight values or humanm counts has changed."""
     2389        """Called when one of the weight values or humanm counts has
     2390        changed."""
     2391        bookedFlight = self._wizard._bookedFlight
     2392        numPassengers = \
     2393            self._numPassengers.get_int() + \
     2394            self._numChildren.get_int() + \
     2395            self._numInfants.get_int()
     2396        minCabinCrew = 0 if numPassengers==0 else \
     2397            (bookedFlight.maxPassengers // 50) + 1
     2398
     2399        extraHelp = []
     2400        enoughCrew = self._numCabinCrew.get_int() >= minCabinCrew
     2401        if enoughCrew:
     2402            self._crewLabel.set_text(xstr("payload_crew"))
     2403            self.setHelp(xstr("payload_help"))
     2404        else:
     2405            self._crewLabel.set_markup("<b><span foreground=\"red\">" +
     2406                                       xstr("payload_crew") +
     2407                                       "</span></b>")
     2408            extraHelp.append(xstr("payload_help_few_crew") % (minCabinCrew,))
     2409        self._crewLabel.set_use_underline(True)
     2410
     2411        tooManyPassengers = numPassengers>bookedFlight.maxPassengers
     2412        if tooManyPassengers:
     2413            self._paxLabel.set_markup("<b><span foreground=\"red\">" +
     2414                                      xstr("payload_pax") +
     2415                                      "</span></b>")
     2416            extraHelp.append(xstr("payload_help_many_pax") % (bookedFlight.maxPassengers,))
     2417        else:
     2418            self._paxLabel.set_text(xstr("payload_pax"))
     2419        self._paxLabel.set_use_underline(True)
     2420
     2421        hlp = xstr("payload_help") + "\n\n"
     2422        for eh in extraHelp:
     2423            hlp += "<b><span foreground=\"red\">" + eh + "</span></b>\n"
     2424        hlp += " \n" * (2-len(extraHelp))
     2425        self.setHelp(hlp)
     2426
     2427        self._button.set_sensitive(enoughCrew and not tooManyPassengers)
     2428
     2429
    22942430        self._updateCalculatedZFW()
    22952431
     
    55395675
    55405676    @property
    5541     def numCrew(self):
    5542         """Get the number of crew members."""
    5543         return self._payloadPage.numCrew
     5677    def numCockpitCrew(self):
     5678        """Get the number of cockpit crew members."""
     5679        return self._payloadPage.numCockpitCrew
     5680
     5681    @property
     5682    def numCabinCrew(self):
     5683        """Get the number of cabin crew members."""
     5684        return self._payloadPage.numCabinCrew
    55445685
    55455686    @property
     
    55475688        """Get the number of passengers."""
    55485689        return self._payloadPage.numPassengers
     5690
     5691    @property
     5692    def numChildren(self):
     5693        """Get the number of child passengers."""
     5694        return self._payloadPage.numChildren
     5695
     5696    @property
     5697    def numInfants(self):
     5698        """Get the number of infant passengers."""
     5699        return self._payloadPage.numInfants
    55495700
    55505701    @property
  • src/mlx/gui/flightlist.py

    r999 r1033  
    610610                         extraColumnAttributes =
    611611                             { "alignment": 0.5 } ),
    612         ColumnDescriptor("numPassengers", xstr("acceptedflt_num_pax"),
     612        ColumnDescriptor("totalNumPassengers", xstr("acceptedflt_num_pax"),
    613613                         type = int, sortable = True,
    614614                         extraColumnAttributes =
  • src/mlx/gui/gui.py

    r1010 r1033  
    263263
    264264    @property
    265     def numCrew(self):
    266         """Get the number of crew members."""
    267         return self._wizard.numCrew
     265    def numCockpitCrew(self):
     266        """Get the number of cockpit crew members."""
     267        return self._wizard.numCockpitCrew
     268
     269    @property
     270    def numCabinCrew(self):
     271        """Get the number of cabin crew members."""
     272        return self._wizard.numCabinCrew
    268273
    269274    @property
     
    271276        """Get the number of passengers."""
    272277        return self._wizard.numPassengers
     278
     279    @property
     280    def numChildren(self):
     281        """Get the number of child passengers."""
     282        return self._wizard.numChildren
     283
     284    @property
     285    def numInfants(self):
     286        """Get the number of infant passengers."""
     287        return self._wizard.numInfants
    273288
    274289    @property
  • src/mlx/gui/pirep.py

    r999 r1033  
    336336                                    bookedFlight.arrivalTime.minute))
    337337
    338         self._numPassengers.set_text(str(bookedFlight.numPassengers))
    339         self._numCrew.set_text(str(bookedFlight.numCrew))
     338        self._numPassengers.set_text(str(bookedFlight.numPassengers) + " + " +
     339                                     str(bookedFlight.numChildren) + " + " +
     340                                     str(bookedFlight.numInfants))
     341        self._numCrew.set_text(str(bookedFlight.numCockpitCrew) + " + " +
     342                               str(bookedFlight.numCabinCrew))
    340343        self._bagWeight.set_text(str(bookedFlight.bagWeight))
    341344        self._cargoWeight.set_text(str(bookedFlight.cargoWeight))
     
    378381            self._rating.set_text("%.1f %%" % (rating,))
    379382
    380         self._flownNumCrew.set_text("%d" % (pirep.numCrew,))
     383        self._flownNumCabinCrew.set_text("%d" % (pirep.numCabinCrew,))
    381384        self._flownNumPassengers.set_text("%d" % (pirep.numPassengers,))
    382385        self._flownBagWeight.set_text("%.0f" % (pirep.bagWeight,))
     
    696699                                    width = 4)
    697700
    698         self._flownNumCrew = \
     701        self._flownNumCabinCrew = \
    699702            PIREPViewer.tableAttach(table, 1, 0,
    700703                                    xstr("pirepView_numCrew"),
     
    898901                                    bookedFlight.arrivalTime.minute))
    899902
    900         self._numPassengers.set_text(str(bookedFlight.numPassengers))
    901         self._numCrew.set_text(str(bookedFlight.numCrew))
     903        self._numPassengers.set_text(str(bookedFlight.numPassengers) + " + " +
     904                                     str(bookedFlight.numChildren) + " + " +
     905                                     str(bookedFlight.numInfants))
     906        self._numCrew.set_text(str(bookedFlight.numCockpitCrew) + " + " +
     907                               str(bookedFlight.numCabinCrew))
    902908        self._bagWeight.set_text(str(bookedFlight.bagWeight))
    903909        self._cargoWeight.set_text(str(bookedFlight.cargoWeight))
     
    943949            self._rating.set_text("%.1f %%" % (rating,))
    944950
    945         self._flownNumCrew.set_value(pirep.numCrew)
     951        self._flownNumCabinCrew.set_value(pirep.numCabinCrew)
    946952        self._flownNumPassengers.set_value(pirep.numPassengers)
     953        self._flownNumChildren.set_value(pirep.numChildren)
     954        self._flownNumInfants.set_value(pirep.numInfants)
    947955        self._flownBagWeight.set_value(pirep.bagWeight)
    948956        self._flownCargoWeight.set_value(pirep.cargoWeight)
     
    13621370        table.set_homogeneous(False)
    13631371
    1364         self._flownNumPassengers = \
    1365             PIREPEditor.tableAttachSpinButton(table, 0, 0,
    1366                                               xstr("pirepView_numPassengers"),
    1367                                               300)
    1368         self._flownNumPassengers.connect("value-changed", self._updateButtons)
    1369         self._flownNumPassengers.set_tooltip_text(xstr("payload_pax_tooltip"))
    1370 
    1371         self._flownNumCrew = \
    1372             PIREPEditor.tableAttachSpinButton(table, 2, 0,
     1372        label = Gtk.Label("<b>" + xstr("pirepView_numPassengers") + "</b>")
     1373        label.set_use_markup(True)
     1374        alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5,
     1375                                  xscale = 0.0, yscale = 0.0)
     1376        alignment.add(label)
     1377        table.attach(alignment, 0, 1, 0, 1)
     1378
     1379
     1380
     1381        self._flownNumPassengers = button = Gtk.SpinButton()
     1382        button.set_range(min = 0, max = 300)
     1383        button.set_increments(step = 1, page = 10)
     1384        button.set_numeric(True)
     1385        button.set_width_chars(2)
     1386        button.set_alignment(1.0)
     1387        button.connect("value-changed", self._updateButtons)
     1388        button.set_tooltip_text(xstr("payload_pax_tooltip"))
     1389
     1390        self._flownNumChildren = button = Gtk.SpinButton()
     1391        button.set_range(min = 0, max = 300)
     1392        button.set_increments(step = 1, page = 10)
     1393        button.set_numeric(True)
     1394        button.set_width_chars(2)
     1395        button.set_alignment(1.0)
     1396        button.connect("value-changed", self._updateButtons)
     1397        button.set_tooltip_text(xstr("payload_pax_children_tooltip"))
     1398
     1399        self._flownNumInfants = button = Gtk.SpinButton()
     1400        button.set_range(min = 0, max = 300)
     1401        button.set_increments(step = 1, page = 10)
     1402        button.set_numeric(True)
     1403        button.set_width_chars(2)
     1404        button.set_alignment(1.0)
     1405        button.connect("value-changed", self._updateButtons)
     1406        button.set_tooltip_text(xstr("payload_pax_infants_tooltip"))
     1407
     1408        paxBox = Gtk.HBox()
     1409        paxBox.pack_start(self._flownNumPassengers, False, False, 0)
     1410        paxBox.pack_start(Gtk.Label("+"), False, False, 4)
     1411        paxBox.pack_start(self._flownNumChildren, False, False, 0)
     1412        paxBox.pack_start(Gtk.Label("+"), False, False, 4)
     1413        paxBox.pack_start(self._flownNumInfants, False, False, 0)
     1414        paxBox.set_halign(Gtk.Align.END)
     1415
     1416        table.attach(paxBox, 1, 4, 0, 1)
     1417
     1418        self._flownNumCabinCrew = \
     1419            PIREPEditor.tableAttachSpinButton(table, 4, 0,
    13731420                                              xstr("pirepView_numCrew"),
    13741421                                              10)
    1375         self._flownNumCrew.connect("value-changed", self._updateButtons)
    1376         self._flownNumCrew.set_tooltip_text(xstr("payload_crew_tooltip"))
     1422        self._flownNumCabinCrew.connect("value-changed", self._updateButtons)
     1423        self._flownNumCabinCrew.set_tooltip_text(xstr("payload_crew_tooltip"))
    13771424
    13781425        self._flownBagWeight = \
     
    14931540                                 buffer.get_end_iter(), True)
    14941541
     1542        numPassengers = \
     1543            self._flownNumPassengers.get_value_as_int() + \
     1544            self._flownNumChildren.get_value_as_int() + \
     1545            self._flownNumInfants.get_value_as_int()
     1546
     1547        minCabinCrew = 0 if numPassengers==0 else \
     1548            (bookedFlight.maxPassengers // 50) + 1
     1549
    14951550        self._okButton.set_sensitive(self._modified and timesOK and
    14961551                                     self._flightInfo.faultsFullyExplained and
    1497                                      self._flownNumPassengers.get_value_as_int()>0 and
    1498                                      self._flownNumCrew.get_value_as_int()>2 and
     1552                                     numPassengers<=bookedFlight.maxPassengers and
     1553                                     self._flownNumCabinCrew.get_value_as_int()>=minCabinCrew and
    14991554                                     self._fuelUsed.get_value_as_int()>0 and
    15001555                                     self._departureRunway.get_text_length()>0 and
     
    15471602        pirep.fuelUsed = self._fuelUsed.get_value()
    15481603
    1549         pirep.numCrew = self._flownNumCrew.get_value()
     1604        pirep.numCabinCrew = self._flownNumCabinCrew.get_value()
    15501605        pirep.numPassengers = self._flownNumPassengers.get_value()
    15511606        pirep.bagWeight = self._flownBagWeight.get_value()
  • 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.