Skip to content

Commit

Permalink
Improve surface status decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglasdc3 committed Apr 4, 2023
1 parent 07ff26d commit a9b4c6e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 9 deletions.
9 changes: 9 additions & 0 deletions src/main/java/aero/t2s/modes/Track.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class Track {
private String wtc = "";
private String registration;
private String operator;
private Angle horizontalSource = Angle.UNAVAILABLE;

public Track(String icao) {
this.icao = icao;
Expand Down Expand Up @@ -548,4 +549,12 @@ public String toString() {
lon
);
}

public void setHorizontalSource(Angle horizontalSource) {
this.horizontalSource = horizontalSource;
}

public Angle getHorizontalSource() {
return horizontalSource;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,27 @@ public AircraftOperationalStatusVersion2Surface(short[] data) {

@Override
public AircraftOperationalStatusVersion2Surface decode() {
verison = Version.VERSION2;
surfaceCapability = new SurfaceCapability((data[5] << 4) | (data[6] & 0b11110000) >>> 4, verison);
version = Version.VERSION2;
surfaceCapability = new SurfaceCapability((data[5] << 4) | (data[6] & 0b11110000) >>> 4, version);
lengthWidthCode = LengthWidthCode.from(data[6] & 0b00001111);
operationalMode = new SurfaceOperationalMode((data[7] << 8) | data[8]);

SIL = SourceIntegrityLevel.from((data[10] & 0b000110000) >>> 4);
SILsupp = SourceIntegrityLevelSupplement.from((data[10] & 0b00000010) >>> 1);

int NICsuppA = (data[9] & 0b00010000) >>> 4;
int NACp = (data[9] & 0b00001111);
NICp = NavigationIntegrityCategory.surface(NACp, NICsuppA);
int GVA = (data[10] & 0b11000000) >>> 6;
int SIL = (data[10] & 0b00110000) >>> 4;

int SILsupp = (data[10] & 0b00000010) >>> 1;

this.SIL = SourceIntegrityLevel.from(SIL);
this.SILsupp = SourceIntegrityLevelSupplement.from(SILsupp);
this.NICp = NavigationIntegrityCategory.surface(NACp, NICsuppA);

if ((data[10] & 0b00001000) != 0) {
if ((data[10] & 0b00000100) != 0) {
horizontalSource = Angle.TRUE_TRACK;
} else {
horizontalSource = Angle.MAGNETIC_TRACK;
} else {
horizontalSource = Angle.TRUE_TRACK;
}
} else {
if ((data[10] & 0b00000100) != 0) {
Expand All @@ -53,6 +57,7 @@ public AircraftOperationalStatusVersion2Surface decode() {
@Override
public void apply(Track track) {
track.setVersion(Version.VERSION2);
track.setHorizontalSource(horizontalSource);
}

public SurfaceCapability getSurfaceCapability() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import aero.t2s.modes.CprPosition;
import aero.t2s.modes.Track;
import aero.t2s.modes.constants.Angle;

public class SurfacePosition extends ExtendedSquitter {
private final String address;
Expand Down Expand Up @@ -69,7 +70,14 @@ public void apply(Track track) {
}

if (trackAvailable) {
track.setTrueHeading(this.track);
if (track.getHorizontalSource() == Angle.TRUE_TRACK) {
track.setTrueHeading(this.track);
} else if (track.getHorizontalSource() == Angle.MAGNETIC_HEADING) {
track.setMagneticHeading(this.track);
} else {
track.setTrueHeading(this.track);
track.setMagneticHeading(this.track);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package aero.t2s.modes.decoder.df.df17;

import aero.t2s.modes.BinaryHelper;
import aero.t2s.modes.constants.*;
import aero.t2s.modes.decoder.df.df17.data.SurfaceOperationalMode;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class AircraftOperationalStatusMessageTest {
@Test
public void it_decodes_surface_version1_message() {
AircraftOperationalStatusMessage message = new AircraftOperationalStatusMessage(BinaryHelper.stringToByteArray("8F40622DF900260283493839FD1F")).decode();

Assertions.assertInstanceOf(AircraftOperationalStatusVersion2.class, message);
Assertions.assertInstanceOf(AircraftOperationalStatusVersion2Surface.class, message);

AircraftOperationalStatusVersion2Surface surface = (AircraftOperationalStatusVersion2Surface) message;
Assertions.assertEquals(Version.VERSION2, surface.getVersion());
Assertions.assertEquals(LengthWidthCode.CAT6, surface.getLengthWidthCode());

Assertions.assertFalse(surface.getSurfaceCapability().isCockpitDisplayOfTraffic());
Assertions.assertFalse(surface.getSurfaceCapability().isUatReceive());
Assertions.assertFalse(surface.getSurfaceCapability().isLowB2Power());
Assertions.assertFalse(surface.getSurfaceCapability().isPositionOffsetApplied());
Assertions.assertFalse(surface.getSurfaceCapability().isReceive1090ES());
Assertions.assertEquals(NavigationUncertaintyCategory.NUC1, surface.getSurfaceCapability().getNACv());
Assertions.assertEquals(0, surface.getSurfaceCapability().getNICsuppC());

Assertions.assertFalse(surface.getOperationalMode().isAcasIdent());
Assertions.assertTrue(surface.getOperationalMode().isGpsLateralOffsetAvailable());
Assertions.assertFalse(surface.getOperationalMode().isSingleAntennaFlag());
Assertions.assertTrue(surface.getOperationalMode().isGpsLongitudinalOffsetAvailable());
Assertions.assertFalse(surface.getOperationalMode().isGpsLongitudinalOffsetAppliedBySensor());
Assertions.assertEquals(AcasState.RA_NOT_ACTIVE, surface.getOperationalMode().getAcasRA());
Assertions.assertEquals(0, surface.getOperationalMode().getGpsLateralOffset());
Assertions.assertEquals(0, surface.getOperationalMode().getGpsLateralOffset());
Assertions.assertEquals(4, surface.getOperationalMode().getGpsLongitudinalOffset());
Assertions.assertEquals(SourceIntegrityLevel.LESS_THEN_ONE_PER_HUNDRED_THOUSAND, surface.getOperationalMode().getSystemDesignAssurance());

Assertions.assertEquals(NavigationIntegrityCategory.RC_75_M, surface.getNICp());
Assertions.assertEquals(Angle.TRUE_TRACK, surface.getHorizontalSource());
}
}

0 comments on commit a9b4c6e

Please sign in to comment.