virtual bool read(ConnectionReader& connection) { double now = Time::now(); Bottle b; bool ok = b.read(connection); if (ok) { mutex.wait(); ct++; if (ct>1) { double dt = now - lastTime; period.add(dt); } lastTime = now; printf("Period is %g +/- %g (%d)\n", period.mean(), period.deviation(), ct); mutex.post(); } return ok; }
static float SlowMix (const Stat& stat1, float b1, const Stat& stat2, float b2) { return (stat1.precision(b1) * stat1.mean() + stat2.precision(b2) * stat2.mean()) / (stat1.precision(b1) + stat2.precision(b2)); }