Package NMEA
Class NMEABitArray
java.lang.Object
NMEA.NMEABitArray
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char[]Lookup table to convert from integer to 6 bit ASCII data for AIS vessel names, destinations, etc. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byteconvert628(char ch) converts a character from an AIS data string into a six bit integer value packed into an 8 bit byte.static charconvert826(int n) Convert a six bit integer value to AIS / NMEA character datastatic byte[]Converts the character lookup data to an integer-to-character LUT, where the indexing is the standard ASCII character, converted to an integer.final booleangetBit(int bit) Returns true if the given bit is setintgetSignedInteger(int b1, int b2) Get a signed integer from the bit array.getString(int b1, int b2) Gets a string based on packed bits from an AIS string using the 6 bit ascii character set.intgetUnsignedInteger(int b1, int b2) Get an unsigned integer from the bit array.final voidsetBit(int bit) Sets a given bitfinal intsize()Returns the size of this bit array (in bits).toString()
-
Field Details
-
ASCII6
public static final char[] ASCII6Lookup table to convert from integer to 6 bit ASCII data for AIS vessel names, destinations, etc. Table 23 from page 55 of IEC 61993
-
-
Constructor Details
-
NMEABitArray
public NMEABitArray() -
NMEABitArray
public NMEABitArray(int size, int[] bits) -
NMEABitArray
public NMEABitArray(int size)
-
-
Method Details
-
getBit
public final boolean getBit(int bit) Returns true if the given bit is set -
setBit
public final void setBit(int bit) Sets a given bit -
size
public final int size()Returns the size of this bit array (in bits). -
getUnsignedInteger
public int getUnsignedInteger(int b1, int b2) Get an unsigned integer from the bit array.Integers can be any number of bits. The first bit is the most significant.
- Parameters:
b1- First bit to unpackb2- Last bit to unpack- Returns:
- unsigned integer value
-
getSignedInteger
public int getSignedInteger(int b1, int b2) Get a signed integer from the bit array.Integers can be any number of bits and are stored in 2's compliment format.
- Parameters:
b1- First bit to unpackb2- Last bit to unpack- Returns:
- signed integer value
-
getString
Gets a string based on packed bits from an AIS string using the 6 bit ascii character set.- Parameters:
b1- First bit from AIS / NMEA datab2- Last bit from AIS / NMEA data- Returns:
- character string
-
convert628
public static byte convert628(char ch) converts a character from an AIS data string into a six bit integer value packed into an 8 bit byte.- Parameters:
ch- Character from AIS or NMEA string- Returns:
- 6 bit integer (0 to 63)
-
convert826
public static char convert826(int n) Convert a six bit integer value to AIS / NMEA character data- Parameters:
n- an six bit ascii code- Returns:
- a six bit character
-
createLUT6
public static byte[] createLUT6()Converts the character lookup data to an integer-to-character LUT, where the indexing is the standard ASCII character, converted to an integer. The resulting lookup table is sparsely populated and should will return 0 for any index not used in charLUTData.- Returns:
- a six bit value packed into one byte
-
toString
-