Changeset 430:8a12f6c1066b


Ignore:
Timestamp:
02/17/13 11:37:30 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
xplane
Phase:
public
Message:

The flight simulator type is available to the checkers and the bank checking now takes it into account for DH8D to avoid trouble due to the overactive autopilot

Location:
src/mlx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/checks.py

    r420 r430  
    954954        """Check if the fault condition holds."""
    955955        if flight.stage==const.STAGE_CRUISE:
    956             bankLimit = 32
     956            isDH8DXplane = flight.aircraftType==const.AIRCRAFT_DH8D and \
     957                           (flight.fsType==const.SIM_XPLANE10 or
     958                            flight.fsType==const.SIM_XPLANE9)
     959            bankLimit = 35 if isDH8DXplane else 30
    957960        elif flight.stage in [const.STAGE_TAKEOFF, const.STAGE_CLIMB,
    958961                              const.STAGE_DESCENT, const.STAGE_LANDING]:
  • src/mlx/flight.py

    r391 r430  
    8686        """Get the flight stage."""
    8787        return self._stage
     88
     89    @property
     90    def fsType(self):
     91        """Get the flight simulator type."""
     92        return self._gui.fsType
    8893
    8994    @property
  • src/mlx/gui/gui.py

    r393 r430  
    6868        self._flight = None
    6969        self._simulator = None
     70        self._fsType = None
    7071        self._monitoring = False
    7172
     
    205206
    206207    @property
     208    def fsType(self):
     209        """Get the flight simulator type."""
     210        return self._fsType
     211
     212    @property
    207213    def entranceExam(self):
    208214        """Get whether an entrance exam is about to be taken."""
     
    425431            self._wizard.connected(fsType, descriptor)
    426432        self._reconnecting = False
     433        self._fsType = fsType
    427434        self._listenHotkeys()
    428435
  • src/mlx/web.py

    r401 r430  
    115115        departureTime = readline(f)
    116116        self.departureTime = BookedFlight.getDateTime(date, departureTime)
    117                                                
     117
    118118        arrivalTime = readline(f)
    119119        self.arrivalTime = BookedFlight.getDateTime(date, arrivalTime)
     
    130130        departureTime = None
    131131        arrivalTime = None
    132        
     132
    133133        line = f.readline()
    134         lineNumber = 0   
     134        lineNumber = 0
    135135        while line:
    136136            lineNumber += 1
    137137            line = line.strip()
    138            
     138
    139139            hashIndex = line.find("#")
    140140            if hashIndex>=0: line = line[:hashIndex]
     
    142142                equalIndex = line.find("=")
    143143                lineOK = equalIndex>0
    144                
     144
    145145                if lineOK:
    146                     key = line[:equalIndex].strip()                   
     146                    key = line[:equalIndex].strip()
    147147                    value = line[equalIndex+1:].strip().replace("\:", ":")
    148                    
     148
    149149                    lineOK = key and value
    150150
     
    196196            self.aircraftTypeName = \
    197197                BookedFlight.TYPE2TYPECODE[self.aircraftType]
    198            
     198
    199199    def writeIntoFile(self, f):
    200200        """Write the flight into a file."""
     
    235235        else:
    236236            raise Exception("Invalid aircraft type code: '" + typeCode + "'")
    237        
     237
    238238    def __repr__(self):
    239239        """Get a representation of the flight."""
     
    248248        s += ">"
    249249        return s
    250        
     250
    251251#------------------------------------------------------------------------------
    252252
     
    279279    def __repr__(self):
    280280        """Get the representation of the plane object."""
    281         s = "<Plane: %s %s" % (self.tailNumber, 
     281        s = "<Plane: %s %s" % (self.tailNumber,
    282282                               "home" if self.status==const.PLANE_HOME else \
    283283                               "away" if self.status==const.PLANE_AWAY else \
     
    288288        s += ">"
    289289        return s
    290        
     290
    291291
    292292#------------------------------------------------------------------------------
     
    323323                gateNumbers.add(p.gateNumber)
    324324        return gateNumbers
    325    
     325
    326326    def updatePlane(self, tailNumber, status, gateNumber = None):
    327327        """Update the status of the given plane."""
     
    330330            plane.status = status
    331331            plane.gateNumber = gateNumber
    332    
     332
    333333    def __iter__(self):
    334334        """Get an iterator over the planes."""
    335335        for plane in self._planes.itervalues():
    336336            yield plane
    337        
     337
    338338    def __getitem__(self, tailNumber):
    339339        """Get the plane with the given tail number.
     
    345345        """Get the representation of the fleet object."""
    346346        return self._planes.__repr__()
    347        
     347
    348348#------------------------------------------------------------------------------
    349349
     
    371371        s += ">"
    372372        return s
    373    
     373
    374374#------------------------------------------------------------------------------
    375375
     
    389389           "E" not in attrs or not attrs["E"]:
    390390            return
    391        
     391
    392392        icao = attrs["A"]
    393393        if icao not in self._notams:
    394394            return
    395        
     395
    396396        begin = datetime.datetime.strptime(attrs["B"], "%Y-%m-%d %H:%M:%S")
    397397
    398398        c = attrs["C"] if "C" in attrs else None
    399399        end = datetime.datetime.strptime(c, "%Y-%m-%d %H:%M:%S") if c else None
    400        
     400
    401401        permanent = attrs["C_flag"]=="PERM" if "C_flag" in attrs else False
    402        
     402
    403403        repeatCycle = attrs["D"] if "D" in attrs else None
    404404
     
    473473    """A login request."""
    474474    iso88592decoder = codecs.getdecoder("iso-8859-2")
    475    
     475
    476476    def __init__(self, callback, pilotID, password, entranceExam):
    477477        """Construct the login request with the given pilot ID and
     
    488488        md5.update(self._pilotID)
    489489        pilotID = md5.hexdigest()
    490        
     490
    491491        md5 = hashlib.md5()
    492492        md5.update(self._password)
     
    524524                result.pilotName = self.iso88592decoder(readline(f))[0]
    525525                result.exams = readline(f)
    526                
     526
    527527                while True:
    528528                    line = readline(f)
     
    540540
    541541        return result
    542        
     542
    543543#------------------------------------------------------------------------------
    544544
    545545class GetFleet(Request):
    546546    """Request to get the fleet from the website."""
    547    
     547
    548548    def __init__(self, callback):
    549549        """Construct the fleet request."""
     
    558558        result.fleet = Fleet(f)
    559559        f.close()
    560        
     560
    561561        return result
    562562
     
    585585                                 ("status", status),
    586586                                 ("kapu", gateNumber)])
    587        
     587
    588588        f = urllib2.urlopen(url, data, timeout = 10.0)
    589589        line = readline(f)
    590        
     590
    591591        result = Result()
    592592        result.success = line == "OK"
    593593
    594594        return result
    595            
     595
    596596#------------------------------------------------------------------------------
    597597
     
    628628
    629629class GetMETARs(Request):
    630     """Get the METARs from the NOAA website for certain airport ICAOs."""   
     630    """Get the METARs from the NOAA website for certain airport ICAOs."""
    631631
    632632    def __init__(self, callback, airports):
     
    639639        url = "http://www.aviationweather.gov/adds/dataserver_current/httpparam?"
    640640        data = urllib.urlencode([ ("dataSource" , "metars"),
    641                                   ("requestType",  "retrieve"), 
     641                                  ("requestType",  "retrieve"),
    642642                                  ("format", "csv"),
    643643                                  ("stationString", " ".join(self._airports)),
     
    652652                if len(line)>5 and line[4]==' ':
    653653                    icao = line[0:4]
    654                     if icao in self._airports:                       
     654                    if icao in self._airports:
    655655                        result.metars[icao] = line.strip().split(",")[0]
    656656        finally:
     
    696696        data["bag"] = str(pirep.bagWeight)
    697697        data["mail"] = str(pirep.mailWeight)
    698        
     698
    699699        data["flttype"] = SendPIREP._flightTypes[pirep.flightType]
    700700        data["onoff"] = "1" if pirep.online else "0"
     
    742742            f.close()
    743743
    744         return result   
     744        return result
    745745#------------------------------------------------------------------------------
    746746
     
    757757        """Perform the sending of the ACARS."""
    758758        print "Sending the online ACARS"
    759        
     759
    760760        url = "http://www.virtualairlines.hu/acars2/acarsonline.php"
    761761
     
    766766        data["pid"] = acars.pid
    767767        data["pilot"] = SendACARS._latin2Encoder(acars.pilotName)[0]
    768    
     768
    769769        data["pass"] = str(bookedFlight.numPassengers)
    770770        data["callsign"] = bookedFlight.callsign
    771771        data["airplane"] = bookedFlight.aircraftTypeName
    772772        data["from"] = bookedFlight.departureICAO
    773         data["to"] = bookedFlight.arrivalICAO       
     773        data["to"] = bookedFlight.arrivalICAO
    774774        data["lajstrom"] = bookedFlight.tailNumber
    775775
     
    779779        data["altitude"] = str(acars.state.altitude)
    780780        data["speed"] = str(acars.state.groundSpeed)
    781        
     781
    782782        data["event"] = acars.getEventText()
    783783
     
    788788            f.close()
    789789
    790         return result   
     790        return result
    791791
    792792#------------------------------------------------------------------------------
     
    813813        """Enqueue a fleet retrieval request."""
    814814        self._addRequest(GetFleet(callback))
    815        
     815
    816816    def updatePlane(self, callback, tailNumber, status, gateNumber = None):
    817         """Update the status of the given plane."""       
     817        """Update the status of the given plane."""
    818818        self._addRequest(UpdatePlane(callback, tailNumber, status, gateNumber))
    819819
     
    821821        """Get the NOTAMs for the given two airports."""
    822822        self._addRequest(GetNOTAMs(callback, departureICAO, arrivalICAO))
    823        
     823
    824824    def getMETARs(self, callback, airports):
    825825        """Get the METARs for the given airports."""
     
    833833        """Send the given ACARS"""
    834834        self._addRequest(SendACARS(callback, acars))
    835        
     835
    836836    def run(self):
    837837        """Process the requests."""
     
    844844
    845845            request.perform()
    846    
     846
    847847    def _addRequest(self, request):
    848848        """Add the given request to the queue."""
     
    855855if __name__ == "__main__":
    856856    import time
    857    
     857
    858858    def callback(returned, result):
    859859        print returned, unicode(result)
    860        
     860
    861861    handler = Handler()
    862862    handler.start()
     
    866866    # Plane: HA-LEG home (gate 67)
    867867    #handler.updatePlane(callback, "HA-LQC", const.PLANE_AWAY, "72")
    868     #time.sleep(3)   
     868    #time.sleep(3)
    869869    #handler.getFleet(callback)
    870870    #time.sleep(3)
     
    873873    #handler.getMETARs(callback, ["LHBP", "EPWA"])
    874874    #time.sleep(5)
    875    
     875
    876876    handler.updatePlane(callback, "HA-LON", const.PLANE_AWAY, "")
    877     time.sleep(3)   
    878 
    879 #------------------------------------------------------------------------------
     877    time.sleep(3)
     878
     879#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.