Getting the location of two different modules

2019-08-08 08:36发布

问题:

I have 2 types of submodules in my network.

  1. AdhocHost which is standard definition in INET framework.
  2. module of type IMobility with its mobility type of type RandomWPMobility, both are standard INET modules.

I can get the location of modules of type AdhocHost by this code:

module = simulation.getModuleByPath("Mynet.host[1]");
c = MobilityAccess().get(module)->getCurrentPosition();

host[*] being of type AdhocHost.

But when I replace host[1] with blockage[1] (blockage is of type IMobility), before running simulation this error appears:

Error in module (MyMobileController) Mynet.mymobilecontroller during network initialization: Model error: module (IMobility)mobility not found.

The module mymobilecontroller is the module that contains this fraction of code. This module does not need to move. Its duty is just to record the location of mobile modules in the network.

What is the problem?

回答1:

The 'MobilityAccess' code expects that you pass a NetworkNode to it that contains a submodule named mobility with the type IMobility. In the first case it is true (with a StandardHost) however in the second case you pass directly an module that has a type of IMobility.

Long story short, a module with a type of IMobility is meant to exist INSIDE of a network node and not at the network level.

Solution: I'm not sure what is the blockage module supposed to do, but it should NOT be a type of IMobility, instead it should be a module that contains a submodule with a type IMobility.



标签: omnet++