Changeset 898:55da787ce6e1 for src


Ignore:
Timestamp:
03/16/18 08:58:18 (6 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Aircraft type information (currently DOW, and crew-specific DOW values) are queried via RPC when logging in.

Location:
src/mlx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/acft.py

    r895 r898  
    9797class Aircraft(object):
    9898    """Base class for aircraft."""
     99    dowCockpit = 2
     100    dowCabin = 3
     101
    99102    @staticmethod
    100103    def create(flight, bookedFlight):
     
    829832class B734(Boeing737CL):
    830833    """Boeing 737-400 aircraft."""
     834    dow = 35100
     835
    831836    def __init__(self, flight):
    832837        super(B734, self).__init__(flight)
    833         self.dow = 35100
    834838        self.mtow = 62822
    835839        self.mlw = 54885
     
    13011305#---------------------------------------------------------------------------------------
    13021306
     1307def setupTypes(aircraftTypes):
     1308    """Setup the values in the given types using the info retrieved
     1309    from the server."""
     1310    for aircraftTypeInfo in aircraftTypes:
     1311        clazz = getClass(aircraftTypeInfo.aircraftType)
     1312
     1313        clazz.dow = aircraftTypeInfo.dow
     1314        clazz.dowCockpit = aircraftTypeInfo.dowCockpit
     1315        clazz.dowCabin = aircraftTypeInfo.dowCabin
     1316
     1317#---------------------------------------------------------------------------------------
     1318
    13031319if __name__ == "__main__":
    13041320    value = SmoothedValue()
  • src/mlx/const.py

    r895 r898  
    224224              AIRCRAFT_T154  : "T154",
    225225              AIRCRAFT_YK40  : "YK40",
    226               AIRCRAFT_B462  : "B462" }
     226              AIRCRAFT_B462  : "B462",
     227              AIRCRAFT_IL62  : "IL62" }
     228
     229#-------------------------------------------------------------------------------
     230
     231## A mapping from ICAO codes to the corresponding aircraft types
     232icao2Type = { "B736" : AIRCRAFT_B736,
     233              "B737" : AIRCRAFT_B737,
     234              "B738" : AIRCRAFT_B738,
     235              "B732" : AIRCRAFT_B732,
     236              "B733" : AIRCRAFT_B733,
     237              "B734" : AIRCRAFT_B734,
     238              "B735" : AIRCRAFT_B735,
     239              "DH8D" : AIRCRAFT_DH8D,
     240              "B762" : AIRCRAFT_B762,
     241              "B763" : AIRCRAFT_B763,
     242              "CRJ2" : AIRCRAFT_CRJ2,
     243              "F70"  : AIRCRAFT_F70,
     244              "DC3"  : AIRCRAFT_DC3,
     245              "T134" : AIRCRAFT_T134,
     246              "T154" : AIRCRAFT_T154,
     247              "YK40" : AIRCRAFT_YK40,
     248              "B462" : AIRCRAFT_B462,
     249              "IL62" : AIRCRAFT_IL62 }
    227250
    228251#-------------------------------------------------------------------------------
  • src/mlx/rpc.py

    r895 r898  
    381381#---------------------------------------------------------------------------------------
    382382
     383class AircraftTypeInfo(RPCObject):
     384    """Information about an aircraft type."""
     385    # The instructions for the construction
     386    _instructions = {
     387        "dow" : int,
     388        "dowCockpit" : int,
     389        "dowCabin" : int,
     390        }
     391
     392    def __init__(self, value):
     393        """Construct the booked flight object from the given RPC result
     394        value."""
     395        super(AircraftTypeInfo, self).__init__(value,
     396                                               AircraftTypeInfo._instructions)
     397        self.aircraftType = const.icao2Type[value["typeCode"]]
     398
     399#---------------------------------------------------------------------------------------
     400
    383401class Registration(object):
    384402    """Data for registration."""
     
    507525            return None
    508526
     527    def getTypes(self):
     528        """Get the data of the aircraft types supported by us."""
     529        value = self._performCall(lambda sessionID:
     530                                  self._server.getTypes(sessionID))
     531
     532        return [AircraftTypeInfo(t) for t in value]
     533
    509534    def getFlights(self):
    510535        """Get the flights available for performing."""
  • src/mlx/web.py

    r895 r898  
    817817            result.types = loginResult[2]
    818818            result.password = password
     819
     820            result.aircraftTypes = client.getTypes()
     821
    819822            flights = client.getFlights()
    820823            result.flights = flights[0]
    821824            result.reportedFlights = flights[1]
    822825            result.rejectedFlights = flights[2]
     826
    823827            if result.rank=="STU":
    824828                reply = client.getEntryExamStatus()
Note: See TracChangeset for help on using the changeset viewer.