report
Class Report

java.lang.Object
  extended by report.Report
Direct Known Subclasses:
AdjacencyGraphvizReport, ConnectivityDtnsim2Report, ConnectivityONEReport, ContactsDuringAnICTReport, ContactsPerHourReport, ContactTimesReport, CreatedMessagesReport, DeliveredMessagesReport, DistanceDelayReport, DTN2Reporter, EncountersVSUniqueEncountersReport, EnergyLevelReport, EventLogReport, MessageDelayReport, MessageDeliveryReport, MessageGraphvizReport, MessageLocationReport, MessageReport, MessageStatsReport, MovementNs2Report, PingAppReporter, TotalEncountersReport, UniqueEncountersReport

public abstract class Report
extends java.lang.Object

Abstract superclass for all reports. All settings defined in this class can be used for all Report classes. Some reports don't implement intervalled reports (INTERVAL_SETTING) and will ignore that setting. Most of the reports implement warm up feature (WARMUP_S) but the implementations are always report specific.


Field Summary
static int DEF_PRECISION
          Default precision of formatted double values
static java.lang.String INTERVAL_SETTING
          The interval (simulated seconds) of creating new settings files -setting id ("interval")
static java.lang.String INTERVALLED_FORMAT
          Suffix for reports that are created on n second intervals
static java.lang.String NAN
          String value for values that could not be calculated
protected  java.io.PrintWriter out
          The print writer used to write output.
static java.lang.String OUT_SUFFIX
          Suffix of report files without explicit output
static java.lang.String OUTPUT_SETTING
          The output file path of the report -setting id ("output")
static java.lang.String PRECISION_SETTING
          Precision of formatted double values - setting id ("precision").
static java.lang.String REPORT_NS
          Name space of the settings that are common to all reports ("Report").
static java.lang.String REPORTDIR_SETTING
          The default output directory of reports (can be overridden per report with OUTPUT_SETTING) -setting id ("Report.reportDir")
static java.lang.String WARMUP_S
          Warm up period -setting id ("warmup").
protected  java.util.Set<java.lang.String> warmupIDs
           
protected  int warmupTime
           
 
Constructor Summary
Report()
          Constructor.
 
Method Summary
protected  void addWarmupID(java.lang.String id)
          Adds a new ID to the warm up ID set
 void done()
          Called when the simulation is done, user requested premature termination or intervalled report generating decided that it's time for the next report.
protected  java.lang.String format(double value)
          Formats a double value according to current precision setting (see PRECISION_SETTING) and returns it in a string.
 java.lang.String getAverage(java.util.List<java.lang.Double> values)
          Returns the average of double values stored in a List or "NaN" for empty lists.
 java.lang.String getIntAverage(java.util.List<java.lang.Integer> values)
          Returns the average of integer values stored in a List
 int getIntMedian(java.util.List<java.lang.Integer> values)
          Returns the median of integer values stored in a List
 java.lang.String getMedian(java.util.List<java.lang.Double> values)
          Returns the median of double values stored in a List
protected  java.lang.String getScenarioName()
          Returns the name of the scenario as read from the settings
protected  Settings getSettings()
          Returns a Settings object initialized for the report class' name space that uses "Report" as the secondary name space.
protected  double getSimTime()
          Returns the current simulation time from the SimClock
 java.lang.String getVariance(java.util.List<java.lang.Double> values)
          Returns the variance of the values in the List.
protected  void init()
          Initializes the report output.
protected  boolean isWarmup()
          Returns true if the warm up period is still ongoing (simTime < warmup)
protected  boolean isWarmupID(java.lang.String id)
          Returns true if the given ID is in the warm up ID set
protected  void newEvent()
          This method should be called before every new (complete) event the report logs.
protected  void setPrefix(java.lang.String txt)
          Sets a prefix that will be inserted before every line in the report
protected  void write(java.lang.String txt)
          Writes a line to report using defined prefix and out writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPORT_NS

public static final java.lang.String REPORT_NS
Name space of the settings that are common to all reports ("Report").

See Also:
Constant Field Values

INTERVAL_SETTING

public static final java.lang.String INTERVAL_SETTING
The interval (simulated seconds) of creating new settings files -setting id ("interval")

See Also:
Constant Field Values

OUTPUT_SETTING

public static final java.lang.String OUTPUT_SETTING
The output file path of the report -setting id ("output")

See Also:
Constant Field Values

PRECISION_SETTING

public static final java.lang.String PRECISION_SETTING
Precision of formatted double values - setting id ("precision"). Defines the amount of decimals shown in formatted double values. Default value is 4.

See Also:
Constant Field Values

DEF_PRECISION

public static final int DEF_PRECISION
Default precision of formatted double values

See Also:
Constant Field Values

REPORTDIR_SETTING

public static final java.lang.String REPORTDIR_SETTING
The default output directory of reports (can be overridden per report with OUTPUT_SETTING) -setting id ("Report.reportDir")

See Also:
Constant Field Values

WARMUP_S

public static final java.lang.String WARMUP_S
Warm up period -setting id ("warmup"). Defines how many seconds from the beginning of the simulation should not be included in the reports. Implementation of the feature is report specific, so check out the respective report classes for details. Default is 0. Must be a positive integer or 0.

See Also:
Constant Field Values

OUT_SUFFIX

public static final java.lang.String OUT_SUFFIX
Suffix of report files without explicit output

See Also:
Constant Field Values

INTERVALLED_FORMAT

public static final java.lang.String INTERVALLED_FORMAT
Suffix for reports that are created on n second intervals

See Also:
Constant Field Values

out

protected java.io.PrintWriter out
The print writer used to write output. See write(String)


NAN

public static final java.lang.String NAN
String value for values that could not be calculated

See Also:
Constant Field Values

warmupTime

protected int warmupTime

warmupIDs

protected java.util.Set<java.lang.String> warmupIDs
Constructor Detail

Report

public Report()
Constructor. Looks for a className.output setting in the Settings and if such is found, uses that as the output file name. Otherwise scenarioname_classname.txt is used as the file name.

Method Detail

init

protected void init()
Initializes the report output. Method is called in the beginning of every new report file. Subclasses must call this method first in their own implementations of init().


newEvent

protected void newEvent()
This method should be called before every new (complete) event the report logs. If the report has no meaningful use for multiple reports, the call can be omitted (then only single output file will be generated)


write

protected void write(java.lang.String txt)
Writes a line to report using defined prefix and out writer.

Parameters:
txt - Line to write
See Also:
setPrefix(String)

format

protected java.lang.String format(double value)
Formats a double value according to current precision setting (see PRECISION_SETTING) and returns it in a string.

Parameters:
value - The value to format
Returns:
Formatted value in a string

setPrefix

protected void setPrefix(java.lang.String txt)
Sets a prefix that will be inserted before every line in the report

Parameters:
txt - Text to use as the prefix

getScenarioName

protected java.lang.String getScenarioName()
Returns the name of the scenario as read from the settings

Returns:
the name of the scenario as read from the settings

getSimTime

protected double getSimTime()
Returns the current simulation time from the SimClock

Returns:
the current simulation time from the SimClock

isWarmup

protected boolean isWarmup()
Returns true if the warm up period is still ongoing (simTime < warmup)

Returns:
true if the warm up period is still ongoing, false if not

addWarmupID

protected void addWarmupID(java.lang.String id)
Adds a new ID to the warm up ID set

Parameters:
id - The ID

isWarmupID

protected boolean isWarmupID(java.lang.String id)
Returns true if the given ID is in the warm up ID set

Parameters:
id - The ID
Returns:
true if the given ID is in the warm up ID set

getSettings

protected Settings getSettings()
Returns a Settings object initialized for the report class' name space that uses "Report" as the secondary name space.

Returns:
a Settings object initialized for the report class' name space

done

public void done()
Called when the simulation is done, user requested premature termination or intervalled report generating decided that it's time for the next report.


getAverage

public java.lang.String getAverage(java.util.List<java.lang.Double> values)
Returns the average of double values stored in a List or "NaN" for empty lists.

Parameters:
values - The list of double values
Returns:
average of double values stored in the List in a formatted String

getIntAverage

public java.lang.String getIntAverage(java.util.List<java.lang.Integer> values)
Returns the average of integer values stored in a List

Parameters:
values - The list of values
Returns:
average of integer values stored in the List or "NaN" for empty lists.

getMedian

public java.lang.String getMedian(java.util.List<java.lang.Double> values)
Returns the median of double values stored in a List

Parameters:
values - The list of double values
Returns:
median of double values stored in the List or "NaN" for empty lists.

getIntMedian

public int getIntMedian(java.util.List<java.lang.Integer> values)
Returns the median of integer values stored in a List

Parameters:
values - The list of values
Returns:
median of integer values stored in the List or 0 for empty lists.

getVariance

public java.lang.String getVariance(java.util.List<java.lang.Double> values)
Returns the variance of the values in the List.

Parameters:
values - The list of values
Returns:
The variance of the values in the list or "NaN" if the list is empty.