source: src/mlx/const.py@ 1073:a5a22d24f890

python3
Last change on this file since 1073:a5a22d24f890 was 1073:a5a22d24f890, checked in by István Váradi <ivaradi@…>, 17 months ago

New constant for X-Plane 12

File size: 15.8 KB
RevLine 
[298]1
2import sys
[859]3import datetime
[4]4
5#-------------------------------------------------------------------------------
6
[298]7## @package mlx.const
8#
9# The constants used by the program.
10
11#-------------------------------------------------------------------------------
12
13## The version of the program
[1066]14VERSION="0.52"
[20]15
16#-------------------------------------------------------------------------------
17
[298]18## The ratio between lbs and kg
[6]19LBSTOKG=0.4536
20
[298]21## The ratio between kgs and lbs
[52]22KGSTOLB=1/LBSTOKG
23
[298]24## The ratio between feet and metre
[6]25FEETTOMETRES=0.3048
26
27#-------------------------------------------------------------------------------
28
[298]29## The ratio between knots and km/h
[241]30KNOTSTOKMPH=1.852
31
[298]32## The ratio between km/h and knots
[241]33KMPHTOKNOTS=1/1.852
34
35#-------------------------------------------------------------------------------
36
[298]37## Flight simulator type: MS Flight Simulator 2004
[6]38SIM_MSFS9 = 1
[4]39
[298]40## Flight simulator type: MS Flight Simulator X
[6]41SIM_MSFSX = 2
[4]42
[298]43## Flight simulator type: X-Plane 9
[6]44SIM_XPLANE9 = 3
[4]45
[298]46## Flight simulator type: X-Plane 10
[6]47SIM_XPLANE10 = 4
[4]48
[657]49## Flight simulator type: Prepar3D
50SIM_P3D = 5
51
[909]52## Flight simulator type: X-Plane 11
53SIM_XPLANE11 = 6
54
[1073]55## Flight simulator type: X-Plane 12
56SIM_XPLANE12 = 7
57
[4]58#-------------------------------------------------------------------------------
59
[298]60## Aircraft type: Boeing 737-600
[4]61AIRCRAFT_B736 = 1
62
[298]63## Aircraft type: Boeing 737-700
[4]64AIRCRAFT_B737 = 2
65
[298]66## Aircraft type: Boeing 737-800
[4]67AIRCRAFT_B738 = 3
68
[298]69## Aircraft type: Boeing 737-800 (charter configuration)
[191]70AIRCRAFT_B738C = 16
71
[790]72## Aircraft type: Boeing 737-200
73AIRCRAFT_B732 = 18
74
[298]75## Aircraft type: Boeing 737-300
[7]76AIRCRAFT_B733 = 4
[4]77
[298]78## Aircraft type: Boeing 737-400
[7]79AIRCRAFT_B734 = 5
[4]80
[298]81## Aircraft type: Boeing 737-500
[7]82AIRCRAFT_B735 = 6
83
[298]84## Aircraft type: Dash-8 Q400
[7]85AIRCRAFT_DH8D = 7
[4]86
[298]87## Aircraft type: Boeing 767-200
[4]88AIRCRAFT_B762 = 8
89
[298]90## Aircraft type: Boeing 767-300
[7]91AIRCRAFT_B763 = 9
[4]92
[298]93## Aircraft type: Canadair CRJ-200
[4]94AIRCRAFT_CRJ2 = 10
95
[298]96## Aircraft type: Fokker F-70
[4]97AIRCRAFT_F70 = 11
98
[298]99## Aircraft type: Lisunov Li-2
[4]100AIRCRAFT_DC3 = 12
101
[298]102## Aircraft type: Tupolev Tu-134
[4]103AIRCRAFT_T134 = 13
104
[298]105## Aircraft type: Tupolev Tu-154
[4]106AIRCRAFT_T154 = 14
107
[298]108## Aircraft type: Yakovlev Yak-40
[4]109AIRCRAFT_YK40 = 15
110
[443]111## Aircraft type: British Aerospace BAe-146
[451]112AIRCRAFT_B462 = 17
[443]113
[1032]114## Aircraft type: Ilyushin IL-62
115AIRCRAFT_IL62 = 18
116
[8]117#-------------------------------------------------------------------------------
118
[298]119## The list of aircraft types that we know of
[175]120# The order is mostly from most recent to oldest considering
121# Malev's history
[191]122aircraftTypes = [AIRCRAFT_B736, AIRCRAFT_B737,
123 AIRCRAFT_B738, AIRCRAFT_B738C,
[175]124 AIRCRAFT_DH8D,
125 AIRCRAFT_F70, AIRCRAFT_CRJ2,
126 AIRCRAFT_B762, AIRCRAFT_B763,
[790]127 AIRCRAFT_B732, AIRCRAFT_B733, AIRCRAFT_B734, AIRCRAFT_B735,
[175]128 AIRCRAFT_T154, AIRCRAFT_T134,
[443]129 AIRCRAFT_YK40, AIRCRAFT_DC3,
[1032]130 AIRCRAFT_B462, AIRCRAFT_IL62]
[175]131
132#-------------------------------------------------------------------------------
133
[858]134## Aircraft type family: Boeing 737 NG
135AIRCRAFT_FAMILY_B737NG = 1
136
137## Aircraft type family: Boeing 737 Classic
138AIRCRAFT_FAMILY_B737CL = 2
139
140## Aircraft type family: Bombardier Dash-8 Q400
141AIRCRAFT_FAMILY_DH8D = 3
142
143## Aircraft type family: Boeing 767
144AIRCRAFT_FAMILY_B767 = 4
145
146## Aircraft type family: Canadair CRJ-200
147AIRCRAFT_FAMILY_CRJ2 = 5
148
149## Aircraft type family: Fokker F-70
150AIRCRAFT_FAMILY_F70 = 6
151
152## Aircraft type family: Lisunov Li-2
153AIRCRAFT_FAMILY_DC3 = 7
154
155## Aircraft type family: Tupolev Tu-134
156AIRCRAFT_FAMILY_T134 = 8
157
158## Aircraft type family: Tupolev Tu-154
159AIRCRAFT_FAMILY_T154 = 9
160
161## Aircraft type family: Yakovlev Yak-40
162AIRCRAFT_FAMILY_YK40 = 10
163
164## Aircraft type family: British Aerospace BAe-146
165AIRCRAFT_FAMILY_B462 = 11
166
167#-------------------------------------------------------------------------------
168
169## Map aircraft families to the list of the types they comprise of
170aircraftFamily2Types = {
171 AIRCRAFT_FAMILY_B737NG: [AIRCRAFT_B736, AIRCRAFT_B737, AIRCRAFT_B738,
172 AIRCRAFT_B738C],
173
174 AIRCRAFT_FAMILY_B737CL: [AIRCRAFT_B732, AIRCRAFT_B733, AIRCRAFT_B734,
175 AIRCRAFT_B735],
176
177 AIRCRAFT_FAMILY_DH8D: [AIRCRAFT_DH8D],
178
179 AIRCRAFT_FAMILY_B767: [AIRCRAFT_B762, AIRCRAFT_B763],
180
181 AIRCRAFT_FAMILY_CRJ2: [AIRCRAFT_CRJ2],
182
183 AIRCRAFT_FAMILY_F70: [AIRCRAFT_F70],
184
185 AIRCRAFT_FAMILY_DC3: [AIRCRAFT_DC3],
186
187 AIRCRAFT_FAMILY_T134: [AIRCRAFT_T134],
188
189 AIRCRAFT_FAMILY_T154: [AIRCRAFT_T154],
190
191 AIRCRAFT_FAMILY_YK40: [AIRCRAFT_YK40],
192
193 AIRCRAFT_FAMILY_B462: [AIRCRAFT_B462]
194
195 }
196
197#-------------------------------------------------------------------------------
198
199def aircraftType2Family(aircraftType):
200 """Get the family for the given aircraft type."""
[919]201 for (family, types) in aircraftFamily2Types.items():
[858]202 if aircraftType in types:
203 return family
204 assert False
205
206#-------------------------------------------------------------------------------
207
[298]208## A mapping of aircraft types to their 'internal' ICAO codes (which are
[191]209# the same as the real ICAO codes, except in a few cases)
210icaoCodes = { AIRCRAFT_B736 : "B736",
211 AIRCRAFT_B737 : "B737",
212 AIRCRAFT_B738 : "B738",
213 AIRCRAFT_B738C : "B738C",
[790]214 AIRCRAFT_B732 : "B732",
[191]215 AIRCRAFT_B733 : "B733",
216 AIRCRAFT_B734 : "B734",
217 AIRCRAFT_B735 : "B735",
218 AIRCRAFT_DH8D : "DH8D",
219 AIRCRAFT_B762 : "B762",
220 AIRCRAFT_B763 : "B763",
221 AIRCRAFT_CRJ2 : "CRJ2",
222 AIRCRAFT_F70 : "F70",
223 AIRCRAFT_DC3 : "DC3",
224 AIRCRAFT_T134 : "T134",
225 AIRCRAFT_T154 : "T154",
[443]226 AIRCRAFT_YK40 : "YK40",
227 AIRCRAFT_B462 : "B462" }
[175]228
229#-------------------------------------------------------------------------------
230
[298]231## Flight stage: boarding
[8]232STAGE_BOARDING = 1
233
[298]234## Flight stage: pushback, startup and taxi
[8]235STAGE_PUSHANDTAXI = 2
236
[298]237## Flight stage: takeoff
[8]238STAGE_TAKEOFF = 3
239
[298]240## Flight stage: RTO
[8]241STAGE_RTO = 4
242
[298]243## Flight stage: climb
[8]244STAGE_CLIMB = 5
245
[298]246## Flight stage: cruise
[8]247STAGE_CRUISE = 6
248
[298]249## Flight stage: descent
[8]250STAGE_DESCENT = 7
251
[298]252## Flight stage: landing
[8]253STAGE_LANDING = 8
254
[298]255## Flight stage: taxi after landing
[8]256STAGE_TAXIAFTERLAND = 9
257
[298]258## Flight stage: parking
[8]259STAGE_PARKING = 10
260
[298]261## Flight stage: go-around
[8]262STAGE_GOAROUND = 11
263
[298]264## Flight stage: end
[8]265STAGE_END = 12
[11]266
267#-------------------------------------------------------------------------------
268
[132]269_stageStrings = { STAGE_BOARDING : "boarding",
270 STAGE_PUSHANDTAXI : "pushback and taxi",
271 STAGE_TAKEOFF : "takeoff",
272 STAGE_RTO : "RTO",
273 STAGE_CLIMB : "climb",
274 STAGE_CRUISE : "cruise",
275 STAGE_DESCENT : "descent",
276 STAGE_LANDING : "landing",
277 STAGE_TAXIAFTERLAND : "taxi",
278 STAGE_PARKING : "parking",
279 STAGE_GOAROUND : "go-around",
280 STAGE_END : "end" }
281
282def stage2string(stage):
283 """Convert the given stage to a lower-case string."""
284 return _stageStrings[stage] if stage in _stageStrings else None
[335]285
[132]286#-------------------------------------------------------------------------------
287
[298]288## Plane status: unknown
[51]289PLANE_UNKNOWN = 0
290
[298]291## Plane status: at home, i.e. LHBP
[51]292PLANE_HOME = 1
293
[298]294## Plane status: away
[51]295PLANE_AWAY = 2
296
[298]297## Plane status: parking
[51]298PLANE_PARKING = 3
299
300#-------------------------------------------------------------------------------
301
[298]302## Flight type: scheduled
[97]303FLIGHTTYPE_SCHEDULED = 0
304
[298]305## Flight type: VIP
[1034]306FLIGHTTYPE_VIP = 1
[97]307
[298]308## Flight type: charter
[1034]309FLIGHTTYPE_CHARTER = 2
310
311## Flight type: old timer (not used anymore)
312FLIGHTTYPE_OLDTIMER = -1
[97]313
314#-------------------------------------------------------------------------------
315
[220]316flightTypes = [ FLIGHTTYPE_SCHEDULED,
317 FLIGHTTYPE_VIP,
[1034]318 FLIGHTTYPE_CHARTER,
319 FLIGHTTYPE_OLDTIMER ]
[220]320
321#-------------------------------------------------------------------------------
322
323_flightTypeStrings = { FLIGHTTYPE_SCHEDULED : "scheduled",
324 FLIGHTTYPE_VIP : "vip",
[1034]325 FLIGHTTYPE_CHARTER : "charter",
326 FLIGHTTYPE_OLDTIMER : "ot" }
[220]327
328def flightType2string(flightType):
329 """Get the string equivalent of the given flight type."""
330 return _flightTypeStrings[flightType] \
[335]331 if flightType in _flightTypeStrings else None
[220]332
[835]333def flightType2index(flightType):
334 """Get the index of the given flight type according to the list above"""
335 return flightTypes.index(flightType)
336
[220]337#-------------------------------------------------------------------------------
338
[298]339## Message type: logger error
[133]340# FIXME: cannot set the hotkey
[132]341MESSAGETYPE_LOGGER_ERROR = 1
342
[298]343## Message type: information
[132]344MESSAGETYPE_INFORMATION = 2
345
[315]346## Message type: in-flight information
347MESSAGETYPE_INFLIGHT = 3
348
[298]349## Message type: fault messages
[315]350MESSAGETYPE_FAULT = 4
[132]351
[298]352## Message type: NO-GO fault messages
[315]353MESSAGETYPE_NOGO = 5
[132]354
[298]355## Message type: gate system messages
[315]356MESSAGETYPE_GATE_SYSTEM = 6
[132]357
[298]358## Message type: environment messages
[133]359# FIXME: flight plan closed (5 sec)
[315]360MESSAGETYPE_ENVIRONMENT = 7
[132]361
[298]362## Message type: help messages
[315]363MESSAGETYPE_HELP = 8
[132]364
[298]365## Message type: visibility messages
[315]366MESSAGETYPE_VISIBILITY = 9
[132]367
368#-------------------------------------------------------------------------------
369
370messageTypes = [ MESSAGETYPE_LOGGER_ERROR,
371 MESSAGETYPE_INFORMATION,
[315]372 MESSAGETYPE_INFLIGHT,
[132]373 MESSAGETYPE_FAULT,
374 MESSAGETYPE_NOGO,
375 MESSAGETYPE_GATE_SYSTEM,
376 MESSAGETYPE_ENVIRONMENT,
377 MESSAGETYPE_HELP,
378 MESSAGETYPE_VISIBILITY ]
379
380#-------------------------------------------------------------------------------
381
382_messageTypeStrings = { MESSAGETYPE_LOGGER_ERROR : "loggerError",
383 MESSAGETYPE_INFORMATION : "information",
[315]384 MESSAGETYPE_INFLIGHT : "inflight",
[132]385 MESSAGETYPE_FAULT : "fault",
386 MESSAGETYPE_NOGO : "nogo",
387 MESSAGETYPE_GATE_SYSTEM : "gateSystem",
388 MESSAGETYPE_ENVIRONMENT : "environment",
389 MESSAGETYPE_HELP : "help",
390 MESSAGETYPE_VISIBILITY : "visibility" }
391
392def messageType2string(messageType):
393 """Get the string equivalent of the given message type."""
394 return _messageTypeStrings[messageType] \
[335]395 if messageType in _messageTypeStrings else None
[132]396
397#-------------------------------------------------------------------------------
398
[298]399## Message display level: none
[132]400MESSAGELEVEL_NONE = 0
401
[298]402## Message display level: only message in the simulator
[132]403MESSAGELEVEL_FS = 1
404
[298]405## Message display level: only sound
[132]406MESSAGELEVEL_SOUND = 2
407
[298]408## Message display level: both
[132]409MESSAGELEVEL_BOTH = 3
410
411#-------------------------------------------------------------------------------
412
413messageLevels = [ MESSAGELEVEL_NONE,
414 MESSAGELEVEL_FS,
415 MESSAGELEVEL_SOUND,
416 MESSAGELEVEL_BOTH ]
417
418#-------------------------------------------------------------------------------
419
420_messageLevelStrings = { MESSAGELEVEL_NONE : "none",
421 MESSAGELEVEL_FS : "fs",
422 MESSAGELEVEL_SOUND : "sound",
423 MESSAGELEVEL_BOTH : "both" }
424
425def messageLevel2string(messageLevel):
426 """Get the string equivalent of the given message level."""
427 return _messageLevelStrings[messageLevel] \
[335]428 if messageLevel in _messageLevelStrings else None
[132]429
430def string2messageLevel(str):
431 """Get the message level for the given string."""
[919]432 for (value, s) in _messageLevelStrings.items():
[132]433 if str==s:
434 return value
435 return MESSAGELEVEL_NONE
436
437#-------------------------------------------------------------------------------
438
[298]439## Sound: ding
[133]440SOUND_DING = "ding.wav"
441
[298]442## Sound: notify
[170]443SOUND_NOTIFY = "notify.wav"
444
[298]445## Sound: NOTAM
[170]446SOUND_NOTAM = "notam.mp3"
447
[298]448## Sound: scream
[170]449SOUND_SCREAM = "sikoly.mp3"
450
[298]451## Sound: boarding
[170]452SOUND_BOARDING = "board.mp3"
453
[298]454## Sound: Malev theme
[170]455SOUND_MALEV = "malev.mp3"
456
[298]457## Sound: taxi: Boeing 737 NG
[170]458SOUND_TAXI_BOEING737NG = "737taxi.mp3"
459
[298]460## Sound: taxi: Boeing 767
[170]461SOUND_TAXI_BOEING767 = "767taxi.mp3"
462
[298]463## Sound: taxi: Fokker F70
[170]464SOUND_TAXI_F70 = "F70taxi.mp3"
465
[298]466## Sound: takeoff preparation request from the captain
[170]467SOUND_CAPTAIN_TAKEOFF = "cpt_takeoff.mp3"
468
[298]469## Sound: cruise
[170]470SOUND_CRUISE = "TOC.mp3"
471
[298]472## Sound: descent
[170]473SOUND_DESCENT = "TOD.mp3"
474
[298]475## Sound: applause
[170]476SOUND_APPLAUSE = "taps.mp3"
477
[298]478## Sound: speedbrake
[170]479SOUND_SPEEDBRAKE = "speed.mp3"
480
[298]481## Sound: taxi after landing
[170]482SOUND_TAXIAFTERLAND = "TaxiAfterLand.mp3"
483
484
[133]485#-------------------------------------------------------------------------------
486
[298]487## Fuel tank: centre
[140]488FUELTANK_CENTRE = 1
489
[298]490## Fuel tank: left
[140]491FUELTANK_LEFT = 2
492
[298]493## Fuel tank: right
[140]494FUELTANK_RIGHT = 3
495
[298]496## Fuel tank: left aux
[140]497FUELTANK_LEFT_AUX = 4
498
[298]499## Fuel tank: right aux
[140]500FUELTANK_RIGHT_AUX = 5
501
[298]502## Fuel tank: left tip
[140]503FUELTANK_LEFT_TIP = 6
504
[298]505## Fuel tank: right tip
[140]506FUELTANK_RIGHT_TIP = 7
507
[298]508## Fuel tank: external 1
[140]509FUELTANK_EXTERNAL1 = 8
510
[298]511## Fuel tank: external 2
[140]512FUELTANK_EXTERNAL2 = 9
513
[298]514## Fuel tank: centre2
[140]515FUELTANK_CENTRE2 = 10
516
517#-------------------------------------------------------------------------------
518
[141]519fuelTanks = [ FUELTANK_CENTRE,
520 FUELTANK_LEFT,
521 FUELTANK_RIGHT,
522 FUELTANK_LEFT_AUX,
523 FUELTANK_RIGHT_AUX,
524 FUELTANK_LEFT_TIP,
525 FUELTANK_RIGHT_TIP,
526 FUELTANK_EXTERNAL1,
527 FUELTANK_EXTERNAL2,
528 FUELTANK_CENTRE2 ]
529
530#-------------------------------------------------------------------------------
531
532_fuelTankStrings = { FUELTANK_CENTRE : "centre",
533 FUELTANK_LEFT : "left",
534 FUELTANK_RIGHT : "right",
535 FUELTANK_LEFT_AUX : "left_aux",
536 FUELTANK_RIGHT_AUX : "right_aux",
537 FUELTANK_LEFT_TIP : "left_tip",
538 FUELTANK_RIGHT_TIP : "right_tip",
539 FUELTANK_EXTERNAL1 : "external1",
540 FUELTANK_EXTERNAL2 : "external2",
541 FUELTANK_CENTRE2 : "centre2" }
542
543def fuelTank2string(fuelTank):
544 """Get the string equivalent of the given fuelTank."""
545 return _fuelTankStrings[fuelTank] \
[335]546 if fuelTank in _fuelTankStrings else None
[141]547
548#-------------------------------------------------------------------------------
549
[274]550_fuelTankLogStrings = { FUELTANK_CENTRE : "centre",
551 FUELTANK_LEFT : "left",
552 FUELTANK_RIGHT : "right",
553 FUELTANK_LEFT_AUX : "left aux",
554 FUELTANK_RIGHT_AUX : "right aux",
555 FUELTANK_LEFT_TIP : "left tip",
556 FUELTANK_RIGHT_TIP : "right tip",
557 FUELTANK_EXTERNAL1 : "external 1",
558 FUELTANK_EXTERNAL2 : "external 2",
559 FUELTANK_CENTRE2 : "centre 2" }
560
561def fuelTank2logString(fuelTank):
562 """Get the log string equivalent of the given fuelTank."""
563 return _fuelTankLogStrings[fuelTank] \
564 if fuelTank in _fuelTankLogStrings else "unknown"
565
566#-------------------------------------------------------------------------------
567
[132]568languages = ["$system", "en_GB", "hu_HU"]
[11]569
[133]570#-------------------------------------------------------------------------------
[859]571
572defaultDate = datetime.date(1900, 1, 1)
573
574#-------------------------------------------------------------------------------
[1033]575
576# The weight of a cabin crew member [kg]
577WEIGHT_CABIN_CREW = 75
578
579# The weight of an adult passenger [kg]
580WEIGHT_PASSENGER = 84
581
582# The weight of an adult passenger on charter flight [kg]
583WEIGHT_PASSENGER_CHARTER = 76
584
585# The weight of a child passenger [kg]
586WEIGHT_CHILD = 35
587
588# The weight of an infant passenger [kg]
589WEIGHT_INFANT = 0
590
591#-------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.