mavis
Class MeasurementStep

java.lang.Object
  extended by mavis.MeasurementStep
All Implemented Interfaces:
java.lang.Iterable<MeasurementResult>

public class MeasurementStep
extends java.lang.Object
implements java.lang.Iterable<MeasurementResult>

A single step in a measurement sequence. Each step can include multiple measurements for improved precision. A step can have a different volume and mass than the related project, but by default the volume and mass of the project will be used. Any changes made to the measurement step will invoke the project's autosaving. Only the project may change the state and results of a measurement step.

All operations are thread-safe.


Nested Class Summary
static class MeasurementStep.State
          The state of a measurement step.
 
Field Summary
private  double mass
          The mass of this step's sample, or a negative number to use the project's default mass.
static int ORIGO_STEP
           
private  Project project
          The project that owns this step, or null if there is no owner.
private  java.util.List<MeasurementResult> results
          The individual measurement results that are part of this measurement step.
private  boolean signalToDriftWarning
          Tells if the step's signal to drift ratio is below the threshold.
private  boolean signalToHolderWarning
          Tells if the step's signal to holder noise ratio is below the threshold.
private  boolean signalToNoiseWarning
          Tells if the step's signal to noise ratio is below the threshold.
private  MeasurementStep.State state
          Tells if this step has been completed or not, or if a measurement is still running.
private  double stepValue
          The AF or Thermal value of this step, or a negative number if it has not been specified.
private  java.lang.Double susceptibility
          The susceptibility of this step's sample, or null to use the project's default volume.
private  boolean theta63Warning
          Tells if the step's theta 63 is above the threshold.
private  java.util.Date timestamp
          The time the measurements were completed, or null if that has not yet happened.
private  double volume
          The volume of this step's sample, or a negative number to use the project's default volume.
 
Constructor Summary
MeasurementStep()
          Creates a blank measurement step.
MeasurementStep(org.w3c.dom.Element element)
          Creates a measurement step from the specified element.
MeasurementStep(org.w3c.dom.Element element, Project project)
          Creates a measurement step from the specified element for a project.
MeasurementStep(Project project)
          Creates a blank measurement step for a project.
 
Method Summary
 void checkMeasurement()
          Checks if the signal to noise, signal to drift or signal to holder ratios are below the safe threshold and if theta63 is above the safe threshold and raise warning flags if necessary.
 java.lang.Double[] getDoubleNoiseVectorN(int n)
           
 org.w3c.dom.Element getElement(org.w3c.dom.Document document)
          Exports this step to a DOM element.
 javax.vecmath.Vector3d getHolder()
          Returns the average of the holder results (raw values).
 double getMass()
          Returns the mass of this step's sample, or a negative number to use the project's default mass.
 int getMeasurementsCount()
           
 javax.vecmath.Vector3d getNoise()
          Returns the average of the noise results (raw values).
 javax.vecmath.Vector3d getNoiseVectorN(int n)
          Returns the Nth noise results vector (raw values), 1 is the first one.
 Project getProject()
          Returns the owner project of this step, or null if there is no owner.
 MeasurementResult getResult(int index)
          Returns the specified result from this step.
 int getResults()
          Returns the number of results in this step.
 boolean getSignalToDriftWarning()
          Called to see if the signal to drift warning has been raised.
 boolean getSignalToHolderWarning()
          Called to see if the signal to holder warning has been raised.
 boolean getSignalToNoiseWarning()
          Called to see if the signal to noise warning has been raised.
 MeasurementStep.State getState()
          Tells if this step has been completed or not, or if a measurement is still running.
 double getStepValue()
          Returns the AF/Thermal value of this step, or a negative number if it has not been specified.
 java.lang.Double getSusceptibility()
          Returns the susceptibility of this step's sample, or null to use the project's default susceptibility.
 boolean getTheta63Warning()
          Called to see if the theta63 warning has been raised.
 java.util.Date getTimestamp()
          Returns the time the measurements were completed, or null if that has not yet happened.
 boolean getWarnings()
          Called to see if any warnings have been raised.
 double getVolume()
          Returns the volume of this step's sample, or a negative number to use the project's default volume.
 boolean isDone()
          Called to see if this step has been marked as done i.e. completed.
 java.util.Iterator<MeasurementResult> iterator()
          Returns an iterator for iterating through this step's measurement results.
 void save()
          Invokes the owner project's autosaving.
 void setMass(double mass)
          Sets the mass of this step's sample.
 void setMeasuring()
          Called when the step's measurements are started.
 void setStepValue(double stepValue)
          Sets the value of this step.
 void setSusceptibility(java.lang.Double susceptibility)
          Sets the susceptibility of this step's sample.
 void setVolume(double volume)
          Sets the volume of this step's sample.
protected  void updateTransforms()
          Updates all of the measurement results with the owner project's transformation matrix and applies the noise and holder fixes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORIGO_STEP

public static final int ORIGO_STEP
See Also:
Constant Field Values

project

private final Project project
The project that owns this step, or null if there is no owner.


state

private MeasurementStep.State state
Tells if this step has been completed or not, or if a measurement is still running.


timestamp

private java.util.Date timestamp
The time the measurements were completed, or null if that has not yet happened. This equals the time of the latest measurement result.


stepValue

private double stepValue
The AF or Thermal value of this step, or a negative number if it has not been specified. The unit is millitesla (when AF) or Celcius (when thermal).


mass

private double mass
The mass of this step's sample, or a negative number to use the project's default mass. The unit is gram.


volume

private double volume
The volume of this step's sample, or a negative number to use the project's default volume. The unit is cm^3.


susceptibility

private java.lang.Double susceptibility
The susceptibility of this step's sample, or null to use the project's default volume. The unit is 10^-6 SI.


results

private final java.util.List<MeasurementResult> results
The individual measurement results that are part of this measurement step.


signalToNoiseWarning

private boolean signalToNoiseWarning
Tells if the step's signal to noise ratio is below the threshold.


signalToDriftWarning

private boolean signalToDriftWarning
Tells if the step's signal to drift ratio is below the threshold.


signalToHolderWarning

private boolean signalToHolderWarning
Tells if the step's signal to holder noise ratio is below the threshold.


theta63Warning

private boolean theta63Warning
Tells if the step's theta 63 is above the threshold.

Constructor Detail

MeasurementStep

public MeasurementStep()
Creates a blank measurement step.


MeasurementStep

public MeasurementStep(Project project)
Creates a blank measurement step for a project.

Parameters:
project - the project who is the owner of this step.

MeasurementStep

public MeasurementStep(org.w3c.dom.Element element)
Creates a measurement step from the specified element. Will update the transformation matrices.

Parameters:
element - the element from which this step will be created.
Throws:
java.lang.NullPointerException - if element is null.
java.lang.IllegalArgumentException - if the element was not in the right format.

MeasurementStep

public MeasurementStep(org.w3c.dom.Element element,
                       Project project)
Creates a measurement step from the specified element for a project. Will update the transformation matrices.

Parameters:
element - the element from which this step will be created.
project - the project who is the owner of this step.
Throws:
java.lang.NullPointerException - if element is null.
java.lang.IllegalArgumentException - if the element was not in the right format.
Method Detail

getElement

public org.w3c.dom.Element getElement(org.w3c.dom.Document document)
Exports this step to a DOM element.

Parameters:
document - the document that will contain this element.

save

public void save()
Invokes the owner project's autosaving. If there is no owner, will do nothing.


getProject

public Project getProject()
Returns the owner project of this step, or null if there is no owner.


getState

public MeasurementStep.State getState()
Tells if this step has been completed or not, or if a measurement is still running.


getTimestamp

public java.util.Date getTimestamp()
Returns the time the measurements were completed, or null if that has not yet happened.


getStepValue

public double getStepValue()
Returns the AF/Thermal value of this step, or a negative number if it has not been specified. The unit is millitesla (when AF) or Celcius (when thermal).


setStepValue

public void setStepValue(double stepValue)
Sets the value of this step. A negative value will clear it. The unit is millitesla (when AF) or Celcius (when thermal).

If this step is part of an AF project, the stepValue will be adjusted to be the closest correct value.

Throws:
java.lang.IllegalStateException - if the step's state is not READY.

getMass

public double getMass()
Returns the mass of this step's sample, or a negative number to use the project's default mass. The unit is gram.


setMass

public void setMass(double mass)
Sets the mass of this step's sample. A negative value will clear it. The unit is gram.


getVolume

public double getVolume()
Returns the volume of this step's sample, or a negative number to use the project's default volume. The unit is cm^3.


setVolume

public void setVolume(double volume)
Sets the volume of this step's sample. A negative value will clear it. The unit is cm^3.


getSusceptibility

public java.lang.Double getSusceptibility()
Returns the susceptibility of this step's sample, or null to use the project's default susceptibility. The unit is 10^-6 SI.


setSusceptibility

public void setSusceptibility(java.lang.Double susceptibility)
Sets the susceptibility of this step's sample. A null value will clear it. The unit is 10^-6 SI.


updateTransforms

protected void updateTransforms()
Updates all of the measurement results with the owner project's transformation matrix and applies the noise and holder fixes. If there is no owner, an identity matrix will be used.


getResults

public int getResults()
Returns the number of results in this step.


getResult

public MeasurementResult getResult(int index)
Returns the specified result from this step.

Parameters:
index - the index of the result.
Returns:
the specified result.
Throws:
java.lang.IndexOutOfBoundsException - if the index is out of range (index < 0 || index >= getResults()).

setMeasuring

public void setMeasuring()
Called when the step's measurements are started. Sets the step's state to MEASURING.

Throws:
java.lang.IllegalStateException - if this method is called when the state is marked as DONE.

isDone

public boolean isDone()
Called to see if this step has been marked as done i.e. completed. The method is just a wrapper for state.isDone();

Returns:
true if this step is marked as completed

getHolder

public javax.vecmath.Vector3d getHolder()
Returns the average of the holder results (raw values). If there are no holder results or this is the holder calibration project itself, will return a zero-filled vector.


getNoise

public javax.vecmath.Vector3d getNoise()
Returns the average of the noise results (raw values). If there are no noise results, will return a zero-filled vector.


getNoiseVectorN

public javax.vecmath.Vector3d getNoiseVectorN(int n)
Returns the Nth noise results vector (raw values), 1 is the first one. If there are no noise results, will return a zero-filled vector. In the end, what noise measurement the vector corresponds to depends on the project type and what measurement substeps the measurement step of such a project consists of.


getDoubleNoiseVectorN

public java.lang.Double[] getDoubleNoiseVectorN(int n)

iterator

public java.util.Iterator<MeasurementResult> iterator()
Returns an iterator for iterating through this step's measurement results.

Specified by:
iterator in interface java.lang.Iterable<MeasurementResult>

getMeasurementsCount

public int getMeasurementsCount()

checkMeasurement

public void checkMeasurement()
Checks if the signal to noise, signal to drift or signal to holder ratios are below the safe threshold and if theta63 is above the safe threshold and raise warning flags if necessary.


getSignalToNoiseWarning

public boolean getSignalToNoiseWarning()
Called to see if the signal to noise warning has been raised.

Returns:
true if the signal to noise ratio is below the threshold.

getSignalToDriftWarning

public boolean getSignalToDriftWarning()
Called to see if the signal to drift warning has been raised.

Returns:
true if the signal to drift ratio is below the threshold.

getSignalToHolderWarning

public boolean getSignalToHolderWarning()
Called to see if the signal to holder warning has been raised.

Returns:
true if the signal to holder ratio is below the threshold.

getTheta63Warning

public boolean getTheta63Warning()
Called to see if the theta63 warning has been raised.

Returns:
true if the theta63 is above the threshold.

getWarnings

public boolean getWarnings()
Called to see if any warnings have been raised.

Returns:
true if any of the signal values are below the threshold or if theta63 is above the threshold.