de.serosystems.lib1090.msgs.bds.ACASActiveResolutionAdvisoryReport Maven / Gradle / Ivy
package de.serosystems.lib1090.msgs.bds;
import de.serosystems.lib1090.exceptions.BadFormatException;
import de.serosystems.lib1090.msgs.adsb.TCASResolutionAdvisoryMsg;
import java.io.Serializable;
import static de.serosystems.lib1090.msgs.adsb.TCASResolutionAdvisoryMsg.*;
/*
* This file is part of de.serosystems.lib1090.
*
* de.serosystems.lib1090 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* de.serosystems.lib1090 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with de.serosystems.lib1090. If not, see .
*/
/**
* Decoder for ACAS active resolution advisory report (BDS 3,0)
* See Annex 10 V4 4.3.8.4.2.2
*/
@SuppressWarnings("unused")
public class ACASActiveResolutionAdvisoryReport extends BDSRegister implements Serializable {
private byte racRecord;
private boolean raTerminated;
private boolean multiThreatEncounter;
private byte threatType;
private short bdsCode;
private short activeRa;
private int threatIdentity;
private ThreatIdentityData threatIdentityData;
/** protected no-arg constructor e.g. for serialization with Kryo **/
protected ACASActiveResolutionAdvisoryReport() {}
/**
* @param msg the 7-byte comm-b message (BDS register) as byte array
* @throws BadFormatException if message has wrong format
*/
public ACASActiveResolutionAdvisoryReport(byte[] msg) throws BadFormatException {
super(msg);
setBds(BDSRegister.bdsCode.ACAS_ACTIVE_RESOLUTION_ADVISORY);
this.bdsCode = extractBdsCode(msg);
activeRa = decodeActiveRa(msg);
racRecord = decodeRacRecord(msg);
raTerminated = decodeRaTerminated(msg);
multiThreatEncounter = decodeMultiThreatEncounter(msg);
threatType = decodeThreatType(msg);
threatIdentity = decodeThreatIdentity(msg);
threatIdentityData = TCASResolutionAdvisoryMsg.extractThreatIdentityData(threatType, msg);
}
/**
* Although TCAS 7 is mandated in European and US airspaces, we could still see aircraft using TCAS 6.
* In this case, the active RA needs to be interpreted differently and the threat identity is not present.
*
* @return whether the message should be assumed to originate from a TSO-C119A compatible system
* (version 6.04 Enhanced).
*/
public boolean isTCAS6() {
// bits 59-88 == 0
return threatIdentity == 0
&& threatType == 0
&& !multiThreatEncounter
&& !raTerminated;
}
/**
* @return 14 bits which indicate the characteristics of the resolution advisory
* (Annex 10 V4, 4.3.8.4.2.2.1.1)
* For TCAS 6 to be interpreted according to ED-143 V1 2.2.3.9.3.2.3.1.2
*/
public short getActiveRA() {
return activeRa;
}
/**
* @return 4 bits which indicate all currently active RACs
* (Annex 10 V4, 4.3.8.4.2.2.1.2)
*/
public byte getRACRecord() {
return racRecord;
}
/**
* @return whether RA previously generated by ACAS has ceased being generated
* (Annex 10 V4, 4.3.8.4.2.2.1.3); not present for TCAS 6 systems
*/
public Boolean hasRATerminated() {
if (isTCAS6()) return null;
return raTerminated;
}
/**
* @return whether two or more simultaneous threats are currently being processed
* (Annex 10 V4, 4.3.8.4.2.2.1.4); not present for TCAS 6 systems
*/
public Boolean hasMultiThreatEncounter() {
if (isTCAS6()) return null;
return multiThreatEncounter;
}
/**
* @return the threat type indicator:
* 0) no identity data in TID
* 1) TID contains Mode S transponder address
* 2) TID contains altitude, range, bearing
* 3) not assigned
* (Annex 10 V4, 4.3.8.4.2.2.1.5);
* not present for TCAS 6 systems
*/
public Byte getThreatType() {
if (isTCAS6()) return null;
return threatType;
}
/**
* @return the threat's identity. Check getThreatType() before.
* (Annex 10 V4, 4.3.8.4.2.2.1.6); not present for TCAS 6 systems
*/
public Integer getThreatIdentity() {
if (isTCAS6()) return null;
return threatIdentity;
}
/**
* A convenient representation of the bit array provided by {@link #getActiveRA()}.
*
* Further interpretation of the bits are subject to the caller which needs to handle differences between
* TCAS 6 and 7 systems (see {@link #isTCAS6()}.
*
* A value set to true indicates that the condition is active.
*
* @return the currently active resolution advisories (if any) generated by own ACAS unit against one or more threat
* aircraft.
*/
public boolean[] getActiveResolutionAdvisories() {
return TCASResolutionAdvisoryMsg.extractActiveResolutionAdvisories(getMessage());
}
/**
* A convenient representation of the bit array provided by {@link #getRACRecord()}.
*
* The active RA complement bits have the following meaning:
*
* - index 0: Do not pass below
* - index 1: Do not pass above
* - index 2: Do not turn left
* - index 3: Do not turn right
*
* The value set to true indicates that the condition is active.
*
* @return the currently active resolution advisory complements (if any) received from other ACAS aircraft equipped
* with on-board resolution capability.
*/
public boolean[] getResolutionAdvisoriesComplementsRecord() {
return TCASResolutionAdvisoryMsg.extractResolutionAdvisoriesComplementsRecord(getMessage());
}
/**
* @return the ICAO 24-bit aircraft address of the threat or the altitude, range, and bearing if the threat is not
* Mode S equipped; not present for TCAS 6 systems
*/
public ThreatIdentityData getThreatIdentityData() {
if (isTCAS6()) return null;
return threatIdentityData;
}
@Override
public String toString() {
return "ACASActiveResolutionAdvisoryReport{" +
"racRecord=" + racRecord +
", raTerminated=" + raTerminated +
", multiThreatEncounter=" + multiThreatEncounter +
", threatType=" + threatType +
", bdsCode=" + bdsCode +
", activeRa=" + activeRa +
", threatIdentity=" + threatIdentity +
", threatIdentityData=" + threatIdentityData +
'}';
}
}