get and set position

461 views
Skip to first unread message

Christian

unread,
Jan 21, 2010, 10:49:03 AM1/21/10
to omnetpp
Hi,

i using omnet without any framework. Is there a way to get the
position and to change them in simulation time?

best regards christian

Marco Pattaro

unread,
Jan 21, 2010, 12:10:47 PM1/21/10
to omnetpp
I think you could use setDisplayString() to edit the @display() in
the NED files from the cpp code, but remember to keep it consistent
with position attributes in che cpp classes. By the way there are many
different mobility modules implemented in INET framework, I'll suggest
you to try some of them before reinventing the wheel

Salutes

Marco

On 21 Gen, 16:49, Christian

Christian

unread,
Jan 21, 2010, 5:40:55 PM1/21/10
to omnetpp
Yes,

but it dont get it work in the way i want. at first time i need the
location information from every model. then i want to calculate the
space between the moduls.
i test it with setDisplayString() but i dont get it work. could you
give me an exampel please?

best regards
christian

Marco Pattaro

unread,
Jan 22, 2010, 10:03:38 AM1/22/10
to omnetpp
Ok, I think I'm working with some similar situation using INET.
Suppose you have to check the distance between a WiFi Host and an AP,
your Network should contain a ChannelControl module, like this

import inet.world.ChannelControl;

Network myNetwork {
// ...
submodules:
// ...
channelcontrol: ChannelControl
{
playgroundSizeX = 100;
playgroundSizeY = 100;
@display("p=10,10");
}
// ...
}

ChannelControl is made to check the wireless hosts comunication
ranges, and is an observer that mantains various informations about
hosts, position included.
I don't know if this module is exactly what you need, but you may
always extend it, or just take it as an example.

Now _every_ Host of which you want to check position (mind it, also
non moving hosts, you'll use NullMobility for those) must have a
Mobility and a NotificationBoard, like this:

import inet.base.NotificationBoard;
import inet.mobility.LinearMobility; // or whatever kind of
mobility you need

module MyHost
{
parameters:
// ...
submodules:
// ...
notificationBoard: NotificationBoard {
parameters:
@display("p=31,41");
}
mobility: LinearMobility {
parameters:
@display("p=32,103");
}
// ...
}

This way the MobilityModule in each host will provade movements and
animations, while the NotificationBoard triggers the right methods for
position changing in the ChannelControl. ChannelControl is a
singleton, so you can get a pointer to it by calling
ChannelControl::get() from any class.

Setted up this things all you have to do is make the ChannelControl to
fit your needs.

Hope it helped.

Marco

On 21 Gen, 23:40, Christian

Christian

unread,
Jan 26, 2010, 5:18:27 AM1/26/10
to omnetpp
I tryed but how could i get inet working in my projekt? i included it
and build an executable file but when i start this he sayed something
like this:

Error in module (cCompundModule) myNetwork (id=1): Class
"ChannelControl" not found -- perhaps its code was not linked in or
the class wasn't registered with Register_Class() or in the case of
modules and channels, with Define_Module()/Define_Channel().

But i dont know why he dont finde the class from the inet framework.
i am using windows is there maybe a path entry to set?

best regards christain

On 22 Jan., 16:03, Marco Pattaro <mpatt...@gmail.com> wrote:
> Ok, I think I'm working with some similar situationusingINET.
> Suppose you have to check the distance between a WiFi Host and an AP,
> your Network should contain a ChannelControl module, like this
>
> importinet.world.ChannelControl;
>
> Network myNetwork {
> // ...
>     submodules:
>     // ...
>          channelcontrol: ChannelControl
>          {
>              playgroundSizeX = 100;
>              playgroundSizeY = 100;
>              @display("p=10,10");
>         }
>     // ...
>
> }
>
> ChannelControl is made to check the wireless hosts comunication
> ranges, and is an observer that mantains various informations about
> hosts, position included.
> I don't know if this module is exactly what you need, but you may
> always extend it, or just take it as an example.
>
> Now _every_ Host of which you want to check position (mind it, also
> non moving hosts, you'll use NullMobility for those) must have a
> Mobility and a NotificationBoard, like this:
>
> importinet.base.NotificationBoard;

> importinet.mobility.LinearMobility;    // or whatever kind of

> > > different mobility modules implemented inINETframework, I'll suggest


> > > you to try some of them before reinventing the wheel
>
> > > Salutes
>
> > > Marco
>
> > > On 21 Gen, 16:49, Christian
>
> > > <hildebrand.christian.om...@googlemail.com> wrote:
> > > > Hi,
>

> > > > iusingomnet without any framework. Is there a way to get the

Peter Staab

unread,
Jan 26, 2010, 5:50:42 AM1/26/10
to omn...@googlegroups.com
Hello,

I am struggling with this problem from time-to-time too.
(In my case) the error is usually caused by
1.) inet framework is compiled in debug or release and my own project is compiled in opposite (e.g. inet: debug, my project: release)
1.1) Sometimes it is required to completely relink the inet framework (clean project, or modify one of the source files - second option is a lot faster...)
2.) inet framework was not compiled successfully, e.g. because a compilation error occured in the directory "under test" --> remove this directory and all linked examples.

With these "fixes" I get my projects to run under Ubuntu+Windows.

I hope that helps,



Christian schrieb:

Marco Pattaro

unread,
Jan 26, 2010, 5:54:55 AM1/26/10
to omn...@googlegroups.com
What do you mean when you say you "included it"? If you mean make you
project reference to INET you have to import INET as a project in the
IDE, then select it from the menu Project->Properties->Project
References of you project. Then, of course, you have to #inlcude the
headers of every class you mean to use inside your C++ files, only if
and when you really need to call methods from INET classes.
I suggest you to use the IDE or else you'll have to edit the Makefile by
yourself.

I never used Oment on Windows but I'm pretty sure that it's the same,
you choose the project references from a list, so the IDE should hadle
Windows stile path in the Makefile.

cheers

Marco

Message has been deleted

Christian

unread,
Jan 27, 2010, 4:45:43 AM1/27/10
to omnetpp
Yes,

i am testing what Peter said und selected befor the inet project in
the IDE, like Marco said.
In the IDE the Modules of INET are reachable. And the compilation
works. But if i am running the executable file it will not find the
source of inet and i dont know why. To testing if my framework not
work i load a new one and it dont work also :-(
In the .ini-file i add the following line: "ned-path = D:\Backup\OMNeT
\inetmanet\inetmanetinetmanetee48aae20100126\src;."
The i am starting and get the following messages:

OMNeT++ Discrete Event Simulation (C) 19922008 Andras Varga, OpenSim
Ltd.
Version: 4.0, build: 09031010709, edition: Academic Public License -
NOT FOR COMMERCIAL USE
See the license for distribution terms and warranty disclaimer
Setting up Tkenv...
Loading NED files from D:\Backup\OMNeT\inetmanet
\inetmanetinetmanetee48aae20100126\src: 313
Loading NED files from D:\Backup\OMNeT\RealFlexSVN\0031: 19

Loading images from ./bitmaps: : 0
Loading images from ./images: : 0 .svn/*: 0 .svn/propbase/*: 0 .svn/
props/*: 0 .svn/textbase/*: 0 .svn/tmp/*: 0 .svn/tmp/propbase/*:
0 .svn /tmp/props/*: 0 .svn/tmp/textbase/*: 0 background/*: 7
background/.svn/*: 0 background/.svn/propbase/*: 0 background/.svn/
props/*: 0 background/.svn/textbase/*: 0 background/.svn/tmp/*: 0
background/.svn/tmp/propbase/*: 0 background/.svn/tmp/props/*: 0
background/.svn/tmp/textbase/*: 0
Loading images from d:/Backup/OMNeT/omnetpp4.0srcwindows/omnetpp4.0/
images: *: 0 abstract/*: 90 background/*: 4 block/*: 320 device/*: 195
ma
ps/*: 9 misc/*: 70 msg/*: 55 old/*: 111 status/*: 28

Plugin path: D:\Backup\OMNeT\inet-manet\inetmanet-inetmanet-
ee48aae-2010-01-26\etc\plugins;./plugins
Loading tcl files from D:\Backup\OMNeT\inet-manet\inetmanet-inetmanet-
ee48aae-2010-01-26\etc\plugins: contextmenu.tcl
Recording event log to file `results\General-0.elog'...

But then he could not find the sources :-( but why?

Best regards
Christian

On 26 Jan., 11:54, Marco Pattaro <mpatt...@gmail.com> wrote:
> What do you mean when you say you "included it"? If you mean make you

> project reference toINETyou have to importINETas a project in the


> IDE, then select it from the menu Project->Properties->Project
> References of you project. Then, of course, you have to #inlcude the
> headers of every class you mean to use inside your C++ files, only if
> and when you really need to call methods fromINETclasses.
> I suggest you to use the IDE or else you'll have to edit the Makefile by
> yourself.
>
> I never used Oment on Windows but I'm pretty sure that it's the same,
> you choose the project references from a list, so the IDE should hadle
> Windows stile path in the Makefile.
>
> cheers
>
> Marco
>
> Christian wrote:

> > I tryed but how could i getinetworking in my projekt? i included it


> > and build an executable file but when i start this he sayed something
> > like this:
>
> > Error in module (cCompundModule) myNetwork (id=1): Class
> > "ChannelControl" not found -- perhaps its code was not linked in or
> > the class wasn't registered with Register_Class() or in the case of
> > modules and channels, with Define_Module()/Define_Channel().
>
> > But i dont know why he dont finde the class from theinetframework.

> > i amusingwindows is there maybe a path entry to set?

Christian

unread,
Jan 27, 2010, 5:07:38 AM1/27/10
to omnetpp
i include the inet framework in the project and could load the modules
in the ide while i writing the ned-files. have i to include the header-
files/cc-files separate? or include any additional paths to the src-
code?

best regards
Christian

On 26 Jan., 11:54, Marco Pattaro <mpatt...@gmail.com> wrote:

> What do you mean when you say you "included it"? If you mean make you

> project reference toINETyou have to importINETas a project in the


> IDE, then select it from the menu Project->Properties->Project
> References of you project. Then, of course, you have to #inlcude the
> headers of every class you mean to use inside your C++ files, only if
> and when you really need to call methods fromINETclasses.
> I suggest you to use the IDE or else you'll have to edit the Makefile by
> yourself.
>
> I never used Oment on Windows but I'm pretty sure that it's the same,
> you choose the project references from a list, so the IDE should hadle
> Windows stile path in the Makefile.
>
> cheers
>
> Marco
>
> Christian wrote:

> > I tryed but how could i getinetworking in my projekt? i included it


> > and build an executable file but when i start this he sayed something
> > like this:
>
> > Error in module (cCompundModule) myNetwork (id=1): Class
> > "ChannelControl" not found -- perhaps its code was not linked in or
> > the class wasn't registered with Register_Class() or in the case of
> > modules and channels, with Define_Module()/Define_Channel().
>
> > But i dont know why he dont finde the class from theinetframework.

> > i amusingwindows is there maybe a path entry to set?

Christian

unread,
Jan 27, 2010, 9:34:16 AM1/27/10
to omnetpp
OK,

i think i am one step forward. I created for testing a virtualbox
(ubuntu and omnet) there i get starting my project with inet in the
following way:
./myProject -n $(path-to-inet-src-folder)
but wenn i want to do this in windows it will not work.
Could anybody tell me why it maybe not working in windows?

best regards
Christian

On 26 Jan., 11:54, Marco Pattaro <mpatt...@gmail.com> wrote:

Christian

unread,
Jan 28, 2010, 7:55:36 AM1/28/10
to omnetpp
Hi,

i will use the framework. In Linux my project starts with:
./myProject -n $(path-to-inet-src-folder)
Now i want to start this project in windows. Here i have the MinGw-
Console. I set in /etc/profile the path to the framework and start the
Project in the same way:
./myProject.exe -n $(path-to-inet-src-folder)
But it did not work. I got the following error message:

Error in module (cCompundModule) myNetwork (id=1): Class
"ChannelControl" not found -- perhaps its code was not linked in or
the class wasn't registered with Register_Class() or in the case of
modules and channels, with Define_Module()/Define_Channel().

And i don't know why? Could Anybody help me?

best regards
christian


On 26 Jan., 11:54, Marco Pattaro <mpatt...@gmail.com> wrote:

Rudolf Hornig

unread,
Jan 28, 2010, 8:41:46 AM1/28/10
to omn...@googlegroups.com
You have to load the libinet.dll otherwise it will not be loaded automatically. i.e. the code if the inet library is in that dll. If the shared lib is not loaded the framewrork will not find the classes belonging to the NED modules.

Use the -l /full/path/to/inet  on the command line. 
e.g. myProject -l c:\inet\src\libinet.dll

-l c:\inet\src\inet

will also work as the lib prefix and .dll suffix is automatically added.

if you add c:\inet\src to the path then
-l inet

will also work.

Honestly I don't know how the linux command worked without that option.

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.


Christian

unread,
Jan 28, 2010, 9:49:23 AM1/28/10
to omnetpp
Thanks,

in the virtualbox i activate the option inet in Properties -> C/C++
General -> Path and Symbols -> References.
Then i can start my project with ./myProject without adding any
parameters.
In windows does it work like you said in the best way "myProject.exe -
l inet".

best regards
christian


On 28 Jan., 14:41, Rudolf Hornig <rudolf.hor...@gmail.com> wrote:
> You have to load the libinet.dll otherwise it will not be loaded
> automatically. i.e. the code if the inet library is in that dll. If the
> shared lib is not loaded the framewrork will not find the classes belonging
> to the NED modules.
>
> Use the -l /full/path/to/inet  on the command line.
> e.g. myProject -l c:\inet\src\libinet.dll
>
> -l c:\inet\src\inet
>
> will also work as the lib prefix and .dll suffix is automatically added.
>
> if you add c:\inet\src to the path then
> -l inet
>
> will also work.
>
> Honestly I don't know how the linux command worked without that option.
>
> Rudolf
>
> On Thu, Jan 28, 2010 at 1:55 PM, Christian <
>

> > omnetpp+u...@googlegroups.com<omnetpp%2Bunsu...@googlegroups.com>

Rudolf Hornig

unread,
Jan 28, 2010, 10:04:42 AM1/28/10
to omn...@googlegroups.com
Ah ok, if you actually LINK against the inet library then on linux, the location of the inel shared library is 
written into your executable. (i.e. there is even no need to set the LD_LIBRARY_PATH variable).

On windows, your path MUST contain the path of the directory which contains the libinet.dll file.

This is NOT the inet-root directory but rather <inet-root/src>. I.e. you must add that one to the path.
Rudolf

To unsubscribe from this group, send email to omnetpp+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages