我的问题很简单,在使用sendDirect()发送消息之前,我会延迟多长时间?我正在使用此函数原型,如下面的代码所示:
sendDirect(cMessage *msg, cModule *mod, const char *gateName, int index=-1)
我知道sendDirect还有其他功能原型,允许传播延迟和持续时间
sendDirect(cMessage *msg, simtime_t propagationDelay, simtime_t duration,
cModule *mod, int gateId)
sendDirect(cMessage *msg, simtime_t propagationDelay, simtime_t duration,
cModule *mod, const char *gateName, int index=-1)
sendDirect(cMessage *msg, simtime_t propagationDelay, simtime_t duration,
cGate *gate)
如何使用我的delay变量创建实际的延迟? 请帮忙 这是我的代码: 经过测试的
package a8;
//
// TODO auto-generated module
//
simple Test
{
parameters:
@display("i=block/circle");
double bpTime @unit(s) = default(2s); //this is my delay variable
gates:
output mydataout3 @directIn;
}
Test.h
#ifndef __A8_TEST_H_
#define __A8_TEST_H_
#include <omnetpp.h>
#include <stdio.h>
#include <string.h>
#include "myMessage_m.h"
/**
* TODO - Generated class
*/
class Test: public cSimpleModule
{
protected:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
virtual myMessage *createMessage();
};
#endif
Test.cc
#include "test.h"
#include <stdio.h>
#include <string.h>
#include "myMessage_m.h"
#include "sha256.h"
#include "aes128.h"
#include "runninglengthencoding.h"
Define_Module(Test);
void Test::initialize()
{
// TODO - Generated method body
myMessage *Newmsg = createMessage();
simtime_t timeout = par("bpTime"); //bptime is of type double
scheduleAt(simTime()+timeout, Newmsg); //this is what is causing the error
cModule *target;
target = getParentModule()->getSubmodule("accesspoint");
sendDirect(Newmsg,target,"radioIn"); //how do I create delay before using this line of code
}
void Test::handleMessage(cMessage *msg)
{
// TODO - Generated method body
}
myMessage *Test::createMessage(){
//code intentionally left out
}