SeRoSystems / lib1090

Java decoding library for Mode S, ADS-B, TIS-B and ADS-R
GNU General Public License v3.0
16 stars 2 forks source link

NACp in v1 and v2 airborne positions #11

Open fixje opened 1 year ago

fixje commented 1 year ago

The method public byte getNACp() is available in AirbornePositionV1Msg and AirbornePositionV2Msg through inheritance. Semantically, this is not correct as stated in the Javadoc:

In ADS-B version 1+ this information is contained in the operational status message. For version 0 it is derived from the format type code.

Maybe we should make this more explicit?

Alternatives that come to my mind, both overriding the method in AirbornePositionV1Msg and AirbornePositionV1Msg:

  1. Throw an Exception
  2. Introduce a field to the V1 and V2 airborne position messages. The overridden getNACp method returns the field value. The field value is set by the state-ful decoder upon reception of an AirborneOperationalStatusMsg
  3. Major refactoring: remove inheritance relationship and replace with appropriate interfaces

In solution (2), the method will only be used when the AirbornePositionMsg is created by an instance of Decoder. Note that we have similar behavior already with getNIC, where supplements need to be set.