我已经开发了一个场景,首先车辆发送自己的消息,并在接收到自己的消息时向车辆局发送消息。只发送一次消息,而不是定期发送消息
自我讯息码写在initialize()
方法中。但在模拟过程中,车辆每秒都会将消息发送给RSU。
我希望邮件只发送一次。我该怎么办? 我附上了我的TraciDemo11p.cc类的handleSelfmessage方法。
if(msg->isSelfMessage()==true)
{
cModule *tmpMobility = getParentModule()->getSubmodule("veinsmobility");
mobility = dynamic_cast<Veins::TraCIMobility*>(tmpMobility);
ASSERT(mobility);
t_channel channel = dataOnSch ? type_SCH : type_CCH;
WaveShortMessage* wsm = prepareWSM("data", dataLengthBits, channel, dataPriority, -1,2);
wsm->setSenderAddress(myAddress);
wsm->setRecipientAddress(1001);
sendMessage(wsm->getWsmData());
}
也包含'initialize()'函数的代码 – user4786271
你究竟把这个代码放在哪里?它是否在[TraCIDemo11p.cc]的'handleSelfMsg'中(https://github.com/sommer/veins/blob/veins-4.5/src/veins/modules/application/traci/TraCIDemo11p.cc)? –