|
From: <dir...@us...> - 2009-07-23 10:21:34
|
Revision: 2096
http://shox.svn.sourceforge.net/shox/?rev=2096&view=rev
Author: dirk_held
Date: 2009-07-23 10:21:18 +0000 (Thu, 23 Jul 2009)
Log Message:
-----------
remove code-snipped-file, after its contents was moved to a class.
Modified Paths:
--------------
trunk/conf/examples/statistics-Intro.txt
Removed Paths:
-------------
trunk/conf/examples/Statistics CodeSnippet.txt
Deleted: trunk/conf/examples/Statistics CodeSnippet.txt
===================================================================
--- trunk/conf/examples/Statistics CodeSnippet.txt 2009-07-23 10:19:52 UTC (rev 2095)
+++ trunk/conf/examples/Statistics CodeSnippet.txt 2009-07-23 10:21:18 UTC (rev 2096)
@@ -1,121 +0,0 @@
-/*
- This code snipped is intended to show, how statistics could be created. The values are stored
- in two ways: as entry in the file statisticsdefault.compact and in a cvs file "statistics.csv",
- using the FileEvaluationLogger class. You need to enable logging in the configuration file, to
- actually create the file statisticsdefault.compact. Do this by adding the section logging:
-
- <logging>
- <log>true</log>
- <nameHistoryFile></nameHistoryFile>
- <nameStatisticsFile>statistics</nameStatisticsFile>
- <logClass>net.sf.shox.debug.compactlogging.CompactFileLogger</logClass>
- </logging>
-
- The history file is ommitted here, to save space and time.
-*/
- static NodeId statNode = NodeId.get(1); // set to a fixed node, to generate valid statistics.
- static final int vals = <a value>; // enter here the number of statistics plus one.
- static Object val[] = new Object[vals]; // This array will hold all your generated values
- static String title[] = new String[vals]; // for each column, add a title, but not forget
- // to replace all spaces with an underline "_".
-
- private static FileEvaluationLogger log = null;
- private static final char separator = ' ';
-
- /**
- * wrapper to generate a statistic item for an integer value.
- *
- * @param idx index into the value array.
- * @param label the label of the statistics item.
- * @param x the value of the statistics item.
- */
- private void statInt(int idx, String now, String label, int x) {
- val[idx] = new Integer(x);
- title[idx] = label;
-
- SimulationManager.logStatistic(statNode, LayerType.NETWORK, "time",
- label, now, Integer.toString(x));
- }
-
- /**
- * wrapper to generate a statistic item for an double value.
- *
- * @param idx index into the value array.
- * @param label the label of the statistics item.
- * @param x the value of the statistics item.
- */
- private void statDouble(int idx, String now, String label, double x) {
- if (x == Double.NaN) {
- x = 0.0;
- }
-
- val[idx] = new Double(Util.round4(x));
- title[idx] = label;
-
- SimulationManager.logStatistic(statNode, LayerType.NETWORK, "time",
- label, now, Double.toString(x));
- }
-
- /**
- * wrapper to generate a statistic item for an percent value.
- *
- * @param idx index into the value array.
- * @param label the label of the statistics item.
- * @param x the value of the statistics item.
- */
- private void statPercent(int idx, String now, String label, double x) {
- statDouble(idx, now, label, x * 100.0);
- }
-
- /**
- * wrapper to generate a statistic item for an time value.
- * The given value is interpreted as simulation time and
- * converted to seconds.
- *
- * @param idx index into the value array.
- * @param label the label of the statistics item.
- * @param x the value of the statistics item.
- */
- private void statTime(int idx, String now, String label, double x) {
- statDouble(idx, now, label, getConfig().getSeconds(x));
- }
-
- /** method to evaluate the counters and to store the statistics. */
- @SuppressWarnings("cast")
- private void generateStatistics(boolean finalize) {
- double now = SimulationManager.getInstance().getCurrentTime();
- double nowD = Configuration.getInstance().getSeconds(now);
- String nowS = Double.toString(nowD);
-
- for (i = 1; i < vals; i++) {
- val[i] = new Double(0.0);
- }
-
- int idx = 1;
-
- val[0] = new Double(nowD);
- title[0] = "time";
-
- statInt(idx++, nowS, "int_stat_title", intStatValue);
- // similar for statDouble, statTime or statPercent
- // add as many calls to stat*(), as you need -> see vals constant
-
- Object val2[] = new Object[idx];
- String title2[] = new String[idx];
-
- for (i = 0; i < idx; i++) {
- val2[i] = val[i];
- title2[i] = title[i];
- }
-
- if (log == null) {
- log = new FileEvaluationLogger(separator, "statistics.csv", title2);
- log.setFlush(true);
- }
-
- log.write((Object[]) val2);
-
- if (finalize) {
- log.close();
- }
- }
\ No newline at end of file
Modified: trunk/conf/examples/statistics-Intro.txt
===================================================================
--- trunk/conf/examples/statistics-Intro.txt 2009-07-23 10:19:52 UTC (rev 2095)
+++ trunk/conf/examples/statistics-Intro.txt 2009-07-23 10:21:18 UTC (rev 2096)
@@ -1 +1,16 @@
-bla
+/*
+ This code snipped is intended to show, how statistics could be created. The values are stored
+ in two ways: as entry in the file statisticsdefault.compact and in a cvs file "statistics.csv",
+ using the FileEvaluationLogger class. You need to enable logging in the configuration file, to
+ actually create the file statisticsdefault.compact. Do this by adding the section logging:
+
+ <logging>
+ <log>true</log>
+ <nameHistoryFile></nameHistoryFile>
+ <nameStatisticsFile>statistics</nameStatisticsFile>
+ <logClass>net.sf.shox.debug.compactlogging.CompactFileLogger</logClass>
+ </logging>
+
+ The history file is ommitted here, to save space and time.
+*/
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|