void WUManager::init()
{
    sendRequest();

    QThread* workHorse = new QThread(this);
    QTimer* timer = new QTimer(0);
    QEventLoop* loop = new QEventLoop();

    timer->setInterval(900000);    // every hour read weather data
    timer->moveToThread(workHorse);
    connect(this,  SIGNAL(replyProcessed()), loop, SLOT(quit()) );
    connect(timer, SIGNAL(timeout()), this, SLOT(sendRequest()));
    connect(workHorse, SIGNAL(started()), timer, SLOT(start()));
    workHorse->start();
    loop->exec();

    QThread* workHorseSensors = new QThread(this);
    QTimer* timerSensors = new QTimer(0);

    timerSensors->setInterval(1000);
    timerSensors->moveToThread(workHorse);
    connect(timerSensors, SIGNAL(timeout()), this, SLOT(readSensors()));
    connect(workHorseSensors, SIGNAL(started()), timerSensors, SLOT(start()));
    workHorseSensors->start();
}
Exemple #2
0
VOIP::VOIP(QObject* p) : QObject(p), speex(SAMPLE_RATE)
{
    qRegisterMetaType<ALshortVector >();
    rec = new Recorder(SAMPLE_RATE, this);
    rec->startRecord();
    connect(rec, SIGNAL(readyRead(ALshortVector)), &speex, SLOT(encode(ALshortVector)), Qt::QueuedConnection);
    connect(&speex, SIGNAL(encoded(QByteArray)), this, SLOT(send(QByteArray)), Qt::QueuedConnection);

    QTimer* updateT = new QTimer;
    connect(updateT, SIGNAL(timeout()), this, SLOT(update()));
    updateT->start(1000);

    udpSocket = new QUdpSocket(this);
    m_port=VOIP_DEFAULT_PORT;

    m_receiver=0;
    m_sound=new Sound(SAMPLE_RATE);
    m_sound->play();

    dataUp = 0;
    setVolume(50);
    m_enabled=true;
    setQuality(4);

    updateT->moveToThread(&m_thread);
    moveToThread(&m_thread);
    m_thread.start();
}
Exemple #3
0
void Time::run()
{
    int interval=5000;
    QThread* somethread = new QThread(this);
    QTimer *timer = new QTimer();

    connect(timer, SIGNAL(timeout()), this, SLOT(VerifPing()));
     timer->start();
     timer->setInterval(interval);
     timer->moveToThread(somethread);
     somethread->start();
}
QCVWidget::QCVWidget(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::QCVWidget)
{
    ui->setupUi(this);
    //setup();
	thread = new QThread();
	RGBCamera *worker = new RGBCamera();
	QTimer *workerTrigger = new QTimer();
	workerTrigger->setInterval(1);

	connect(workerTrigger, SIGNAL(timeout()), worker, SLOT(slotGrabFrame()));
	connect(this, SIGNAL(sigSetup(int)), worker, SLOT(slotSetup(int)));
	connect(worker, SIGNAL(sigFrame(QImage)), this, SLOT(slotFrame(QImage)));

	workerTrigger->start();
	worker->moveToThread(thread);
	workerTrigger->moveToThread(thread);
	thread->start();

	emit sigSetup(0);
}