0
votes

Suppose I have the following simple module defined in Client.ned:

simple Client
{
    parameters:
        volatile int xServerCoord = 1;
        volatile int yServerCoord = 2;
}

Also suppose that we have the following network defined in Network.ned:

network Traditional
{
    parameters:
        volatile int xDiff = intuniform(-20,20);
        volatile int yDiff = intuniform(-20,20);
    submodules:
        client: Client {
            parameters:
                xCoord = xServerCoord + xDiff;
                yCoord = yServerCoord + yDiff;
                @display("p=$xCoord,$yCoord");
    };
}

When I try to run the simulation, I get the following error:

Cannot evaluate parameter 'xCoord': (omnetpp::cModule)Traditional: Unknown parameter 'xServerCoord' -- during network initialization

Is it possible for me to read the xServerCoord and yServerCoord parameters within Network.ned?

Thanks.

1

1 Answers

1
votes

The definition of a parameter in NED requires indication of type, for example:

parameters:
    int xServerCoord;
    int yServerCoord;

It is possible to assign a value of parameter in NED, for example:

 parameters:
    int xServerCoord = 1;

but one should be aware that this value cannot be later modified, because according to OMNeT++ Manual:

A non-default value assigned from NED cannot be overwritten later in NED or from ini files; it becomes “hardcoded” as far as ini files and NED usage are concerned. In contrast, default values are possible to overwrite.

The better solution is to assign default value, for example:

 parameters:
    int xServerCoord = default(1);

To use a parameter from other module, the name of the module has to be used before the name of parameter.

Therefore the network definition may look like:

network Traditional
{
    parameters:
        volatile int xDiff = intuniform(-20,20);
        volatile int yDiff = intuniform(-20,20);
    submodules:
      client: Client {
        parameters:
            client.xServerCoord = client.xServerCoord + xDiff;
            client.yServerCoord = client.yServerCoord + yDiff;

  };
}