source: src/mlx/const.py@ 1077:e230d26ca700

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

Constants and basic support for MSFS 2020 (re #364).

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