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年10月25日
    3
  • ScaleAnimation开始结束位置分析[通俗易懂]

    ScaleAnimation开始结束位置分析[通俗易懂]做项目的时候,需要用到动画,大小和位置都不一样。刚开始想到的是ScaleAnimation和TranslateAnimation进行组合,但实验后发现,目标位置始终不对,只用TranslateAnimation是没有问题,所以ScaleAnimation应该不只是进行了缩放经过查找资料,发现ScaleAnimation还进行起始位置的移动。ScaleAnimation分为两种情况,从本身的位置…

    2022年10月15日
    1
  • 在Windows 8.1及IE 11中如何使用HttpWatch

    在Windows 8.1及IE 11中如何使用HttpWatch

    2021年8月26日
    53
  • Subprocess报FileNotFoundError

    Subprocess报FileNotFoundErrorSubprocess报FileNotFoundError代码如下:运行时报错,FileNotFoundError:pipenv解决方案:因为pipenv找不到,所以需要指定全路径​whichpipenv#结果显示/root/anaconda3/bin/pipenv#因此修改代码中pipenv为全路径的,可成功运行另外,报FileNotFoundError…

    2025年6月12日
    2
  • ipsec iptables_iptables -p

    ipsec iptables_iptables -piptablesiptables[-t表名]命令选项[链名][条件匹配][-j目标动作或跳转]-t表名可以省略,指定规则存放在哪个表中,默认为filter表用于存放相同功能的规则filter表:负责过滤功能能,nat表:网络地址转换功能mangle表:拆解报文做出修改并重新封装的功能raw表:关闭nat表上启用的连接追踪机制命令选项-A在…

    2022年10月7日
    3
  • IIC软件协议及硬件知识汇总

    IIC软件协议及硬件知识汇总IIC软件协议及硬件相关知识,真的是非常齐全了!

    2022年7月22日
    10

发表回复

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

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