Changeset 430:8a12f6c1066b for src/mlx
- Timestamp:
- 02/17/13 11:37:30 (12 years ago)
- Branch:
- xplane
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/checks.py
r420 r430 954 954 """Check if the fault condition holds.""" 955 955 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 957 960 elif flight.stage in [const.STAGE_TAKEOFF, const.STAGE_CLIMB, 958 961 const.STAGE_DESCENT, const.STAGE_LANDING]: -
src/mlx/flight.py
r391 r430 86 86 """Get the flight stage.""" 87 87 return self._stage 88 89 @property 90 def fsType(self): 91 """Get the flight simulator type.""" 92 return self._gui.fsType 88 93 89 94 @property -
src/mlx/gui/gui.py
r393 r430 68 68 self._flight = None 69 69 self._simulator = None 70 self._fsType = None 70 71 self._monitoring = False 71 72 … … 205 206 206 207 @property 208 def fsType(self): 209 """Get the flight simulator type.""" 210 return self._fsType 211 212 @property 207 213 def entranceExam(self): 208 214 """Get whether an entrance exam is about to be taken.""" … … 425 431 self._wizard.connected(fsType, descriptor) 426 432 self._reconnecting = False 433 self._fsType = fsType 427 434 self._listenHotkeys() 428 435 -
src/mlx/web.py
r401 r430 115 115 departureTime = readline(f) 116 116 self.departureTime = BookedFlight.getDateTime(date, departureTime) 117 117 118 118 arrivalTime = readline(f) 119 119 self.arrivalTime = BookedFlight.getDateTime(date, arrivalTime) … … 130 130 departureTime = None 131 131 arrivalTime = None 132 132 133 133 line = f.readline() 134 lineNumber = 0 134 lineNumber = 0 135 135 while line: 136 136 lineNumber += 1 137 137 line = line.strip() 138 138 139 139 hashIndex = line.find("#") 140 140 if hashIndex>=0: line = line[:hashIndex] … … 142 142 equalIndex = line.find("=") 143 143 lineOK = equalIndex>0 144 144 145 145 if lineOK: 146 key = line[:equalIndex].strip() 146 key = line[:equalIndex].strip() 147 147 value = line[equalIndex+1:].strip().replace("\:", ":") 148 148 149 149 lineOK = key and value 150 150 … … 196 196 self.aircraftTypeName = \ 197 197 BookedFlight.TYPE2TYPECODE[self.aircraftType] 198 198 199 199 def writeIntoFile(self, f): 200 200 """Write the flight into a file.""" … … 235 235 else: 236 236 raise Exception("Invalid aircraft type code: '" + typeCode + "'") 237 237 238 238 def __repr__(self): 239 239 """Get a representation of the flight.""" … … 248 248 s += ">" 249 249 return s 250 250 251 251 #------------------------------------------------------------------------------ 252 252 … … 279 279 def __repr__(self): 280 280 """Get the representation of the plane object.""" 281 s = "<Plane: %s %s" % (self.tailNumber, 281 s = "<Plane: %s %s" % (self.tailNumber, 282 282 "home" if self.status==const.PLANE_HOME else \ 283 283 "away" if self.status==const.PLANE_AWAY else \ … … 288 288 s += ">" 289 289 return s 290 290 291 291 292 292 #------------------------------------------------------------------------------ … … 323 323 gateNumbers.add(p.gateNumber) 324 324 return gateNumbers 325 325 326 326 def updatePlane(self, tailNumber, status, gateNumber = None): 327 327 """Update the status of the given plane.""" … … 330 330 plane.status = status 331 331 plane.gateNumber = gateNumber 332 332 333 333 def __iter__(self): 334 334 """Get an iterator over the planes.""" 335 335 for plane in self._planes.itervalues(): 336 336 yield plane 337 337 338 338 def __getitem__(self, tailNumber): 339 339 """Get the plane with the given tail number. … … 345 345 """Get the representation of the fleet object.""" 346 346 return self._planes.__repr__() 347 347 348 348 #------------------------------------------------------------------------------ 349 349 … … 371 371 s += ">" 372 372 return s 373 373 374 374 #------------------------------------------------------------------------------ 375 375 … … 389 389 "E" not in attrs or not attrs["E"]: 390 390 return 391 391 392 392 icao = attrs["A"] 393 393 if icao not in self._notams: 394 394 return 395 395 396 396 begin = datetime.datetime.strptime(attrs["B"], "%Y-%m-%d %H:%M:%S") 397 397 398 398 c = attrs["C"] if "C" in attrs else None 399 399 end = datetime.datetime.strptime(c, "%Y-%m-%d %H:%M:%S") if c else None 400 400 401 401 permanent = attrs["C_flag"]=="PERM" if "C_flag" in attrs else False 402 402 403 403 repeatCycle = attrs["D"] if "D" in attrs else None 404 404 … … 473 473 """A login request.""" 474 474 iso88592decoder = codecs.getdecoder("iso-8859-2") 475 475 476 476 def __init__(self, callback, pilotID, password, entranceExam): 477 477 """Construct the login request with the given pilot ID and … … 488 488 md5.update(self._pilotID) 489 489 pilotID = md5.hexdigest() 490 490 491 491 md5 = hashlib.md5() 492 492 md5.update(self._password) … … 524 524 result.pilotName = self.iso88592decoder(readline(f))[0] 525 525 result.exams = readline(f) 526 526 527 527 while True: 528 528 line = readline(f) … … 540 540 541 541 return result 542 542 543 543 #------------------------------------------------------------------------------ 544 544 545 545 class GetFleet(Request): 546 546 """Request to get the fleet from the website.""" 547 547 548 548 def __init__(self, callback): 549 549 """Construct the fleet request.""" … … 558 558 result.fleet = Fleet(f) 559 559 f.close() 560 560 561 561 return result 562 562 … … 585 585 ("status", status), 586 586 ("kapu", gateNumber)]) 587 587 588 588 f = urllib2.urlopen(url, data, timeout = 10.0) 589 589 line = readline(f) 590 590 591 591 result = Result() 592 592 result.success = line == "OK" 593 593 594 594 return result 595 595 596 596 #------------------------------------------------------------------------------ 597 597 … … 628 628 629 629 class 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.""" 631 631 632 632 def __init__(self, callback, airports): … … 639 639 url = "http://www.aviationweather.gov/adds/dataserver_current/httpparam?" 640 640 data = urllib.urlencode([ ("dataSource" , "metars"), 641 ("requestType", "retrieve"), 641 ("requestType", "retrieve"), 642 642 ("format", "csv"), 643 643 ("stationString", " ".join(self._airports)), … … 652 652 if len(line)>5 and line[4]==' ': 653 653 icao = line[0:4] 654 if icao in self._airports: 654 if icao in self._airports: 655 655 result.metars[icao] = line.strip().split(",")[0] 656 656 finally: … … 696 696 data["bag"] = str(pirep.bagWeight) 697 697 data["mail"] = str(pirep.mailWeight) 698 698 699 699 data["flttype"] = SendPIREP._flightTypes[pirep.flightType] 700 700 data["onoff"] = "1" if pirep.online else "0" … … 742 742 f.close() 743 743 744 return result 744 return result 745 745 #------------------------------------------------------------------------------ 746 746 … … 757 757 """Perform the sending of the ACARS.""" 758 758 print "Sending the online ACARS" 759 759 760 760 url = "http://www.virtualairlines.hu/acars2/acarsonline.php" 761 761 … … 766 766 data["pid"] = acars.pid 767 767 data["pilot"] = SendACARS._latin2Encoder(acars.pilotName)[0] 768 768 769 769 data["pass"] = str(bookedFlight.numPassengers) 770 770 data["callsign"] = bookedFlight.callsign 771 771 data["airplane"] = bookedFlight.aircraftTypeName 772 772 data["from"] = bookedFlight.departureICAO 773 data["to"] = bookedFlight.arrivalICAO 773 data["to"] = bookedFlight.arrivalICAO 774 774 data["lajstrom"] = bookedFlight.tailNumber 775 775 … … 779 779 data["altitude"] = str(acars.state.altitude) 780 780 data["speed"] = str(acars.state.groundSpeed) 781 781 782 782 data["event"] = acars.getEventText() 783 783 … … 788 788 f.close() 789 789 790 return result 790 return result 791 791 792 792 #------------------------------------------------------------------------------ … … 813 813 """Enqueue a fleet retrieval request.""" 814 814 self._addRequest(GetFleet(callback)) 815 815 816 816 def updatePlane(self, callback, tailNumber, status, gateNumber = None): 817 """Update the status of the given plane.""" 817 """Update the status of the given plane.""" 818 818 self._addRequest(UpdatePlane(callback, tailNumber, status, gateNumber)) 819 819 … … 821 821 """Get the NOTAMs for the given two airports.""" 822 822 self._addRequest(GetNOTAMs(callback, departureICAO, arrivalICAO)) 823 823 824 824 def getMETARs(self, callback, airports): 825 825 """Get the METARs for the given airports.""" … … 833 833 """Send the given ACARS""" 834 834 self._addRequest(SendACARS(callback, acars)) 835 835 836 836 def run(self): 837 837 """Process the requests.""" … … 844 844 845 845 request.perform() 846 846 847 847 def _addRequest(self, request): 848 848 """Add the given request to the queue.""" … … 855 855 if __name__ == "__main__": 856 856 import time 857 857 858 858 def callback(returned, result): 859 859 print returned, unicode(result) 860 860 861 861 handler = Handler() 862 862 handler.start() … … 866 866 # Plane: HA-LEG home (gate 67) 867 867 #handler.updatePlane(callback, "HA-LQC", const.PLANE_AWAY, "72") 868 #time.sleep(3) 868 #time.sleep(3) 869 869 #handler.getFleet(callback) 870 870 #time.sleep(3) … … 873 873 #handler.getMETARs(callback, ["LHBP", "EPWA"]) 874 874 #time.sleep(5) 875 875 876 876 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.