Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions lib/plugins/Label_MA.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('Label_MA', () => {
expect(decodeResult.formatted.description).toBe('Unknown');
expect(decodeResult.raw.label).toBe('H1');
expect(decodeResult.raw.sublabel).toBe('DF');
expect(decodeResult.raw.tail).toBe('.F-HREV');
expect(decodeResult.raw.tail).toBe('F-HREV');
expect(decodeResult.raw.text).toBe('A350,000354,1,1,TB000000/REP035,01,02;H01,035,01,02,4000,00066,.F-HREV,3,0,08,12,19,06,58,42,071/H02,KSFO LFPO,FBU711 ,S0285,S0385,S0142S0185/H03, /A10,06,58,40,+26535,+01198,045,+0493,321723,XXXXXX,--------,0423,+0573/A11,06,58,32,+26356,+01221,041,+0502,324326,XXXXXX,--------,0424,+0614/:');
expect(decodeResult.formatted.items.length).toBe(4);
});
Expand All @@ -42,8 +42,28 @@ describe('Label_MA', () => {
expect(decodeResult.formatted.description).toBe('Unknown');
expect(decodeResult.raw.label).toBe('H1');
expect(decodeResult.raw.sublabel).toBe('DF');
expect(decodeResult.raw.tail).toBe('.ET-BAY');
expect(decodeResult.raw.text).toBe('A350,000243,1,1,');
expect(decodeResult.formatted.items.length).toBe(4);
expect(decodeResult.raw.tail).toBe('ET-BAY');
expect(decodeResult.remaining.text).toBe('A350,000243,1,1,');
expect(decodeResult.formatted.items.length).toBe(3);
});

test('decodes twice', () => {
const text = "T20!<<,B/k&,Z:/=Hs!'iLt0/1h8|*KJNa__;Kes\"hV'&4]J&&&;\"X/O6%0d7TMg5=d7'gcZ:j\"2EiA7k`-`$]f/<L\\63L-&,<Pi[2<O9p^t+Khl*&\\e^,*%4:H<-9Lm>r>q-b^jGP>WX4Dk3IrQ:U4%?]H$4HCd0Z(^Yq+lXXR!=niT!#;:5UAQ`JU@Bfn/*)TSu?G=LuOlLaFSmkGi]eE[!o&j@iX^g0r)T9!Ye)k6aOmSf`8G)8,hS5Fq_trW*!!";
// decodes to label 80
// 3D01 RMPSRV 2501/02 LEMD/MMUN .EC-NOI\n/LAV Y/CAB Y/MEDA N/SEC N/WAS N/WAT N/FUEL N/WCHRR 01/WCHRS --/WCHRC --/UMNR --/MAAS N\nBUENAS NOCHES, ETA 0055Z Y NOS HAN PEDIDO UNA WCHR QUE AL PARECER NO TENIAMOS CONSTANCIA DE ELLA, POR SI PODEIS PEDIRLO A OPS CUN. MUCHAS GRACIAS
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want this message stored somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put the remaining parts in remaining

const decodeResult = plugin.decode({ text: text });

expect(decodeResult.decoded).toBe(true);
expect(decodeResult.decoder.decodeLevel).toBe('full');
expect(decodeResult.formatted.description).toBe('Unknown');
expect(decodeResult.raw.label).toBe('80');
expect(decodeResult.raw.sublabel).toBeUndefined();
expect(decodeResult.raw.tail).toBe('EC-NOI');
expect(decodeResult.raw.text).toBeUndefined();
expect(decodeResult.raw.flight_number).toBe('2501');
expect(decodeResult.raw.departure_icao).toBe('LEMD');
expect(decodeResult.raw.arrival_icao).toBe('MMUN');
expect(decodeResult.raw.day).toBe(2);
expect(decodeResult.formatted.items.length).toBe(7); // Tail twice
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should probably have an if tail exists, don't add again - but i don't want to

});
});
8 changes: 5 additions & 3 deletions lib/plugins/Label_MA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class Label_MA extends DecoderPlugin {
ResultFormatter.sublabel(decodeResult, miamResult.message.data.acars.sublabel);
}
if(miamResult.message.data.acars.tail) {
ResultFormatter.tail(decodeResult, miamResult.message.data.acars.tail);
ResultFormatter.tail(decodeResult, miamResult.message.data.acars.tail.replace('.', ''));
}

const messageText = miamResult.message.data.acars.text;
Expand All @@ -40,14 +40,16 @@ export class Label_MA extends DecoderPlugin {

if(decoded.decoded) {
// decodeResult.decoder.decodeLevel = decoded.decoder.decodeLevel;
decodeResult.raw = {...decodeResult.raw, ...decoded.raw};
decodeResult.raw = {...decodeResult.raw, ...decoded.raw };
decodeResult.formatted.items.push(...decoded.formatted.items);
decodeResult.remaining = decoded.remaining;
} else {
ResultFormatter.text(decodeResult, messageText);
decodeResult.remaining = {text: messageText};
}
} else if(messageText) {
decodeResult.decoder.decodeLevel = 'partial';
ResultFormatter.text(decodeResult, messageText);
decodeResult.remaining = {text: messageText};
} else {
decodeResult.decoder.decodeLevel = 'partial';
}
Expand Down