report
Class Report

java.lang.Object
  extended by report.Report
Direct Known Subclasses:
AdjacencyGraphvizReport, ConnectivityDtnsim2Report, ContactTimesReport, DeliveredMessagesReport, DistanceDelayReport, MessageDelayReport, MessageDeliveryReport, MessageGraphvizReport, MessageStatsReport, MovementNs2Report

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.


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
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 REPORTDIR_SETTING
          The default output directory of reports (can be overriden per report with OUTPUT_SETTING) -setting id ("Report.reportDir")
 
Constructor Summary
Report()
          Constructor.
 
Method Summary
 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.
protected  java.lang.String getScenarioName()
          Returns the name of the scenario as read from the settings
protected  double getSimTime()
          Returns the current simulation time from the SimClock
protected  void init()
          Intializes the report output.
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

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 overriden per report with OUTPUT_SETTING) -setting id ("Report.reportDir")

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)

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()
Intializes 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

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.