Skip to content

Commit

Permalink
adding support for H1 #M1FPN messages (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
makrsmark authored Feb 26, 2024
1 parent d1dee54 commit fc2c16b
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
68 changes: 67 additions & 1 deletion lib/plugins/Label_H1_FPN.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('Label H1 Preamble FPN decoder has right qualifiers', () => {
expect(decoderPlugin.qualifiers).toBeDefined();
expect(decoderPlugin.qualifiers()).toEqual({
labels: ['H1'],
preambles: ['FPN'],
preambles: ['FPN', '#M1BFPN'],
});
});

Expand Down Expand Up @@ -199,6 +199,72 @@ test('decodes Label H1 Preamble FPN with SN and TS', () => {
expect(decodeResult.formatted.items[5].value).toBe('0xf5e1');
});


test('decodes Label H1 Preamble #M1BFPN', () => {
const decoder = new MessageDecoder();
const decoderPlugin = new Label_H1_FPN(decoder);

// https://app.airframes.io/messages/2400593101
const text = '#M1BFPN/RI:DA:KJFK:AA:KPHX:CR:JFKPHX20..KG701..KG702..KP702..KP703..KD601..KD602..PUB..ALS.J102.GUP:A:EAGUL6.GUP:F:HOMRR90E1';
const decodeResult = decoderPlugin.decode({ text: text });
console.log(JSON.stringify(decodeResult, null, 2));

expect(decodeResult.decoded).toBe(true);
expect(decodeResult.decoder.decodeLevel).toBe('full');
expect(decodeResult.decoder.name).toBe('label-h1-fpn');
expect(decodeResult.formatted.description).toBe('Flight Plan');
expect(decodeResult.formatted.items.length).toBe(7);
expect(decodeResult.formatted.items[0].label).toBe('Route Status');
expect(decodeResult.formatted.items[0].value).toBe('Route Inactive');
expect(decodeResult.formatted.items[1].label).toBe('Origin');
expect(decodeResult.formatted.items[1].value).toBe('KJFK');
expect(decodeResult.formatted.items[2].label).toBe('Destination');
expect(decodeResult.formatted.items[2].value).toBe('KPHX');
expect(decodeResult.formatted.items[3].label).toBe('Company Route');
expect(decodeResult.formatted.items[3].value).toBe('JFKPHX20: >> KG701 >> KG702 >> KP702 >> KP703 >> KD601 >> KD602 >> PUB >> ALS > J102 > GUP');
expect(decodeResult.formatted.items[4].label).toBe('Arrival Procedure');
expect(decodeResult.formatted.items[4].value).toBe('EAGUL6 starting at GUP');
expect(decodeResult.formatted.items[5].label).toBe('Aircraft Route');
expect(decodeResult.formatted.items[5].value).toBe('HOMRR');
expect(decodeResult.formatted.items[6].label).toBe('Message Checksum');
expect(decodeResult.formatted.items[6].value).toBe('0x90e1');
});


// Does not match the preamble
// This might move to a different parser, but while we're here...
test('decodes Label H1 #M1BFPN No Preamble', () => {
const decoder = new MessageDecoder();
const decoderPlugin = new Label_H1_FPN(decoder);

// https://app.airframes.io/messages/2400409588
const text = 'F37AKL0767#M1BFPN/TS232008,022324/RP:DA:TNCA:AA:TNCB:R:11O:D:ADRI1F..IRLEP.A574..PJG:AP:RNV10(10O)/PR,,110,,183,7,13,,M7,25,,,P30,M40,36090,13,3455,300/DTTNCB,10O,119,23440847C0';
const decodeResult = decoderPlugin.decode({ text: text });
console.log(JSON.stringify(decodeResult, null, 2));

expect(decodeResult.decoded).toBe(true);
expect(decodeResult.decoder.decodeLevel).toBe('full'); // should be partial
expect(decodeResult.decoder.name).toBe('label-h1-fpn');
expect(decodeResult.raw.message_timestamp).toBe(1708730408);
expect(decodeResult.formatted.description).toBe('Flight Plan');
expect(decodeResult.formatted.items.length).toBe(7);
expect(decodeResult.formatted.items[0].label).toBe('Route Status');
expect(decodeResult.formatted.items[0].value).toBe('Route Planned');
expect(decodeResult.formatted.items[1].label).toBe('Origin');
expect(decodeResult.formatted.items[1].value).toBe('TNCA');
expect(decodeResult.formatted.items[2].label).toBe('Destination');
expect(decodeResult.formatted.items[2].value).toBe('TNCB');
expect(decodeResult.formatted.items[3].label).toBe('Runway');
expect(decodeResult.formatted.items[3].value).toBe('11O');
expect(decodeResult.formatted.items[4].label).toBe('Departure Procedure');
expect(decodeResult.formatted.items[4].value).toBe('ADRI1F: >> IRLEP > A574 >> PJG');
expect(decodeResult.formatted.items[5].label).toBe('Approach Procedure');
expect(decodeResult.formatted.items[5].value).toBe('RNV10(10O)/PR,,110,,183,7,13,,M7,25,,,P30,M40,36090,13,3455,300/DTTNCB,10O,119,234408'); /// TODO - Fix
expect(decodeResult.formatted.items[6].label).toBe('Message Checksum');
expect(decodeResult.formatted.items[6].value).toBe('0x47c0');
// expect(decodeResult.remaining.text).toBe('F37AKL0767'); // KL0767 is the flight number
});

test('decodes Label H1 Preamble FPN <invalid>', () => {
const decoder = new MessageDecoder();
const decoderPlugin = new Label_H1_FPN(decoder);
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/Label_H1_FPN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class Label_H1_FPN extends DecoderPlugin {
qualifiers() { // eslint-disable-line class-methods-use-this
return {
labels: ["H1"],
preambles: ['FPN'],
preambles: ['FPN', '#M1BFPN'],
};
}

Expand Down

0 comments on commit fc2c16b

Please sign in to comment.