Skip to content

Commit

Permalink
Merge pull request #42 from terminal2/improve-bds-60-decoding
Browse files Browse the repository at this point in the history
Improve BDS60 decoding real messages can contain larger gaps in IRS /…
  • Loading branch information
Douglasdc3 authored Oct 6, 2022
2 parents 303507a + f2f3e63 commit 39bb3e7
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/main/java/aero/t2s/modes/decoder/df/bds/Bds60.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public Bds60(short[] data) {
}

if (statusBaroRocd && statusIrsRocd) {
if (Math.abs(irsRocd - baroRocd) > 500) {
if (Math.abs(irsRocd - baroRocd) > 700) {
invalidate();
return;
}
Expand Down
43 changes: 43 additions & 0 deletions src/test/java/aero/t2s/modes/decoder/df/DfRealMessageTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package aero.t2s.modes.decoder.df;

import aero.t2s.modes.BinaryHelper;
import aero.t2s.modes.database.ModeSDatabase;
import aero.t2s.modes.decoder.Decoder;
import aero.t2s.modes.decoder.UnknownDownlinkFormatException;
import aero.t2s.modes.decoder.df.bds.Bds60;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import static org.junit.jupiter.api.Assertions.*;

public class DfRealMessageTest {
@Test
public void test_bds60() throws UnknownDownlinkFormatException {
DownlinkFormat df = testMessage("A0001838E71A21357F640110A153");

assertInstanceOf(DF20.class, df);

assertTrue(((DF20)df).isValid());
assertFalse(((DF20)df).isMultipleMatches());
assertInstanceOf(Bds60.class, ((DF20)df).getBds());
assertEquals(38000, ((DF20) df).getAltitude().getAltitude());

Bds60 bds = (Bds60) ((DF20)df).getBds();
assertTrue(bds.isStatusMagneticHeading());
assertEquals(289.863, bds.getMagneticHeading(), 0.001);
assertTrue(bds.isStatusIas());
assertEquals(272, bds.getIas());
assertTrue(bds.isStatusMach());
assertEquals(0.852, bds.getMach());
assertTrue(bds.isStatusBaroRocd());
assertEquals(-640, bds.getBaroRocd());
assertTrue(bds.isStatusIrsRocd());
assertEquals(32, bds.getIrsRocd());
}

private DownlinkFormat testMessage(String message) throws UnknownDownlinkFormatException {
Decoder decoder = new Decoder(new HashMap<>(), 50, 2, ModeSDatabase.createDatabase());

return decoder.decode(BinaryHelper.stringToByteArray(message));
}
}
22 changes: 0 additions & 22 deletions src/test/java/aero/t2s/modes/decoder/df/DfTEst.java

This file was deleted.

0 comments on commit 39bb3e7

Please sign in to comment.