org.opengts.util
Class Accelerometer

java.lang.Object
  extended by org.opengts.util.Accelerometer

public class Accelerometer
extends java.lang.Object

Accerometer XYZ-axis container.


Nested Class Summary
static class Accelerometer.ForceUnits
           
 
Field Summary
static double G_PER_MPSS_FORCE
           
static double METERS_PER_SEC_SQ_PER_G
           
static double MPH_PER_SEC_PER_G
           
static double MPH_PER_SEC_PER_MPSS
           
static double MPSS_PER_G_FORCE
           
 
Constructor Summary
Accelerometer()
          Constructor
Accelerometer(Accelerometer other)
          Copy Constructor
Accelerometer(double x, double y, double z)
          Constructor
Accelerometer(java.lang.String xyz)
          Constructor
 
Method Summary
static double Convert_G_to_MSS(double G)
          Convert G-Force to Meters/Second/Second
static double Convert_MSS_to_G(double MSS)
          Convert Meters/Second/Second to G-Force
static java.lang.String CreateGoogleDataTableJSON(int intervMS, boolean G, Accelerometer... ACCList)
          Creates a Google DataTable JSON object containing the specified Accelerometer elements.
 boolean equals(java.lang.Object other)
          Returns true if the specified Accelerometer is equal to this instance.
 double getAxis(int axis, boolean G)
          Gets the specified axis accelerometer value.
static Accelerometer.ForceUnits GetForceUnitsForName(java.lang.String name)
          Gets the ForceUnits enum for the specified name
static Accelerometer.ForceUnits GetForceUnitsForName(java.lang.String name, Accelerometer.ForceUnits dft)
          Gets the ForceUnits enum for the specified name
 double getMagnitude()
          Gets the vector magnitude (Meters/Second/Second)
 double getMagnitude(boolean G)
          Gets the vector magnitude.
 double getMagnitudeG()
          Gets the vector magnitude (G-Force)
static Accelerometer GetMaximumMagnitude(Accelerometer... ACCList)
          Gets the maximum absolute-value Accelerometer magnitude
static Accelerometer GetMaximumMagnitude(java.util.List<Accelerometer> ACCList)
          Gets the maximum absolute-value Accelerometer magnitude
 int getValidAxis()
          Gets the valid axis bitmap
 double getXAxis()
          Gets the X-Axis accelerometer value (Meters/Second/Second).
 double getXAxis(boolean G)
          Gets the X-Axis accelerometer value.
 double getXAxisG()
          Gets the X-Axis accelerometer value (G-Force).
static double[] GetXAxisMinMax(boolean G, Accelerometer... ACCList)
          Gets the X-Axis min/max values for the specified Axis.
 double getYAxis()
          Gets the Y-Axis accelerometer value (Meters/Second/Second).
 double getYAxis(boolean G)
          Gets the Y-Axis accelerometer value.
 double getYAxisG()
          Gets the Y-Axis accelerometer value (G-Force).
static double[] GetYAxisMinMax(boolean G, Accelerometer... ACCList)
          Gets the Y-Axis min/max values for the specified Axis.
 double getZAxis()
          Gets the Z-Axis accelerometer value (Meters/Second/Second).
 double getZAxis(boolean G)
          Gets the Z-Axis accelerometer value.
 double getZAxisG()
          Gets the Z-Axis accelerometer value (G-Force).
static double[] GetZAxisMinMax(boolean G, Accelerometer... ACCList)
          Gets the Y-Axis min/max values for the specified Axis.
 boolean hasAxis(int axis)
          Returns true if the specified axis is available
 boolean hasMagnitude()
          Returns true if this Accelerometer instance has a valid magnitude
 boolean hasXAxis()
          Returns true if the X-Axis value is valid
 boolean hasYAxis()
          Returns true if the Y-Axis value is valid
 boolean hasZAxis()
          Returns true if the Z-Axis value is valid
static int IndexOfListEndChar(java.lang.String xyzListStr, int fromNdx)
          Gets the index of the end-of-list character
static int IndexOfListStartChar(java.lang.String xyzListStr, int fromNdx)
          Gets the index of the start-of-list character
 boolean isValid()
          Returns true if all axis' are valid
static boolean isValid(Accelerometer A)
          Returns true if the specified Accelerometer is valid
static Accelerometer[] ParseAccelerometer(java.lang.String xyzListStr)
          Parse Accelerometer list.
static Accelerometer[] ParseAccelerometer(java.lang.String xyzListStr, int fromNdx)
          Parse Accelerometer list.
 void setXAxis(double MSS)
          Sets the X-Axis accelerometer value (Meters/Second/Second).
 void setXAxisG(double G)
          Sets the X-Axis accelerometer value (G-Force).
 void setYAxis(double MSS)
          Sets the Y-Axis accelerometer value (Meters/Second/Second).
 void setYAxisG(double G)
          Sets the Y-Axis accelerometer value (G-Force).
 void setZAxis(double MSS)
          Sets the Z-Axis accelerometer value (Meters/Second/Second).
 void setZAxisG(double G)
          Sets the Z-Axis accelerometer value (G-Force).
static boolean startsWithListChar(java.lang.String xyzListStr)
          Returns true if the specified list starts with a Accelerometer list character
static java.lang.String ToListString(Accelerometer[] accList)
          Returns a properly formatted Accelerometer list String
static java.lang.StringBuffer ToListString(Accelerometer[] accList, java.lang.StringBuffer sb)
          Appends a properly formatted Accelerometer list to the specified StringBuffer
static java.lang.String ToListString(java.util.List<Accelerometer> accList)
          Returns a properly formatted Accelerometer list String
static java.lang.StringBuffer ToListString(java.util.List<Accelerometer> accList, java.lang.StringBuffer sb)
          Appends a properly formatted Accelerometer list to the specified StringBuffer
 java.lang.String toString()
          Gets the String representation of this instance
 java.lang.String toString(java.lang.StringBuffer sb)
          Gets the String representation of this instance
 java.lang.String toString(java.lang.StringBuffer sb, boolean G, java.lang.String format)
          Gets the String representation of this instance
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

METERS_PER_SEC_SQ_PER_G

public static final double METERS_PER_SEC_SQ_PER_G
See Also:
Constant Field Values

MPSS_PER_G_FORCE

public static final double MPSS_PER_G_FORCE
See Also:
Constant Field Values

G_PER_MPSS_FORCE

public static final double G_PER_MPSS_FORCE
See Also:
Constant Field Values

MPH_PER_SEC_PER_MPSS

public static final double MPH_PER_SEC_PER_MPSS
See Also:
Constant Field Values

MPH_PER_SEC_PER_G

public static final double MPH_PER_SEC_PER_G
See Also:
Constant Field Values
Constructor Detail

Accelerometer

public Accelerometer()
Constructor


Accelerometer

public Accelerometer(double x,
                     double y,
                     double z)
Constructor

Parameters:
x - X-Axis acceleration (Meters/Second/Second)
y - Y-Axis acceleration (Meters/Second/Second)
z - Z-Axis acceleration (Meters/Second/Second)

Accelerometer

public Accelerometer(java.lang.String xyz)
Constructor

Parameters:
xyz - Comma separated XYZ-Axis acceleration (in Meters/Second/Second)

Accelerometer

public Accelerometer(Accelerometer other)
Copy Constructor

Method Detail

IndexOfListStartChar

public static int IndexOfListStartChar(java.lang.String xyzListStr,
                                       int fromNdx)
Gets the index of the start-of-list character


IndexOfListEndChar

public static int IndexOfListEndChar(java.lang.String xyzListStr,
                                     int fromNdx)
Gets the index of the end-of-list character


startsWithListChar

public static boolean startsWithListChar(java.lang.String xyzListStr)
Returns true if the specified list starts with a Accelerometer list character


ParseAccelerometer

public static Accelerometer[] ParseAccelerometer(java.lang.String xyzListStr)
Parse Accelerometer list. Leading/Trailing list characters (..) or [..], are optional. Does not return null.


ParseAccelerometer

public static Accelerometer[] ParseAccelerometer(java.lang.String xyzListStr,
                                                 int fromNdx)
Parse Accelerometer list. Leading/Trailing list characters (..) or [..], are required. Does not return null.


ToListString

public static java.lang.StringBuffer ToListString(Accelerometer[] accList,
                                                  java.lang.StringBuffer sb)
Appends a properly formatted Accelerometer list to the specified StringBuffer


ToListString

public static java.lang.String ToListString(Accelerometer[] accList)
Returns a properly formatted Accelerometer list String


ToListString

public static java.lang.StringBuffer ToListString(java.util.List<Accelerometer> accList,
                                                  java.lang.StringBuffer sb)
Appends a properly formatted Accelerometer list to the specified StringBuffer


ToListString

public static java.lang.String ToListString(java.util.List<Accelerometer> accList)
Returns a properly formatted Accelerometer list String


Convert_G_to_MSS

public static double Convert_G_to_MSS(double G)
Convert G-Force to Meters/Second/Second


Convert_MSS_to_G

public static double Convert_MSS_to_G(double MSS)
Convert Meters/Second/Second to G-Force


GetForceUnitsForName

public static Accelerometer.ForceUnits GetForceUnitsForName(java.lang.String name)
Gets the ForceUnits enum for the specified name


GetForceUnitsForName

public static Accelerometer.ForceUnits GetForceUnitsForName(java.lang.String name,
                                                            Accelerometer.ForceUnits dft)
Gets the ForceUnits enum for the specified name


GetXAxisMinMax

public static double[] GetXAxisMinMax(boolean G,
                                      Accelerometer... ACCList)
Gets the X-Axis min/max values for the specified Axis. Does not return null.

Parameters:
G - True to return value in G-force units, Meters/Second/Second otherwise
ACCList - The Accelerometer array
Returns:
A 2-element double array containing the min/max values.

GetYAxisMinMax

public static double[] GetYAxisMinMax(boolean G,
                                      Accelerometer... ACCList)
Gets the Y-Axis min/max values for the specified Axis. Does not return null.

Parameters:
G - True to return value in G-force units, Meters/Second/Second otherwise
ACCList - The Accelerometer array
Returns:
A 2-element double array containing the min/max values.

GetZAxisMinMax

public static double[] GetZAxisMinMax(boolean G,
                                      Accelerometer... ACCList)
Gets the Y-Axis min/max values for the specified Axis. Does not return null.

Parameters:
G - True to return value in G-force units, Meters/Second/Second otherwise
ACCList - The Accelerometer array
Returns:
A 2-element double array containing the min/max values.

GetMaximumMagnitude

public static Accelerometer GetMaximumMagnitude(Accelerometer... ACCList)
Gets the maximum absolute-value Accelerometer magnitude


GetMaximumMagnitude

public static Accelerometer GetMaximumMagnitude(java.util.List<Accelerometer> ACCList)
Gets the maximum absolute-value Accelerometer magnitude


CreateGoogleDataTableJSON

public static java.lang.String CreateGoogleDataTableJSON(int intervMS,
                                                         boolean G,
                                                         Accelerometer... ACCList)
Creates a Google DataTable JSON object containing the specified Accelerometer elements.

Parameters:
intervMS - The time interval between accelerometer elements (in milliseconds).
G - True to return the DataTable in G-force units.
ACCList - The array of Accelerometer elements.
Returns:
The Google DataTable JSON object

hasXAxis

public boolean hasXAxis()
Returns true if the X-Axis value is valid


getXAxis

public double getXAxis()
Gets the X-Axis accelerometer value (Meters/Second/Second). Returns NaN if axis data is not available.

Returns:
The X-Axis accelerometer value (Meters/Second/Second)

getXAxisG

public double getXAxisG()
Gets the X-Axis accelerometer value (G-Force). Returns NaN if axis data is not available.

Returns:
The X-Axis accelerometer value (G-Force)

getXAxis

public double getXAxis(boolean G)
Gets the X-Axis accelerometer value. Returns NaN if axis data is not available.

Parameters:
G - True to return value in G-force units, Meters/Second/Second otherwise
Returns:
The X-Axis accelerometer value

setXAxis

public void setXAxis(double MSS)
Sets the X-Axis accelerometer value (Meters/Second/Second).

Parameters:
MSS - The X-Axis accelerometer value (Meters/Second/Second)

setXAxisG

public void setXAxisG(double G)
Sets the X-Axis accelerometer value (G-Force).

Parameters:
G - The X-Axis accelerometer value (G-Force)

hasYAxis

public boolean hasYAxis()
Returns true if the Y-Axis value is valid


getYAxis

public double getYAxis()
Gets the Y-Axis accelerometer value (Meters/Second/Second). Returns NaN if axis data is not available.

Returns:
The Y-Axis accelerometer value (Meters/Second/Second)

getYAxisG

public double getYAxisG()
Gets the Y-Axis accelerometer value (G-Force). Returns NaN if axis data is not available.

Returns:
The Y-Axis accelerometer value (G-Force)

getYAxis

public double getYAxis(boolean G)
Gets the Y-Axis accelerometer value. Returns NaN if axis data is not available.

Parameters:
G - True to return value in G-force units, Meters/Second/Second otherwise
Returns:
The Y-Axis accelerometer value

setYAxis

public void setYAxis(double MSS)
Sets the Y-Axis accelerometer value (Meters/Second/Second).

Parameters:
MSS - The Y-Axis accelerometer value (Meters/Second/Second)

setYAxisG

public void setYAxisG(double G)
Sets the Y-Axis accelerometer value (G-Force).

Parameters:
G - The Y-Axis accelerometer value (G-Force)

hasZAxis

public boolean hasZAxis()
Returns true if the Z-Axis value is valid


getZAxis

public double getZAxis()
Gets the Z-Axis accelerometer value (Meters/Second/Second). Returns NaN if axis data is not available.

Returns:
The Z-Axis accelerometer value (Meters/Second/Second)

getZAxisG

public double getZAxisG()
Gets the Z-Axis accelerometer value (G-Force). Returns NaN if axis data is not available.

Returns:
The Z-Axis accelerometer value (G-Force)

getZAxis

public double getZAxis(boolean G)
Gets the Z-Axis accelerometer value. Returns NaN if axis data is not available.

Parameters:
G - True to return value in G-force units, Meters/Second/Second otherwise
Returns:
The Z-Axis accelerometer value

setZAxis

public void setZAxis(double MSS)
Sets the Z-Axis accelerometer value (Meters/Second/Second).

Parameters:
MSS - The Z-Axis accelerometer value (Meters/Second/Second)

setZAxisG

public void setZAxisG(double G)
Sets the Z-Axis accelerometer value (G-Force).

Parameters:
G - The Z-Axis accelerometer value (G-Force)

hasAxis

public boolean hasAxis(int axis)
Returns true if the specified axis is available

Parameters:
axis - The desired axis (0=X, 1=Y, 2=Z)
Returns:
True if the specified axis is available

getAxis

public double getAxis(int axis,
                      boolean G)
Gets the specified axis accelerometer value. Returns NaN if axis data is not available.

Parameters:
axis - The desired axis (0=X, 1=Y, 2=Z)
G - True to return value in G-force units, Meters/Second/Second otherwise
Returns:
The Z-Axis accelerometer value

getValidAxis

public int getValidAxis()
Gets the valid axis bitmap


isValid

public boolean isValid()
Returns true if all axis' are valid


isValid

public static boolean isValid(Accelerometer A)
Returns true if the specified Accelerometer is valid


hasMagnitude

public boolean hasMagnitude()
Returns true if this Accelerometer instance has a valid magnitude


getMagnitude

public double getMagnitude()
Gets the vector magnitude (Meters/Second/Second)

Returns:
The vector magnitude (Meters/Second/Second)

getMagnitudeG

public double getMagnitudeG()
Gets the vector magnitude (G-Force)

Returns:
The vector magnitude in (G-Force)

getMagnitude

public double getMagnitude(boolean G)
Gets the vector magnitude.

Parameters:
G - True to return value in G-force units, Meters/Second/Second otherwise
Returns:
The vector magnitude.

equals

public boolean equals(java.lang.Object other)
Returns true if the specified Accelerometer is equal to this instance.

Overrides:
equals in class java.lang.Object
Parameters:
other - The other Accelerometer instance.
Returns:
True if the specified Accelerometer is equal to this instance.

toString

public java.lang.String toString()
Gets the String representation of this instance

Overrides:
toString in class java.lang.Object
Returns:
The String representation of this instance

toString

public java.lang.String toString(java.lang.StringBuffer sb)
Gets the String representation of this instance

Returns:
The String representation of this instance

toString

public java.lang.String toString(java.lang.StringBuffer sb,
                                 boolean G,
                                 java.lang.String format)
Gets the String representation of this instance

Returns:
The String representation of this instance