You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
In Resource Manager module the unit of the variable currentNodePower is mWatts. TRUE?
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.
The text was updated successfully, but these errors were encountered:
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.
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:
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:
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.
The text was updated successfully, but these errors were encountered: