#include <simulator.hpp>
Public Types | |
typedef Simulator * | SimulatorPtr |
Pointer that clients should use. | |
Public Member Functions | |
void | addNode (NodePtr nodeToAdd) |
Associate a node with this simulator object. | |
void | runSimulation (const SimTime &stopTime) |
Execute events on the event queue. | |
SimTime | currentTime () const |
Get the current time in the simulator. | |
bool | scheduleEvent (EventPtr eventToSchedule, const SimTime &eventDelay) |
Add an event to the event queue. | |
bool | cancelEvent (EventPtr eventToCancel) |
Cancel an event from the event queue. | |
void | setLogStreamManager (LogStreamManagerPtr logStreamManager) const |
Set the simulator's log stream manager. | |
LogStreamManagerPtr | getLogStreamManager () const |
Get a pointer to the simulator's log stream manager. | |
void | seedRandNumGenerator (const t_uint seed) const |
Seed the random number generator. | |
RandNumGeneratorPtr | getRandNumGenerator () const |
Get a pointer to the simulator's random number generator. | |
void | reset () |
Reset the state of the simulator to its initial state. | |
void | addSimulationEndListener (SimulationEndListenerPtr listener) |
Add a listener that will be notified when the simulation ends. | |
Static Public Member Functions | |
static SimulatorPtr | instance () |
The class uses the Singleton design pattern. |
Definition at line 244 of file simulator.hpp.
void Simulator::addNode | ( | NodePtr | nodeToAdd | ) | [inline] |
Associate a node with this simulator object.
nodeToAdd | the node that will be associated. |
Definition at line 422 of file simulator.hpp.
void Simulator::addSimulationEndListener | ( | SimulationEndListenerPtr | listener | ) | [inline] |
Add a listener that will be notified when the simulation ends.
listener | a pointer to the object to be notified. |
Definition at line 513 of file simulator.hpp.
Referenced by RfidTagPhy::create(), RfidTagMac::create(), RfidTagApp::create(), RfidReaderPhy::create(), RfidReaderMac::create(), RfidReaderApp::create(), and LinkLayer::create().
bool Simulator::cancelEvent | ( | EventPtr | eventToCancel | ) | [inline] |
Cancel an event from the event queue.
If the event pointer exists in the queue, it is removed.
eventToCancel | a pointer to the event being cancelled. |
Definition at line 446 of file simulator.hpp.
Referenced by Node::cancelEvent().
SimTime Simulator::currentTime | ( | ) | const [inline] |
Get the current time in the simulator.
Definition at line 417 of file simulator.hpp.
Referenced by Node::currentTime(), RfidReaderApp::doReadProcess(), Ricean::fadingFactor(), RfidReaderApp::getNextReadTime(), RfidReaderApp::handleRecvdPacket(), scheduleEvent(), ApplicationLayer::start(), and ApplicationLayer::stop().
LogStreamManagerPtr Simulator::getLogStreamManager | ( | ) | const [inline] |
Get a pointer to the simulator's log stream manager.
Definition at line 480 of file simulator.hpp.
RandNumGeneratorPtr Simulator::getRandNumGenerator | ( | ) | const [inline] |
Get a pointer to the simulator's random number generator.
Definition at line 474 of file simulator.hpp.
Referenced by Ricean::fadingFactor(), and RfidTagMac::handleRequestPacket().
SimulatorPtr Simulator::instance | ( | ) | [inline, static] |
The class uses the Singleton design pattern.
Definition at line 486 of file simulator.hpp.
Referenced by Node::cancelEvent(), RfidTagPhy::create(), RfidTagMac::create(), RfidTagApp::create(), RfidReaderPhy::create(), RfidReaderMac::create(), RfidReaderApp::create(), LinkLayer::create(), Node::currentTime(), RfidReaderApp::doReadProcess(), Ricean::fadingFactor(), RfidReaderApp::getNextReadTime(), RfidReaderApp::handleRecvdPacket(), RfidTagMac::handleRequestPacket(), Node::scheduleEvent(), ApplicationLayer::start(), and ApplicationLayer::stop().
void Simulator::reset | ( | ) |
Reset the state of the simulator to its initial state.
This clears the event queue and resets the clock to the original start time.
Definition at line 40 of file simulator.cpp.
References SimTime::setTime().
void Simulator::runSimulation | ( | const SimTime & | stopTime | ) |
Execute events on the event queue.
While the event queue is not empty, this will continue to pop and execute events. After the simulation object is set up, this is called to start executing the events. The event queue is in ascending order by the execution time of events.
stopTime | the time at which the simulation should stop. |
Definition at line 19 of file simulator.cpp.
bool Simulator::scheduleEvent | ( | EventPtr | eventToSchedule, | |
const SimTime & | eventDelay | |||
) | [inline] |
Add an event to the event queue.
The event is pushed onto the event queue and scheduled to fire after eventDelay in the future.
eventToSchedule | a pointer to the event being scheduled. | |
eventDelay | how far in the future the event should be scheduled. eventDelay is added to the currentTime to schedule the time at which the event will fire. |
Definition at line 427 of file simulator.hpp.
References currentTime().
Referenced by Node::scheduleEvent(), ApplicationLayer::start(), and ApplicationLayer::stop().
void Simulator::seedRandNumGenerator | ( | const t_uint | seed | ) | const |
Seed the random number generator.
seed | the new seed. |
Definition at line 34 of file simulator.cpp.
void Simulator::setLogStreamManager | ( | LogStreamManagerPtr | logStreamManager | ) | const [inline] |
Set the simulator's log stream manager.
logStreamManager | a pointer to the simulator's log stream manager. |