All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Restricts the number of events per unit of time. More...
#include <EventRestrictor.h>
Signals | |
| void | flushAll () |
Public Member Functions | |
| EventRestrictor (QObject *parent=0) | |
| bool | newEvent () |
| void | setInterval (int ms) |
| ~EventRestrictor () | |
Restricts the number of events per unit of time.
| QGpCoreTools::EventRestrictor::EventRestrictor | ( | QObject * | parent = 0 | ) |
References flushAll().
: QObject(parent)
{
_chrono.start();
_lastEvent.setSingleShot(true);
connect(&_lastEvent, SIGNAL(timeout()), this, SIGNAL(flushAll()));
}
References flushAll().
{
emit flushAll();
}
| void QGpCoreTools::EventRestrictor::flushAll | ( | ) | [signal] |
Referenced by EventRestrictor(), and ~EventRestrictor().
Referenced by Engine::signalDataChanged().
{
int delay=_chrono.elapsed();
if(delay>=_lastEvent.interval()) {
_chrono.start();
return true;
} else {
_lastEvent.stop();
_lastEvent.start(_lastEvent.interval()-delay);
return false;
}
}
| void QGpCoreTools::EventRestrictor::setInterval | ( | int | ms | ) | [inline] |
Referenced by AcquisitionWidget::AcquisitionWidget(), and Engine::Engine().
{_lastEvent.setInterval(ms);}