bug 1997: fix PlotProbe() documentation and usage for GnuplotHelper and FileHelper
This commit is contained in:
@@ -34,10 +34,11 @@ using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("GnuplotHelperExample");
|
||||
|
||||
/*
|
||||
* 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,12 +46,10 @@ public:
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
NS_OBJECT_ENSURE_REGISTERED (Emitter);
|
||||
@@ -80,18 +79,9 @@ void
|
||||
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)
|
||||
{
|
||||
@@ -114,18 +104,6 @@ int main (int argc, char *argv[])
|
||||
Ptr<Emitter> emitter = CreateObject<Emitter> ();
|
||||
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 gnuplot helper will be used to produce output used to make
|
||||
// gnuplot plots.
|
||||
@@ -134,17 +112,19 @@ int main (int argc, char *argv[])
|
||||
// Create the gnuplot helper.
|
||||
GnuplotHelper plotHelper;
|
||||
|
||||
// Configure the plot.
|
||||
// Configure the plot. Arguments include file prefix, plot title,
|
||||
// x-label, y-label, and output file type
|
||||
plotHelper.ConfigurePlot ("gnuplot-helper-example",
|
||||
"Emitter Counts vs. Time",
|
||||
"Emitter Count vs. Time",
|
||||
"Time (Seconds)",
|
||||
"Emitter Count",
|
||||
"png");
|
||||
|
||||
// Plot the values generated by the probe. The path that we provide
|
||||
// helps to disambiguate the source of the trace.
|
||||
plotHelper.PlotProbe ("ns3::DoubleProbe",
|
||||
"/Names/Probe/Output",
|
||||
// Create a probe. Because the trace source we are interested in is
|
||||
// of type uint32_t, we specify the type of probe to use by the first
|
||||
// argument specifying its ns3 TypeId.
|
||||
plotHelper.PlotProbe ("ns3::Uinteger32Probe",
|
||||
"/Names/Emitter/Counter",
|
||||
"Output",
|
||||
"Emitter Count",
|
||||
GnuplotAggregator::KEY_INSIDE);
|
||||
|
||||
Reference in New Issue
Block a user