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)
上一篇 2025年6月6日 上午7:22
下一篇 2025年6月6日 上午8:01


相关推荐

  • JETSON ORIN NANO系列入门教程(一、产品介绍)

    JETSON ORIN NANO系列入门教程(一、产品介绍)

    2026年3月13日
    3
  • latex多行公式一个编号_组合公式大括号

    latex多行公式一个编号_组合公式大括号本文的主要内容有:如何输入行内公式如何输入行间公式、多行公式常用的数学符号输入方法相信观察力敏锐的同学一定已经注意到在上一次的推送里的这段代码:\documentclass[a4paper,12pt,landscape,twocolumn]{book}\usepackage{amsmath}\begin{document}$\frac{x}{y}$\[\i…

    2022年10月9日
    6
  • MongoDB 客户端工具(图)

    MongoDB 客户端工具(图)转自 nbsp http hi baidu com shepherdnewa blog item 962368f05d1f htmlhttp www javabloger com article mongodb gui win linux mac htmlNoSQL 的运动不止 MongoDB 作为其中的主力军发展迅猛 但是图形化工具少见

    2026年3月17日
    2
  • 网页视频下载mp4格式到本地

    发现个网页视频地址下载成mp4格式的资源,分享给大家:git下载地址:​​​​​​​https://gitee.com/tiankf/mp4如果本文对你有帮助还麻烦赞一下,在此感谢啦!

    2022年4月7日
    42
  • 画平行线的四种方法_苏教版画垂线教学反思

    画平行线的四种方法_苏教版画垂线教学反思平行线的画法教学反思(通用3篇)作为一名优秀的人民教师,我们的任务之一就是课堂教学,教学的心得体会可以总结在教学反思中,来参考自己需要的教学反思吧!下面是小编整理的平行线的画法教学反思(通用3篇),欢迎大家分享。平行线的画法教学反思1每到学习平行线的画法,总有学生学起来感到困难,用尺子移来移去,实在太麻烦,而且学生在以后也不容易记住。正是基于这样的认识画平行线的教学只能由教师传授给学生,他们也只能…

    2026年2月1日
    5
  • linux 复制文件夹内所有文件到另一个文件夹

    linux 复制文件夹内所有文件到另一个文件夹cp-Rf/home/user1/*/root/temp/将/home/user1目录下的所有东西拷到/root/temp/下而不拷贝user1目录本身。即格式为:cp-Rf原路径/目的路径/

    2022年8月23日
    7

发表回复

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

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