Search code examples
omnet++inet

Can I set the node position in the .ini file or programmatically?


While I can set the node position in the .ned file

hostA: <default("WirelessHost")> like INetworkNode {
        @display("p=300,400");
    }

is it possible to specify the position in the .ini file like *.hostA.**.setPosition(posX, posY)

or in the App source file?

*.hostA.numApps = 1
*.hostA.app[0].typename = "MyApp"

am using omnetpp-5.4.1 and inet-4.0.0


Solution

  • By using the @display string, you define the rendering of the module in graphical environments. This is not related to a physical position of a node in the default case.

    What you like to have is a module that implements the IMobility interface. What this means is that the according instance must be an existing module interface, which the concrete module type must implement. An example for this can be found in the INET example mobility. The module you should have a look to is called MobileHost. By using an implementation like this, you can set the position of the module in the omnetpp.ini file:

    **.host[0].mobility.initialX = 50m
    **.host[0].mobility.initialY = 200m
    

    However, you can also use the @display string in this case by setting:

    **.host[0].mobility.initFromDisplayString = true