From 3e07a1f841f51fc61f301d1b43ed5b090ed04de9 Mon Sep 17 00:00:00 2001 From: Mark Bumiller Date: Tue, 29 Oct 2024 20:45:34 -0400 Subject: [PATCH] Adding /ET parsing --- lib/plugins/Label_H1_POS.test.ts | 78 +++++++++++++++++--------------- lib/utils/h1_helper.ts | 10 ++++ 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/lib/plugins/Label_H1_POS.test.ts b/lib/plugins/Label_H1_POS.test.ts index fc5d6e4..828e378 100644 --- a/lib/plugins/Label_H1_POS.test.ts +++ b/lib/plugins/Label_H1_POS.test.ts @@ -288,20 +288,22 @@ describe('Label_H1 POS', () => { expect(decodeResult.raw.message_timestamp).toBe(1709476093); expect(decodeResult.raw.flight_number).toBe('BANKR31'); expect(decodeResult.raw.mission_number).toBe(''); - expect(decodeResult.formatted.items.length).toBe(6); + expect(decodeResult.formatted.items.length).toBe(7); expect(decodeResult.formatted.items[0].label).toBe('Tail'); expect(decodeResult.formatted.items[0].value).toBe('91459S'); - expect(decodeResult.formatted.items[1].label).toBe('Aircraft Position'); - expect(decodeResult.formatted.items[1].value).toBe('39.462 N, 77.598 W'); - expect(decodeResult.formatted.items[2].label).toBe('Aircraft Route'); - expect(decodeResult.formatted.items[2].value).toBe('(39.500 N, 77.183 W)@14:28:00 > (38.933 N, 77.250 W)@03:14:30 > ?'); - expect(decodeResult.formatted.items[3].label).toBe('Altitude'); - expect(decodeResult.formatted.items[3].value).toBe('24000 feet'); - expect(decodeResult.formatted.items[4].label).toBe('Outside Air Temperature (C)'); - expect(decodeResult.formatted.items[4].value).toBe('-28 degrees'); - expect(decodeResult.formatted.items[5].label).toBe('Message Checksum'); - expect(decodeResult.formatted.items[5].value).toBe('0x9071'); - expect(decodeResult.remaining.text).toBe('MR64,0/ET31539,27619,MT370/CG311,160,350/FB732/VR32'); + expect(decodeResult.formatted.items[1].label).toBe('Estimated Time of Arrival'); + expect(decodeResult.formatted.items[1].value).toBe('15:39:00'); + expect(decodeResult.formatted.items[2].label).toBe('Aircraft Position'); + expect(decodeResult.formatted.items[2].value).toBe('39.462 N, 77.598 W'); + expect(decodeResult.formatted.items[3].label).toBe('Aircraft Route'); + expect(decodeResult.formatted.items[3].value).toBe('(39.500 N, 77.183 W)@14:28:00 > (38.933 N, 77.250 W)@03:14:30 > ?'); + expect(decodeResult.formatted.items[4].label).toBe('Altitude'); + expect(decodeResult.formatted.items[4].value).toBe('24000 feet'); + expect(decodeResult.formatted.items[5].label).toBe('Outside Air Temperature (C)'); + expect(decodeResult.formatted.items[5].value).toBe('-28 degrees'); + expect(decodeResult.formatted.items[6].label).toBe('Message Checksum'); + expect(decodeResult.formatted.items[6].value).toBe('0x9071'); + expect(decodeResult.remaining.text).toBe('MR64,0,27619,MT370/CG311,160,350/FB732/VR32'); }); test('#variant 7', () => { @@ -316,20 +318,22 @@ describe('Label_H1 POS', () => { expect(decodeResult.raw.message_timestamp).toBe(1709487127); expect(decodeResult.raw.flight_number).toBe(''); expect(decodeResult.raw.mission_number).toBe(''); - expect(decodeResult.formatted.items.length).toBe(6); + expect(decodeResult.formatted.items.length).toBe(7); expect(decodeResult.formatted.items[0].label).toBe('Tail'); expect(decodeResult.formatted.items[0].value).toBe('746026'); - expect(decodeResult.formatted.items[1].label).toBe('Aircraft Position'); - expect(decodeResult.formatted.items[1].value).toBe('42.965 N, 108.150 W'); - expect(decodeResult.formatted.items[2].label).toBe('Aircraft Route'); - expect(decodeResult.formatted.items[2].value).toBe('WAIDE@17:32:07 > WEDAK@03:17:59 > ?'); - expect(decodeResult.formatted.items[3].label).toBe('Altitude'); - expect(decodeResult.formatted.items[3].value).toBe('32000 feet'); - expect(decodeResult.formatted.items[4].label).toBe('Outside Air Temperature (C)'); - expect(decodeResult.formatted.items[4].value).toBe('-49 degrees'); - expect(decodeResult.formatted.items[5].label).toBe('Message Checksum'); - expect(decodeResult.formatted.items[5].value).toBe('0x4e17'); - expect(decodeResult.remaining.text).toBe('F37#M1B/MR1,/ET031846,267070,T468/CG264,110,360/FB742/VR32'); + expect(decodeResult.formatted.items[1].label).toBe('Estimated Time of Arrival'); + expect(decodeResult.formatted.items[1].value).toBe('18:46:00'); + expect(decodeResult.formatted.items[2].label).toBe('Aircraft Position'); + expect(decodeResult.formatted.items[2].value).toBe('42.965 N, 108.150 W'); + expect(decodeResult.formatted.items[3].label).toBe('Aircraft Route'); + expect(decodeResult.formatted.items[3].value).toBe('WAIDE@17:32:07 > WEDAK@03:17:59 > ?'); + expect(decodeResult.formatted.items[4].label).toBe('Altitude'); + expect(decodeResult.formatted.items[4].value).toBe('32000 feet'); + expect(decodeResult.formatted.items[5].label).toBe('Outside Air Temperature (C)'); + expect(decodeResult.formatted.items[5].value).toBe('-49 degrees'); + expect(decodeResult.formatted.items[6].label).toBe('Message Checksum'); + expect(decodeResult.formatted.items[6].value).toBe('0x4e17'); + expect(decodeResult.remaining.text).toBe('F37#M1B/MR1,,267070,T468/CG264,110,360/FB742/VR32'); }); test('variant 8', () => { @@ -490,20 +494,22 @@ describe('Label_H1 POS', () => { expect(decodeResult.raw.message_timestamp).toBe(1725804426); expect(decodeResult.raw.flight_number).toBe('WIDE21'); expect(decodeResult.raw.mission_number).toBe('7PZWTCP21222'); - expect(decodeResult.formatted.items.length).toBe(6); + expect(decodeResult.formatted.items.length).toBe(7); expect(decodeResult.formatted.items[0].label).toBe('Tail'); expect(decodeResult.formatted.items[0].value).toBe('91517S'); - expect(decodeResult.formatted.items[1].label).toBe('Aircraft Position'); - expect(decodeResult.formatted.items[1].value).toBe('37.625 N, 77.613 W'); - expect(decodeResult.formatted.items[2].label).toBe('Aircraft Route'); - expect(decodeResult.formatted.items[2].value).toBe('JAXSN@14:07:00 > LOOEY@09:14:17 > ?'); - expect(decodeResult.formatted.items[3].label).toBe('Altitude'); - expect(decodeResult.formatted.items[3].value).toBe('30000 feet'); - expect(decodeResult.formatted.items[4].label).toBe('Outside Air Temperature (C)'); - expect(decodeResult.formatted.items[4].value).toBe('-26 degrees'); - expect(decodeResult.formatted.items[5].label).toBe('Message Checksum'); - expect(decodeResult.formatted.items[5].value).toBe('0xc696'); - expect(decodeResult.remaining.text).toBe('MR238,2/ET91456,21329,M080T490/CG293,160,350/FB583/VR32'); + expect(decodeResult.formatted.items[1].label).toBe('Estimated Time of Arrival'); + expect(decodeResult.formatted.items[1].value).toBe('14:56:00'); + expect(decodeResult.formatted.items[2].label).toBe('Aircraft Position'); + expect(decodeResult.formatted.items[2].value).toBe('37.625 N, 77.613 W'); + expect(decodeResult.formatted.items[3].label).toBe('Aircraft Route'); + expect(decodeResult.formatted.items[3].value).toBe('JAXSN@14:07:00 > LOOEY@09:14:17 > ?'); + expect(decodeResult.formatted.items[4].label).toBe('Altitude'); + expect(decodeResult.formatted.items[4].value).toBe('30000 feet'); + expect(decodeResult.formatted.items[5].label).toBe('Outside Air Temperature (C)'); + expect(decodeResult.formatted.items[5].value).toBe('-26 degrees'); + expect(decodeResult.formatted.items[6].label).toBe('Message Checksum'); + expect(decodeResult.formatted.items[6].value).toBe('0xc696'); + expect(decodeResult.remaining.text).toBe('MR238,2,21329,M080T490/CG293,160,350/FB583/VR32'); }); test('decodes Label H1 Preamble #M1BPOS ', () => { diff --git a/lib/utils/h1_helper.ts b/lib/utils/h1_helper.ts index 5ac0be9..27b83a6 100644 --- a/lib/utils/h1_helper.ts +++ b/lib/utils/h1_helper.ts @@ -53,6 +53,16 @@ export class H1Helper { processTimeOfDeparture(decodeResult, fields[i].substring(2).split(',')); // Strip off TD } else if (fields[i].startsWith('FX')) { ResultFormatter.freetext(decodeResult, fields[i].substring(2)); + } else if (fields[i].startsWith('ET')) { + if(fields[i].length === 7) { // 1 digit day + //ResultFormatter.dayOfMonth(decodeResult, Number(fields[i].substring(1, 3))); + ResultFormatter.eta(decodeResult, DateTimeUtils.convertHHMMSSToTod(fields[i].substring(3)+'00')); + } else if(fields[i].length === 8) { // 2 digit day + //ResultFormatter.dayOfMonth(decodeResult, Number(fields[i].substring(2, 4))); + ResultFormatter.eta(decodeResult, DateTimeUtils.convertHHMMSSToTod(fields[i].substring(4)+'00')); + } else { + ResultFormatter.unknown(decodeResult, fields[i], '/'); + } } else { ResultFormatter.unknown(decodeResult, fields[i], '/'); }