Skip to content

Commit

Permalink
Adding /ET parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
makrsmark committed Oct 30, 2024
1 parent d2ae4d2 commit 3e07a1f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 36 deletions.
78 changes: 42 additions & 36 deletions lib/plugins/Label_H1_POS.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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 <invalid>', () => {
Expand Down
10 changes: 10 additions & 0 deletions lib/utils/h1_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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], '/');
}
Expand Down

0 comments on commit 3e07a1f

Please sign in to comment.