Class TimeStampWriter
java.lang.Object
tools.descartes.dlim.exporter.utils.TimeStampWriter
- Direct Known Subclasses:
EqualDistanceTimestampWriter
,UniformDistributionTimestampWriter
Creates a time-stamp file from an arrival rate list. Abstract class. Subclasses must implement
the
(PrintWriter writer, double step, double arrRate, double tmpStep, double tmpTime)
writeTimestampsForArrivalRate
method to define the exact sampling of timestamps-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
The constructor.protected
TimeStampWriter
(String endOfLineCharacter) Instantiates a new time stamp writer. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
formatDoubleForDecimalPlaces
(double d) Formats the double to only contain decimalplaces decimals after the period.void
generateTimeStampsFromArrivalRates
(File file, List<ArrivalRateTuple> arrRates, int decimalPlaces, double stretch, double arDevisor) Generate time stamps from arrival rates.protected int
Gets the decimal places.protected String
Gets the end of line character for the .csv.protected double
Gets the time stretch factor.protected abstract void
writeTimestampsForArrivalRate
(PrintWriter writer, double step, double arrRate, double tmpStep, double tmpTime) Write the arrival rate using the provided writer in the specific chosen format.
-
Constructor Details
-
TimeStampWriter
Instantiates a new time stamp writer.- Parameters:
endOfLineCharacter
- The character before the end of a line in the output file. Note: the "\n" is always printed after this character. It does not have to be included here.
-
TimeStampWriter
protected TimeStampWriter()The constructor.
-
-
Method Details
-
getEndOfLineCharacter
Gets the end of line character for the .csv.- Returns:
- the end of line character
-
getDecimalplaces
protected int getDecimalplaces()Gets the decimal places.- Returns:
- the decimal places
-
formatDoubleForDecimalPlaces
Formats the double to only contain decimalplaces decimals after the period.- Parameters:
d
- The double to format.- Returns:
- The formatted double as a String.
-
getStretch
protected double getStretch()Gets the time stretch factor.- Returns:
- the stretch
-
generateTimeStampsFromArrivalRates
public void generateTimeStampsFromArrivalRates(File file, List<ArrivalRateTuple> arrRates, int decimalPlaces, double stretch, double arDevisor) Generate time stamps from arrival rates.- Parameters:
file
- The filename of the produced output filearrRates
- The list of arrival rates as provided by the ArrivalRateGenerator.decimalPlaces
- The amount of decimal places a time-stamp is allowed to have.stretch
- The factor by which to stretch the times of the arrival rate tuples. Using a value < 1 compresses the time.arDevisor
- Divide the arrival rates from the arrival rate tuples by this to produce less time-stamps. Using a value < 1 produces more time stamps
-
writeTimestampsForArrivalRate
protected abstract void writeTimestampsForArrivalRate(PrintWriter writer, double step, double arrRate, double tmpStep, double tmpTime) Write the arrival rate using the provided writer in the specific chosen format.- Parameters:
writer
- PrintWriter, is already initialized and writing.step
- step between two time stampsarrRate
- current arrival ratetmpStep
- the temporary steptmpTime
- the temporary time
-