@airframes/acars-decoder 1.2.1 → 1.3.2

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 (71) hide show
  1. package/README.md +6 -0
  2. package/babel.config.js +6 -0
  3. package/coverage/clover.xml +1722 -0
  4. package/coverage/coverage-final.json +23 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +131 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +196 -0
  13. package/coverage/lcov.info +2177 -0
  14. package/dist/DecoderPlugin.d.ts +16 -0
  15. package/dist/DecoderPlugin.js +66 -0
  16. package/dist/DecoderPluginInterface.d.ts +7 -0
  17. package/dist/DecoderPluginInterface.js +3 -0
  18. package/dist/IcaoDecoder.d.ts +8 -0
  19. package/dist/IcaoDecoder.js +106 -0
  20. package/dist/MessageDecoder.d.ts +12 -0
  21. package/dist/MessageDecoder.js +97 -0
  22. package/dist/bin/acars-decoder-test.d.ts +2 -0
  23. package/dist/bin/acars-decoder-test.js +38 -0
  24. package/dist/bin/acars-decoder.d.ts +2 -0
  25. package/dist/bin/acars-decoder.js +20 -0
  26. package/dist/plugins/Label_15.d.ts +11 -0
  27. package/dist/plugins/Label_15.js +42 -0
  28. package/dist/plugins/Label_20_CFB.01.d.ts +11 -0
  29. package/dist/plugins/Label_20_CFB.01.js +71 -0
  30. package/dist/plugins/Label_20_POS.d.ts +11 -0
  31. package/dist/plugins/Label_20_POS.js +64 -0
  32. package/dist/plugins/Label_44_ETA.d.ts +11 -0
  33. package/dist/plugins/Label_44_ETA.js +71 -0
  34. package/dist/plugins/Label_44_IN.d.ts +11 -0
  35. package/dist/plugins/Label_44_IN.js +71 -0
  36. package/dist/plugins/Label_44_OFF.d.ts +11 -0
  37. package/dist/plugins/Label_44_OFF.js +76 -0
  38. package/dist/plugins/Label_44_ON.d.ts +11 -0
  39. package/dist/plugins/Label_44_ON.js +71 -0
  40. package/dist/plugins/Label_44_POS.d.ts +11 -0
  41. package/dist/plugins/Label_44_POS.js +83 -0
  42. package/dist/plugins/Label_5Z.d.ts +11 -0
  43. package/dist/plugins/Label_5Z.js +122 -0
  44. package/dist/plugins/Label_80.d.ts +12 -0
  45. package/dist/plugins/Label_80.js +205 -0
  46. package/dist/plugins/Label_8E.d.ts +10 -0
  47. package/dist/plugins/Label_8E.js +57 -0
  48. package/dist/plugins/Label_B6.d.ts +11 -0
  49. package/dist/plugins/Label_B6.js +28 -0
  50. package/dist/plugins/Label_ColonComma.d.ts +10 -0
  51. package/dist/plugins/Label_ColonComma.js +30 -0
  52. package/dist/plugins/Label_H1.d.ts +9 -0
  53. package/dist/plugins/Label_H1.js +17 -0
  54. package/dist/plugins/Label_H1_M1BPOS.d.ts +11 -0
  55. package/dist/plugins/Label_H1_M1BPOS.js +56 -0
  56. package/dist/plugins/Label_H1_M1BPRG.d.ts +11 -0
  57. package/dist/plugins/Label_H1_M1BPRG.js +38 -0
  58. package/dist/plugins/Label_QP.d.ts +10 -0
  59. package/dist/plugins/Label_QP.js +51 -0
  60. package/dist/plugins/Label_QQ.d.ts +10 -0
  61. package/dist/plugins/Label_QQ.js +51 -0
  62. package/dist/plugins/Label_QR.d.ts +10 -0
  63. package/dist/plugins/Label_QR.js +51 -0
  64. package/dist/plugins/Label_QS.d.ts +10 -0
  65. package/dist/plugins/Label_QS.js +51 -0
  66. package/dist/plugins/Label_SQ.d.ts +10 -0
  67. package/dist/plugins/Label_SQ.js +106 -0
  68. package/dist/plugins/official.d.ts +19 -0
  69. package/dist/plugins/official.js +24 -0
  70. package/jest.config.ts +195 -0
  71. package/package.json +12 -4
@@ -0,0 +1,16 @@
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
+ export default _default;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class DecoderPlugin {
4
+ constructor(decoder, options = {}) {
5
+ this.name = 'unknown';
6
+ this.defaultResult = {
7
+ decoded: false,
8
+ decoder: {
9
+ name: 'unknown',
10
+ type: 'pattern-match',
11
+ decodeLevel: 'none',
12
+ },
13
+ formatted: {
14
+ description: 'Unknown',
15
+ items: [],
16
+ },
17
+ raw: {},
18
+ remaining: {},
19
+ };
20
+ this.decoder = decoder;
21
+ this.options = options;
22
+ }
23
+ id() {
24
+ console.log('DecoderPlugin subclass has not overriden id() to provide a unique ID for this plugin!');
25
+ return 'abstract_decoder_plugin';
26
+ }
27
+ meetsStateRequirements() {
28
+ return true;
29
+ }
30
+ // onRegister(store: Store<any>) {
31
+ // this.store = store;
32
+ // }
33
+ qualifiers() {
34
+ const labels = [];
35
+ return {
36
+ labels,
37
+ };
38
+ }
39
+ decode(message) {
40
+ const decodeResult = this.defaultResult;
41
+ decodeResult.remaining.text = message.text;
42
+ return decodeResult;
43
+ }
44
+ // Utilities
45
+ // TODO: Move these to a utilities class and instanciate here for use in subclasses
46
+ decodeStringCoordinates(stringCoords) {
47
+ var results = {};
48
+ const firstChar = stringCoords.substring(0, 1);
49
+ if (firstChar == 'N' || firstChar == 'S') {
50
+ // format: N12345W123456
51
+ results.latitudeDirection = stringCoords.substring(0, 1);
52
+ results.latitude = (Number(stringCoords.substring(1, 6)) / 1000) * (results.latitudeDirection === 'S' ? -1 : 1);
53
+ results.longitudeDirection = stringCoords.substring(6, 7);
54
+ results.longitude = (Number(stringCoords.substring(7, 13)) / 1000) * (results.longitudeDirection === 'W' ? -1 : 1);
55
+ }
56
+ else {
57
+ console.log(`DEBUG: decodeStringCoordinates: Failure to decode String-based coordinates: ${stringCoords}`);
58
+ }
59
+ return results;
60
+ }
61
+ coordinateString(coords) {
62
+ return `${Math.abs(coords.latitude)} ${coords.latitudeDirection}, ${Math.abs(coords.longitude)} ${coords.longitudeDirection}`;
63
+ }
64
+ }
65
+ exports.DecoderPlugin = DecoderPlugin;
66
+ exports.default = {};
@@ -0,0 +1,7 @@
1
+ export interface DecoderPluginInterface {
2
+ decode(message: any): any;
3
+ meetsStateRequirements(): boolean;
4
+ qualifiers(): any;
5
+ }
6
+ declare const _default: {};
7
+ export default _default;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = {};
@@ -0,0 +1,8 @@
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
+ export default _default;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class IcaoDecoder {
4
+ constructor(icao) {
5
+ this.name = 'icao-decoder-typescript';
6
+ this.icao = icao;
7
+ }
8
+ isMilitary() {
9
+ let i = this.icao;
10
+ return (false
11
+ // us military
12
+ //adf7c8-adf7cf = united states mil_5(uf)
13
+ //adf7d0-adf7df = united states mil_4(uf)
14
+ //adf7e0-adf7ff = united states mil_3(uf)
15
+ //adf800-adffff = united states mil_2(uf)
16
+ || i.match(/^adf[7-9]/)
17
+ || i.match(/^adf[a-f]/)
18
+ //ae0000-afffff = united states mil_1(uf)
19
+ || i.match(/^a(e|f)/)
20
+ //010070-01008f = egypt_mil
21
+ || i.match(/^0100(7|8)/)
22
+ //0a4000-0a4fff = algeria mil(ap)
23
+ || i.match(/^0a4/)
24
+ //33ff00-33ffff = italy mil(iy)
25
+ || i.match(/^33ff/)
26
+ //350000-37ffff = spain mil(sp)
27
+ || (i >= '350000' && i <= '37ffff')
28
+ //3a8000-3affff = france mil_1(fs)
29
+ || i.match(/^3a(8|9|[a-f])/)
30
+ //3b0000-3bffff = france mil_2(fs)
31
+ || i.match(/^3b/)
32
+ //3e8000-3ebfff = germany mil_1(df)
33
+ // remove 8 and 9 from mil arnge
34
+ || i.match(/^3e(a|b)/)
35
+ //3f4000-3f7fff = germany mil_2(df)
36
+ //3f8000-3fbfff = germany mil_3(df)
37
+ || i.match(/^3f([4-9]|[a-b])/)
38
+ //400000-40003f = united kingdom mil_1(ra)
39
+ || i.match(/^4000[0-3]/)
40
+ //43c000-43cfff = united kingdom mil(ra)
41
+ || i.match(/^43c/)
42
+ //444000-447fff = austria mil(aq)
43
+ || (i.match(/^44[4-7]/) && i != '447ac7')
44
+ //44f000-44ffff = belgium mil(bc)
45
+ || i.match(/^44f/)
46
+ //457000-457fff = bulgaria mil(bu)
47
+ || i.match(/^457/)
48
+ //45f400-45f4ff = denmark mil(dg)
49
+ || i.match(/^45f4/)
50
+ //468000-4683ff = greece mil(gc)
51
+ || i.match(/^468[0-3]/)
52
+ //473c00-473c0f = hungary mil(hm)
53
+ || i.match(/^473c0/)
54
+ //478100-4781ff = norway mil(nn)
55
+ || i.match(/^4781/)
56
+ //480000-480fff = netherlands mil(nm)
57
+ || i.match(/^480/)
58
+ //48d800-48d87f = poland mil(po)
59
+ || i.match(/^48d8[0-7]/)
60
+ //497c00-497cff = portugal mil(pu)
61
+ || i.match(/^497c/)
62
+ //498420-49842f = czech republic mil(ct)
63
+ || i.match(/^49842/)
64
+ //4b7000-4b7fff = switzerland mil(su)
65
+ || i.match(/^4b7/)
66
+ //4b8200-4b82ff = turkey mil(tq)
67
+ || i.match(/^4b82/)
68
+ //506f00-506fff = slovenia mil(sj)
69
+ || i.match(/^506f/)
70
+ //70c070-70c07f = oman mil(on)
71
+ || i.match(/^70c07/)
72
+ //710258-71025f = saudi arabia mil_1(sx)
73
+ //710260-71027f = saudi arabia mil_2(sx)
74
+ //710280-71028f = saudi arabia mil_3(sx)
75
+ //710380-71039f = saudi arabia mil_4(sx)
76
+ || i.match(/^7102[5-8]/)
77
+ || i.match(/^7103[8-9]/)
78
+ //738a00-738aff = israel mil(iz)
79
+ || i.match(/^738a/)
80
+ //7c822e-7c822f = australia mil_1(av)
81
+ //7c8230-7c823f = australia mil_2(av)
82
+ //7c8240-7c827f = australia mil_3(av)
83
+ //7c8280-7c82ff = australia mil_4(av)
84
+ //7c8300-7c83ff = australia mil_5(av)
85
+ //7c8400-7c87ff = australia mil_6(av)
86
+ //7c8800-7c8fff = australia mil_7(av)
87
+ || i.match(/^7c8([2-4]|8)/)
88
+ //7c9000-7c9fff = australia mil_8(av)
89
+ //7ca000-7cbfff = australia mil_9(av)
90
+ || (i >= '7c9000' && i <= '7cbfff')
91
+ //7cc000-7cffff = australia mil_10(av) 7cc409 not mil, remove this range
92
+ //7d0000-7dffff = australia mil_11(av)
93
+ //7e0000-7fffff = australia mil_12(av)
94
+ || i.match(/^7[d-f]/)
95
+ //800200-8002ff = india mil(im)
96
+ || i.match(/^8002/)
97
+ //c20000-c3ffff = canada mil(cb)
98
+ || i.match(/^c[2-3]/)
99
+ //e40000-e41fff = brazil mil(bq)
100
+ || i.match(/^e4[0-1]/)
101
+ //e80600-e806ff = chile mil(cq)
102
+ || i.match(/^e806/));
103
+ }
104
+ }
105
+ exports.IcaoDecoder = IcaoDecoder;
106
+ exports.default = {};
@@ -0,0 +1,12 @@
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
+ export default _default;
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const Plugins = require("./plugins/official");
4
+ class MessageDecoder {
5
+ constructor() {
6
+ this.name = 'acars-decoder-typescript';
7
+ this.plugins = [];
8
+ this.debug = false;
9
+ this.registerPlugin(new Plugins.Label_ColonComma(this));
10
+ this.registerPlugin(new Plugins.Label_5Z(this));
11
+ this.registerPlugin(new Plugins.Label_15(this));
12
+ this.registerPlugin(new Plugins.Label_20_POS(this));
13
+ this.registerPlugin(new Plugins.Label_44_ETA(this));
14
+ this.registerPlugin(new Plugins.Label_44_IN(this));
15
+ this.registerPlugin(new Plugins.Label_44_OFF(this));
16
+ this.registerPlugin(new Plugins.Label_44_ON(this));
17
+ this.registerPlugin(new Plugins.Label_44_POS(this));
18
+ this.registerPlugin(new Plugins.Label_B6_Forwardslash(this));
19
+ this.registerPlugin(new Plugins.Label_H1_M1BPOS(this));
20
+ this.registerPlugin(new Plugins.Label_80(this));
21
+ this.registerPlugin(new Plugins.Label_8E(this));
22
+ this.registerPlugin(new Plugins.Label_SQ(this));
23
+ this.registerPlugin(new Plugins.Label_QP(this));
24
+ this.registerPlugin(new Plugins.Label_QQ(this));
25
+ this.registerPlugin(new Plugins.Label_QR(this));
26
+ this.registerPlugin(new Plugins.Label_QS(this));
27
+ }
28
+ registerPlugin(plugin) {
29
+ const pluginInstance = plugin;
30
+ // plugin.onRegister(this.store);
31
+ this.plugins.push(plugin);
32
+ return true;
33
+ }
34
+ decode(message, options = {}) {
35
+ // console.log('All plugins');
36
+ // console.log(this.plugins);
37
+ const usablePlugins = this.plugins.filter((plugin) => {
38
+ const qualifiers = plugin.qualifiers();
39
+ if (qualifiers.labels.includes(message.label)) {
40
+ if (qualifiers.preambles && qualifiers.preambles.length > 0) {
41
+ const matching = qualifiers.preambles.filter((preamble) => {
42
+ // console.log(message.text.substring(0, preamble.length));
43
+ // console.log(preamble);
44
+ return message.text.substring(0, preamble.length) === preamble;
45
+ });
46
+ // console.log(matching);
47
+ return matching.length >= 1;
48
+ }
49
+ else { // eslint-disable-line no-else-return
50
+ return true;
51
+ }
52
+ }
53
+ return false;
54
+ });
55
+ if (options.debug) {
56
+ console.log('Usable plugins');
57
+ console.log(usablePlugins);
58
+ }
59
+ let result;
60
+ if (usablePlugins.length > 0) {
61
+ const plugin = usablePlugins[0];
62
+ result = plugin.decode(message);
63
+ }
64
+ else {
65
+ result = {
66
+ decoded: false,
67
+ decodeLevel: 'none',
68
+ error: 'No known decoder plugin for this message',
69
+ message: message,
70
+ remaining: {
71
+ text: message.text,
72
+ },
73
+ raw: {},
74
+ formatted: {},
75
+ };
76
+ }
77
+ if (options.debug) {
78
+ let performDebug = true;
79
+ if (options.debug.only_decoded) {
80
+ performDebug = result.decoded;
81
+ }
82
+ if (performDebug) {
83
+ console.log('Result');
84
+ console.log(result);
85
+ }
86
+ }
87
+ return result;
88
+ }
89
+ lookupAirportByIata(iata) {
90
+ const airportsArray = []; // = this.store.state.acarsData.airports;
91
+ // console.log(airportsArray);
92
+ const airport = airportsArray.filter((e) => e.iata === iata);
93
+ return airport;
94
+ }
95
+ }
96
+ exports.MessageDecoder = MessageDecoder;
97
+ exports.default = {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,38 @@
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 5Z
29
+ decode('5Z', '/R3 SNAORD 2205-14 SNA');
30
+ // Label 80 + 3N01 POSRPT
31
+ decode('80', "3N01 POSRPT 0570/13 MSLP/KJFK .N603AV/04F 00:59\n\
32
+ /NWYP ORF /HDG 074/MCH 779\n\
33
+ /POS N3630.7W07701.8/FL 350/TAS 453/SAT -054\n\
34
+ /SWND 079/DWND 216/FOB N006857/ETA 01:40.3");
35
+ // Label H1 + M1BPOS
36
+ decode('H1', '#M1BPOSN32492W117178,N33492W118335,195835,350,N32463W117143,195907,N32359W117014,M51,25872,249/TS195835,1214195C27');
37
+ // Label 8E
38
+ decode("8E", "EGSS,1618");
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,11 @@
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;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const DecoderPlugin_1 = require("../DecoderPlugin");
4
+ // General Aviation Position Report
5
+ class Label_15 extends DecoderPlugin_1.DecoderPlugin {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.name = 'label-5z';
9
+ }
10
+ qualifiers() {
11
+ return {
12
+ labels: ['15'],
13
+ preambles: ['(2'],
14
+ };
15
+ }
16
+ decode(message, options = {}) {
17
+ const decodeResult = this.defaultResult;
18
+ decodeResult.decoder.name = this.name;
19
+ decodeResult.formatted.description = 'Position Report';
20
+ const twoZeeRegex = /^\(2(?<between>.+)\(Z$/;
21
+ const results = message.text.match(twoZeeRegex);
22
+ if (results) {
23
+ // Style: (2N38111W 82211266 76400-64(Z
24
+ // console.log(`Label 15 Position Report: between = ${results.groups.between}`);
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
+ decodeResult.formatted.items.push({
31
+ type: 'coordinates',
32
+ label: 'Coordinates',
33
+ value: `${decodeResult.raw.latitude} ${decodeResult.raw.latitude_direction}, ${decodeResult.raw.longitude} ${decodeResult.raw.longitude_direction}`,
34
+ });
35
+ }
36
+ decodeResult.decoded = true;
37
+ decodeResult.decoder.decodeLevel = 'partial';
38
+ return decodeResult;
39
+ }
40
+ }
41
+ exports.Label_15 = Label_15;
42
+ exports.default = {};
@@ -0,0 +1,11 @@
1
+ import { DecoderPlugin } from '../DecoderPlugin';
2
+ export declare class Label_20_CFB01 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;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const DecoderPlugin_1 = require("../DecoderPlugin");
4
+ // In Air Report
5
+ class Label_20_CFB01 extends DecoderPlugin_1.DecoderPlugin {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.name = 'label-20-cfb01';
9
+ }
10
+ qualifiers() {
11
+ return {
12
+ labels: ['20'],
13
+ preambles: ['#CFB.01'],
14
+ };
15
+ }
16
+ decode(message, options = {}) {
17
+ const decodeResult = this.defaultResult;
18
+ decodeResult.decoder.name = this.name;
19
+ decodeResult.formatted.description = 'Crew Flight Bag Message';
20
+ decodeResult.message = message;
21
+ // Style: IN02,N38338W121179,KMHR,KPDX,0806,2355,005.1
22
+ // Match: IN02,coords,departure_icao,arrival_icao,current_date,current_time,fuel_in_tons
23
+ const regex = /^IN02,(?<unsplit_coords>.*),(?<departure_icao>.*),(?<arrival_icao>.*),(?<current_date>.*),(?<current_time>.*),(?<fuel_in_tons>.*)$/;
24
+ const results = message.text.match(regex);
25
+ if (results) {
26
+ if (options.debug) {
27
+ console.log(`Label 44 ETA Report: groups`);
28
+ console.log(results.groups);
29
+ }
30
+ const coordsRegex = /(?<lac>[NS])(?<la>.+)\s*(?<lnc>[EW])(?<ln>.+)/;
31
+ const coordsResults = results.groups.unsplit_coords.match(coordsRegex);
32
+ decodeResult.raw.latitude_direction = coordsResults.groups.lac;
33
+ decodeResult.raw.latitude = Number(coordsResults.groups.la) / 1000;
34
+ decodeResult.raw.longitude_direction = coordsResults.groups.lnc;
35
+ decodeResult.raw.longitude = Number(coordsResults.groups.ln) / 1000;
36
+ decodeResult.raw.departure_icao = results.groups.departure_icao;
37
+ decodeResult.raw.arrival_icao = results.groups.arrival_icao;
38
+ decodeResult.raw.current_time = Date.parse(new Date().getFullYear() + "-" +
39
+ results.groups.current_date.substr(0, 2) + "-" +
40
+ results.groups.current_date.substr(2, 2) + "T" +
41
+ results.groups.current_time.substr(0, 2) + ":" +
42
+ results.groups.current_time.substr(2, 2) + ":00Z");
43
+ if (results.groups.fuel_in_tons != '***' && results.groups.fuel_in_tons != '****') {
44
+ decodeResult.raw.fuel_in_tons = Number(results.groups.fuel_in_tons);
45
+ }
46
+ decodeResult.formatted.items.push({
47
+ type: 'aircraft_position',
48
+ code: 'POS',
49
+ label: 'Aircraft Position',
50
+ value: `${decodeResult.raw.latitude} ${decodeResult.raw.latitude_direction}, ${decodeResult.raw.longitude} ${decodeResult.raw.longitude_direction}`,
51
+ });
52
+ decodeResult.formatted.items.push({
53
+ type: 'origin',
54
+ code: 'ORG',
55
+ label: 'Origin',
56
+ value: decodeResult.raw.departure_icao,
57
+ });
58
+ decodeResult.formatted.items.push({
59
+ type: 'destination',
60
+ code: 'DST',
61
+ label: 'Destination',
62
+ value: decodeResult.raw.arrival_icao,
63
+ });
64
+ }
65
+ decodeResult.decoded = true;
66
+ decodeResult.decoder.decodeLevel = 'full';
67
+ return decodeResult;
68
+ }
69
+ }
70
+ exports.Label_20_CFB01 = Label_20_CFB01;
71
+ exports.default = {};
@@ -0,0 +1,11 @@
1
+ import { DecoderPlugin } from '../DecoderPlugin';
2
+ export declare class Label_20_POS 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;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const DecoderPlugin_1 = require("../DecoderPlugin");
4
+ // Position Report
5
+ class Label_20_POS extends DecoderPlugin_1.DecoderPlugin {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.name = 'label-20-pos';
9
+ }
10
+ qualifiers() {
11
+ return {
12
+ labels: ['20'],
13
+ preambles: ['POS'],
14
+ };
15
+ }
16
+ decode(message, options = {}) {
17
+ const decodeResult = this.defaultResult;
18
+ decodeResult.decoder.name = this.name;
19
+ decodeResult.formatted.description = 'Position Report';
20
+ decodeResult.message = message;
21
+ decodeResult.raw.preamble = message.text.substring(0, 3);
22
+ const content = message.text.substring(3);
23
+ console.log('Content: ' + content);
24
+ const fields = content.split(',');
25
+ console.log('Field Count: ' + fields.length);
26
+ if (fields.length == 11) {
27
+ // N38160W077075,,211733,360,OTT,212041,,N42,19689,40,544
28
+ console.log(`DEBUG: ${this.name}: Variation 1 detected`);
29
+ // Field 1: Coordinates
30
+ const rawCoords = fields[0];
31
+ decodeResult.raw.position = this.decodeStringCoordinates(rawCoords);
32
+ decodeResult.formatted.items.push({
33
+ type: 'position',
34
+ label: 'Position',
35
+ value: this.coordinateString(decodeResult.raw.position),
36
+ });
37
+ decodeResult.decoded = true;
38
+ decodeResult.decoder.decodeLevel = 'full';
39
+ }
40
+ else if (fields.length == 5) {
41
+ // N38160W077075,,211733,360,OTT
42
+ console.log(`DEBUG: ${this.name}: Variation 2 detected`);
43
+ // Field 1: Coordinates
44
+ const rawCoords = fields[0];
45
+ decodeResult.raw.position = this.decodeStringCoordinates(rawCoords);
46
+ decodeResult.formatted.items.push({
47
+ type: 'position',
48
+ label: 'Position',
49
+ value: this.coordinateString(decodeResult.raw.position),
50
+ });
51
+ decodeResult.decoded = true;
52
+ decodeResult.decoder.decodeLevel = 'full';
53
+ }
54
+ else {
55
+ // Unknown!
56
+ console.log(`DEBUG: ${this.name}: Unknown variation. Field count: ${fields.length}, content: ${content}`);
57
+ decodeResult.decoded = false;
58
+ decodeResult.decoder.decodeLevel = 'none';
59
+ }
60
+ return decodeResult;
61
+ }
62
+ }
63
+ exports.Label_20_POS = Label_20_POS;
64
+ exports.default = {};
@@ -0,0 +1,11 @@
1
+ import { DecoderPlugin } from '../DecoderPlugin';
2
+ export declare class Label_44_ETA 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;