OMNET++在定义网络(network)或复合模块(module)A时,其子模块可能为其他复合模块B的对象。此时,在A中无法访问B的子模块,因此,若B的子模块与A有接口,则需定义B的外部接口。
simple C{
gates:
inout cg[];
}
module B{
gates:
inout bg[];
submodules:
c1 C;
c2 C;
connections:
c1.cg++ <--> bg++;
c2.cg++ <--> bg++;
}.
network A{
submodules:
b1:B{
gates:
bg[];
}
b2:B{
gates:
bg[];
}
connections:
b1.bg++ <--> b2.bg++;
b1.bg++ <--> b2.bg++;
}
注意:A模块中,有b1和b2两个B模块的对象,两者的外部接口bg的size均为2,则在B模块中,外部接口bg的size需小于或等于2。