Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#14 Float parameters in BMacLayer

v2.2
closed-fixed
nobody
MAC (4)
5
2012-11-05
2012-03-05
Tobias Smolka
No

Although BMacLayer defines some of the parameters as doubles in NED, the module itself is loading their values as integers. This is particularly problematic with parameters slotDuration, checkInterval and txPower, since they can be often set to a value between 0 to 1. Please see attached trivial patch for the details.

Discussion

1 2 > >> (Page 1 of 2)
  • Tobias Smolka
    Tobias Smolka
    2012-03-05

     
    Attachments
  • Michael Lindig
    Michael Lindig
    2012-03-05

    • status: open --> open-invalid
     
  • Michael Lindig
    Michael Lindig
    2012-03-05

    Sorry, but the par(...) function does a implicit conversion to double (in this case not a conversion to integer), because the values are from double type.

     
  • Tobias Smolka
    Tobias Smolka
    2012-03-05

    Thank you for such a fast response. You are probably right, which means, that I didn't identify the source of this problem correctly. However, I can still reproduce it and posted patch fixes it for me.

    Steps to reproduce the problem:

    Plain installation of OMNet++ 4.2.1 and MiXiM 2.2.1, downloadable from official websites. Example "bmac". When I set parameter "slotDuration" to "0.9s" instead of default value "1s", the final value of variable slotDuration in BMacLayer module is "0". I checked it simply by printing it on EV.

    Could you please confirm this behavior?

     
  • Michael Lindig
    Michael Lindig
    2012-03-05

    Maybe a compiler issue! Can you change the line:

    slotDuration = hasPar("slotDuration") ? par("slotDuration") : 1;

    into

    slotDuration = hasPar("slotDuration") ? par("slotDuration") : 1.; // a dot after 1 ;)

    and test it again.

     
  • Tobias Smolka
    Tobias Smolka
    2012-03-05

    Good point! The value is now correct.

    I am using OMNeT++ under Windows 7 x64. I would therefore suggest applying discussed change at least for "slotDuration" and "txPower" in this module. I was not able to identify similar problem in other modules.

    Thank you for support.

     
  • Michael Lindig
    Michael Lindig
    2012-03-05

    OK, Thanks!

    I will check the code for that initializing issue and will correct it by explicit call to the requested type.

    Michael

     
  • Michael Lindig
    Michael Lindig
    2012-03-05

    • status: open-invalid --> open-fixed
     
  • xVen1y Really enjoyed this article.Thanks Again. Much obliged.

     
1 2 > >> (Page 1 of 2)