View | Details | Raw Unified | Return to bug 645
Collapse All | Expand All

(-)5d448b8564e5 (+11 lines)
Added Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>stats</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
	</buildSpec>
9
	<natures>
10
	</natures>
11
</projectDescription>
(-)a/examples/stats/README (+20 lines)
 Lines 14-16    Link Here 
14
available online on the ns-3 wiki at:
14
available online on the ns-3 wiki at:
15
15
16
http://www.nsnam.org/wiki/index.php/Statistical_Framework_for_Network_Simulation
16
http://www.nsnam.org/wiki/index.php/Statistical_Framework_for_Network_Simulation
17
18
*** Using ns-3 with the OMNeT++ analysis tool ***
19
20
The stat framework can write out the result in a format that is compatible with the
21
output format of OMNeT++ 4 Discrete Event Simulator Framework.
22
Use the wifi-example-omnet.sh script to generate the results in OMNeT++ format.
23
24
If you want to analyse the results with OMNeT++'s result analyser tool:
25
a) Download OMNeT++ 4 and install it. Start the IDE. (www.omnetpp.org)
26
b) If you do not want to install the whole simulator framework, there is a seperate 
27
   package which contains only the analysis tool from the OMNeT++ package.
28
   You can download it from http://omnetpp.org/download/release/omnetpp-scave.tgz
29
30
Once you are running the OMNeT++ IDE or the separate analysis tool (SCAVE)
31
- Choose File|Import...|Existing Projects into Workspace, then click [Next]
32
- Select root directory. (choose the examples/stats directory) and click [Finish]
33
34
Double click the wifi-example-omnet.anf in the opened project and select 
35
the Chart page to see the created chart. Experiment with the analysis tool and read its
36
documentation: http://omnetpp.org/doc/omnetpp40/userguide/ch09.html
(-)a/examples/stats/wifi-example-db.sh (-2 / +2 lines)
 Lines 64-71    Link Here 
64
    from Singletons rx, Singletons tx, Experiments exp \
64
    from Singletons rx, Singletons tx, Experiments exp \
65
    where rx.run = tx.run AND \
65
    where rx.run = tx.run AND \
66
          rx.run = exp.run AND \
66
          rx.run = exp.run AND \
67
          rx.name='receiver-rx-packets' AND \
67
          rx.variable='receiver-rx-packets' AND \
68
          tx.name='sender-tx-packets' \
68
          tx.variable='sender-tx-packets' \
69
    group by exp.input \
69
    group by exp.input \
70
    order by abs(exp.input) ASC;"
70
    order by abs(exp.input) ASC;"
71
71
(-)5d448b8564e5 (+18 lines)
Added Link Here 
1
<?xml version="1.0" encoding="UTF-8"?>
2
<scave:Analysis xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:scave="http://www.omnetpp.org/omnetpp/scave">
3
  <inputs>
4
    <inputs name="/stats/*.sca"/>
5
  </inputs>
6
  <datasets>
7
    <datasets name="Tx vs Rx">
8
      <items xsi:type="scave:Add" filterPattern="name(sender-tx-packets) or name(receiver-rx-packets) or name(measurement) "/>
9
      <items xsi:type="scave:ScatterChart" name="Scatter distance vs Rx/Tx" xDataPattern="module(.) AND name(measurement)">
10
        <properties name="X.Axis.Title" value="Distance"/>
11
        <properties name="Y.Axis.Title" value="Rx/Tx packets"/>
12
      </items>
13
    </datasets>
14
  </datasets>
15
  <chartSheets>
16
    <chartSheets name="default" charts="//@datasets/@datasets.0/@items.1"/>
17
  </chartSheets>
18
</scave:Analysis>
(-)5d448b8564e5 (+22 lines)
Added Link Here 
1
#!/bin/sh
2
3
DISTANCES="25 50 75 100 125 145 147 150 152 155 157 160 162 165 167 170 172 175 177 180"
4
TRIALS="1 2 3 4 5"
5
6
echo WiFi Experiment Example - OMNeT++ output
7
8
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:bin/
9
10
for trial in $TRIALS
11
do
12
  for distance in $DISTANCES
13
  do
14
    echo Trial $trial, distance $distance
15
    ../../waf --run "wifi-example-sim --format=omnet --distance=$distance --run=run-$distance-$trial"
16
  done
17
done
18
19
rm *.sca
20
mv ../../*.sca .
21
22
echo "Done; data in data-run-*.sca files. Open SCAVE, create a new workspace and import this directory."
(-)a/examples/stats/wifi-example-sim.cc (+6 lines)
 Lines 200-205    Link Here 
200
  Ptr<CounterCalculator<uint32_t> > totalTx =
200
  Ptr<CounterCalculator<uint32_t> > totalTx =
201
    CreateObject<CounterCalculator<uint32_t> >();
201
    CreateObject<CounterCalculator<uint32_t> >();
202
  totalTx->SetKey("wifi-tx-frames");
202
  totalTx->SetKey("wifi-tx-frames");
203
  totalTx->SetContext("node[0]");
203
  Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
204
  Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTx",
204
                  MakeBoundCallback(&TxCallback, totalTx));
205
                  MakeBoundCallback(&TxCallback, totalTx));
205
  data.AddDataCalculator(totalTx);
206
  data.AddDataCalculator(totalTx);
 Lines 211-216    Link Here 
211
  Ptr<PacketCounterCalculator> totalRx =
212
  Ptr<PacketCounterCalculator> totalRx =
212
    CreateObject<PacketCounterCalculator>();
213
    CreateObject<PacketCounterCalculator>();
213
  totalRx->SetKey("wifi-rx-frames");
214
  totalRx->SetKey("wifi-rx-frames");
215
  totalRx->SetContext("node[1]");
214
  Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
216
  Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx",
215
                  MakeCallback(&PacketCounterCalculator::PacketUpdate,
217
                  MakeCallback(&PacketCounterCalculator::PacketUpdate,
216
                               totalRx));
218
                               totalRx));
 Lines 225-230    Link Here 
225
  Ptr<PacketCounterCalculator> appTx =
227
  Ptr<PacketCounterCalculator> appTx =
226
    CreateObject<PacketCounterCalculator>();
228
    CreateObject<PacketCounterCalculator>();
227
  appTx->SetKey("sender-tx-packets");
229
  appTx->SetKey("sender-tx-packets");
230
  appTx->SetContext("node[0]");
228
  Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx",
231
  Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx",
229
                  MakeCallback(&PacketCounterCalculator::PacketUpdate,
232
                  MakeCallback(&PacketCounterCalculator::PacketUpdate,
230
                                    appTx));
233
                                    appTx));
 Lines 237-242    Link Here 
237
  Ptr<CounterCalculator<> > appRx =
240
  Ptr<CounterCalculator<> > appRx =
238
    CreateObject<CounterCalculator<> >();
241
    CreateObject<CounterCalculator<> >();
239
  appRx->SetKey("receiver-rx-packets");
242
  appRx->SetKey("receiver-rx-packets");
243
  appRx->SetContext("node[1]");
240
  receiver->SetCounter(appRx);
244
  receiver->SetCounter(appRx);
241
  data.AddDataCalculator(appRx);
245
  data.AddDataCalculator(appRx);
242
246
 Lines 263-268    Link Here 
263
  Ptr<PacketSizeMinMaxAvgTotalCalculator> appTxPkts =
267
  Ptr<PacketSizeMinMaxAvgTotalCalculator> appTxPkts =
264
    CreateObject<PacketSizeMinMaxAvgTotalCalculator>();
268
    CreateObject<PacketSizeMinMaxAvgTotalCalculator>();
265
  appTxPkts->SetKey("tx-pkt-size");
269
  appTxPkts->SetKey("tx-pkt-size");
270
  appTxPkts->SetContext("node[0]");
266
  Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx",
271
  Config::Connect("/NodeList/0/ApplicationList/*/$Sender/Tx",
267
                  MakeCallback
272
                  MakeCallback
268
                    (&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate,
273
                    (&PacketSizeMinMaxAvgTotalCalculator::PacketUpdate,
 Lines 277-282    Link Here 
277
  Ptr<TimeMinMaxAvgTotalCalculator> delayStat =
282
  Ptr<TimeMinMaxAvgTotalCalculator> delayStat =
278
    CreateObject<TimeMinMaxAvgTotalCalculator>();
283
    CreateObject<TimeMinMaxAvgTotalCalculator>();
279
  delayStat->SetKey("delay");
284
  delayStat->SetKey("delay");
285
  delayStat->SetContext(".");
280
  receiver->SetDelayTracker(delayStat);
286
  receiver->SetDelayTracker(delayStat);
281
  data.AddDataCalculator(delayStat);
287
  data.AddDataCalculator(delayStat);
282
288
(-)a/src/contrib/stats/basic-data-calculators.h (-12 / +14 lines)
 Lines 29-35    Link Here 
29
  //------------------------------------------------------------
29
  //------------------------------------------------------------
30
  //--------------------------------------------
30
  //--------------------------------------------
31
  template <typename T  = uint32_t>
31
  template <typename T  = uint32_t>
32
  class MinMaxAvgTotalCalculator : public DataCalculator {
32
  class MinMaxAvgTotalCalculator : public DataCalculator,
33
                                   public StatisticalSummary {
33
  public:
34
  public:
34
    MinMaxAvgTotalCalculator();
35
    MinMaxAvgTotalCalculator();
35
    virtual ~MinMaxAvgTotalCalculator();
36
    virtual ~MinMaxAvgTotalCalculator();
 Lines 38-43    Link Here 
38
39
39
    virtual void Output(DataOutputCallback &callback) const;
40
    virtual void Output(DataOutputCallback &callback) const;
40
41
42
    long getCount() const { return m_count; }
43
    double getSum() const { return m_total; }
44
    double getMin() const { return m_min; }
45
    double getMax() const { return m_max; }
46
    double getMean() const { return m_total / (double)m_count; }
47
    double getStddev() const { return NaN; } // unsupported
48
    double getVariance() const { return NaN; } // unsupported
49
    double getSqrSum() const { return NaN; } // unsupported
50
41
  protected:
51
  protected:
42
    virtual void DoDispose(void);
52
    virtual void DoDispose(void);
43
53
 Lines 86-108    Link Here 
86
    }
96
    }
87
    // end MinMaxAvgTotalCalculator::Update
97
    // end MinMaxAvgTotalCalculator::Update
88
  }
98
  }
99
89
  template <typename T>
100
  template <typename T>
90
  void
101
  void
91
  MinMaxAvgTotalCalculator<T>::Output(DataOutputCallback &callback) const
102
  MinMaxAvgTotalCalculator<T>::Output(DataOutputCallback &callback) const
92
  {
103
  {
93
    callback.OutputSingleton(m_key, "count", m_count);
104
      callback.OutputStatistic(m_context, m_key, this);
94
    if (m_count > 0) {
95
      callback.OutputSingleton(m_key, "total", m_total);
96
      callback.OutputSingleton(m_key, "average", m_total/m_count);
97
      callback.OutputSingleton(m_key, "max", m_max);
98
      callback.OutputSingleton(m_key, "min", m_min);
99
    }
100
    // end MinMaxAvgTotalCalculator::Output
101
  }
105
  }
102
106
103
107
104
105
106
  //------------------------------------------------------------
108
  //------------------------------------------------------------
107
  //--------------------------------------------
109
  //--------------------------------------------
108
  template <typename T  = uint32_t>
110
  template <typename T  = uint32_t>
 Lines 178-184    Link Here 
178
  void
180
  void
179
  CounterCalculator<T>::Output(DataOutputCallback &callback) const
181
  CounterCalculator<T>::Output(DataOutputCallback &callback) const
180
  {
182
  {
181
    callback.OutputSingleton(m_key, "count", m_count);
183
    callback.OutputSingleton(m_context, m_key, m_count);
182
    // end CounterCalculator::Output
184
    // end CounterCalculator::Output
183
  }
185
  }
184
186
(-)a/src/contrib/stats/data-calculator.cc (+16 lines)
 Lines 27-32    Link Here 
27
27
28
NS_LOG_COMPONENT_DEFINE("DataCalculator");
28
NS_LOG_COMPONENT_DEFINE("DataCalculator");
29
29
30
static double zero = 0;
31
const double ns3::NaN = zero / zero;
30
32
31
//--------------------------------------------------------------
33
//--------------------------------------------------------------
32
//----------------------------------------------
34
//----------------------------------------------
 Lines 70-75    Link Here 
70
72
71
//----------------------------------------------
73
//----------------------------------------------
72
void
74
void
75
DataCalculator::SetContext(const std::string context)
76
{
77
  m_context = context;
78
  // end DataCalculator::SetContext
79
}
80
81
std::string
82
DataCalculator::GetContext() const
83
{
84
  return m_context;
85
  // end DataCalculator::GetContext
86
}
87
//----------------------------------------------
88
void
73
DataCalculator::Enable()
89
DataCalculator::Enable()
74
{
90
{
75
  m_enabled = true;
91
  m_enabled = true;
(-)a/src/contrib/stats/data-calculator.h (+51 lines)
 Lines 26-34    Link Here 
26
#include "ns3/simulator.h"
26
#include "ns3/simulator.h"
27
27
28
namespace ns3 {
28
namespace ns3 {
29
  extern const double NaN;
30
  inline bool isNaN(double x) { return x != x; }
29
31
30
  class DataOutputCallback;
32
  class DataOutputCallback;
31
33
34
  class StatisticalSummary {
35
	  public:
36
	    /**
37
	     * Returns the number of the observations.
38
	     */
39
	    virtual long getCount() const = 0;
40
41
	    /**
42
	     * Returns the sum of the values.
43
	     * @see getWeightedSum()
44
	     */
45
	    virtual double getSum() const = 0;
46
47
	    /**
48
	     * Returns the sum of the squared values.
49
	     * @see getWeightedSqrSum()
50
	     */
51
	    virtual double getSqrSum() const = 0;
52
53
	    /**
54
	     * Returns the minimum of the values.
55
	     */
56
	    virtual double getMin() const = 0;
57
58
	    /**
59
	     * Returns the maximum of the values.
60
	     */
61
	    virtual double getMax() const = 0;
62
63
	    /**
64
	     * Returns the mean of the (weighted) observations.
65
	     */
66
	    virtual double getMean() const = 0;
67
68
	    /**
69
	     * Returns the standard deviation of the (weighted) observations.
70
	     */
71
	    virtual double getStddev() const = 0;
72
73
	    /**
74
	     * Returns the variance of the (weighted) observations.
75
	     */
76
	    virtual double getVariance() const = 0;
77
  };
78
32
  //------------------------------------------------------------
79
  //------------------------------------------------------------
33
  //--------------------------------------------
80
  //--------------------------------------------
34
  class DataCalculator : public Object {
81
  class DataCalculator : public Object {
 Lines 43-48    Link Here 
43
    void SetKey(const std::string key);
90
    void SetKey(const std::string key);
44
    std::string GetKey() const;
91
    std::string GetKey() const;
45
92
93
    void SetContext(const std::string context);
94
    std::string GetContext() const;
95
46
    virtual void Start(const Time& startTime);
96
    virtual void Start(const Time& startTime);
47
    virtual void Stop(const Time& stopTime);
97
    virtual void Stop(const Time& stopTime);
48
98
 Lines 52-57    Link Here 
52
    bool m_enabled;  // Descendant classes *must* check & respect m_enabled!
102
    bool m_enabled;  // Descendant classes *must* check & respect m_enabled!
53
103
54
    std::string m_key;
104
    std::string m_key;
105
    std::string m_context;
55
106
56
    virtual void DoDispose(void);
107
    virtual void DoDispose(void);
57
108
(-)a/src/contrib/stats/data-output-interface.h (+5 lines)
 Lines 23-28    Link Here 
23
23
24
#include "ns3/object.h"
24
#include "ns3/object.h"
25
#include "ns3/nstime.h"
25
#include "ns3/nstime.h"
26
#include "ns3/data-calculator.h"
26
27
27
namespace ns3 {
28
namespace ns3 {
28
29
 Lines 52-57    Link Here 
52
  public:
53
  public:
53
    virtual ~DataOutputCallback() {}
54
    virtual ~DataOutputCallback() {}
54
55
56
    virtual void OutputStatistic(std::string key,
57
                                 std::string variable,
58
                                 const StatisticalSummary *statSum) = 0;
59
55
    virtual void OutputSingleton(std::string key,
60
    virtual void OutputSingleton(std::string key,
56
                                 std::string variable,
61
                                 std::string variable,
57
                                 int val) = 0;
62
                                 int val) = 0;
(-)a/src/contrib/stats/omnet-data-output.cc (-22 / +90 lines)
 Lines 19-24    Link Here 
19
 */
19
 */
20
20
21
#include <fstream>
21
#include <fstream>
22
#include <cstdlib>
22
23
23
#include "ns3/log.h"
24
#include "ns3/log.h"
24
#include "ns3/nstime.h"
25
#include "ns3/nstime.h"
 Lines 54-79    Link Here 
54
}
55
}
55
56
56
//----------------------------------------------
57
//----------------------------------------------
58
59
inline bool isNumeric(const std::string& s) {
60
  char *endp;
61
  strtod(s.c_str(), &endp);
62
  return endp == s.c_str() + s.size();
63
}
64
57
void
65
void
58
OmnetDataOutput::Output(DataCollector &dc)
66
OmnetDataOutput::Output(DataCollector &dc)
59
{
67
{
60
68
61
  std::ofstream scalarFile;
69
  std::ofstream scalarFile;
62
  std::string fn = m_filePrefix + ".sca";
70
  std::string fn = m_filePrefix +"-"+dc.GetRunLabel()+ ".sca";
63
  scalarFile.open(fn.c_str(), std::ios_base::app);
71
  scalarFile.open(fn.c_str(), std::ios_base::out);
64
72
65
  scalarFile << std::endl;
73
  // TODO add timestamp to the runlevel
66
  scalarFile << "run " << dc.GetRunLabel() << std::endl;
74
  scalarFile << "run " << dc.GetRunLabel() << std::endl;
67
  scalarFile << std::endl;
68
  scalarFile << "attr experiment \"" << dc.GetExperimentLabel()
75
  scalarFile << "attr experiment \"" << dc.GetExperimentLabel()
69
            << "\"" << std::endl;
76
            << "\"" << std::endl;
70
  scalarFile << "attr strategy \"" << dc.GetStrategyLabel()
77
  scalarFile << "attr strategy \"" << dc.GetStrategyLabel()
71
            << "\"" << std::endl;
78
            << "\"" << std::endl;
72
  scalarFile << "attr input \"" << dc.GetInputLabel()
79
  scalarFile << "attr measurement \"" << dc.GetInputLabel()
73
            << "\"" << std::endl;
80
            << "\"" << std::endl;
74
  scalarFile << "attr description \"" << dc.GetDescription()
81
  scalarFile << "attr description \"" << dc.GetDescription()
75
            << "\"" << std::endl;
82
            << "\"" << std::endl;
76
  scalarFile << std::endl;
77
83
78
  for (MetadataList::iterator i = dc.MetadataBegin();
84
  for (MetadataList::iterator i = dc.MetadataBegin();
79
       i != dc.MetadataEnd(); i++) {
85
       i != dc.MetadataEnd(); i++) {
 Lines 83-89    Link Here 
83
  }
89
  }
84
90
85
  scalarFile << std::endl;
91
  scalarFile << std::endl;
86
92
  if (isNumeric(dc.GetInputLabel())) {
93
     scalarFile << "scalar . measurement \"" << dc.GetInputLabel()
94
            << "\"" << std::endl;
95
  }
96
  for (MetadataList::iterator i = dc.MetadataBegin();
97
       i != dc.MetadataEnd(); i++) {
98
    std::pair<std::string, std::string> blob = (*i);
99
    if (isNumeric(blob.second)) {
100
       scalarFile << "scalar . \"" << blob.first << "\" \"" << blob.second << "\""
101
               << std::endl;
102
    }
103
  }
87
  OmnetOutputCallback callback(&scalarFile);
104
  OmnetOutputCallback callback(&scalarFile);
88
105
89
  for (DataCalculatorList::iterator i = dc.DataCalculatorBegin();
106
  for (DataCalculatorList::iterator i = dc.DataCalculatorBegin();
 Lines 97-102    Link Here 
97
  // end OmnetDataOutput::Output
114
  // end OmnetDataOutput::Output
98
}
115
}
99
116
117
100
OmnetDataOutput::OmnetOutputCallback::OmnetOutputCallback
118
OmnetDataOutput::OmnetOutputCallback::OmnetOutputCallback
101
  (std::ostream *scalar) :
119
  (std::ostream *scalar) :
102
  m_scalar(scalar)
120
  m_scalar(scalar)
 Lines 104-145    Link Here 
104
}
122
}
105
123
106
void
124
void
107
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key,
125
OmnetDataOutput::OmnetOutputCallback::OutputStatistic(std::string context,
108
                                                      std::string variable,
126
                                                      std::string name,
127
                                                      const StatisticalSummary *statSum)
128
{
129
	if (context == "")
130
		context = ".";
131
	if (name == "")
132
		name = "\"\"";
133
	(*m_scalar) << "statistic " << context << " " << name << std::endl;
134
	if (!isNaN(statSum->getCount()))
135
		(*m_scalar) << "field count " << statSum->getCount() << std::endl;
136
	if (!isNaN(statSum->getSum()))
137
		(*m_scalar) << "field sum " << statSum->getSum() << std::endl;
138
	if (!isNaN(statSum->getMean()))
139
		(*m_scalar) << "field mean " << statSum->getMean() << std::endl;
140
	if (!isNaN(statSum->getMin()))
141
		(*m_scalar) << "field min " << statSum->getMin() << std::endl;
142
	if (!isNaN(statSum->getMax()))
143
		(*m_scalar) << "field max " << statSum->getMax() << std::endl;
144
	if (!isNaN(statSum->getSqrSum()))
145
		(*m_scalar) << "field sqrsum " << statSum->getSqrSum() << std::endl;
146
	if (!isNaN(statSum->getStddev()))
147
		(*m_scalar) << "field stddev " << statSum->getStddev() << std::endl;
148
}
149
150
void
151
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context,
152
                                                      std::string name,
109
                                                      int val)
153
                                                      int val)
110
{
154
{
111
  (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl;
155
	if (context == "")
156
		context = ".";
157
	if (name == "")
158
		name = "\"\"";
159
  (*m_scalar) << "scalar " << context << " " << name << " " << val << std::endl;
112
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
160
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
113
}
161
}
162
114
void
163
void
115
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key,
164
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context,
116
                                                      std::string variable,
165
                                                      std::string name,
117
                                                      uint32_t val)
166
                                                      uint32_t val)
118
{
167
{
119
  (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl;
168
	if (context == "")
169
		context = ".";
170
	if (name == "")
171
		name = "\"\"";
172
  (*m_scalar) << "scalar " << context << " " << name << " " << val << std::endl;
120
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
173
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
121
}
174
}
175
122
void
176
void
123
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key,
177
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context,
124
                                                      std::string variable,
178
                                                      std::string name,
125
                                                      double val)
179
                                                      double val)
126
{
180
{
127
  (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl;
181
	if (context == "")
182
		context = ".";
183
	if (name == "")
184
		name = "\"\"";
185
    (*m_scalar) << "scalar " << context << " " << name << " " << val << std::endl;
128
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
186
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
129
}
187
}
188
130
void
189
void
131
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key,
190
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context,
132
                                                      std::string variable,
191
                                                      std::string name,
133
                                                      std::string val)
192
                                                      std::string val)
134
{
193
{
135
  (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl;
194
	if (context == "")
195
		context = ".";
196
	if (name == "")
197
		name = "\"\"";
198
    (*m_scalar) << "scalar " << context << " " << name << " " << val << std::endl;
136
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
199
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
137
}
200
}
201
138
void
202
void
139
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string key,
203
OmnetDataOutput::OmnetOutputCallback::OutputSingleton(std::string context,
140
                                                      std::string variable,
204
                                                      std::string name,
141
                                                      Time val)
205
                                                      Time val)
142
{
206
{
143
  (*m_scalar) << "scalar " << key << " " << variable << " " << val << std::endl;
207
	if (context == "")
208
		context = ".";
209
	if (name == "")
210
		name = "\"\"";
211
    (*m_scalar) << "scalar " << context << " " << name << " " << val.GetTimeStep() << std::endl;
144
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
212
  // end OmnetDataOutput::OmnetOutputCallback::OutputSingleton
145
}
213
}
(-)a/src/contrib/stats/omnet-data-output.h (-10 / +14 lines)
 Lines 45-68    Link Here 
45
    public:
45
    public:
46
      OmnetOutputCallback(std::ostream *scalar);
46
      OmnetOutputCallback(std::ostream *scalar);
47
47
48
      void OutputSingleton(std::string key,
48
      void OutputStatistic(std::string context,
49
                           std::string variable,
49
                           std::string name,
50
                           const StatisticalSummary *statSum);
51
52
      void OutputSingleton(std::string context,
53
                           std::string name,
50
                           int val);
54
                           int val);
51
55
52
      void OutputSingleton(std::string key,
56
      void OutputSingleton(std::string context,
53
                           std::string variable,
57
                           std::string name,
54
                           uint32_t val);
58
                           uint32_t val);
55
59
56
      void OutputSingleton(std::string key,
60
      void OutputSingleton(std::string context,
57
                           std::string variable,
61
                           std::string name,
58
                           double val);
62
                           double val);
59
63
60
      void OutputSingleton(std::string key,
64
      void OutputSingleton(std::string context,
61
                           std::string variable,
65
                           std::string name,
62
                           std::string val);
66
                           std::string val);
63
67
64
      void OutputSingleton(std::string key,
68
      void OutputSingleton(std::string context,
65
                           std::string variable,
69
                           std::string name,
66
                           Time val);
70
                           Time val);
67
71
68
    private:
72
    private:
(-)a/src/contrib/stats/sqlite-data-output.cc (+19 lines)
 Lines 154-159    Link Here 
154
}
154
}
155
155
156
void
156
void
157
SqliteDataOutput::SqliteOutputCallback::OutputStatistic(std::string key,
158
                       std::string variable,
159
                       const StatisticalSummary *statSum)
160
{
161
	OutputSingleton(key,variable+"-count", (double)statSum->getCount());
162
	if (!isNaN(statSum->getSum()))
163
		OutputSingleton(key,variable+"-total", statSum->getSum());
164
	if (!isNaN(statSum->getMax()))
165
		OutputSingleton(key,variable+"-max", statSum->getMax());
166
	if (!isNaN(statSum->getMin()))
167
		OutputSingleton(key,variable+"-min", statSum->getMin());
168
	if (!isNaN(statSum->getSqrSum()))
169
		OutputSingleton(key,variable+"-sqrsum", statSum->getSqrSum());
170
	if (!isNaN(statSum->getStddev()))
171
		OutputSingleton(key,variable+"-stddev", statSum->getStddev());
172
}
173
174
175
void
157
SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key,
176
SqliteDataOutput::SqliteOutputCallback::OutputSingleton(std::string key,
158
                                                        std::string variable,
177
                                                        std::string variable,
159
                                                        int val)
178
                                                        int val)
(-)a/src/contrib/stats/sqlite-data-output.h (+4 lines)
 Lines 48-53    Link Here 
48
    public:
48
    public:
49
      SqliteOutputCallback(Ptr<SqliteDataOutput> owner, std::string run);
49
      SqliteOutputCallback(Ptr<SqliteDataOutput> owner, std::string run);
50
50
51
      void OutputStatistic(std::string key,
52
                           std::string variable,
53
                           const StatisticalSummary *statSum);
54
51
      void OutputSingleton(std::string key,
55
      void OutputSingleton(std::string key,
52
                           std::string variable,
56
                           std::string variable,
53
                           int val);
57
                           int val);
(-)a/src/contrib/stats/time-data-calculators.cc (-5 / +5 lines)
 Lines 70-81    Link Here 
70
void
70
void
71
TimeMinMaxAvgTotalCalculator::Output(DataOutputCallback &callback) const
71
TimeMinMaxAvgTotalCalculator::Output(DataOutputCallback &callback) const
72
{
72
{
73
  callback.OutputSingleton(m_key, "count", m_count);
73
  callback.OutputSingleton(m_context, m_key + "-count", m_count);
74
  if (m_count > 0) {
74
  if (m_count > 0) {
75
    callback.OutputSingleton(m_key, "total", m_total);
75
    callback.OutputSingleton(m_context, m_key + "-total", m_total);
76
    callback.OutputSingleton(m_key, "average", m_total/Scalar(m_count));
76
    callback.OutputSingleton(m_context, m_key + "-average", m_total/Scalar(m_count));
77
    callback.OutputSingleton(m_key, "max", m_max);
77
    callback.OutputSingleton(m_context, m_key + "-max", m_max);
78
    callback.OutputSingleton(m_key, "min", m_min);
78
    callback.OutputSingleton(m_context, m_key + "-min", m_min);
79
  }
79
  }
80
  // end TimeMinMaxAvgTotalCalculator::Output
80
  // end TimeMinMaxAvgTotalCalculator::Output
81
}
81
}

Return to bug 645