tiktok案例分析_metaobject

tiktok案例分析_metaobjecttictoc12.ned文件//input:指定当前门是输入门,只能和输出门连接,只能接受消息//output:当前门是输出门,只能和输入门连接,只能发送消息//inout:既是输入门又是输出门,既能发送消息也能接受消息simpleTxc12{parameters:@display(“i=block/routing”);gates:inoutgate[];//declaretwowayconnections声明双向连接}

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全家桶1年46,售后保障稳定

tictoc12.ned文件

//input:指定当前门是输入门,只能和输出门连接,只能接受消息
//output:当前门是输出门,只能和输入门连接,只能发送消息
//inout:既是输入门又是输出门,既能发送消息也能接受消息

simple Txc12
{ 
   
    parameters:
        @display("i=block/routing");
    gates:
        inout gate[];  // declare two way connections声明双向连接
}

// using two way connections to further simplify the network definition
network Tictoc12
{ 
   
    types:
        channel Channel extends ned.DelayChannel { 
   
            delay = 100ms;
        }
    submodules:
        tic[6]: Txc12;
    connections:
        tic[0].gate++ <--> Channel <--> tic[1].gate++;
        tic[1].gate++ <--> Channel <--> tic[2].gate++;
        tic[1].gate++ <--> Channel <--> tic[4].gate++;
        tic[3].gate++ <--> Channel <--> tic[4].gate++;
        tic[4].gate++ <--> Channel <--> tic[5].gate++;
}

Jetbrains全家桶1年46,售后保障稳定

Txc12.cc文件

//输入输出门向量,随机消息发送

#include <stdio.h>
#include <string.h>
#include <omnetpp.h>
using namespace omnetpp;

/** * Let's make it more interesting by using several (n) `tic' modules, * and connecting every module to every other. For now, let's keep it * simple what they do: module 0 generates a message, and the others * keep tossing it around in random directions until it arrives at * module 2. */
class Txc12 : public cSimpleModule
{ 
   
  protected:
    virtual void forwardMessage(cMessage *msg);
    virtual void initialize() override;
    virtual void handleMessage(cMessage *msg) override;
};

Define_Module(Txc12);

void Txc12::initialize()
{ 
   
    if (getIndex() == 0) { 
   
        // Boot the process scheduling the initial message as a self-message.
        char msgname[20];
        sprintf(msgname, "tic-%d", getIndex());
        cMessage *msg = new cMessage(msgname);
        scheduleAt(0.0, msg);
    }
}

void Txc12::handleMessage(cMessage *msg)
{ 
   
    if (getIndex() == 3) { 
   
        // Message arrived.
        EV << "Message " << msg << " arrived.\n";
        delete msg;
    }
    else { 
   
        // We need to forward the message.
        forwardMessage(msg);
    }
}

void Txc12::forwardMessage(cMessage *msg)
{ 
   
    // In this example, we just pick a random gate to send it on.在这个例子中,我们只需选择一个随机门来发送它。
    // We draw a random number between 0 and the size of gate `gate[]'.我们画了一个介于0和“gate[]”大小之间的随机数。
    int n = gateSize("gate");
    int k = intuniform(0, n-1);
    EV << "Forwarding message " << msg << " on gate[" << k << "]\n";
    // $o and $i suffix is used to identify the input/output part of a two way gate。$o和$i后缀用于标识双向门的输入/输出部分
    //inout门发送消息,门的名称+“$o”表示输出门,门的名称+“$i”表示输入门
    send(msg, "gate$o", k);
}

omnetpp.ini

[Config Tictoc12]
network = Tictoc12
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/234383.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • python 进制转换[通俗易懂]

    python 进制转换[通俗易懂]文章目录前言一、Python提供的进制转换方法1.二进制转十进制2.八进制转十进制3.十六进制转十进制4.十进制转十六进制5.十进制转二进制6.十进制转八进制二、自定义进制转换1.转十进制2.十进制转七进制总结前言十进制是我们常用的数字形式,但机器使用的却是二进制,八进制,十六进制之类的,所以进制转换是基础要求,很多编程语言提供的有进制转换的方法,下面我们开始学习一、Python提供的进制转换方法1.二进制转十进制s=’1001’print(int(s,2))结果如下:in..

    2022年5月12日
    53
  • mybatis 创建SqlSessionFactory

    mybatis 创建SqlSessionFactory创建SqlSessionFactory有两种方式:一种是通过XML,另一种是通过Java代码。Stringresource="org/mybatis/example/mybatis-config.xml";InputStreaminputStream=Resources.getResourceAsStream(resource);SqlSessionFactorysqlSess…

    2022年5月5日
    49
  • 用什么软件写html语言,写html代码用什么软件

    用什么软件写html语言,写html代码用什么软件写html代码的软件:1、SublimeText;2、Dreamweaver;3、WebStorm;4、HBuilder;5、Notepad;6、VSCode;7、Vim;8、AptanaStudio;9、IntelliJIDEA。本教程操作环境:windows7系统、HTML5版、DellG3电脑。1、SublimeTextSublimeText是一个跨平台的代码编辑器,同时支持W…

    2022年5月30日
    58
  • mount CIFS return ERR -12 and report Cannot allocate memory[通俗易懂]

    mount CIFS return ERR -12 and report Cannot allocate memory

    2022年1月28日
    64
  • Spring Boot 无侵入式 实现API接口统一JSON格式返回

    点击上方“全栈程序员社区”,星标公众号 重磅干货,第一时间送达 作者:小魏小魏我们去那里呀 blog.csdn.net/qq_34347620/article/details/10…

    2021年6月24日
    106
  • Qt5 QMediaPlayer 音乐播放器

    Qt5 QMediaPlayer 音乐播放器   暑假用Qt写的音乐播放器,界面有点丑,然后功能也有点少,还有一些bug,然后现在趁着寒假的时间把之前的界面给改了一下,并添加了一些功能,修改了一些bug,实现功能包括基本的歌曲播放暂停,上一首,下一首,添加歌曲,添加为我喜欢,添加至我的收藏,最近播放,列表的右键菜单,主窗口的右键菜单,删除歌曲,多选,查看歌曲信息,改变播放模式(顺序播放,随机播放,单曲循环),歌曲定位,清除列表,换皮肤…

    2022年5月30日
    40

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号