概述
更详细视频教程参考《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++ tictoc1 实例分析所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复