Class ExtendedDataType<T,O,S,G extends GtuDataInterface>
java.lang.Object
org.opentrafficsim.kpi.sampling.data.ExtendedDataType<T,O,S,G>
- Type Parameters:
T- type of valueO- output typeS- storage typeG- gtu data type
- All Implemented Interfaces:
Identifiable
- Direct Known Subclasses:
ExtendedDataTypeFloat,ExtendedDataTypeList,ExtendedDataTypeNumber
public abstract class ExtendedDataType<T,O,S,G extends GtuDataInterface> extends Object implements Identifiable
Type class to define different types of data by which trajectories can be extended beyond the basic t, x, v, a. Extend this
class to define a new data type. Extended data types are defined with 3 generic types.
<T> is the type of a single
scalar value, <O> is the output type of the whole trajectory, e.g. List<Double> or FloatLengthVector,
and <S> is the storage type by which the data is gathered, e.g. List<Double> or float[].
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Version:
- $Revision$, $LastChangedDate$, by $Author$, initial version 11 okt. 2016
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Constructor Summary
Constructors Constructor Description ExtendedDataType(String id)Constructor setting the id. -
Method Summary
Modifier and Type Method Description abstract Oconvert(S storage, int size)Convert storage type to output type.booleanequals(Object obj)abstract StringformatValue(String format, T value)Formats the value into a string.StringgetId()abstract TgetOutputValue(O output, int index)Returns a specific output value.abstract TgetStorageValue(S storage, int index)Returns a specific storage value.abstract TgetValue(G gtu)Returns the current value of the gtu.inthashCode()abstract SinitializeStorage()Returns an initial storage object.<AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>, R extends DoubleScalarInterface.Rel<RU, R>, RA extends DoubleScalarInterface.RelWithAbs<AU, A, RU, RA>, A extends DoubleScalarInterface.Abs<AU, A, RU, RA>, FR extends FloatScalarInterface.Rel<RU, FR>, FRA extends FloatScalarInterface.RelWithAbs<AU, FA, RU, FRA>, FA extends FloatScalarInterface.Abs<AU, FA, RU, FRA>>
Tinterpolate(T value0, T value1, double f)Interpolate value between two measured values.abstract SsetValue(S storage, int index, T value)Returns an updated list/array/vector of the storage type, including a new value at given index.
-
Constructor Details
-
ExtendedDataType
Constructor setting the id.- Parameters:
id- String; id
-
-
Method Details
-
getId
- Specified by:
getIdin interfaceIdentifiable- Returns:
- id
-
getValue
Returns the current value of the gtu.- Parameters:
gtu- G; gtu- Returns:
- current value of the gtu
-
setValue
Returns an updated list/array/vector of the storage type, including a new value at given index.- Parameters:
storage- S; storageindex- int; index to store next valuevalue- T; value to add- Returns:
- updated list/array/vector of the storage type, including a new value at given index
-
getOutputValue
Returns a specific output value. This is used to store extended data types as generic file, i.e. text file.- Parameters:
output- O; outputindex- int; index of value to return- Returns:
- the i'th output value
- Throws:
SamplingException- wheniis out of bounds.
-
getStorageValue
Returns a specific storage value. This is used to bypass conversion to the output type when trajectories are cut.- Parameters:
storage- S; storageindex- int; index of value to return- Returns:
- the i'th output value
- Throws:
SamplingException- wheniis out of bounds.
-
initializeStorage
Returns an initial storage object.- Returns:
- initial storage object.
-
convert
Convert storage type to output type.- Parameters:
storage- S; stored datasize- int; size of trajectory- Returns:
- converted output
-
formatValue
Formats the value into a string. If the value is numeric, the default implementation is:String.format(format, value.si);
- Parameters:
format- String; formatvalue- T; value- Returns:
- formatted value
-
interpolate
public <AU extends AbsoluteLinearUnit<AU, RU>, RU extends Unit<RU>, R extends DoubleScalarInterface.Rel<RU, R>, RA extends DoubleScalarInterface.RelWithAbs<AU, A, RU, RA>, A extends DoubleScalarInterface.Abs<AU, A, RU, RA>, FR extends FloatScalarInterface.Rel<RU, FR>, FRA extends FloatScalarInterface.RelWithAbs<AU, FA, RU, FRA>, FA extends FloatScalarInterface.Abs<AU, FA, RU, FRA>> T interpolate(T value0, T value1, double f)Interpolate value between two measured values. The default implementation takes a linear interpolation over time forDoubleScalar,FloatScalar,DoubleandFloat, or the closest value in time otherwise.- Type Parameters:
AU- unit of value, if values areDoubleScalarRU- the corresponding relative unitR- the relative double typeRA- the relative double type belonging to the absolute typeA- the absolute double typeFR- the relative float typeFRA- the relative float type belonging to the absolute typeFA- the absolute float type- Parameters:
value0- T; first valuevalue1- T; second valuef- double; interpolation fraction- Returns:
- interpolated value
-
hashCode
public final int hashCode() -
equals
-