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 @@ ...@@ -8,7 +8,7 @@
using namespace std; using namespace std;
MinDelaySensor::MinDelaySensor(DelaySensor * newDelay) MinDelaySensor::MinDelaySensor(DelaySensor * newDelay)
: minimum(1000000, -0.01), minDelay(1000000) : minimum(1000000, -0.01), minDelay(1000000), lastreported(-1)
{ {
delay = newDelay; delay = newDelay;
} }
...@@ -20,16 +20,18 @@ void MinDelaySensor::localSend(PacketInfo *) ...@@ -20,16 +20,18 @@ void MinDelaySensor::localSend(PacketInfo *)
void MinDelaySensor::localAck(PacketInfo * packet) void MinDelaySensor::localAck(PacketInfo * packet)
{ {
int current = delay->getLastDelay(); int current = delay->getLastDelay();
if (current < minimum && current != 0) int oneway = current / 2;
if (current < minimum && current != 0 && oneway != lastreported)
{ {
minDelay = current; minDelay = current;
ostringstream buffer; ostringstream buffer;
buffer << "delay=" << minDelay/2; buffer << "delay=" << oneway;
minimum.reset(current); minimum.reset(current);
global::output->eventMessage(buffer.str(), packet->elab, global::output->eventMessage(buffer.str(), packet->elab,
CommandOutput::FORWARD_PATH); CommandOutput::FORWARD_PATH);
global::output->eventMessage(buffer.str(), packet->elab, global::output->eventMessage(buffer.str(), packet->elab,
CommandOutput::BACKWARD_PATH); CommandOutput::BACKWARD_PATH);
lastreported = oneway;
} }
else else
{ {
......
...@@ -24,6 +24,7 @@ private: ...@@ -24,6 +24,7 @@ private:
Decayer minimum; Decayer minimum;
DelaySensor * delay; DelaySensor * delay;
int minDelay; int minDelay;
int lastreported;
}; };
#endif #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