Access a Network parameter

725 views
Skip to first unread message

De

unread,
Jul 6, 2010, 11:06:34 AM7/6/10
to omnetpp
I have created a cSimpleModule class in my simulation and I am trying
to access a parameter created in the network part of the ned file.
Simply using the par() function doesn't work because that tries to
access parameters from the corresponding module in the ned file. But I
want something from the network. Is there a way I can do this?

C++ file:

GoodGuy::GoodGuy(){
...
// ***These are the values I want access to***
numG = par("numGood");
numB = par("numBad");
}

NED file:

simple GoodGuy{
gates:
input port @directin @loose;
}

network Lizzy{
parameters:

// ***These are the parameters in the network***
// ***See how I need them in the network scope here.***

int numGood @prompt("Number of good guys?");
int numBad = intuniform(0,numGood);

submodules:
G[numGood]: GoodGuy;
B[numBad]: BadGuy ;
}

De

unread,
Jul 7, 2010, 9:36:21 AM7/7/10
to omnetpp
Btw, I know this looks like a lot of code to read, but the code isn't
necessary to answer my question. It's just there for clarifications.

HAEFLINGER, PATRICK (PATRICK)

unread,
Jul 7, 2010, 9:42:48 AM7/7/10
to omn...@googlegroups.com

Hi,

 

You can either use :

 

numG = getParentModule()->par("numGood");

 

This has to be adapted depending on your topology...

 

or use the first upper level module holding the parameter you are looking for :

 

numG = getAncestorPar(("numGood");

 

Patrick

 

 

-----Message d'origine-----
De : omn...@googlegroups.com [mailto:omn...@googlegroups.com] De la part de De
Envoyé : mardi 6 juillet 2010 17:07
À : omnetpp
Objet : [Omnetpp-l] Access a Network parameter

--

You received this message because you are subscribed to the Google Groups "omnetpp" group.

To post to this group, send email to omn...@googlegroups.com.

To unsubscribe from this group, send email to omnetpp+u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/omnetpp?hl=en.

 

De

unread,
Jul 7, 2010, 11:52:25 AM7/7/10
to omnetpp
Thank you for the suggestion but it gave me a runtime error. I think
because those options are still looking for the values in module
parameters, but the ones I want are in the network parameters. And
I've yet to find any methods to get to network parameters.

I tried grouping some things into a compound module and then using the
methods you suggested but then things messed up with the prompt
messages.

-De

Andras Varga

unread,
Jul 7, 2010, 12:33:50 PM7/7/10
to omn...@googlegroups.com
simulation.getSystemModule()->par("bla");

system module == the toplevel module in the model == "the network"

Andras

-De

--

De

unread,
Jul 7, 2010, 4:09:18 PM7/7/10
to omnetpp
Thanks, I think that worked. My program is still finicky, but I think
that's a separate issue.

Thank You both again, you're always very helpful.

-De
Reply all
Reply to author
Forward
0 new messages