更详细视频教程参考《OMNeT++TicToc案例精讲》https://edu.csdn.net/course/detail/30015
class Txc1 : public cSimpleModule
{
protected:
// The following redefined virtual function holds the algorithm.
virtual void initialize() override;
virtual void handleMessage(cMessage *msg) override;
};
// The module class needs to be registered with OMNeT++
//所有模块实现时,必须添加Define_Module(XXX);
Define_Module(Txc1);
//初始化函数
void Txc1::initialize()
{
// Am I Tic or Toc?
//getName当前实例的名称,也就是NED中模块实例的名称
if (strcmp("tic", getName()) == 0) {
// create and send first message on gate "out". "tictocMsg" is an
// arbitrary string which will be the name of the message object.
//定义消息,消息名称
cMessage *msg = new cMessage("tictocMsg");
//消息发送
send(msg, "out");
}
}
//消息处理函数
void Txc1::handleMessage(cMessage *msg)
{
// 消息发送
send(msg, "out"); // send out the message
}
最后
以上就是喜悦小蘑菇最近收集整理的关于omnet++ tictoc1 实例分析的全部内容,更多相关omnet++内容请搜索靠谱客的其他文章。
发表评论 取消回复