Skip to content

Commit

Permalink
Merge pull request #48 from terminal2/bds-60-baro-rocd
Browse files Browse the repository at this point in the history
When all bits are set to 1 on baro ROCD, value is 0
  • Loading branch information
Douglasdc3 authored Oct 10, 2022
2 parents 6d8139a + 183509d commit 53f1aaf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
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 @@ -79,7 +79,7 @@ public Bds60(short[] data) {
}

double baroSign = ((data[8] >>> 4) & 0x1) == 1 ? -512.0 : 0.0;
baroRocd = ((((data[8] & 0b00001111) << 5) | (data[9] >>> 3)) + baroSign) * ROCD_ACCURCY;
baroRocd = (((((data[8] & 0b00001111) << 5) | (data[9] >>> 3)) + baroSign) * ROCD_ACCURCY) % 16384;
if (statusBaroRocd) {
if (baroRocd < -8000 || baroRocd > 8000) {
invalidate();
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/aero/t2s/modes/decoder/df/DfRealMessageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,31 @@ public void test_df21_bds60_4CA708() throws UnknownDownlinkFormatException {
assertEquals(236.7, bds.getMagneticHeading(), 0.1);
}

@Test
public void test_df21_bds60_00000() throws UnknownDownlinkFormatException {
DownlinkFormat df = testMessage("A800198EEABA2B30F0041257522A");

assertInstanceOf(DF21.class, df);
DF21 df21 = (DF21) df;
assertEquals("000000", df.getIcao()); // Military / corrupt transponder
assertEquals(5652, df21.getModeA());

assertTrue(df21.isValid());
assertInstanceOf(Bds60.class, df21.getBds());

Bds60 bds = (Bds60) df21.getBds();
assertTrue(bds.isStatusIrsRocd());
assertEquals(576, bds.getIrsRocd(), 0.1);
assertTrue(bds.isStatusBaroRocd());
assertEquals(0, bds.getBaroRocd(), 0.1);
assertTrue(bds.isStatusIas());
assertEquals(277, bds.getIas());
assertTrue(bds.isStatusMach());
assertEquals(0.77, bds.getMach(), 0.1);
assertTrue(bds.isStatusMagneticHeading());
assertEquals(300.0, bds.getMagneticHeading(), 0.1);
}

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

Expand Down

0 comments on commit 53f1aaf

Please sign in to comment.