如何根据每条消息发送“结构”向量?

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

我正在尝试为每条消息发送“结构”的向量,但是在定义消息字段时会产生以下错误:

进入目录'/home/veins/workspace.omnetpp/veins/src'静脉/模块/应用程序/clustertraci/ClusterTraCI11p.cc静脉/模块/应用程序/clustertraci/ClusterTraCI11p.cc:160:40:错误:没有从“向量”到“常量向量”的可行转换frameOfUpdate-> setUpdateTable(updateTable);

我阅读了OMnet ++手册的第6章,但我不知道如何解决此问题。

Message Code

Code Implementation

消息代码(MyMessage.msg):

cplusplus {{
#include "veins/base/utils/Coord.h"
#include "veins/modules/messages/BaseFrame1609_4_m.h"
#include "veins/base/utils/SimpleAddress.h"
#include <iostream>
#include <vector>

struct updateTableStruct {
        int car;
        char update;
};

typedef std::vector<updateTableStruct> UpdateTable;
}}


namespace veins;

class BaseFrame1609_4;
class noncobject Coord;
class noncobject UpdateTable;
class LAddress::L2Type extends void;

packet ClusterMessageUpdate extends BaseFrame1609_4 {
    LAddress::L2Type senderAddress = -1;
    int serial = 0;

    UpdateTable updateTable;

MyApp.cc:

void ClusterTraCI11p::handleSelfMsg(cMessage* msg) {
     if (ClusterMessage* frame = dynamic_cast<ClusterMessage*>(msg)) {

         ClusterMessageUpdate* frameOfUpdate = new ClusterMessageUpdate;
         populateWSM(frameOfUpdate, CH2);
         frameOfUpdate->setSenderAddress(myId);
         frameOfUpdate->setUpdateTable(updateTable);
         sendDelayedDown(frameOfUpdate, uniform(0.1, 0.02));

    }
    else {
        DemoBaseApplLayer::handleSelfMsg(msg);
    }
}

MyApp.h中用于分析的部分代码:

  struct updateTableStruct {
        int car;
        char update;
    };

    typedef std::vector<updateTableStruct> UpdateTable;
    UpdateTable updateTable;

omnet++ veins
1个回答
0
投票

您遇到类型不匹配:在MyApp.h中定义类型UpdateTable,然后在MyMessage.h中定义类型。虽然这两种类型具有相同的内容,并且appear

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