--- a/src/stats/examples/file-helper-example.cc Tue Oct 14 13:29:05 2014 -0700
+++ b/src/stats/examples/file-helper-example.cc Wed Oct 15 07:00:24 2014 -0700
@@ -34,10 +34,11 @@
NS_LOG_COMPONENT_DEFINE ("FileHelperExample");
-/*
- * This is our test object, an object that increments counters at
- * various times and emits one of them as a trace source.
- */
+//
+// This is our test object, an object that increments a counter according
+// to a Poisson process, and exports the (integer-valued) count as a
+// trace source.
+//
class Emitter : public Object
{
public:
@@ -45,10 +46,9 @@
Emitter ();
private:
void DoInitialize (void);
- void Emit (void);
void Count (void);
- TracedValue<double> m_counter; // normally this would be integer type
+ TracedValue<uint32_t> m_counter;
Ptr<ExponentialRandomVariable> m_var;
};
@@ -80,19 +80,10 @@
Emitter::DoInitialize (void)
{
NS_LOG_FUNCTION (this);
- Simulator::Schedule (Seconds (m_var->GetValue ()), &Emitter::Emit, this);
Simulator::Schedule (Seconds (m_var->GetValue ()), &Emitter::Count, this);
}
void
-Emitter::Emit (void)
-{
- NS_LOG_FUNCTION (this);
- NS_LOG_DEBUG ("Emitting at " << Simulator::Now ().GetSeconds ());
- Simulator::Schedule (Seconds (m_var->GetValue ()), &Emitter::Emit, this);
-}
-
-void
Emitter::Count (void)
{
NS_LOG_FUNCTION (this);
@@ -115,18 +106,6 @@
Names::Add ("/Names/Emitter", emitter);
//
- // This Probe will be hooked to the Emitter's trace source object by
- // accessing it by path name in the Config database.
- //
-
- Ptr<DoubleProbe> probe = CreateObject<DoubleProbe> ();
- probe->SetName ("PathProbe");
- Names::Add ("/Names/Probe", probe);
-
- // Note, no return value is checked here.
- probe->ConnectByPath ("/Names/Emitter/Counter");
-
- //
// This file helper will be used to put data values into a file.
//
@@ -138,12 +117,12 @@
FileAggregator::FORMATTED);
// Set the labels for this formatted output file.
- fileHelper.Set2dFormat ("Time (Seconds) = %.3e\tCount = %.0f");
+ fileHelper.Set2dFormat ("Time (Seconds) = %.3f\tCount = %.0f");
// Write the values generated by the probe. The path that we
// provide helps to disambiguate the source of the trace.
- fileHelper.WriteProbe ("ns3::DoubleProbe",
- "/Names/Probe/Output",
+ fileHelper.WriteProbe ("ns3::Uinteger32Probe",
+ "/Names/Emitter/Counter",
"Output");
// The Emitter object is not associated with an ns-3 node, so