decodes.tsdb.algo.LastValueFromPeriod Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opendcs Show documentation
Show all versions of opendcs Show documentation
A collection of software for aggregatting and processing environmental data such as from NOAA GOES satellites.
The newest version!
package decodes.tsdb.algo;
import ilex.var.NamedVariable;
import decodes.tsdb.DbCompException;
import org.opendcs.annotations.algorithm.Algorithm;
import org.opendcs.annotations.algorithm.Input;
import org.opendcs.annotations.algorithm.Output;
/**
*/
@Algorithm(description = "Within a given window select the most recent valid value to be at the end")
public class LastValueFromPeriod
extends AW_AlgorithmBase
{
@Input
public double input;
private double lastValue = Double.NEGATIVE_INFINITY;
@Output
public NamedVariable output = new NamedVariable("output", 0);
// Allow javac to generate a no-args constructor.
/**
* Algorithm-specific initialization provided by the subclass.
*/
protected void initAWAlgorithm( )
throws DbCompException
{
_awAlgoType = AWAlgoType.AGGREGATING;
_aggPeriodVarRoleName = "output";
}
/**
* This method is called once before iterating all time slices.
*/
protected void beforeTimeSlices()
throws DbCompException
{
lastValue = Double.NEGATIVE_INFINITY;
}
/**
* Do the algorithm for a single time slice.
* AW will fill in user-supplied code here.
* Base class will set inputs prior to calling this method.
* User code should call one of the setOutput methods for a time-slice
* output variable.
*
* @throws DbCompException (or subclass thereof) if execution of this
* algorithm is to be aborted.
*/
protected void doAWTimeSlice()
throws DbCompException
{
if( !isMissing( input ) ){
lastValue = input;
}
}
/**
* This method is called once after iterating all time slices.
*/
protected void afterTimeSlices()
throws DbCompException
{
setOutput(output, lastValue);
}
}