Contents tab of simple module is empty / watch() does not work

10 views
Skip to first unread message

platzhirsch

unread,
Aug 27, 2010, 5:51:21 AM8/27/10
to omnetpp
Hey there,

I created a simple module of my own. Now I want to watch local fields.
They are not static and declared protected. When I enter WATCH(...);
in initialize(); of the class.cc implementation, it runs over the
code, but when I open the module on the running simulation, contents
is empty.

What reason would this cause?

Best regards,
Konrad

HAEFLINGER, PATRICK (PATRICK)

unread,
Aug 27, 2010, 6:24:29 AM8/27/10
to omn...@googlegroups.com
Hi Konrad,

Strange, can you join a copy of your module code otherwize it would be difficult to help you more !

Patrick

-----Message d'origine-----
De : omn...@googlegroups.com [mailto:omn...@googlegroups.com] De la part de platzhirsch
Envoyé : vendredi 27 août 2010 11:51
À : omnetpp
Objet : [Omnetpp-l] Contents tab of simple module is empty / watch() does not work

Hey there,

Best regards,
Konrad

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

platzhirsch

unread,
Aug 27, 2010, 7:15:53 AM8/27/10
to omnetpp
Watchdog.ned
simple Watchdog {}

---
Watchdog.h

#ifndef __WATCHDOG_H
#define __WATCHDOG_H

#include <omnetpp.h>
#include "IPAddress.h"

#include <map>
#include <iterator>

class Watchdog: public cSimpleModule {

protected:

int score[255][255];
std::map<IPAddress,int> IP2ClientNumber;

int getScore(int i, int j) { return score[i][j]; }
void setScore(int i, int j, int value) { score[i][j] = value;}
};

#endif

---
Watchdog.cc

#include "Watchdog.h"

Define_Module(Watchdog);

void Watchdog::initialize() {

int x = 5;
WATCH(x);

std::map<IPAddress,int>::iterator it;
for (int i = 1; i <= 255; ++i) {
IPAddress *addr = new IPAddress(145,236,0,i);
IP2ClientNumber[*addr] = i-1;
}

for (int i = 0; i < 255; ++i) {
for (int j = 0; j < 255; ++j) {
score[i][j] = 50;
}
}
}

void Watchdog::handleMessage(cMessage *msg) {}



On Aug 27, 12:24 pm, "HAEFLINGER, PATRICK (PATRICK)"

HAEFLINGER, PATRICK (PATRICK)

unread,
Aug 27, 2010, 8:08:47 AM8/27/10
to omn...@googlegroups.com
Several remarks :
- the declaration of : virtual void initialize() is missing in the Watchdog.h file
- You are trying to watch a variable which is local to "initialize" method, this will not give you any result as outside of "initialize this variable is not defined

Patrick

-----Message d'origine-----
De : omn...@googlegroups.com [mailto:omn...@googlegroups.com] De la part de platzhirsch

Envoyé : vendredi 27 août 2010 13:16
À : omnetpp
Objet : [Omnetpp-l] Re: Contents tab of simple module is empty / watch() does not work

platzhirsch

unread,
Aug 27, 2010, 8:25:33 AM8/27/10
to omnetpp
Thanks, its working now :)
Reply all
Reply to author
Forward
0 new messages