Commit 41ca8e25 authored by Robert Ricci's avatar Robert Ricci
Browse files

Don't report a new value if the new one would be the same as the old

parent 241974a4
......@@ -8,7 +8,7 @@
using namespace std;
MinDelaySensor::MinDelaySensor(DelaySensor * newDelay)
: minimum(1000000, -0.01), minDelay(1000000)
: minimum(1000000, -0.01), minDelay(1000000), lastreported(-1)
{
delay = newDelay;
}
......@@ -20,16 +20,18 @@ void MinDelaySensor::localSend(PacketInfo *)
void MinDelaySensor::localAck(PacketInfo * packet)
{
int current = delay->getLastDelay();
if (current < minimum && current != 0)
int oneway = current / 2;
if (current < minimum && current != 0 && oneway != lastreported)
{
minDelay = current;
ostringstream buffer;
buffer << "delay=" << minDelay/2;
buffer << "delay=" << oneway;
minimum.reset(current);
global::output->eventMessage(buffer.str(), packet->elab,
CommandOutput::FORWARD_PATH);
global::output->eventMessage(buffer.str(), packet->elab,
CommandOutput::BACKWARD_PATH);
lastreported = oneway;
}
else
{
......
......@@ -24,6 +24,7 @@ private:
Decayer minimum;
DelaySensor * delay;
int minDelay;
int lastreported;
};
#endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment