Changeset 443:acbe605bb814


Ignore:
Timestamp:
02/28/13 18:56:30 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added support for the BAe 146-200 aircraft type (re #182)

Files:
11 edited

Legend:

Unmodified
Added
Removed
  • dcdatagen.py

    r440 r443  
    3535# Type groups
    3636typeGroups = [ ["B736", "B737", "B738", "B738C", "B733", "B734", "B735",
    37                 "DH8D", "B762", "B763", "CRJ2", "F70" ],
     37                "DH8D", "B762", "B763", "CRJ2", "F70", "B462" ],
    3838               ["DC3", "T134", "T154", "YK40"] ]
    3939
  • doc/overview.dox

    r302 r443  
    1111 * Note, that to be able to understand the code most effectively, it
    1212 * is important to either use the application actively, or to read its
    13  * user documentation carefully. 
     13 * user documentation carefully.
    1414 *
    1515 * \section overview Overview
    1616 *
    17  * The application was written in 
     17 * The application was written in
    1818 * <a href="http://python.org">Python 2</a>. The Python wrapper
    1919 * <a href="http://gtk.org">Gtk+</a> toolkit was used for the graphical
     
    2323 * as the primary toolkit, while it has no reliable port for Windows
    2424 * yet. Therefore it was decided to support both Gtk+ 2 and 3
    25  * depending on the platform. For Gtk+ 2 the 
     25 * depending on the platform. For Gtk+ 2 the
    2626 * <a href="http://pygtk.org">PyGTK</a> wrapper is used, while for Gtk+
    2727 * 3 the <a href="https://live.gnome.org/PyGObject">PyGObject</a>
     
    3333 * <a href="http://www.schiratti.com/dowson.html">FSUIPC</a>
    3434 * interface. The author has created a Python mapping for it, which
    35  * has been submitted for inclusion into the SDK, so it will hopefully 
     35 * has been submitted for inclusion into the SDK, so it will hopefully
    3636 * appear in its next version. It is planned to support X-Plane in the
    3737 * near future (hopefully by the end of 2012) on both Linux and
     
    4545 * Gtk+ and Gtk+ itself. Since Python is an interpreted language,
    4646 * there is no need for any special build system.
    47  * 
     47 *
    4848 * Python and Gtk+ are readily available on most Linux distributions,
    4949 * but some links are probably useful for Windows users:
     
    5454 * \li To create install packages, you also need py2exe: <a href="http://www.py2exe.org/">http://www.py2exe.org</a>,
    5555 * \li as well as the Nullsoft Install System: http://nsis.sourceforge.net/Main_Page
    56  * 
     56 *
    5757 * The install package can be created by running the \c makeinst.bat
    5858 * file. It contains some absolute paths, so check those befure
     
    8181 *    thread. Instead, use \c gobject.idle_add to "inject" the
    8282 *    operation into the main thread.
    83  * -# To ensure the responsiveness of the GUI, only operations 
     83 * -# To ensure the responsiveness of the GUI, only operations
    8484 *    that take a short time should be executed in the GUI thread.
    8585 *
     
    9898 * simulator is to be supported, a class with the same (or at least
    9999 * sufficiently similar) public interface should be implemented.
    100  *             
     100 *
    101101 * The most important function of the program is the
    102102 * continuous monitoring of the aircraft's parameters and some other
    103103 * data. The monitoring is started using the \ref
    104104 * mlx.fsuipc.Simulator.startMonitoring "startMonitoring" function of
    105  * the simulator object. If started, it calls the \ref 
     105 * the simulator object. If started, it calls the \ref
    106106 * mlx.acft.Aircraft.handleState "handleState" function of the
    107107 * mlx.acft.Aircraft instance used. The mlx.acft module contains one
     
    114114 * smoothed values of IAS and VS, and then calls each "checker". A
    115115 * checker is an instance of a subclass of mlx.checks.StateChecker,
    116  * which checks a one or a few parameters that are important from some 
     116 * which checks a one or a few parameters that are important from some
    117117 * aspect of the correct execution of a flight. For example, a checker
    118  * may check if the \ref mlx.checks.StrobeLightsChecker 
     118 * may check if the \ref mlx.checks.StrobeLightsChecker
    119119 * "strobe lights" are switched on and off at the right stages of the
    120120 * flight. But some checkers simply log some \ref
    121121 * mlx.checks.AltimeterLogger "value" whenever it changes
    122122 * in an "interesting" way, or \ref mlx.checks.ACARSSender "send the
    123  * ACARS" periodically. 
     123 * ACARS" periodically.
    124124 *
    125125 * There is also a \ref mlx.checks.StageCheker "checker" which
    126126 * detects the changes in the stage of the flight, and calls the
    127127 * \ref mlx.acft.Aircraft.setStage "setStage" function of the
    128  * aircraft, if there is a change. It first calls the 
     128 * aircraft, if there is a change. It first calls the
    129129 * \ref mlx.flight.Flight "flight"'s \ref mlx.flight.Flight.setStage
    130130 * "setStage" function, which notifies the GUI and the \ref
     
    139139 * mlx.soundsched.SoundScheduler "sound scheduler" to check if some
    140140 * backround sound should be played. If the check list hotkey is
    141  * pressed, the \ref mlx.soundsched.ChecklistScheduler 
     141 * pressed, the \ref mlx.soundsched.ChecklistScheduler
    142142 * "checklist scheduler" is notified too.
    143143 *
    144144 * As mentioned, there is a \ref mlx.logger.Logger "logger" in the
    145145 * application, which contains the textual log lines as well as the
    146  * faults and their scores. 
     146 * faults and their scores.
    147147 *
    148148 * The business logic part contains many other components, but they
     
    151151 * modules for more information.
    152152 *
    153  * \subsection arch_gui GUI     
     153 * \subsection arch_gui GUI
    154154 *
    155155 * As mentioned, the GUI is implemented using Gtk+. This toolkit
     
    158158 * experience with Glade in an earlier project, it was decided to not
    159159 * use it. Instead, the GUI elements are created and handled by
    160  * hand-written code. 
     160 * hand-written code.
    161161 *
    162162 * The central class of the graphical user interface is
     
    165165 * connection to the simulator and creates the \ref mlx.flight.Flight
    166166 * "flight" and \ref mlx.flight.Aircraft "aircraft" objects as
    167  * needed. 
     167 * needed.
    168168 *
    169169 * To understand the operation of the GUI, one should be familiar with
    170170 * Gtk+, but otherwise it is pretty straighforward. See the
    171  * documentation of the relevant modules for more information.
     171 * documentation of the relevant modules for more information.
     172 *
     173 * \section newtype Adding a new aircraft type
     174 *
     175 * While new aircraft types will probably not be added too often, here
     176 * is a checklist about what should be modified when such a
     177 * requirement arises.
     178 *
     179 * First, it is worth to know what data you need to add the new type:
     180 *
     181 * \li the aircraft's type name and its ICAO code
     182 * \li the following weights: DOW, MZFW, MTOW, MLW
     183 * \li the flap settings and their speed limits
     184 * \li the speed limit for extending/retracting the gear (VLE)
     185 * \li the number and types of the fuel tanks
     186 * \li the type code the MAVA website uses to identify the type
     187 * \li if the plane has reversers, what is the operating limit speed,
     188 *     if any
     189 * \li does the plane support the notion of a takeoff derate, and if
     190 *     so, what data should be given
     191 * \li what lights does the plane have
     192 *
     193 * If you have the data, you can add the type by modifying the source
     194 * files as per the checklist below:
     195 *
     196 * -# \c src/mlx/const.py: look for the constants named AIRCRAFT_xxx.
     197 *    Add the new type at the end of the list of those constants, with
     198 *    a number 1 greater than the number of the last existing
     199 *    type. The part of the constant's name after the underscore (xxx
     200 *    above) should be the ICAO code of the aircraft type.
     201 * -# \c src/mlx/const.py: below this list of constants, you can find
     202 *    an array named \c aircraftTypes. Add the type constant to it.
     203 * -# \c src/mlx/const.py: further below you can find a dictionary
     204 *    mapping te aircraft type to the corresponding ICAO codes. Add
     205 *    the new type to it.
     206 * -# \c src/mlx/acft.py: add a new subclass of \ref
     207 *    mlx.acft.Aircraft. Its name should be the ICAO code. Check an
     208 *    existing aircraft and add the same variables containing the
     209 *    weights, the flap speed limits and the gear speed limit. There
     210 *    may be some other member variables or functions that should be
     211 * -# \c src/mlx/acft.py: there is a dictionary named \c _classes
     212 *    towards the end of the file. Add the type to it.
     213 * -# \c src/mlx/web.py: the \ref mlx.web.BookedFlight class contains
     214 *    two dictionaries, the mapping between the types and the values the MAVA
     215 *    website uses to identify the type. Add the appropriate values
     216 *    here.
     217 * -# \c src/mlx/fsuipc.py: add a subclass of \ref
     218 *    mlx.fsuipc.GenericAircraftModel for the new type named the ICAO
     219 *    code of the type followed by the word \c Model. Implement its
     220 *    constructor to supply the base class with the flaps notches
     221 *    (starting with 0), the array of constants describing the fuel
     222 *    tanks the model has, and the number of engines. Also implement
     223 *    the name of the model, which should be something like
     224 *    "FSUIPC/Generic ...". If necessary implement other functions or
     225 *    set other members.
     226 * -# \c src/mlx/fsuipc.py: add the new type and model class to the
     227 *    dictionary named \c _genericModels towards the end of the file.
     228 * -# \c src/mlx/fsuipc.py: if you have a model that has some
     229 *    non-generic characteristics, create a specific class for
     230 *    it. This class should be a subclass of the generic class
     231 *    created, and it should be registered at the bottom of the file,
     232 *    as the other models are.
     233 * -# \c src/mlx/gui/common.py: this file contains a dictionary called
     234 *    \ref mlx.gui.common.aircraftNames. Add the new type it it. It
     235 *    contains the mapping from the type constants to their
     236 *    language-specific names. The string ID is "aircraft_" followed by
     237 *    the lower-cased ICAO code.
     238 * -# \c locale/hu/mlx.po, locale/en/mlx.po: the beginning of this
     239 *    file contains mapping from the string ID previously used to the
     240 *    actual name of the aircraft. Add the new type as appropriate.
     241 * -# \c dcdatagen.py: this program generates some source and message
     242 *    files related to the delay codes. Currently there are two
     243 *    tables, one for old-timer types and the other for the "modern" types.
     244 *    The file contains a list of lists called \c typeGroups. Add the
     245 *    type's ICAO code the appropriate list.
     246 *
     247 * When all the changes have been made, run \c make in the root
     248 * directory to update some source files.
    172249 */
    173  
  • locale/en/mlx.po

    r437 r443  
    6363msgid "aircraft_yk40"
    6464msgstr "Yakovlev Yak-40"
     65
     66msgid "aircraft_b462"
     67msgstr "British Aerospace 146-200"
    6568
    6669msgid "file_filter_all"
  • locale/hu/mlx.po

    r437 r443  
    6464msgstr "Jakovlev Jak-40"
    6565
     66msgid "aircraft_b462"
     67msgstr "British Aerospace 146-200"
     68
    6669msgid "file_filter_all"
    6770msgstr "Összes fájl"
  • src/mlx/acft.py

    r409 r443  
    10171017#---------------------------------------------------------------------------------------
    10181018
     1019class B462(Aircraft):
     1020    """British Aerospace BAe-146 aircraft.
     1021
     1022    The aircraft type-specific values in the aircraft state have the following
     1023    structure:
     1024    - fuel: left, centre, right
     1025    - n1: left outer, left inner, right inner, right outer
     1026    - reverser: empty (the plane has no reversers)"""
     1027    def __init__(self, flight):
     1028        super(B462, self).__init__(flight)
     1029        self.dow = 25706
     1030        self.mtow = 43998
     1031        self.mlw = 38599
     1032        self.mzfw = 33792
     1033        self.gearSpeedLimit = 210
     1034        self.flapSpeedLimits = { 18 : 217,
     1035                                 24 : 180,
     1036                                 30 : 170,
     1037                                 33 : 150 }
     1038
     1039#---------------------------------------------------------------------------------------
     1040
    10191041mostFuelTanks = [const.FUELTANK_LEFT_TIP, const.FUELTANK_EXTERNAL1,
    10201042                 const.FUELTANK_LEFT_AUX,
     
    10401062             const.AIRCRAFT_T134  : T134,
    10411063             const.AIRCRAFT_T154  : T154,
    1042              const.AIRCRAFT_YK40  : YK40 }
     1064             const.AIRCRAFT_YK40  : YK40,
     1065             const.AIRCRAFT_B462  : B462 }
    10431066
    10441067#---------------------------------------------------------------------------------------
  • src/mlx/checks.py

    r416 r443  
    13041304        return flight.stage in [const.STAGE_DESCENT, const.STAGE_LANDING,
    13051305                                const.STAGE_TAXIAFTERLAND] and \
     1306            state.reverser and \
    13061307            state.groundSpeed<aircraft.reverseMinSpeed and max(state.reverser)
    13071308
  • src/mlx/const.py

    r437 r443  
    9595## Aircraft type: Yakovlev Yak-40
    9696AIRCRAFT_YK40 = 15
     97
     98## Aircraft type: British Aerospace BAe-146
     99AIRCRAFT_B462 = 16
    97100
    98101#-------------------------------------------------------------------------------
     
    108111                 AIRCRAFT_B733, AIRCRAFT_B734, AIRCRAFT_B735,
    109112                 AIRCRAFT_T154, AIRCRAFT_T134,
    110                  AIRCRAFT_YK40, AIRCRAFT_DC3]
     113                 AIRCRAFT_YK40, AIRCRAFT_DC3,
     114                 AIRCRAFT_B462]
    111115
    112116#-------------------------------------------------------------------------------
     
    129133              AIRCRAFT_T134  : "T134",
    130134              AIRCRAFT_T154  : "T154",
    131               AIRCRAFT_YK40  : "YK40" }
     135              AIRCRAFT_YK40  : "YK40",
     136              AIRCRAFT_B462  : "B462" }
    132137
    133138#-------------------------------------------------------------------------------
  • src/mlx/fsuipc.py

    r412 r443  
    20432043#------------------------------------------------------------------------------
    20442044
     2045class B462Model(GenericAircraftModel):
     2046    """Generic model for the British Aerospace BAe 146-200 aircraft."""
     2047    fuelTanks = [const.FUELTANK_LEFT, const.FUELTANK_CENTRE,
     2048                 const.FUELTANK_RIGHT]
     2049
     2050    def __init__(self):
     2051        """Construct the model."""
     2052        super(B462Model, self). \
     2053            __init__(flapsNotches = [0, 18, 24, 30, 33],
     2054                     fuelTanks = B462Model.fuelTanks,
     2055                     numEngines = 4)
     2056
     2057    @property
     2058    def name(self):
     2059        """Get the name for this aircraft model."""
     2060        return "FSUIPC/Generic British Aerospace 146"
     2061
     2062    def getAircraftState(self, aircraft, timestamp, data):
     2063        """Get an aircraft state object for the given monitoring data.
     2064
     2065        This removes the reverser value for the middle engine."""
     2066        state = super(B462Model, self).getAircraftState(aircraft, timestamp, data)
     2067        state.reverser = []
     2068        return state
     2069
     2070#------------------------------------------------------------------------------
     2071
    20452072_genericModels = { const.AIRCRAFT_B736  : B737Model,
    20462073                   const.AIRCRAFT_B737  : B737Model,
     
    20582085                   const.AIRCRAFT_T134  : T134Model,
    20592086                   const.AIRCRAFT_T154  : T154Model,
    2060                    const.AIRCRAFT_YK40  : YK40Model }
     2087                   const.AIRCRAFT_YK40  : YK40Model,
     2088                   const.AIRCRAFT_B462  : B462Model }
    20612089
    20622090#------------------------------------------------------------------------------
  • src/mlx/gui/common.py

    r438 r443  
    298298                  _const.AIRCRAFT_T134  : xstr("aircraft_t134"),
    299299                  _const.AIRCRAFT_T154  : xstr("aircraft_t154"),
    300                   _const.AIRCRAFT_YK40  : xstr("aircraft_yk40") }
     300                  _const.AIRCRAFT_YK40  : xstr("aircraft_yk40"),
     301                  _const.AIRCRAFT_B462  : xstr("aircraft_b462") }
    301302
    302303#------------------------------------------------------------------------------
  • src/mlx/pyuipc_sim.py

    r408 r443  
    158158    ENGINE_3 = 2
    159159
     160    ## Engine index: engine #4
     161    ENGINE_4 = 3
     162
    160163    ## The number of hotkey entries
    161164    HOTKEY_SIZE = 56
     
    295298        self.visibility = 10000
    296299
    297         self.n1 = [0.0, 0.0, 0.0]
    298         self.throttles = [0.0, 0.0, 0.0]
     300        self.n1 = [0.0, 0.0, 0.0, 0.0]
     301        self.throttles = [0.0, 0.0, 0.0, 0.0]
    299302
    300303        self.payloadCount = 1
     
    328331        self.eng2DeIce = False
    329332        self.eng3DeIce = False
     333        self.eng4DeIce = False
    330334        self.propDeIce = False
    331335        self.structDeIce = False
     
    427431        elif offset==0x09e2:       # Engine #3 de-ice
    428432            return 1 if self.eng3DeIce else 0
     433        elif offset==0x0a54:       # Engine #4 throttle
     434            return self._getThrottle(self.ENGINE_4)
     435        elif offset==0x0a7a:       # Engine #4 de-ice
     436            return 1 if self.eng4DeIce else 0
    429437        elif offset==0x0af4:       # Fuel weight
    430438            return int(self.fuelWeight * 256.0)
     
    533541            return self.n1[self.ENGINE_2]
    534542        elif offset==0x2200:       # Engine #3 N1
     543            return self.n1[self.ENGINE_3]
     544        elif offset==0x2300:       # Engine #4 N1
    535545            return self.n1[self.ENGINE_3]
    536546        elif offset==0x2ea0:       # Elevator trim
     
    695705        elif offset==0x09e2:       # Engine #3 de-ice
    696706            self.eng3DeIce = value!=0
     707        elif offset==0x0a54:       # Engine #4 throttle
     708            self._setThrottle(self.ENGINE_4, value)
     709        elif offset==0x0a7a:       # Engine #4 de-ice
     710            self.eng4DeIce = value!=0
    697711        elif offset==0x0af4:       # Fuel weight
    698712            self.fuelWeight = value / 256.0
     
    796810        elif offset==0x2200:       # Engine #3 N1
    797811            self.n1[self.ENGINE_3] = value
     812        elif offset==0x2300:       # Engine #4 N1
     813            self.n1[self.ENGINE_4] = value
    798814        elif offset==0x2ea0:       # Elevator trim
    799815            self.elevatorTrim = value * 180.0 / math.pi
     
    14131429        self._valueHandlers["n1_3"] = ([(0x2200, "f")], lambda value: value,
    14141430                                       lambda word: float(word))
     1431        self._valueHandlers["n1_4"] = ([(0x2300, "f")], lambda value: value,
     1432                                       lambda word: float(word))
    14151433
    14161434        self._valueHandlers["throttle_1"] = ([(0x088c, "H")],
     
    14211439                                             CLI.throttle2pyuipc)
    14221440        self._valueHandlers["throttle_3"] = ([(0x09bc, "H")],
     1441                                             CLI.pyuipc2throttle,
     1442                                             CLI.throttle2pyuipc)
     1443        self._valueHandlers["throttle_4"] = ([(0x0a54, "H")],
    14231444                                             CLI.pyuipc2throttle,
    14241445                                             CLI.throttle2pyuipc)
     
    14901511                                            CLI.bool2str, CLI.str2bool)
    14911512        self._valueHandlers["eng3Deice"] = ([(0x09e2, "H")],
     1513                                            CLI.bool2str, CLI.str2bool)
     1514        self._valueHandlers["eng4Deice"] = ([(0x0a7a, "H")],
    14921515                                            CLI.bool2str, CLI.str2bool)
    14931516        self._valueHandlers["propDeice"] = ([(0x337c, "b")],
  • src/mlx/web.py

    r401 r443  
    6363                      "TU3"  : const.AIRCRAFT_T134,
    6464                      "TU5"  : const.AIRCRAFT_T154,
    65                       "YK4"  : const.AIRCRAFT_YK40 }
     65                      "YK4"  : const.AIRCRAFT_YK40,
     66                      "146"  : const.AIRCRAFT_B462 }
    6667
    6768    TYPE2TYPECODE = { const.AIRCRAFT_B736  : "736",
     
    8081                      const.AIRCRAFT_T134  : "TU3",
    8182                      const.AIRCRAFT_T154  : "TU5",
    82                       const.AIRCRAFT_YK40  : "YK4" }
     83                      const.AIRCRAFT_YK40  : "YK4",
     84                      const.AIRCRAFT_B462  : "146" }
    8385
    8486    @staticmethod
     
    115117        departureTime = readline(f)
    116118        self.departureTime = BookedFlight.getDateTime(date, departureTime)
    117                                                
     119
    118120        arrivalTime = readline(f)
    119121        self.arrivalTime = BookedFlight.getDateTime(date, arrivalTime)
     
    130132        departureTime = None
    131133        arrivalTime = None
    132        
     134
    133135        line = f.readline()
    134         lineNumber = 0   
     136        lineNumber = 0
    135137        while line:
    136138            lineNumber += 1
    137139            line = line.strip()
    138            
     140
    139141            hashIndex = line.find("#")
    140142            if hashIndex>=0: line = line[:hashIndex]
     
    142144                equalIndex = line.find("=")
    143145                lineOK = equalIndex>0
    144                
     146
    145147                if lineOK:
    146                     key = line[:equalIndex].strip()                   
     148                    key = line[:equalIndex].strip()
    147149                    value = line[equalIndex+1:].strip().replace("\:", ":")
    148                    
     150
    149151                    lineOK = key and value
    150152
     
    196198            self.aircraftTypeName = \
    197199                BookedFlight.TYPE2TYPECODE[self.aircraftType]
    198            
     200
    199201    def writeIntoFile(self, f):
    200202        """Write the flight into a file."""
     
    235237        else:
    236238            raise Exception("Invalid aircraft type code: '" + typeCode + "'")
    237        
     239
    238240    def __repr__(self):
    239241        """Get a representation of the flight."""
     
    248250        s += ">"
    249251        return s
    250        
     252
    251253#------------------------------------------------------------------------------
    252254
     
    279281    def __repr__(self):
    280282        """Get the representation of the plane object."""
    281         s = "<Plane: %s %s" % (self.tailNumber, 
     283        s = "<Plane: %s %s" % (self.tailNumber,
    282284                               "home" if self.status==const.PLANE_HOME else \
    283285                               "away" if self.status==const.PLANE_AWAY else \
     
    288290        s += ">"
    289291        return s
    290        
     292
    291293
    292294#------------------------------------------------------------------------------
     
    323325                gateNumbers.add(p.gateNumber)
    324326        return gateNumbers
    325    
     327
    326328    def updatePlane(self, tailNumber, status, gateNumber = None):
    327329        """Update the status of the given plane."""
     
    330332            plane.status = status
    331333            plane.gateNumber = gateNumber
    332    
     334
    333335    def __iter__(self):
    334336        """Get an iterator over the planes."""
    335337        for plane in self._planes.itervalues():
    336338            yield plane
    337        
     339
    338340    def __getitem__(self, tailNumber):
    339341        """Get the plane with the given tail number.
     
    345347        """Get the representation of the fleet object."""
    346348        return self._planes.__repr__()
    347        
     349
    348350#------------------------------------------------------------------------------
    349351
     
    371373        s += ">"
    372374        return s
    373    
     375
    374376#------------------------------------------------------------------------------
    375377
     
    389391           "E" not in attrs or not attrs["E"]:
    390392            return
    391        
     393
    392394        icao = attrs["A"]
    393395        if icao not in self._notams:
    394396            return
    395        
     397
    396398        begin = datetime.datetime.strptime(attrs["B"], "%Y-%m-%d %H:%M:%S")
    397399
    398400        c = attrs["C"] if "C" in attrs else None
    399401        end = datetime.datetime.strptime(c, "%Y-%m-%d %H:%M:%S") if c else None
    400        
     402
    401403        permanent = attrs["C_flag"]=="PERM" if "C_flag" in attrs else False
    402        
     404
    403405        repeatCycle = attrs["D"] if "D" in attrs else None
    404406
     
    473475    """A login request."""
    474476    iso88592decoder = codecs.getdecoder("iso-8859-2")
    475    
     477
    476478    def __init__(self, callback, pilotID, password, entranceExam):
    477479        """Construct the login request with the given pilot ID and
     
    488490        md5.update(self._pilotID)
    489491        pilotID = md5.hexdigest()
    490        
     492
    491493        md5 = hashlib.md5()
    492494        md5.update(self._password)
     
    524526                result.pilotName = self.iso88592decoder(readline(f))[0]
    525527                result.exams = readline(f)
    526                
     528
    527529                while True:
    528530                    line = readline(f)
     
    540542
    541543        return result
    542        
     544
    543545#------------------------------------------------------------------------------
    544546
    545547class GetFleet(Request):
    546548    """Request to get the fleet from the website."""
    547    
     549
    548550    def __init__(self, callback):
    549551        """Construct the fleet request."""
     
    558560        result.fleet = Fleet(f)
    559561        f.close()
    560        
     562
    561563        return result
    562564
     
    585587                                 ("status", status),
    586588                                 ("kapu", gateNumber)])
    587        
     589
    588590        f = urllib2.urlopen(url, data, timeout = 10.0)
    589591        line = readline(f)
    590        
     592
    591593        result = Result()
    592594        result.success = line == "OK"
    593595
    594596        return result
    595            
     597
    596598#------------------------------------------------------------------------------
    597599
     
    628630
    629631class GetMETARs(Request):
    630     """Get the METARs from the NOAA website for certain airport ICAOs."""   
     632    """Get the METARs from the NOAA website for certain airport ICAOs."""
    631633
    632634    def __init__(self, callback, airports):
     
    639641        url = "http://www.aviationweather.gov/adds/dataserver_current/httpparam?"
    640642        data = urllib.urlencode([ ("dataSource" , "metars"),
    641                                   ("requestType",  "retrieve"), 
     643                                  ("requestType",  "retrieve"),
    642644                                  ("format", "csv"),
    643645                                  ("stationString", " ".join(self._airports)),
     
    652654                if len(line)>5 and line[4]==' ':
    653655                    icao = line[0:4]
    654                     if icao in self._airports:                       
     656                    if icao in self._airports:
    655657                        result.metars[icao] = line.strip().split(",")[0]
    656658        finally:
     
    696698        data["bag"] = str(pirep.bagWeight)
    697699        data["mail"] = str(pirep.mailWeight)
    698        
     700
    699701        data["flttype"] = SendPIREP._flightTypes[pirep.flightType]
    700702        data["onoff"] = "1" if pirep.online else "0"
     
    742744            f.close()
    743745
    744         return result   
     746        return result
    745747#------------------------------------------------------------------------------
    746748
     
    757759        """Perform the sending of the ACARS."""
    758760        print "Sending the online ACARS"
    759        
     761
    760762        url = "http://www.virtualairlines.hu/acars2/acarsonline.php"
    761763
     
    766768        data["pid"] = acars.pid
    767769        data["pilot"] = SendACARS._latin2Encoder(acars.pilotName)[0]
    768    
     770
    769771        data["pass"] = str(bookedFlight.numPassengers)
    770772        data["callsign"] = bookedFlight.callsign
    771773        data["airplane"] = bookedFlight.aircraftTypeName
    772774        data["from"] = bookedFlight.departureICAO
    773         data["to"] = bookedFlight.arrivalICAO       
     775        data["to"] = bookedFlight.arrivalICAO
    774776        data["lajstrom"] = bookedFlight.tailNumber
    775777
     
    779781        data["altitude"] = str(acars.state.altitude)
    780782        data["speed"] = str(acars.state.groundSpeed)
    781        
     783
    782784        data["event"] = acars.getEventText()
    783785
     
    788790            f.close()
    789791
    790         return result   
     792        return result
    791793
    792794#------------------------------------------------------------------------------
     
    813815        """Enqueue a fleet retrieval request."""
    814816        self._addRequest(GetFleet(callback))
    815        
     817
    816818    def updatePlane(self, callback, tailNumber, status, gateNumber = None):
    817         """Update the status of the given plane."""       
     819        """Update the status of the given plane."""
    818820        self._addRequest(UpdatePlane(callback, tailNumber, status, gateNumber))
    819821
     
    821823        """Get the NOTAMs for the given two airports."""
    822824        self._addRequest(GetNOTAMs(callback, departureICAO, arrivalICAO))
    823        
     825
    824826    def getMETARs(self, callback, airports):
    825827        """Get the METARs for the given airports."""
     
    833835        """Send the given ACARS"""
    834836        self._addRequest(SendACARS(callback, acars))
    835        
     837
    836838    def run(self):
    837839        """Process the requests."""
     
    844846
    845847            request.perform()
    846    
     848
    847849    def _addRequest(self, request):
    848850        """Add the given request to the queue."""
     
    855857if __name__ == "__main__":
    856858    import time
    857    
     859
    858860    def callback(returned, result):
    859861        print returned, unicode(result)
    860        
     862
    861863    handler = Handler()
    862864    handler.start()
     
    866868    # Plane: HA-LEG home (gate 67)
    867869    #handler.updatePlane(callback, "HA-LQC", const.PLANE_AWAY, "72")
    868     #time.sleep(3)   
     870    #time.sleep(3)
    869871    #handler.getFleet(callback)
    870872    #time.sleep(3)
     
    873875    #handler.getMETARs(callback, ["LHBP", "EPWA"])
    874876    #time.sleep(5)
    875    
     877
    876878    handler.updatePlane(callback, "HA-LON", const.PLANE_AWAY, "")
    877     time.sleep(3)   
    878 
    879 #------------------------------------------------------------------------------
     879    time.sleep(3)
     880
     881#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.