@airframes/acars-decoder 1.4.6 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/.github/FUNDING.yml +1 -1
  2. package/.github/workflows/yarn-test.yml +11 -4
  3. package/README.md +32 -0
  4. package/index.d.ts +17 -0
  5. package/index.ts +2 -0
  6. package/package.json +5 -13
  7. package/tsconfig.json +2 -2
  8. package/yarn-error.log +3354 -0
  9. package/coverage/clover.xml +0 -1799
  10. package/coverage/coverage-final.json +0 -24
  11. package/coverage/lcov-report/base.css +0 -224
  12. package/coverage/lcov-report/block-navigation.js +0 -87
  13. package/coverage/lcov-report/favicon.png +0 -0
  14. package/coverage/lcov-report/index.html +0 -131
  15. package/coverage/lcov-report/prettify.css +0 -1
  16. package/coverage/lcov-report/prettify.js +0 -2
  17. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  18. package/coverage/lcov-report/sorter.js +0 -196
  19. package/coverage/lcov.info +0 -2278
  20. package/dist/DateTimeUtils.d.ts +0 -8
  21. package/dist/DateTimeUtils.js +0 -27
  22. package/dist/DecoderPlugin.d.ts +0 -18
  23. package/dist/DecoderPlugin.js +0 -71
  24. package/dist/DecoderPluginInterface.d.ts +0 -7
  25. package/dist/DecoderPluginInterface.js +0 -3
  26. package/dist/IcaoDecoder.d.ts +0 -10
  27. package/dist/IcaoDecoder.js +0 -111
  28. package/dist/MessageDecoder.d.ts +0 -14
  29. package/dist/MessageDecoder.js +0 -129
  30. package/dist/bin/acars-decoder-test.d.ts +0 -2
  31. package/dist/bin/acars-decoder-test.js +0 -53
  32. package/dist/bin/acars-decoder.d.ts +0 -2
  33. package/dist/bin/acars-decoder.js +0 -20
  34. package/dist/index.d.ts +0 -4
  35. package/dist/index.js +0 -20
  36. package/dist/plugins/Label_15.d.ts +0 -11
  37. package/dist/plugins/Label_15.js +0 -40
  38. package/dist/plugins/Label_16_N_Space.d.ts +0 -11
  39. package/dist/plugins/Label_16_N_Space.js +0 -80
  40. package/dist/plugins/Label_16_N_Space.test.d.ts +0 -1
  41. package/dist/plugins/Label_16_N_Space.test.js +0 -84
  42. package/dist/plugins/Label_1M_Slash.d.ts +0 -11
  43. package/dist/plugins/Label_1M_Slash.js +0 -61
  44. package/dist/plugins/Label_1M_Slash.test.d.ts +0 -1
  45. package/dist/plugins/Label_1M_Slash.test.js +0 -43
  46. package/dist/plugins/Label_20_CFB.01.d.ts +0 -11
  47. package/dist/plugins/Label_20_CFB.01.js +0 -69
  48. package/dist/plugins/Label_20_POS.d.ts +0 -11
  49. package/dist/plugins/Label_20_POS.js +0 -62
  50. package/dist/plugins/Label_30_Slash_EA.d.ts +0 -11
  51. package/dist/plugins/Label_30_Slash_EA.js +0 -54
  52. package/dist/plugins/Label_30_Slash_EA.test.d.ts +0 -1
  53. package/dist/plugins/Label_30_Slash_EA.test.js +0 -35
  54. package/dist/plugins/Label_44_ETA.d.ts +0 -11
  55. package/dist/plugins/Label_44_ETA.js +0 -69
  56. package/dist/plugins/Label_44_IN.d.ts +0 -11
  57. package/dist/plugins/Label_44_IN.js +0 -69
  58. package/dist/plugins/Label_44_OFF.d.ts +0 -11
  59. package/dist/plugins/Label_44_OFF.js +0 -74
  60. package/dist/plugins/Label_44_ON.d.ts +0 -11
  61. package/dist/plugins/Label_44_ON.js +0 -69
  62. package/dist/plugins/Label_44_POS.d.ts +0 -11
  63. package/dist/plugins/Label_44_POS.js +0 -81
  64. package/dist/plugins/Label_5Z.d.ts +0 -11
  65. package/dist/plugins/Label_5Z.js +0 -120
  66. package/dist/plugins/Label_80.d.ts +0 -12
  67. package/dist/plugins/Label_80.js +0 -203
  68. package/dist/plugins/Label_8E.d.ts +0 -10
  69. package/dist/plugins/Label_8E.js +0 -48
  70. package/dist/plugins/Label_8E.test.d.ts +0 -1
  71. package/dist/plugins/Label_8E.test.js +0 -32
  72. package/dist/plugins/Label_B6.d.ts +0 -11
  73. package/dist/plugins/Label_B6.js +0 -26
  74. package/dist/plugins/Label_ColonComma.d.ts +0 -10
  75. package/dist/plugins/Label_ColonComma.js +0 -28
  76. package/dist/plugins/Label_H1.d.ts +0 -9
  77. package/dist/plugins/Label_H1.js +0 -18
  78. package/dist/plugins/Label_H1_M1BPOS.d.ts +0 -11
  79. package/dist/plugins/Label_H1_M1BPOS.js +0 -54
  80. package/dist/plugins/Label_H1_M1BPRG.d.ts +0 -11
  81. package/dist/plugins/Label_H1_M1BPRG.js +0 -36
  82. package/dist/plugins/Label_QP.d.ts +0 -10
  83. package/dist/plugins/Label_QP.js +0 -49
  84. package/dist/plugins/Label_QQ.d.ts +0 -10
  85. package/dist/plugins/Label_QQ.js +0 -49
  86. package/dist/plugins/Label_QR.d.ts +0 -10
  87. package/dist/plugins/Label_QR.js +0 -49
  88. package/dist/plugins/Label_QS.d.ts +0 -10
  89. package/dist/plugins/Label_QS.js +0 -49
  90. package/dist/plugins/Label_SQ.d.ts +0 -10
  91. package/dist/plugins/Label_SQ.js +0 -104
  92. package/dist/plugins/official.d.ts +0 -22
  93. package/dist/plugins/official.js +0 -38
  94. package/src/DateTimeUtils.ts +0 -26
  95. package/src/DecoderPlugin.ts +0 -83
  96. package/src/DecoderPluginInterface.ts +0 -9
  97. package/src/IcaoDecoder.ts +0 -137
  98. package/src/MessageDecoder.ts +0 -117
  99. package/src/bin/acars-decoder-test.ts +0 -67
  100. package/src/bin/acars-decoder.ts +0 -23
  101. package/src/index.d.ts +0 -15
  102. package/src/index.ts +0 -4
  103. package/src/plugins/Label_15.ts +0 -45
  104. package/src/plugins/Label_16_N_Space.test.ts +0 -94
  105. package/src/plugins/Label_16_N_Space.ts +0 -91
  106. package/src/plugins/Label_1M_Slash.test.ts +0 -45
  107. package/src/plugins/Label_1M_Slash.ts +0 -69
  108. package/src/plugins/Label_20_CFB.01.ts +0 -81
  109. package/src/plugins/Label_20_POS.ts +0 -68
  110. package/src/plugins/Label_30_Slash_EA.test.ts +0 -37
  111. package/src/plugins/Label_30_Slash_EA.ts +0 -60
  112. package/src/plugins/Label_44_ETA.ts +0 -81
  113. package/src/plugins/Label_44_IN.ts +0 -81
  114. package/src/plugins/Label_44_OFF.ts +0 -88
  115. package/src/plugins/Label_44_ON.ts +0 -81
  116. package/src/plugins/Label_44_POS.ts +0 -96
  117. package/src/plugins/Label_5Z.ts +0 -125
  118. package/src/plugins/Label_80.ts +0 -215
  119. package/src/plugins/Label_8E.test.ts +0 -34
  120. package/src/plugins/Label_8E.ts +0 -55
  121. package/src/plugins/Label_B6.ts +0 -28
  122. package/src/plugins/Label_ColonComma.ts +0 -32
  123. package/src/plugins/Label_H1.ts +0 -18
  124. package/src/plugins/Label_H1_M1BPOS.ts +0 -60
  125. package/src/plugins/Label_H1_M1BPRG.ts +0 -40
  126. package/src/plugins/Label_QP.ts +0 -54
  127. package/src/plugins/Label_QQ.ts +0 -54
  128. package/src/plugins/Label_QR.ts +0 -54
  129. package/src/plugins/Label_QS.ts +0 -54
  130. package/src/plugins/Label_SQ.ts +0 -111
  131. package/src/plugins/official.ts +0 -22
@@ -1,38 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Label_5Z"), exports);
18
- __exportStar(require("./Label_15"), exports);
19
- __exportStar(require("./Label_16_N_Space"), exports);
20
- __exportStar(require("./Label_20_POS"), exports);
21
- __exportStar(require("./Label_30_Slash_EA"), exports);
22
- __exportStar(require("./Label_44_ETA"), exports);
23
- __exportStar(require("./Label_44_IN"), exports);
24
- __exportStar(require("./Label_44_OFF"), exports);
25
- __exportStar(require("./Label_44_ON"), exports);
26
- __exportStar(require("./Label_44_POS"), exports);
27
- __exportStar(require("./Label_80"), exports);
28
- __exportStar(require("./Label_8E"), exports);
29
- __exportStar(require("./Label_B6"), exports);
30
- __exportStar(require("./Label_ColonComma"), exports);
31
- __exportStar(require("./Label_H1_M1BPOS"), exports);
32
- __exportStar(require("./Label_H1_M1BPRG"), exports);
33
- __exportStar(require("./Label_1M_Slash"), exports);
34
- __exportStar(require("./Label_SQ"), exports);
35
- __exportStar(require("./Label_QR"), exports);
36
- __exportStar(require("./Label_QP"), exports);
37
- __exportStar(require("./Label_QS"), exports);
38
- __exportStar(require("./Label_QQ"), exports);
@@ -1,26 +0,0 @@
1
- export class DateTimeUtils {
2
-
3
- // Expects a four digit UTC time string (HHMM)
4
- public static UTCToString(UTCString: string) {
5
- let utcDate = new Date();
6
- utcDate.setUTCHours(+UTCString.substr(0, 2), +UTCString.substr(2, 2), 0);
7
- return utcDate.toTimeString();
8
- }
9
-
10
- // Expects a six digit date string and a four digit UTC time string
11
- // (DDMMYY) (HHMM)
12
- public static UTCDateTimeToString(dateString: string, timeString: string) {
13
- let utcDate = new Date();
14
- utcDate.setUTCDate(+dateString.substr(0, 2));
15
- utcDate.setUTCMonth(+dateString.substr(2, 2));
16
- if (dateString.length === 6) {
17
- utcDate.setUTCFullYear(2000 + +dateString.substr(4, 2));
18
- }
19
- utcDate.setUTCHours(+timeString.substr(0, 2), +timeString.substr(2, 2), 0);
20
- return utcDate.toUTCString();
21
- }
22
- }
23
-
24
- export default {
25
- DateTimeUtils,
26
- };
@@ -1,83 +0,0 @@
1
- import { DecoderPluginInterface } from './DecoderPluginInterface';
2
-
3
- export abstract class DecoderPlugin implements DecoderPluginInterface {
4
- decoder!: any;
5
-
6
- name: string = 'unknown';
7
-
8
- defaultResult: any = {
9
- decoded: false,
10
- decoder: <any>{
11
- name: 'unknown',
12
- type: 'pattern-match',
13
- decodeLevel: 'none',
14
- },
15
- formatted: <any>{
16
- description: 'Unknown',
17
- items: <any>[],
18
- },
19
- raw: <any>{},
20
- remaining: <any>{},
21
- };
22
-
23
- options: Object;
24
-
25
- constructor(decoder : any, options : any = {}) {
26
- this.decoder = decoder;
27
- this.options = options;
28
- }
29
-
30
- id() : string { // eslint-disable-line class-methods-use-this
31
- console.log('DecoderPlugin subclass has not overriden id() to provide a unique ID for this plugin!');
32
- return 'abstract_decoder_plugin';
33
- }
34
-
35
- meetsStateRequirements() : boolean { // eslint-disable-line class-methods-use-this
36
- return true;
37
- }
38
-
39
- // onRegister(store: Store<any>) {
40
- // this.store = store;
41
- // }
42
-
43
- qualifiers() : any { // eslint-disable-line class-methods-use-this
44
- const labels : Array<string> = [];
45
-
46
- return {
47
- labels,
48
- };
49
- }
50
-
51
- decode(message: any) : any { // eslint-disable-line class-methods-use-this
52
- const decodeResult: any = this.defaultResult;
53
- decodeResult.remaining.text = message.text;
54
- return decodeResult;
55
- }
56
-
57
- // Utilities
58
- // TODO: Move these to a utilities class and instanciate here for use in subclasses
59
-
60
- decodeStringCoordinates(stringCoords: String) : any { // eslint-disable-line class-methods-use-this
61
- var results : any = {};
62
- const firstChar = stringCoords.substring(0, 1);
63
- if (firstChar == 'N' || firstChar == 'S') {
64
- // format: N12345W123456
65
- results.latitudeDirection = stringCoords.substring(0, 1);
66
- results.latitude = (Number(stringCoords.substring(1, 6)) / 1000) * (results.latitudeDirection === 'S' ? -1 : 1);
67
- results.longitudeDirection = stringCoords.substring(6, 7);
68
- results.longitude = (Number(stringCoords.substring(7, 13)) / 1000) * (results.longitudeDirection === 'W' ? -1 : 1);
69
- } else {
70
- console.log(`DEBUG: decodeStringCoordinates: Failure to decode String-based coordinates: ${stringCoords}`);
71
- }
72
-
73
- return results;
74
- }
75
-
76
- coordinateString(coords: any) : String {
77
- return `${Math.abs(coords.latitude)} ${coords.latitudeDirection}, ${Math.abs(coords.longitude)} ${coords.longitudeDirection}`
78
- }
79
- }
80
-
81
- export default {
82
- DecoderPlugin,
83
- };
@@ -1,9 +0,0 @@
1
- export interface DecoderPluginInterface {
2
- decode(message: any) : any;
3
- meetsStateRequirements() : boolean;
4
- // onRegister(store: Store<any>) : void;
5
- qualifiers() : any;
6
- }
7
-
8
- export default {
9
- }
@@ -1,137 +0,0 @@
1
- export class IcaoDecoder {
2
- name : string;
3
- icao : string;
4
-
5
- constructor(icao: string) {
6
- this.name = 'icao-decoder-typescript';
7
- this.icao = icao;
8
- }
9
-
10
- isMilitary() {
11
- let i = this.icao;
12
- return (
13
- false
14
- // us military
15
- //adf7c8-adf7cf = united states mil_5(uf)
16
- //adf7d0-adf7df = united states mil_4(uf)
17
- //adf7e0-adf7ff = united states mil_3(uf)
18
- //adf800-adffff = united states mil_2(uf)
19
- || i.match(/^adf[7-9]/)
20
- || i.match(/^adf[a-f]/)
21
- //ae0000-afffff = united states mil_1(uf)
22
- || i.match(/^a(e|f)/)
23
-
24
- //010070-01008f = egypt_mil
25
- || i.match(/^0100(7|8)/)
26
-
27
- //0a4000-0a4fff = algeria mil(ap)
28
- || i.match(/^0a4/)
29
-
30
- //33ff00-33ffff = italy mil(iy)
31
- || i.match(/^33ff/)
32
-
33
- //350000-37ffff = spain mil(sp)
34
- || (i >= '350000' && i <= '37ffff')
35
-
36
- //3a8000-3affff = france mil_1(fs)
37
- || i.match(/^3a(8|9|[a-f])/)
38
- //3b0000-3bffff = france mil_2(fs)
39
- || i.match(/^3b/)
40
-
41
- //3e8000-3ebfff = germany mil_1(df)
42
- // remove 8 and 9 from mil arnge
43
- || i.match(/^3e(a|b)/)
44
- //3f4000-3f7fff = germany mil_2(df)
45
- //3f8000-3fbfff = germany mil_3(df)
46
- || i.match(/^3f([4-9]|[a-b])/)
47
-
48
- //400000-40003f = united kingdom mil_1(ra)
49
- || i.match(/^4000[0-3]/)
50
- //43c000-43cfff = united kingdom mil(ra)
51
- || i.match(/^43c/)
52
-
53
- //444000-447fff = austria mil(aq)
54
- || (i.match(/^44[4-7]/) && i != '447ac7')
55
-
56
- //44f000-44ffff = belgium mil(bc)
57
- || i.match(/^44f/)
58
-
59
- //457000-457fff = bulgaria mil(bu)
60
- || i.match(/^457/)
61
-
62
- //45f400-45f4ff = denmark mil(dg)
63
- || i.match(/^45f4/)
64
-
65
- //468000-4683ff = greece mil(gc)
66
- || i.match(/^468[0-3]/)
67
-
68
- //473c00-473c0f = hungary mil(hm)
69
- || i.match(/^473c0/)
70
-
71
- //478100-4781ff = norway mil(nn)
72
- || i.match(/^4781/)
73
- //480000-480fff = netherlands mil(nm)
74
- || i.match(/^480/)
75
- //48d800-48d87f = poland mil(po)
76
- || i.match(/^48d8[0-7]/)
77
- //497c00-497cff = portugal mil(pu)
78
- || i.match(/^497c/)
79
- //498420-49842f = czech republic mil(ct)
80
- || i.match(/^49842/)
81
-
82
- //4b7000-4b7fff = switzerland mil(su)
83
- || i.match(/^4b7/)
84
- //4b8200-4b82ff = turkey mil(tq)
85
- || i.match(/^4b82/)
86
-
87
- //506f00-506fff = slovenia mil(sj)
88
- || i.match(/^506f/)
89
-
90
- //70c070-70c07f = oman mil(on)
91
- || i.match(/^70c07/)
92
-
93
- //710258-71025f = saudi arabia mil_1(sx)
94
- //710260-71027f = saudi arabia mil_2(sx)
95
- //710280-71028f = saudi arabia mil_3(sx)
96
- //710380-71039f = saudi arabia mil_4(sx)
97
- || i.match(/^7102[5-8]/)
98
- || i.match(/^7103[8-9]/)
99
-
100
- //738a00-738aff = israel mil(iz)
101
- || i.match(/^738a/)
102
-
103
- //7c822e-7c822f = australia mil_1(av)
104
- //7c8230-7c823f = australia mil_2(av)
105
- //7c8240-7c827f = australia mil_3(av)
106
- //7c8280-7c82ff = australia mil_4(av)
107
- //7c8300-7c83ff = australia mil_5(av)
108
- //7c8400-7c87ff = australia mil_6(av)
109
- //7c8800-7c8fff = australia mil_7(av)
110
- || i.match(/^7c8([2-4]|8)/)
111
- //7c9000-7c9fff = australia mil_8(av)
112
- //7ca000-7cbfff = australia mil_9(av)
113
- || (i >= '7c9000' && i <= '7cbfff')
114
- //7cc000-7cffff = australia mil_10(av) 7cc409 not mil, remove this range
115
- //7d0000-7dffff = australia mil_11(av)
116
- //7e0000-7fffff = australia mil_12(av)
117
- || i.match(/^7[d-f]/)
118
-
119
- //800200-8002ff = india mil(im)
120
- || i.match(/^8002/)
121
-
122
- //c20000-c3ffff = canada mil(cb)
123
- || i.match(/^c[2-3]/)
124
-
125
- //e40000-e41fff = brazil mil(bq)
126
- || i.match(/^e4[0-1]/)
127
-
128
- //e80600-e806ff = chile mil(cq)
129
- || i.match(/^e806/)
130
- );
131
- }
132
-
133
- }
134
-
135
- export default {
136
- IcaoDecoder
137
- };
@@ -1,117 +0,0 @@
1
- import { DecoderPluginInterface } from './DecoderPluginInterface'; // eslint-disable-line import/no-cycle
2
-
3
- import * as Plugins from './plugins/official';
4
-
5
- export class MessageDecoder {
6
- name : string;
7
- plugins : Array<DecoderPluginInterface>;
8
- debug : boolean;
9
-
10
- constructor() {
11
- this.name = 'acars-decoder-typescript';
12
- this.plugins = [];
13
- this.debug = false;
14
-
15
- this.registerPlugin(new Plugins.Label_ColonComma(this));
16
- this.registerPlugin(new Plugins.Label_5Z(this));
17
- this.registerPlugin(new Plugins.Label_15(this));
18
- this.registerPlugin(new Plugins.Label_16_N_Space(this));
19
- this.registerPlugin(new Plugins.Label_20_POS(this));
20
- this.registerPlugin(new Plugins.Label_30_Slash_EA(this));
21
- this.registerPlugin(new Plugins.Label_44_ETA(this));
22
- this.registerPlugin(new Plugins.Label_44_IN(this));
23
- this.registerPlugin(new Plugins.Label_44_OFF(this));
24
- this.registerPlugin(new Plugins.Label_44_ON(this));
25
- this.registerPlugin(new Plugins.Label_44_POS(this));
26
- this.registerPlugin(new Plugins.Label_B6_Forwardslash(this));
27
- this.registerPlugin(new Plugins.Label_H1_M1BPOS(this));
28
- this.registerPlugin(new Plugins.Label_80(this));
29
- this.registerPlugin(new Plugins.Label_8E(this));
30
- this.registerPlugin(new Plugins.Label_1M_Slash(this));
31
- this.registerPlugin(new Plugins.Label_SQ(this));
32
- this.registerPlugin(new Plugins.Label_QP(this));
33
- this.registerPlugin(new Plugins.Label_QQ(this));
34
- this.registerPlugin(new Plugins.Label_QR(this));
35
- this.registerPlugin(new Plugins.Label_QS(this));
36
- }
37
-
38
- registerPlugin(plugin: DecoderPluginInterface) : boolean {
39
- const pluginInstance = plugin;
40
- // plugin.onRegister(this.store);
41
- this.plugins.push(plugin);
42
- return true;
43
- }
44
-
45
- decode(message: any, options: any = {}) {
46
- // console.log('All plugins');
47
- // console.log(this.plugins);
48
- const usablePlugins = this.plugins.filter((plugin) => {
49
- const qualifiers : any = plugin.qualifiers();
50
-
51
- if (qualifiers.labels.includes(message.label)) {
52
- if (qualifiers.preambles && qualifiers.preambles.length > 0) {
53
- const matching = qualifiers.preambles.filter((preamble: string) => { // eslint-disable-line arrow-body-style,max-len
54
- // console.log(message.text.substring(0, preamble.length));
55
- // console.log(preamble);
56
- return message.text.substring(0, preamble.length) === preamble;
57
- });
58
- // console.log(matching);
59
- return matching.length >= 1;
60
- } else { // eslint-disable-line no-else-return
61
- return true;
62
- }
63
- }
64
-
65
- return false;
66
- });
67
-
68
- if (options.debug) {
69
- console.log('Usable plugins');
70
- console.log(usablePlugins);
71
- }
72
-
73
- let result;
74
- if (usablePlugins.length > 0) {
75
- const plugin: DecoderPluginInterface = usablePlugins[0];
76
- result = plugin.decode(message);
77
- } else {
78
- result = {
79
- decoded: false,
80
- decodeLevel: 'none',
81
- error: 'No known decoder plugin for this message',
82
- message: message,
83
- remaining: {
84
- text: message.text,
85
- },
86
- raw: {},
87
- formatted: {},
88
- };
89
- }
90
-
91
- if (options.debug) {
92
- let performDebug = true;
93
- if (options.debug.only_decoded) {
94
- performDebug = result.decoded;
95
- }
96
-
97
- if (performDebug) {
98
- console.log('Result');
99
- console.log(result);
100
- }
101
- }
102
-
103
- return result;
104
- }
105
-
106
- lookupAirportByIata(iata: string) : any {
107
- const airportsArray : Array<any> = []; // = this.store.state.acarsData.airports;
108
- // console.log(airportsArray);
109
- const airport = airportsArray.filter((e: any) => e.iata === iata);
110
-
111
- return airport;
112
- }
113
- }
114
-
115
- export default {
116
- MessageDecoder,
117
- };
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { MessageDecoder } from '../MessageDecoder';
4
-
5
- function debugMessage(message: any, decoding: any) {
6
- console.log("ORIGINAL MESSAGE");
7
- console.log("Label:", message.label);
8
- console.log("Text:", message.text);
9
- console.log();
10
- console.log("Decoded Message:");
11
- console.log(decoding.formatted.description);
12
- if (decoding.formatted.items && decoding.formatted.items.length > 0) {
13
- decoding.formatted.items.forEach((item: any) => {
14
- console.log(`${item.label} - ${item.value}`);
15
- });
16
- }
17
- console.log();
18
- }
19
-
20
- function decode(label: string, text: string) {
21
- const message = {
22
- label: label,
23
- text: text
24
- };
25
- const decoder = new MessageDecoder();
26
- const decoding = decoder.decode(message);
27
- debugMessage(message, decoding);
28
- }
29
-
30
- // Label 16 with N space
31
- decode('16', 'N 44.203,W 86.546,31965,6, 290');
32
- decode('16', 'N 42.777,W 85.477,35004,6, 132');
33
- decode('16', 'N 28.177/W 96.055');
34
- decode('16', 'N 44.640/W119.729');
35
-
36
- // Label 30 with slash EA
37
- decode('30', '/EA1830/DSKSFO/SK24');
38
- decode('30', '/EA1611/DSMMSD/SK24');
39
- decode('30', '/EA1719/DSKSFO/SK23');
40
-
41
- // Label 5Z
42
- decode('5Z', '/R3 SNAORD 2205-14 SNA');
43
-
44
- // Label 80 + 3N01 POSRPT
45
- decode(
46
- '80',
47
- "3N01 POSRPT 0570/13 MSLP/KJFK .N603AV/04F 00:59\n\
48
- /NWYP ORF /HDG 074/MCH 779\n\
49
- /POS N3630.7W07701.8/FL 350/TAS 453/SAT -054\n\
50
- /SWND 079/DWND 216/FOB N006857/ETA 01:40.3"
51
- );
52
-
53
- // Label H1 + M1BPOS
54
- decode(
55
- 'H1',
56
- '#M1BPOSN32492W117178,N33492W118335,195835,350,N32463W117143,195907,N32359W117014,M51,25872,249/TS195835,1214195C27'
57
- );
58
-
59
- // Label 8E
60
- decode("8E", "EGSS,1618");
61
-
62
- // Label 1M with slash
63
- decode("1M", `/BA0843/ETA01/230822/LDSP/EGLL/EGSS/2JK0
64
- 1940/EGLL27L/10 `);
65
- decode("1M", `/AY1416/ETA02/230822/EDDF/EFHK/EETN/2JK0
66
- 1956/EFHK04L/50
67
- / / / / / /`);
@@ -1,23 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { MessageDecoder } from '../MessageDecoder';
4
-
5
- const decoder = new MessageDecoder();
6
- const message = {
7
- label: process.argv[2],
8
- text: process.argv[3]
9
- };
10
-
11
- console.log("Original Message:");
12
- console.log(message.text);
13
- console.log();
14
-
15
- const result = decoder.decode(message, { debug: true });
16
-
17
- console.log("Decoded Message:");
18
- console.log(result.formatted.description);
19
- if (result.formatted.items && result.formatted.items.length > 0) {
20
- result.formatted.items.forEach((item: any) => {
21
- console.log(`${item.label} - ${item.value}`);
22
- });
23
- }
package/src/index.d.ts DELETED
@@ -1,15 +0,0 @@
1
-
2
- interface DecoderPlugin {
3
- decode: (data: string) => string;
4
- coordinateString: (coords: any) => string;
5
- }
6
-
7
- interface MessageDecoder {
8
- constructor(): MessageDecoder;
9
- registerPlugin(plugin: DecoderPlugin): boolean;
10
- decode: (data: string, options: any) => string;
11
- lookupAirportByIata: (iata: string) => string;
12
- name: string;
13
- plugins: Array<DecoderPlugin>;
14
- debug: boolean;
15
- }
package/src/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './DateTimeUtils';
2
- export * from './DecoderPlugin';
3
- export * from './IcaoDecoder';
4
- export * from './MessageDecoder';
@@ -1,45 +0,0 @@
1
- import { DecoderPlugin } from '../DecoderPlugin';
2
-
3
- // General Aviation Position Report
4
- export class Label_15 extends DecoderPlugin {
5
- name = 'label-5z';
6
-
7
- qualifiers() { // eslint-disable-line class-methods-use-this
8
- return {
9
- labels: ['15'],
10
- preambles: ['(2'],
11
- };
12
- }
13
-
14
- decode(message: any, options: any = {}) : any {
15
- const decodeResult: any = this.defaultResult;
16
- decodeResult.decoder.name = this.name;
17
- decodeResult.formatted.description = 'Position Report';
18
-
19
- const twoZeeRegex = /^\(2(?<between>.+)\(Z$/;
20
- const results = message.text.match(twoZeeRegex);
21
- if (results) {
22
- // Style: (2N38111W 82211266 76400-64(Z
23
- // console.log(`Label 15 Position Report: between = ${results.groups.between}`);
24
-
25
- decodeResult.raw.latitude_direction = results.groups.between.substr(0, 1);
26
- decodeResult.raw.latitude = Number(results.groups.between.substr(1, 5)) / 1000;
27
- decodeResult.raw.longitude_direction = results.groups.between.substr(6, 1);
28
- decodeResult.raw.longitude = Number(results.groups.between.substr(7, 6)) / 1000;
29
- decodeResult.remaining.text = results.groups.between.substr(13);
30
-
31
- decodeResult.formatted.items.push({
32
- type: 'coordinates',
33
- label: 'Coordinates',
34
- value: `${decodeResult.raw.latitude} ${decodeResult.raw.latitude_direction}, ${decodeResult.raw.longitude} ${decodeResult.raw.longitude_direction}`,
35
- });
36
- }
37
-
38
- decodeResult.decoded = true;
39
- decodeResult.decoder.decodeLevel = 'partial';
40
-
41
- return decodeResult;
42
- }
43
- }
44
-
45
- export default {};
@@ -1,94 +0,0 @@
1
- import { MessageDecoder } from '../MessageDecoder';
2
- import { Label_16_N_Space } from './Label_16_N_Space';
3
-
4
- test('decodes Label 16 variant 1', () => {
5
- const decoder = new MessageDecoder();
6
- const decoderPlugin = new Label_16_N_Space(decoder);
7
-
8
- expect(decoderPlugin.decode).toBeDefined();
9
- expect(decoderPlugin.name).toBe('label-16-n-space');
10
- expect(decoderPlugin.qualifiers).toBeDefined();
11
- expect(decoderPlugin.qualifiers()).toEqual({
12
- labels: ['16'],
13
- preambles: ['N '],
14
- });
15
-
16
- const text = 'N 44.203,W 86.546,31965,6, 290';
17
- const decodeResult = decoderPlugin.decode({ text: text });
18
- console.log(JSON.stringify(decodeResult, null, 2));
19
-
20
- expect(decodeResult.decoded).toBe(true);
21
- expect(decodeResult.decoder.decodeLevel).toBe('partial');
22
- expect(decodeResult.decoder.name).toBe('label-16-n-space');
23
- expect(decodeResult.formatted.description).toBe('Position Report');
24
- expect(decodeResult.message.text).toBe(text);
25
- expect(decodeResult.raw.latitude_direction).toBe('N');
26
- expect(decodeResult.raw.latitude).toBe(44.203);
27
- expect(decodeResult.raw.longitude_direction).toBe('W');
28
- expect(decodeResult.raw.longitude).toBe(86.546);
29
- expect(decodeResult.raw.flight_level).toBe(31965);
30
- expect(decodeResult.formatted.items.length).toBe(2);
31
- expect(decodeResult.formatted.items[0].type).toBe('aircraft_position');
32
- expect(decodeResult.formatted.items[0].code).toBe('POS');
33
- expect(decodeResult.formatted.items[0].label).toBe('Aircraft Position');
34
- expect(decodeResult.formatted.items[0].value).toBe('44.203 N, 86.546 W');
35
- expect(decodeResult.formatted.items[1].type).toBe('flight_level');
36
- expect(decodeResult.formatted.items[1].code).toBe('FL');
37
- expect(decodeResult.formatted.items[1].label).toBe('Flight Level');
38
- expect(decodeResult.formatted.items[1].value).toBe(31965);
39
- });
40
-
41
- test('decodes Label 16 variant 2', () => {
42
- const decoder = new MessageDecoder();
43
- const decoderPlugin = new Label_16_N_Space(decoder);
44
-
45
- expect(decoderPlugin.decode).toBeDefined();
46
- expect(decoderPlugin.name).toBe('label-16-n-space');
47
- expect(decoderPlugin.qualifiers).toBeDefined();
48
- expect(decoderPlugin.qualifiers()).toEqual({
49
- labels: ['16'],
50
- preambles: ['N '],
51
- });
52
-
53
- const text = 'N 28.177/W 96.055';
54
- const decodeResult = decoderPlugin.decode({ text: text });
55
- console.log(JSON.stringify(decodeResult, null, 2));
56
-
57
- expect(decodeResult.decoded).toBe(true);
58
- expect(decodeResult.decoder.decodeLevel).toBe('full');
59
- expect(decodeResult.decoder.name).toBe('label-16-n-space');
60
- expect(decodeResult.formatted.description).toBe('Position Report');
61
- expect(decodeResult.message.text).toBe(text);
62
- expect(decodeResult.raw.latitude_direction).toBe('N');
63
- expect(decodeResult.raw.latitude).toBe(28.177);
64
- expect(decodeResult.raw.longitude_direction).toBe('W');
65
- expect(decodeResult.raw.longitude).toBe(96.055);
66
- expect(decodeResult.formatted.items.length).toBe(1);
67
- expect(decodeResult.formatted.items[0].type).toBe('aircraft_position');
68
- expect(decodeResult.formatted.items[0].code).toBe('POS');
69
- expect(decodeResult.formatted.items[0].label).toBe('Aircraft Position');
70
- expect(decodeResult.formatted.items[0].value).toBe('28.177 N, 96.055 W');
71
- });
72
-
73
- test('decodes Label 16 variant <invalid>', () => {
74
- const decoder = new MessageDecoder();
75
- const decoderPlugin = new Label_16_N_Space(decoder);
76
-
77
- expect(decoderPlugin.decode).toBeDefined();
78
- expect(decoderPlugin.name).toBe('label-16-n-space');
79
- expect(decoderPlugin.qualifiers).toBeDefined();
80
- expect(decoderPlugin.qualifiers()).toEqual({
81
- labels: ['16'],
82
- preambles: ['N '],
83
- });
84
-
85
- const text = 'N Bogus message';
86
- const decodeResult = decoderPlugin.decode({ text: text });
87
- console.log(JSON.stringify(decodeResult, null, 2));
88
-
89
- expect(decodeResult.decoded).toBe(false);
90
- expect(decodeResult.decoder.decodeLevel).toBe('none');
91
- expect(decodeResult.decoder.name).toBe('label-16-n-space');
92
- expect(decodeResult.formatted.description).toBe('Position Report');
93
- expect(decodeResult.message.text).toBe(text);
94
- });