Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Be consistent in the use of power units throughout the code. #1

Open
boulis opened this issue Feb 1, 2014 · 1 comment
Open

Be consistent in the use of power units throughout the code. #1

boulis opened this issue Feb 1, 2014 · 1 comment
Assignees

Comments

@boulis
Copy link
Owner

boulis commented Feb 1, 2014

Julien Romieux reported this in the forum:
I would like to add an extra cost every time a sensor sampling is done.
I would like to know if I am right on few points:

  1.   In Resource Manager module the unit of the variable currentNodePower is mWatts. TRUE?
    
  2.   In Sensor Manager module the unit of the variable pwrConsumptionPerDevice is Watts. (because after reading it, it is divided by 1000, see code below). TRUE?
    
while ((token = pwrTokenizer.nextToken()) != NULL)
   pwrConsumptionPerDevice.push_back(((double)atof(token)) / 1000.0f);

In order to achieve my goal which was to add an extra cost every time a sensor sampling is done, I went into the Sensor Manager module, in handleMessage() function, case SENSOR_READING_MESSAGE and I found these few lines of comments:

// update the remaining energy of the node
// CONSUME_ENERGY(pwrConsumptionPerDevice[sensorIndex]);
// +++ will need to change to powerDrawn();

I replaced them by:

powerDrawn(pwrConsumptionPerDevice[sensorIndex]);

PROBLEM: This line of code above called in the Sensor Manager module, will call the function handleMessage(), case RESOURCE_MANAGER_DRAW_POWER in the Resource Manager module.

Then the power sent by the Sensor Manager module pwrConsumptionPerDevice[sensorIndex] which is in Watts will be added to the currentNodePower which is in mWatts.

To avoid that, I removed the “/ 1000.0f” in the function which read the value of pwrConsumptionPerDevice:

AM I RIGHT ?


Julien is right (double check pending). We should have uniform handling of units in all code, and mW seems the right unit scale. So just delete the /1000.0 and also add the powerDrawn statement.

@ghost ghost assigned boulis Feb 1, 2014
@boulis
Copy link
Owner Author

boulis commented Mar 16, 2017

With commit 0aaf5a5 I corrected the power units problem in the Sensor Manager, and updated the default value in .ned.

BUT I have still left the powerDrawn() call commented out. This is because it needs to be accompanied by a scheduled timer call to draw 0 power after a while (after the sample is taken). For sensing devices that do not experience extra power consumption when sampled (I think this is most digital sensors, like temperature) then their power consumption can be accounted in the baseline one.

It would be good to have it defined distinctly though. So have a constant sensor power consumption, and also for some sensors we can have an extra per sample power consumption.

@boulis boulis removed the bug label Dec 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant