Simple signaling problem

512 views
Skip to first unread message

Konstantin Boyanov

unread,
Sep 1, 2010, 7:49:19 AM9/1/10
to omnetpp
Hello all,

I am new to the OMNeT++ environment and I am sorry if my question was
answered already, I just didn't managed to find any reference up until
now.

I am trying to pass a very simple signal between two modules, a
modified Source module from the queueinglib example and a simple
module I made on my own (named IOcontroller).

I extended the definition of the Source class like follows:

class QUEUEING_API Source : public SourceBase, public
cListener
{
...
}

and also added a public signal handling function

public:
virtual void receiveSignal(cComponent *src, simsignal_t
id, long l);

In the initialization function of my IOcontroller module I register
the signal like follows:

iocBusySignal = registerSignal("IOCmoduleIsBusy");

and then in the handleMessage function of the IOcontroller module I
emit a signal every time the down strem link is still busy:

emit(iocBusySignal, 0);

In the Source module I subscribe to the signal like follows (in the
initialize function):

subscribe("IOCmoduleIsBusy", this);

but It seems that my receiveSignal() function is never being called,
although I am sure that the signal is emited (I emit it every time the
handleMessage is called, just for testing). My receiveSignal looks
like this:

void Source::receiveSignal(cComponent *src, simsignal_t id, long l){
// if received the signal, do not allow further messages to be
scheduled for "creation"
EV << this->getFullName() << ": received SEND BLOCKED Signal from
IOC!" << endl;
sendBlocked = true;
}

Any idea why I am not getting the signals, e.g. the receiveSignal()
function called?

Many thanks,
Konstantin Boyanov

Konstantin Boyanov

unread,
Sep 2, 2010, 7:11:09 AM9/2/10
to omnetpp
Hi again,

Could anyone just post a simple example of defining, subscribing and
using signals please?

Many thanks,
Konstantin

Rudolf Hornig

unread,
Sep 2, 2010, 12:17:38 PM9/2/10
to omn...@googlegroups.com
One idea: You are registering the signal in the initialize function of IOcontroller while you are subscribing to it in the initialize function of Source... Now the issue might be that it is NOT defined in what order the different submodule's init functions are called. It might be that The Source.init is executed first and IOcontroller.init is only after that... (at the monet inits are called in the order of appearance in the ned file, but this might change anytime)

Try to put IOcontroller BEFORE Source in your NED file to test the hipothesis. But please note that this is UNDEFINED behavior. The correct handling would be to have multi stage init where registrations are taking place in the first stage and subscriptions in the second...

Rudolf


--
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.


Konstantin Boyanov

unread,
Sep 3, 2010, 7:40:46 AM9/3/10
to omnetpp
Hi,

I modified my code to support two staged initialization, where the
signal registration is done in stage 0 and signal subscription is done
in stage 1. But still the receiveSignal() function of the Source does
not get called during the simulation (according to my lame printf
debugging).

Can it be a problem if i register my signal in IOcontroller with a
string name for the signal, like this:

iocBusySignal = registerSignal("IOCmoduleIsBusy");

and then in the Source module use the same string in the subscribe()
function like this:

subscribe("IOCmoduleIsBusy", this);

Of course the Source module is subsclassed from cListener.

Many thanks,
Konstantin

Konstantin Boyanov

unread,
Sep 6, 2010, 6:07:07 AM9/6/10
to omnetpp
Hello,

I am really stuck with this singlaing issue and cannot understand why
my singals don't get caught (i.e. receiveSignal does not get called)?

Any ideas on this could be helpful, so do not hesitate to reply :)

Many thanks,
Konstantin

Konstantin Boyanov

unread,
Sep 7, 2010, 7:22:27 AM9/7/10
to omnetpp
Hello again,

I found an issue that brought me a step further - there was no
declaration of the signal I want to send in the .ned file of my
module, like:

@signal[IOCmoduleIsBusy](type="long");

But this also could not help me get my signal handling function get
called. Do I need some special entries in other ned files (for example
the ned file for the module receiveing the signal)? What are all the
places where I should deifine my signals (other than ned files and C++
classes)? Do I need additional configuration parameters for the
signals in the ini files?

Many thanks,
Konstantin

Andras Varga

unread,
Sep 7, 2010, 9:20:12 AM9/7/10
to omn...@googlegroups.com
Actually, at the moment @signal NED declarations are only for informational
purposes, they won't affect program execution. Signals don't need to be
declared in the inifile or anything -- registerSignal() is enough (and you
need that to obtain the simsignal_t)

Andras

Konstantin Boyanov

unread,
Sep 7, 2010, 10:00:33 AM9/7/10
to omnetpp
Hi,

First of all, thanks for the reply.

Obviously I am doing womething worng with the signaling because I
cannot get the signal delivered to the module that has subscribed to
it.

I have 2 modules, MasterInterface and Source. The Source module is a
slightly modification of the Source module from the OMNeT++ examples.

The init functions of these two modules look like this:

void MasterInterface::initialize(int stage)
{
switch(stage){
case 0:
iocBusySignal = registerSignal("IOCmoduleIsBusy");
break;
case 1:
currentlyStored = 0;
break;
}
}

void Source::initialize(int stage)
{
switch(stage){
case 0:
startTime = par("startTime");
stopTime = par("stopTime");
numJobs = par("numJobs");
break;
case 1:
iocBusySignal = registerSignal("IOCmoduleIsBusy");
subscribe(iocBusySignal, this);

// schedule the first message timer for start time
scheduleAt(startTime, new cMessage("newJobTimer"));
break;
}

}

And the receiveSignal() function of the Source module looks like this,
it only prints out a dummy message, so just to make sure that the
function is called:

void Source::receiveSignal(cComponent *source, simsignal_t signalID,
long l){
// if received the signal, do not allow further messages to be
scheduled for "creation"
EV<< "###########################################" << endl;
EV << this->getFullName() << " at " << this->getParentModule()-
>getFullName() << " received SEND BLOCKED Signal from IOC!" << endl;
EV<< "###########################################" << endl;
}

However this message does not get shown in the Tkenv output. So I
suppose somehow the signal I registered first from the MasterInterface
Module (which is actually supposed to emit it in various cases during
the simulation), and then subscribed to from the Source Module, does
not get sent to the Source module and the receiveFunction does not get
called.

I have subclassed the Source from cListener like this:
class QUEUEING_API Source : public SourceBase, protected cListener
{
....

Is this wrong? if not do you have any idea what am I doing wrong?
Because I don't, and I spend almost a week now trying to get a simple
signaling between two modules working. I suppose signaling is an easy
feature, and as such I just wanted to use it to generate some
backpressure information between the two modules. If signaling is not
supposed to be used for such purpose, can you please point me to
another approach for generating back pressure between two
communicating modules?

Best regards,
Konstantin

Andras Varga

unread,
Sep 7, 2010, 10:25:20 AM9/7/10
to omn...@googlegroups.com
Are you aware that signals only propagate UPWARDS? I.e. a signal can be
received in the parent, grandparent etc up to the root, but NOT by a
sibling. BTW, there are plenty of signal examples in test/core/*.test, you
can check them too.

Andras

> -----Original Message-----
> From: omn...@googlegroups.com [mailto:omn...@googlegroups.com] On
> Behalf Of Konstantin Boyanov
> Sent: Tuesday, September 07, 2010 4:01 PM
> To: omnetpp
> Subject: [Omnetpp-l] Re: Simple signaling problem
>

Konstantin Boyanov

unread,
Sep 7, 2010, 10:41:37 AM9/7/10
to omnetpp
Hello,

> Are you aware that signals only propagate UPWARDS? I.e. a signal can be
> received in the parent, grandparent etc up to the root, but NOT by a
> sibling.

No, I was unfortunately not. So if I want to exchange information
between two modules on the same "layer" I have to connect them with
channels and send packets over those. Or rethink my model hierarchy
and introduce additional lower "layers" which will then emit the
signals. Is there any other way to do this?

>BTW, there are plenty of signal examples in test/core/*.test, you
> can check them too.

Thanks for that, I will have a look.

Many thanks,
Konstantin

sjs

unread,
Apr 8, 2014, 12:40:08 AM4/8/14
to omn...@googlegroups.com
Hi Andras,

http://www.omnest.com/overview.php says " Signals emitted from a module propagate up to the root in the module hierarchy, and modules and other code can subscribe to selected signals at any level."
I am also trying what Konstantin was trying to do. What is the current state of this problem?

How can I catch signals emitted by multiple modules without disturbing the existing model (without connecting modules with channels...)

Please help me!

Well Konstantin, did you find a solution?

Thanks

Best Regards,
SJS

sjs

unread,
Apr 8, 2014, 3:08:27 AM4/8/14
to omn...@googlegroups.com
Oh ok. Done!
Subscribed at simulation.getSystemModule()->subscribe(...); worked for me.

Imtithal Saeed

unread,
May 21, 2020, 5:38:09 PM5/21/20
to OMNeT++ Users
"and also added a public signal handling function

           public:
               virtual void receiveSignal(cComponent *src, simsignal_t
id, long l);"

should be overridden shouldn't it?
Reply all
Reply to author
Forward
0 new messages