Я использую Omnetpp-5.6.1 и хочу получить симуляцию времени. Я использую ti c to c пример, и когда я ставлю функцию simTime()
, она возвращает только 0. Мой код такой:
#include <string.h>
#include <omnetpp.h>
using namespace omnetpp;
/**
* Derive the Txc1 class from cSimpleModule. In the Tictoc1 network,
* both the `tic' and `toc' modules are Txc1 objects, created by OMNeT++
* at the beginning of the simulation.
*/
class Txc1 : public cSimpleModule
{
protected:
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
// The module class needs to be registered with OMNeT++
Define_Module(Txc1);
void Txc1::initialize()
{
if (strcmp("source", getName()) == 0) {
// create and send first message on gate "out". "tictocMsg" is an
// arbitrary string which will be the name of the message object.
cMessage *msg = new cMessage("tictocMsg");
send(msg, "out");
}
}
void Txc1::handleMessage(cMessage *msg)
{
EV<< msg->getSendingTime()<< Simtime() ;
send(msg, "out"); // send out the message
}
Я нашел эту функцию здесь но я не знаю, как его использовать.
Как я могу решить эту проблему?