Changeset 1033:330058d37574 for src/mlx/gui/weighthelp.py
- Timestamp:
- 03/14/22 08:46:34 (2 years ago)
- Branch:
- python3
- hg-Phase:
- (<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/weighthelp.py
r996 r1033 4 4 from mlx.i18n import xstr 5 5 from mlx.checks import PayloadChecker 6 from mlx.rpc import BookedFlight 7 8 import mlx.const as const 6 9 7 10 #------------------------------------------------------------------------------- … … 319 322 self._usingHelp.set_sensitive(True) 320 323 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 323 329 self._pax = -1 324 self._humanWeight = 82.0 330 self._children = -1 331 self._infants = -1 325 332 self._bag = -1 326 333 self._cargo = -1 … … 341 348 def _setupCalculated(self): 342 349 """Setup the labels for the calculated values.""" 343 if self._crew<0: 350 crewWeight = self._getCrewWeight() 351 if crewWeight is None: 344 352 self._crewLabel.set_text(xstr("weighthelp_crew") % ("-",)) 345 353 self._crewWeight.set_text("-") 346 354 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),)) 349 358 self._crewWeight.set_text("%.0f" % (crewWeight,)) 350 351 if self._pax<0: 359 360 paxWeight = self._getPaxWeight() 361 if paxWeight<0: 352 362 self._paxLabel.set_text(xstr("weighthelp_pax") % ("-",)) 353 363 self._paxWeight.set_text("-") 354 364 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),)) 357 369 self._paxWeight.set_text("%.0f" % (paxWeight,)) 358 370 … … 416 428 self._setWeightLabel(self._fsGross, self._fsGrossValue) 417 429 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 418 450 def _calculateWeights(self): 419 451 """Calculate the payload and the zero-fuel weight. … … 421 453 It returns a tuple with these two items. If any of the items cannot be 422 454 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 \ 424 458 self._bag<0 or self._cargo<0 or self._mail<0: 425 459 payload = -1 426 460 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 429 462 430 463 if payload<0 or self._dowValue<0: … … 442 475 self._gui.logger.untimedMessage("The weight calculation help function was used by the pilot") 443 476 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 445 482 self._pax = self._gui.numPassengers 483 self._children = self._gui.numChildren 484 self._infants = self._gui.numInfants 446 485 self._bag = self._gui.bagWeight 447 486 self._cargo = self._gui.cargoWeight 448 487 self._mail = self._gui.mailWeight 488 self._dowValue = bookedFlight.dow 449 489 450 490 aircraft = self._gui.flight.aircraft 451 self._humanWeight = aircraft.humanWeight452 self._dowValue = aircraft.dow453 491 self._mzfwValue = aircraft.mzfw 454 492 self._mtowValue = aircraft.mtow
Note:
See TracChangeset
for help on using the changeset viewer.