在tictoc5中.ned文件使用了通配符
将tic和toc的计数器最大值都设为了5,由于ini文件的优先级别高所以txc5.cc文件中的设置没有起到作用
运行结果:
另外在tictoc5中:我们可以创建一个新的简单模型通过继承从其他一和指定 或压倒一切的一些参数。 在我们的情况下,我们将获得两个简单的 模块类型( Tic 和 Toc).
simple Txc5
{parameters:bool sendMsgOnInit = default(false);int limit = default(2);@display("i=block/routing");gates:input in;output out;
}//
// Specialize the module by defining parameters. We could have left the whole body
// empty, because the default value of the sendMsgOnInit parameter is false anyway.
// Note that the limit parameter is still unbound here.
//
simple Tic5 extends Txc5//注意到我们是从TXc5中继承的,只是修改了一些参数
{parameters:@display("i=,cyan");sendMsgOnInit = true; // Tic modules should send a message on init
}//
// Specialize the module by defining parameters. We could have left the whole body
// empty, because the default value of the sendMsgOnInit parameter is false anyway.
// Note that the limit parameter is still unbound here.
//
simple Toc5 extends Txc5
{parameters:@display("i=,gold");sendMsgOnInit = false; // Toc modules should NOT send a message on init
}//
// Adding module parameters.
//
network Tictoc5
{submodules:tic: Tic5; // the limit parameter is still unbound here. We will get it from the ini filetoc: Toc5;connections:tic.out --> { delay = 100ms; } --> toc.in;tic.in <-- { delay = 100ms; } <-- toc.out;
}