source: src/mlx/const.py@ 907:953dc1f27659

Last change on this file since 907:953dc1f27659 was 907:953dc1f27659, checked in by István Váradi <ivaradi@…>, 6 years ago

Stepped version

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