Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/rpc.py

    r889 r908  
    208208                      "TU5"  : const.AIRCRAFT_T154,
    209209                      "YK4"  : const.AIRCRAFT_YK40,
    210                       "146"  : const.AIRCRAFT_B462 }
     210                      "146"  : const.AIRCRAFT_B462,
     211                      "IL6"  : const.AIRCRAFT_IL62 }
    211212
    212213    # FIXME: copied from web.BookedFlight
     
    228229                      const.AIRCRAFT_T154  : "TU5",
    229230                      const.AIRCRAFT_YK40  : "YK4",
    230                       const.AIRCRAFT_B462  : "146" }
     231                      const.AIRCRAFT_B462  : "146",
     232                      const.AIRCRAFT_IL62  : "IL6" }
    231233
    232234    # FIXME: copied from web.BookedFlight
     
    234236    def _decodeAircraftType(typeCode):
    235237        """Decode the aircraft type from the given typeCode."""
    236         if typeCode in BookedFlight.TYPECODE2TYPE:
    237             return BookedFlight.TYPECODE2TYPE[typeCode]
     238        if typeCode in const.icao2Type:
     239            return const.icao2Type[typeCode]
    238240        else:
    239241            raise Exception("Invalid aircraft type code: '" + typeCode + "'")
     
    275277    _instructions = {
    276278        "numPassengers" : int,
    277         "numCrew" : int,
     279        "numCockpitCrew" : int,
     280        "numCabinCrew" : int,
    278281        "bagWeight" : int,
    279282        "cargoWeight" : int,
     
    307310        print >> f, "tail_nr=%s" % (self.tailNumber,)
    308311        print >> f, "passenger=%d" % (self.numPassengers,)
    309         print >> f, "crew=%d" % (self.numCrew,)
     312        print >> f, "crew=%d" % (self.numCockpitrew + self.numCabinCrew,)
    310313        print >> f, "bag=%d" % (self.bagWeight,)
    311314        print >> f, "cargo=%d" % (self.cargoWeight,)
     
    376379        for planeValue in value:
    377380            self._addPlane(Plane(planeValue))
     381
     382#---------------------------------------------------------------------------------------
     383
     384class AircraftTypeInfo(RPCObject):
     385    """Information about an aircraft type."""
     386    # The instructions for the construction
     387    _instructions = {
     388        "dow" : int,
     389        "dowCockpit" : int,
     390        "dowCabin" : int,
     391        }
     392
     393    def __init__(self, value):
     394        """Construct the booked flight object from the given RPC result
     395        value."""
     396        super(AircraftTypeInfo, self).__init__(value,
     397                                               AircraftTypeInfo._instructions)
     398        self.aircraftType = const.icao2Type[value["typeCode"]]
    378399
    379400#---------------------------------------------------------------------------------------
     
    498519            self._sessionID = reply.value["sessionID"]
    499520
    500             types = [BookedFlight.TYPECODE2TYPE[typeCode]
     521            types = [const.icao2Type[typeCode]
    501522                     for typeCode in reply.value["typeCodes"]]
    502523
     
    504525        else:
    505526            return None
     527
     528    def getTypes(self):
     529        """Get the data of the aircraft types supported by us."""
     530        value = self._performCall(lambda sessionID:
     531                                  self._server.getTypes(sessionID))
     532
     533        return [AircraftTypeInfo(t) for t in value]
    506534
    507535    def getFlights(self):
     
    599627        of type codes, if any."""
    600628        typeCodes = None if types is None else \
    601             [BookedFlight.TYPE2TYPECODE[type] for type in types]
     629          [const.icaoCodes[type] for type in types]
    602630
    603631        values = self._performCall(lambda sessionID:
Note: See TracChangeset for help on using the changeset viewer.