codinghard

主要四个函数:

  1.  initialize();       (初始化变量,调度初始化事件,如调用2)不是构造器
  2.  handleMessage(cMessage *msg);
    • send()  发消息给别的模块
    • scheduleAt()  给自己发消息
    • cancelEvent()      删除一个scheduleAt()调度事件
  3. activity();
  4.  finish();        仿真结束记录统计信息。不是构析器。

.h文件

#include <omnetpp.h>

using namespace omnetpp;

namespace sin {   //包名,项目名


class Txc : public cSimpleModule
{
  protected:
    virtual void initialize();
    virtual void handleMessage(cMessage *msg);
    virtual void finish();
};

}; 

.cc文件

#include "Txc.h"

namespace sin {

Define_Module(Txc);

void Txc::initialize()
{
    if (par("sendInitialMessage").boolValue())
    {
        cMessage *msg = new cMessage("tictocMsg");
        send(msg, "out");
    }
}

void Txc::handleMessage(cMessage *msg)
{
    send(msg, "out");
}

}; // namespace

 

分类:

技术点:

相关文章:

  • 2022-01-10
  • 2021-08-17
  • 2022-12-23
  • 2021-12-16
  • 2021-10-05
  • 2021-06-16
猜你喜欢
  • 2021-09-25
  • 2021-09-25
  • 2021-09-25
  • 2021-10-05
  • 2021-07-11
  • 2021-06-01
  • 2021-08-06
相关资源
相似解决方案