All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.esi.metis.aisparser.impl.AISMessage16UnitImpl Maven / Gradle / Ivy

Go to download

This package supports the parsing of AIS messages in Java. AIS, the Automatic Identification System, is a system aiming at improving maritime safety by exchanging messages between ships, other vehicles in particular aircraft involved in search-and-rescue (SAR), and (fixed) base stations. To be precise, this package support the ITU-R M.1371-4 AIS standard. See our extensive javadoc and in particular the class AISParser for more information on how to use this package. The parser was used in the Poseidon project, and is improved in the Metis project to better handle uncertain information. Both projects were led by the Embedded Systems Institute. In both projects Thales Nederlands was the carrying industrial partner, and multiple Dutch universities participated.

The newest version!
package nl.esi.metis.aisparser.impl;

import nl.esi.metis.aisparser.AISMessage16Unit;
import nl.esi.metis.aisparser.Sixbit;
/** ESI AIS Parser
 * 
 * Copyright 2011/2012 by Pierre van de Laar (Embedded Systems Institute)
 * Copyright 2008 by Brian C. Lane 
 * All Rights Reserved
 * 
 * @author Pierre van de Laar
 * @author Brian C. Lane
 */

/**
 * Field Nr     Field Name                          NrOf Bits   (from, to )
 * ------------------------------------------------------------------------
 *  1	destinationID                          	  30	(  0,  29)
 *  2	offset                                 	  12	(  30,  41)
 *  3	increment                              	  10	(  42,  51)
 *                                               ---- +
 *                     (maximum) number of bits    52
 */
class AISMessage16UnitImpl implements AISMessage16Unit {
	private static final int DESTINATIONID_FROM = 0;
	private static final int DESTINATIONID_TO = 29;

	private int destinationID;
	/** destinationID
	 * @return int value of destinationID (30 bits offset + [0,29])
	 */
	public int getDestinationID() { return destinationID; }


	private static final int OFFSET_FROM = 30;
	private static final int OFFSET_TO = 41;

	private int offset;
	/** offset
	 * @return int value of offset (12 bits offset+ [30,41])
	 */
	public int getOffset() { return offset; }


	private static final int INCREMENT_FROM = 42;
	private static final int INCREMENT_TO = 51;

	private int increment;
	/** increment
	 * @return int value of increment (10 bits offset+ [42,51])
	 */
	public int getIncrement() { return increment; }

	public AISMessage16UnitImpl (int offset, Sixbit content)
	{
		assert(content.length() >= offset + INCREMENT_TO);
		destinationID = content.getIntFromTo(offset+DESTINATIONID_FROM,offset+DESTINATIONID_TO);
		this.offset = content.getIntFromTo(offset+OFFSET_FROM,offset+OFFSET_TO);
		increment = content.getIntFromTo(offset+INCREMENT_FROM,offset+INCREMENT_TO);
	}
	

	/** Generates a String representing the AIS message. 
	 * Format: all fields are shown in the order as specified by the standard separated by the SEPARATOR string.
	 */
	@Override
	public String toString() {
		return destinationID + "/" +
				offset + "/" +
				increment;
	}			
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy