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