Changeset 443:acbe605bb814 for src/mlx
- Timestamp:
- 02/28/13 18:56:30 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/acft.py
r409 r443 1017 1017 #--------------------------------------------------------------------------------------- 1018 1018 1019 class 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 1019 1041 mostFuelTanks = [const.FUELTANK_LEFT_TIP, const.FUELTANK_EXTERNAL1, 1020 1042 const.FUELTANK_LEFT_AUX, … … 1040 1062 const.AIRCRAFT_T134 : T134, 1041 1063 const.AIRCRAFT_T154 : T154, 1042 const.AIRCRAFT_YK40 : YK40 } 1064 const.AIRCRAFT_YK40 : YK40, 1065 const.AIRCRAFT_B462 : B462 } 1043 1066 1044 1067 #--------------------------------------------------------------------------------------- -
src/mlx/checks.py
r416 r443 1304 1304 return flight.stage in [const.STAGE_DESCENT, const.STAGE_LANDING, 1305 1305 const.STAGE_TAXIAFTERLAND] and \ 1306 state.reverser and \ 1306 1307 state.groundSpeed<aircraft.reverseMinSpeed and max(state.reverser) 1307 1308 -
src/mlx/const.py
r437 r443 95 95 ## Aircraft type: Yakovlev Yak-40 96 96 AIRCRAFT_YK40 = 15 97 98 ## Aircraft type: British Aerospace BAe-146 99 AIRCRAFT_B462 = 16 97 100 98 101 #------------------------------------------------------------------------------- … … 108 111 AIRCRAFT_B733, AIRCRAFT_B734, AIRCRAFT_B735, 109 112 AIRCRAFT_T154, AIRCRAFT_T134, 110 AIRCRAFT_YK40, AIRCRAFT_DC3] 113 AIRCRAFT_YK40, AIRCRAFT_DC3, 114 AIRCRAFT_B462] 111 115 112 116 #------------------------------------------------------------------------------- … … 129 133 AIRCRAFT_T134 : "T134", 130 134 AIRCRAFT_T154 : "T154", 131 AIRCRAFT_YK40 : "YK40" } 135 AIRCRAFT_YK40 : "YK40", 136 AIRCRAFT_B462 : "B462" } 132 137 133 138 #------------------------------------------------------------------------------- -
src/mlx/fsuipc.py
r412 r443 2043 2043 #------------------------------------------------------------------------------ 2044 2044 2045 class 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 2045 2072 _genericModels = { const.AIRCRAFT_B736 : B737Model, 2046 2073 const.AIRCRAFT_B737 : B737Model, … … 2058 2085 const.AIRCRAFT_T134 : T134Model, 2059 2086 const.AIRCRAFT_T154 : T154Model, 2060 const.AIRCRAFT_YK40 : YK40Model } 2087 const.AIRCRAFT_YK40 : YK40Model, 2088 const.AIRCRAFT_B462 : B462Model } 2061 2089 2062 2090 #------------------------------------------------------------------------------ -
src/mlx/gui/common.py
r438 r443 298 298 _const.AIRCRAFT_T134 : xstr("aircraft_t134"), 299 299 _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") } 301 302 302 303 #------------------------------------------------------------------------------ -
src/mlx/pyuipc_sim.py
r408 r443 158 158 ENGINE_3 = 2 159 159 160 ## Engine index: engine #4 161 ENGINE_4 = 3 162 160 163 ## The number of hotkey entries 161 164 HOTKEY_SIZE = 56 … … 295 298 self.visibility = 10000 296 299 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] 299 302 300 303 self.payloadCount = 1 … … 328 331 self.eng2DeIce = False 329 332 self.eng3DeIce = False 333 self.eng4DeIce = False 330 334 self.propDeIce = False 331 335 self.structDeIce = False … … 427 431 elif offset==0x09e2: # Engine #3 de-ice 428 432 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 429 437 elif offset==0x0af4: # Fuel weight 430 438 return int(self.fuelWeight * 256.0) … … 533 541 return self.n1[self.ENGINE_2] 534 542 elif offset==0x2200: # Engine #3 N1 543 return self.n1[self.ENGINE_3] 544 elif offset==0x2300: # Engine #4 N1 535 545 return self.n1[self.ENGINE_3] 536 546 elif offset==0x2ea0: # Elevator trim … … 695 705 elif offset==0x09e2: # Engine #3 de-ice 696 706 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 697 711 elif offset==0x0af4: # Fuel weight 698 712 self.fuelWeight = value / 256.0 … … 796 810 elif offset==0x2200: # Engine #3 N1 797 811 self.n1[self.ENGINE_3] = value 812 elif offset==0x2300: # Engine #4 N1 813 self.n1[self.ENGINE_4] = value 798 814 elif offset==0x2ea0: # Elevator trim 799 815 self.elevatorTrim = value * 180.0 / math.pi … … 1413 1429 self._valueHandlers["n1_3"] = ([(0x2200, "f")], lambda value: value, 1414 1430 lambda word: float(word)) 1431 self._valueHandlers["n1_4"] = ([(0x2300, "f")], lambda value: value, 1432 lambda word: float(word)) 1415 1433 1416 1434 self._valueHandlers["throttle_1"] = ([(0x088c, "H")], … … 1421 1439 CLI.throttle2pyuipc) 1422 1440 self._valueHandlers["throttle_3"] = ([(0x09bc, "H")], 1441 CLI.pyuipc2throttle, 1442 CLI.throttle2pyuipc) 1443 self._valueHandlers["throttle_4"] = ([(0x0a54, "H")], 1423 1444 CLI.pyuipc2throttle, 1424 1445 CLI.throttle2pyuipc) … … 1490 1511 CLI.bool2str, CLI.str2bool) 1491 1512 self._valueHandlers["eng3Deice"] = ([(0x09e2, "H")], 1513 CLI.bool2str, CLI.str2bool) 1514 self._valueHandlers["eng4Deice"] = ([(0x0a7a, "H")], 1492 1515 CLI.bool2str, CLI.str2bool) 1493 1516 self._valueHandlers["propDeice"] = ([(0x337c, "b")], -
src/mlx/web.py
r401 r443 63 63 "TU3" : const.AIRCRAFT_T134, 64 64 "TU5" : const.AIRCRAFT_T154, 65 "YK4" : const.AIRCRAFT_YK40 } 65 "YK4" : const.AIRCRAFT_YK40, 66 "146" : const.AIRCRAFT_B462 } 66 67 67 68 TYPE2TYPECODE = { const.AIRCRAFT_B736 : "736", … … 80 81 const.AIRCRAFT_T134 : "TU3", 81 82 const.AIRCRAFT_T154 : "TU5", 82 const.AIRCRAFT_YK40 : "YK4" } 83 const.AIRCRAFT_YK40 : "YK4", 84 const.AIRCRAFT_B462 : "146" } 83 85 84 86 @staticmethod … … 115 117 departureTime = readline(f) 116 118 self.departureTime = BookedFlight.getDateTime(date, departureTime) 117 119 118 120 arrivalTime = readline(f) 119 121 self.arrivalTime = BookedFlight.getDateTime(date, arrivalTime) … … 130 132 departureTime = None 131 133 arrivalTime = None 132 134 133 135 line = f.readline() 134 lineNumber = 0 136 lineNumber = 0 135 137 while line: 136 138 lineNumber += 1 137 139 line = line.strip() 138 140 139 141 hashIndex = line.find("#") 140 142 if hashIndex>=0: line = line[:hashIndex] … … 142 144 equalIndex = line.find("=") 143 145 lineOK = equalIndex>0 144 146 145 147 if lineOK: 146 key = line[:equalIndex].strip() 148 key = line[:equalIndex].strip() 147 149 value = line[equalIndex+1:].strip().replace("\:", ":") 148 150 149 151 lineOK = key and value 150 152 … … 196 198 self.aircraftTypeName = \ 197 199 BookedFlight.TYPE2TYPECODE[self.aircraftType] 198 200 199 201 def writeIntoFile(self, f): 200 202 """Write the flight into a file.""" … … 235 237 else: 236 238 raise Exception("Invalid aircraft type code: '" + typeCode + "'") 237 239 238 240 def __repr__(self): 239 241 """Get a representation of the flight.""" … … 248 250 s += ">" 249 251 return s 250 252 251 253 #------------------------------------------------------------------------------ 252 254 … … 279 281 def __repr__(self): 280 282 """Get the representation of the plane object.""" 281 s = "<Plane: %s %s" % (self.tailNumber, 283 s = "<Plane: %s %s" % (self.tailNumber, 282 284 "home" if self.status==const.PLANE_HOME else \ 283 285 "away" if self.status==const.PLANE_AWAY else \ … … 288 290 s += ">" 289 291 return s 290 292 291 293 292 294 #------------------------------------------------------------------------------ … … 323 325 gateNumbers.add(p.gateNumber) 324 326 return gateNumbers 325 327 326 328 def updatePlane(self, tailNumber, status, gateNumber = None): 327 329 """Update the status of the given plane.""" … … 330 332 plane.status = status 331 333 plane.gateNumber = gateNumber 332 334 333 335 def __iter__(self): 334 336 """Get an iterator over the planes.""" 335 337 for plane in self._planes.itervalues(): 336 338 yield plane 337 339 338 340 def __getitem__(self, tailNumber): 339 341 """Get the plane with the given tail number. … … 345 347 """Get the representation of the fleet object.""" 346 348 return self._planes.__repr__() 347 349 348 350 #------------------------------------------------------------------------------ 349 351 … … 371 373 s += ">" 372 374 return s 373 375 374 376 #------------------------------------------------------------------------------ 375 377 … … 389 391 "E" not in attrs or not attrs["E"]: 390 392 return 391 393 392 394 icao = attrs["A"] 393 395 if icao not in self._notams: 394 396 return 395 397 396 398 begin = datetime.datetime.strptime(attrs["B"], "%Y-%m-%d %H:%M:%S") 397 399 398 400 c = attrs["C"] if "C" in attrs else None 399 401 end = datetime.datetime.strptime(c, "%Y-%m-%d %H:%M:%S") if c else None 400 402 401 403 permanent = attrs["C_flag"]=="PERM" if "C_flag" in attrs else False 402 404 403 405 repeatCycle = attrs["D"] if "D" in attrs else None 404 406 … … 473 475 """A login request.""" 474 476 iso88592decoder = codecs.getdecoder("iso-8859-2") 475 477 476 478 def __init__(self, callback, pilotID, password, entranceExam): 477 479 """Construct the login request with the given pilot ID and … … 488 490 md5.update(self._pilotID) 489 491 pilotID = md5.hexdigest() 490 492 491 493 md5 = hashlib.md5() 492 494 md5.update(self._password) … … 524 526 result.pilotName = self.iso88592decoder(readline(f))[0] 525 527 result.exams = readline(f) 526 528 527 529 while True: 528 530 line = readline(f) … … 540 542 541 543 return result 542 544 543 545 #------------------------------------------------------------------------------ 544 546 545 547 class GetFleet(Request): 546 548 """Request to get the fleet from the website.""" 547 549 548 550 def __init__(self, callback): 549 551 """Construct the fleet request.""" … … 558 560 result.fleet = Fleet(f) 559 561 f.close() 560 562 561 563 return result 562 564 … … 585 587 ("status", status), 586 588 ("kapu", gateNumber)]) 587 589 588 590 f = urllib2.urlopen(url, data, timeout = 10.0) 589 591 line = readline(f) 590 592 591 593 result = Result() 592 594 result.success = line == "OK" 593 595 594 596 return result 595 597 596 598 #------------------------------------------------------------------------------ 597 599 … … 628 630 629 631 class 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.""" 631 633 632 634 def __init__(self, callback, airports): … … 639 641 url = "http://www.aviationweather.gov/adds/dataserver_current/httpparam?" 640 642 data = urllib.urlencode([ ("dataSource" , "metars"), 641 ("requestType", "retrieve"), 643 ("requestType", "retrieve"), 642 644 ("format", "csv"), 643 645 ("stationString", " ".join(self._airports)), … … 652 654 if len(line)>5 and line[4]==' ': 653 655 icao = line[0:4] 654 if icao in self._airports: 656 if icao in self._airports: 655 657 result.metars[icao] = line.strip().split(",")[0] 656 658 finally: … … 696 698 data["bag"] = str(pirep.bagWeight) 697 699 data["mail"] = str(pirep.mailWeight) 698 700 699 701 data["flttype"] = SendPIREP._flightTypes[pirep.flightType] 700 702 data["onoff"] = "1" if pirep.online else "0" … … 742 744 f.close() 743 745 744 return result 746 return result 745 747 #------------------------------------------------------------------------------ 746 748 … … 757 759 """Perform the sending of the ACARS.""" 758 760 print "Sending the online ACARS" 759 761 760 762 url = "http://www.virtualairlines.hu/acars2/acarsonline.php" 761 763 … … 766 768 data["pid"] = acars.pid 767 769 data["pilot"] = SendACARS._latin2Encoder(acars.pilotName)[0] 768 770 769 771 data["pass"] = str(bookedFlight.numPassengers) 770 772 data["callsign"] = bookedFlight.callsign 771 773 data["airplane"] = bookedFlight.aircraftTypeName 772 774 data["from"] = bookedFlight.departureICAO 773 data["to"] = bookedFlight.arrivalICAO 775 data["to"] = bookedFlight.arrivalICAO 774 776 data["lajstrom"] = bookedFlight.tailNumber 775 777 … … 779 781 data["altitude"] = str(acars.state.altitude) 780 782 data["speed"] = str(acars.state.groundSpeed) 781 783 782 784 data["event"] = acars.getEventText() 783 785 … … 788 790 f.close() 789 791 790 return result 792 return result 791 793 792 794 #------------------------------------------------------------------------------ … … 813 815 """Enqueue a fleet retrieval request.""" 814 816 self._addRequest(GetFleet(callback)) 815 817 816 818 def updatePlane(self, callback, tailNumber, status, gateNumber = None): 817 """Update the status of the given plane.""" 819 """Update the status of the given plane.""" 818 820 self._addRequest(UpdatePlane(callback, tailNumber, status, gateNumber)) 819 821 … … 821 823 """Get the NOTAMs for the given two airports.""" 822 824 self._addRequest(GetNOTAMs(callback, departureICAO, arrivalICAO)) 823 825 824 826 def getMETARs(self, callback, airports): 825 827 """Get the METARs for the given airports.""" … … 833 835 """Send the given ACARS""" 834 836 self._addRequest(SendACARS(callback, acars)) 835 837 836 838 def run(self): 837 839 """Process the requests.""" … … 844 846 845 847 request.perform() 846 848 847 849 def _addRequest(self, request): 848 850 """Add the given request to the queue.""" … … 855 857 if __name__ == "__main__": 856 858 import time 857 859 858 860 def callback(returned, result): 859 861 print returned, unicode(result) 860 862 861 863 handler = Handler() 862 864 handler.start() … … 866 868 # Plane: HA-LEG home (gate 67) 867 869 #handler.updatePlane(callback, "HA-LQC", const.PLANE_AWAY, "72") 868 #time.sleep(3) 870 #time.sleep(3) 869 871 #handler.getFleet(callback) 870 872 #time.sleep(3) … … 873 875 #handler.getMETARs(callback, ["LHBP", "EPWA"]) 874 876 #time.sleep(5) 875 877 876 878 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.