source: src/mlx/const.py@ 917:803dc6bacfa5

Last change on this file since 917:803dc6bacfa5 was 917:803dc6bacfa5, checked in by István Váradi <ivaradi@…>, 5 years ago

Merged 0.39

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