【问题标题】:Can I create omnet++ cc source file for INET module StandaredHost or any module我可以为 INET 模块 StandaredHost 或任何模块创建 omnet++ cc 源文件吗
【发布时间】:2017-03-20 17:53:04
【问题描述】:

我不知道这个问题听起来如何,但我是这里询问有关科学的任何问题的最佳场所。

我正在尝试为 INET 模式创建一个 cc omnet++ 源文件。就像我们在简单模块中所做的那样,我们使用 cSimpleModule 简单地继承该类,然后我们实现 Initialize 和 handleMessage 方法。我尝试创建一个 cc 源文件,然后由 StandaredHost 继承它并声明这两个方法初始化和 handleMessge,但它不起作用。

我想知道这样做的正确方法。

我想要实现的是,我想为每个模块制作一个源文件,当我可以探测消息、安排它、应用其他排队算法时,就像我们做简单模块一样。

【问题讨论】:

    标签: omnet++ inet


    【解决方案1】:

    来自INETStandardHostcompound module。通常复合模块包括simple modules。在OMNeT++ 中,为简单模块定义了行为。所以不能为复合模块定义 C++ 类。

    【讨论】:

    • 不是 100% 正确,可以为复合模块定义 C++ 代码,手册指出:Although the C++ class for a compound module can be overridden with the @class property, this is a feature that should probably never be used. Encapsulate the code into a simple module, and add it as a submodule.The user defines simple module types by subclassing cSimpleModule. Compound modules are instantiated with cModule, although the user can override it with @class in the NED file, and can even use a simple module C++ class (i.e. one derived from cSimpleModule) for a compound module.
    • @MichaelKirsche:你写的是真的。但是,复合模块的 C++ 类不能发送消息,也不能处理传入的消息。只有cSimpleModule 实现了handleMessage() 并且能够发送消息。
    • 绝对真实的 Jerzy,行为应该进入简单的模块。和手动状态一样,最好将代码封装成一个简单的模块,添加到子模块中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-09
    相关资源
    最近更新 更多