新的语法结构,采用了大括号

simple Mobility
{
    parameters:
        
double  MinSpeed;
        
double  MaxSpeed;
    @display(
" i=block/broadcast " );
    gates:
        output 
out ;
}
 

simple BottomLayer
{
    @display(
" i=block/table " );
    gates:
        input fromMobility;
        input fromPosition;
        output toPosition;
}
 

simple Position
{
    @display(
" i=block/cogwheel " );
    gates:
        input fromBottom;
        output toBottom;
}


module MobileHost
{
    @display(
" i=device/laptop " );
    submodules:
        bottomLayer: BottomLayer 
{
            @display(
" p=133,43 " );
        }

        mobility: Mobility 
{
            @display(
" p=236,43 " );
        }

        position: Position 
{
            @display(
" p=133,126 " );
        }

    connections:
        mobility.
out   -->  bottomLayer.fromMobility;
        position.toBottom 
-->  bottomLayer.fromPosition;
        bottomLayer.toPosition 
-->  position.fromBottom;
}
 



新的like语法

moduleinterface Mobility    // 被like的模块不再是simple,变为moduleinterface
{
    parameters:
        
double  minSpeed;       // 最小速度
         double  maxSpeed;      //  最大速度
         double  movKind;       //  节点运动到边界时的处理方式
         double  XRange;        //  节点布置区域的宽度
         double  YRange;        //  节点布置区域的长度
         double  pauseTime;     //  到达一个目标后的等待时间
         double  moveInterval;  //  两步之间的时间
        @display( " i=block/cogwheel,blue " );
    gates:
        output 
out ;
}


simple bottomLayer
{
    parameters:
        
double  seed_r;     //  锚节点的通信半径
         double  node_r;    //  待定位节点的通信半径
         double  isSeed;    //  是否是锚节点
        @display( " i=block/table,blue " );
    gates:
        input fromMobility;
        input fromPosition;
        output toPosition;
}


moduleinterface Positioning
{
    parameters:
        
double  isSeed;             // 是否是锚节点
         double  announceInterval;  //  锚节点广播自身位置的时间间隔
         double  updateInterval;    //  待定位节点两次定位间的时间间隔
         double  seed_r;            //  锚节点的通信半径
         double  node_r;            //  待定位节点的通信半径
         double  max_v;             //  最大速度
         double  delta;             //  抽样点可能的误差
        @display( " i=block/circle,blue " );
    gates:
        input fromBottom;
        output toBottom;
}

module MobileHost
{
    parameters:
        
int  isSeed;      // 是否是锚节点
         int  numHost;    //  总的结点数
         double  x;       //  真实位置的x坐标
         double  y;       //  真实位置的y坐标
         double  Xbound;  //  布置区域的宽度
         double  Ybound;  //  布置区域的长度
         double  seed_r;  //  锚节点的通信半径
         double  node_r;  //  待定位节点的通信半径
         string  mobilityModel;  //  移动模型
         string  posAlgorithm;   //  定位算法
    submodules:
        mobility: 
< mobilityModel >  like Mobility  { // 新的like语法,增加尖括号
            XRange 
=  Xbound;        // 增加大括号,parameters变为可选
            YRange 
=  Ybound;
            @display(
" p=96,77 " );
        }

        bottomlayer: bottomLayer 
{
            isSeed 
=  isSeed;
            seed_r 
=  seed_r;
            node_r 
=  node_r;
            @display(
" p=279,77 " );
        }

        position: 
< posAlgorithm >  like Positioning  {
            isSeed 
=  isSeed;
            seed_r 
=  seed_r;
            node_r 
=  node_r;
            max_v 
=  INPUT;
            delta 
=  INPUT;
            announceInterval 
=  INPUT;
            updateInterval 
=  INPUT;
            @display(
" p=279,170 " );
        }

    connections:
        mobility.
out   -->  bottomlayer.fromMobility;
        position.toBottom 
-->  bottomlayer.fromPosition;
        bottomlayer.toPosition 
-->  position.fromBottom;
}


新的子模块数组定义方式
module MobileSensorNet
{
    parameters:
        
int numHost;
        
double anchorFraction;
        
double playgroundSizeX;
        
double playgroundSizeY;
        @display(
"i=block/network2");
    submodules:
        seed[numHost 
* anchorFraction]: MobileHost { //新的子模块数组定义方式
            isSeed 
= 1;
            numHost 
= numHost;
            Xbound 
= playgroundSizeX;
            Ybound 
= playgroundSizeY;
            x 
= intuniform(0,playgroundSizeX);
            y 
= intuniform(0,playgroundSizeY);
        }

        node[numHost 
- numHost * anchorFraction]: MobileHost {
            isSeed 
= 0;
            numHost 
= numHost;
            Xbound 
= playgroundSizeX;
            Ybound 
= playgroundSizeY;
            x 
= intuniform(0,playgroundSizeX);
            y 
= intuniform(0,playgroundSizeY);
        }

}


总之,越来越像C++了