我正在尝试为每条消息发送一个“结构”向量,但是在定义消息字段时会生成以下错误:
进入目录 '/home/veins/workspace.omnetpp/veins/src' 静脉/模块/应用程序/clustertraci/ClusterTraCI11p.cc 静脉/模块/应用程序/clustertraci/ClusterTraCI11p.cc:160:40:错误:从'没有可行的转换向量'到'常量向量' frameOfUpdate->setUpdateTable(updateTable);
我阅读了 OMnet ++ 手册的第 6 章,但我不明白如何解决这个问题。
消息代码(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;
我的应用程序.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;