wsm消息发送者的外部ID

问题描述 投票:0回答:1

我正在使用omnet 5.0,sumo-0.25.0和venles-4.4。车辆收到消息时; onData()被调用。我可以使用mobility->getExternalId()获取当前车辆的外部ID;但是我怎么知道wsm邮件发件人

的外部ID

initialize()的代码:

void TraCIDemo11p::initialize(int stage) {
    BaseWaveApplLayer::initialize(stage);
    if (stage == 0) {
        mobility = TraCIMobilityAccess().get(getParentModule());
        traci = mobility->getCommandInterface();
        traciVehicle = mobility->getVehicleCommandInterface();
        annotations = AnnotationManagerAccess().getIfExists();
        ASSERT(annotations);
        getExternalID =  mobility->getExternalId();
        sentMessage = false;
        lastDroveAt = simTime();

        findHost()->subscribe(parkingStateChangedSignal, this);
        isParking = false;
        sendWhileParking = par("sendWhileParking").boolValue();
    }
}

onData()的代码:

void TraCIDemo11p::onData(WaveShortMessage* wsm) {
    std::cout << " I am "<< getExternalID  <<"and I received a message from ???? "<<endl;
    findHost()->getDisplayString().updateWith("r=16,green");
    annotations->scheduleErase(1, annotations->drawLine(wsm->getSenderPos(), mobility->getPositionAt(simTime()), "blue"));

    if (mobility->getRoadId()[0] != ':') 
          traciVehicle->changeRoute(wsm->getWsmData(), 9999);
    if (!sentMessage) 
          sendMessage(wsm->getWsmData());

}
omnet++ veins sumo
1个回答
0
投票

一辆汽车可以用两个标识符表示,一个是从SUMO获得的(即调用getExternalId()),也可能是veins的一个(通常是myId) ,调用getSenderAddress()后在WaveShortMessage中使用的是myId,所以我建议您集中注意最后一个。

[查看这两个文件,以更好地了解所使用的标识符和现有方法:“ BaseWaveApplLayer.h / .cc”和“ WaveShortMessage_m.h / .cc”

我希望这会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.