Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Aircraft object ot DF class when available #41

Merged
merged 1 commit into from
Oct 6, 2022
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
Add Aircraft object ot DF class when available
  • Loading branch information
Douglasdc3 committed Oct 6, 2022
commit f59acfb31b8ec6ff1a24872c2e9cfcac653eae4d
2 changes: 1 addition & 1 deletion src/main/java/aero/t2s/modes/decoder/Decoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public DownlinkFormat decode(short[] data) throws UnknownDownlinkFormatException
throw new UnknownDownlinkFormatException(downlinkFormat, data);
}

return df.decode();
return df.decode().aircraft(modeSDatabase.find(df.getIcao()));
}

public Track getTrack(String icao) {
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/aero/t2s/modes/decoder/df/DownlinkFormat.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package aero.t2s.modes.decoder.df;

import aero.t2s.modes.Track;
import aero.t2s.modes.database.ModeSDatabase;
import aero.t2s.modes.decoder.Common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -12,6 +13,7 @@ public abstract class DownlinkFormat {
protected final short[] data;

private final String icao;
private ModeSDatabase.ModeSAircraft aircraft;

public DownlinkFormat(short[] data, IcaoAddress icaoAddressFrom) {
this.data = data;
Expand All @@ -35,6 +37,16 @@ public short[] getData() {
return data;
}

public DownlinkFormat aircraft(ModeSDatabase.ModeSAircraft aircraft) {
this.aircraft = aircraft == null ? new ModeSDatabase.ModeSAircraft(this.getIcao(), null, null, null) : aircraft;

return this;
}

public ModeSDatabase.ModeSAircraft getAircraft() {
return this.aircraft;
}

protected enum IcaoAddress {
FROM_MESSAGE,
FROM_PARITY,
Expand Down