MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { qDebug() << "MainWindow::MainWindow() - ThreadId: " << QThread::currentThreadId(); x1 = new QVector<double>(INIT_DATA_SIZE); y1 = new QVector<double>(INIT_DATA_SIZE); y2 = new QVector<double>(INIT_DATA_SIZE); y3 = new QVector<double>(INIT_DATA_SIZE); y4 = new QVector<double>(INIT_DATA_SIZE); ui->setupUi(this); m_kldatabase = new KLDatabase(this); m_updatePlotTimer = new QTimer(this); m_updatePlotTimer->setInterval(5000); m_startAquisitionTimer = new QTimer(this); m_startAquisitionTimer->setSingleShot(true); m_acquisitionThread = new QThread(this); m_reader = new ReadDataWorker(m_kldatabase); m_reader->moveToThread(m_acquisitionThread); QObject::connect(m_startAquisitionTimer, SIGNAL(timeout()), this, SLOT(startAquisition()) ); QObject::connect(m_acquisitionThread, SIGNAL(started()), m_reader, SLOT(process()) ); QObject::connect(m_acquisitionThread, SIGNAL(finished()), m_reader, SLOT(deleteLater()) ); QObject::connect(m_acquisitionThread, SIGNAL(finished()), m_acquisitionThread, SLOT(deleteLater())); QObject::connect(m_reader, SIGNAL(newData()), this, SLOT(newData()) ); QObject::connect(m_reader, SIGNAL(readErrno(int)), this, SLOT(handleErrNo(int)) ); QObject::connect(m_updatePlotTimer, SIGNAL(timeout()), this, SLOT(onDrawPlot()) ); QObject::connect(ui->pushButton_1, SIGNAL(clicked()), this, SLOT(selectLongTimespan()) ); QObject::connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(selectMediumTimespan()) ); QObject::connect(ui->pushButton_3, SIGNAL(clicked()), this, SLOT(selectShortTimespan()) ); QObject::connect(this,SIGNAL(drawPlot()),this,SLOT(onDrawPlot()) ); QObject::connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(onMenuExit()) ); m_initKl = new InitWidget(this); m_initKl->show(); m_pressUsb = new PressUsb(this); m_pressUsb->hide(); m_timeInterval = TimeInterval::LONG; m_tickSpacing = TickSpacing::DAYS; setButtonActive(ui->pushButton_1); // initialize plot makePlot(); m_startAquisitionTimer->start(500); }
void MainWindow::selectLongTimespan() { //qDebug() << "7 Tage"; setButtonActive(ui->pushButton_1); setButtonNormal(ui->pushButton_2); setButtonNormal(ui->pushButton_3); setTimeInterval(TimeInterval::LONG); setTickSpacing(TickSpacing::DAYS); ui->customPlot->xAxis->setSubTickCount(3); ui->customPlot->xAxis->setDateTimeFormat("dd.MM.yy"); emit drawPlot(); }
void MainWindow::selectMediumTimespan() { //qDebug() << "24 Stunden"; setButtonNormal(ui->pushButton_1); setButtonActive(ui->pushButton_2); setButtonNormal(ui->pushButton_3); setTimeInterval(TimeInterval::MEDIUM); setTickSpacing(TickSpacing::HOURS); ui->customPlot->xAxis->setSubTickCount(3); ui->customPlot->xAxis->setDateTimeFormat("dd.MM.yy hh:mm"); emit drawPlot(); }
void MainWindow::selectShortTimespan() { //qDebug() << "15 Minuten"; setButtonNormal(ui->pushButton_1); setButtonNormal(ui->pushButton_2); setButtonActive(ui->pushButton_3); setTimeInterval(TimeInterval::SHORT); setTickSpacing(TickSpacing::MINUTES); ui->customPlot->xAxis->setSubTickCount(4); ui->customPlot->xAxis->setDateTimeFormat("dd.MM.yy hh:mm"); emit drawPlot(); }
bool ComposerEngine::tickOldScript(OldScript *script) { if (script->_currDelay) { script->_currDelay--; return true; } bool running = true; bool erasedOldSprite = false; while (running && script->_stream->pos() < (int)script->_size) { uint16 spriteId, scriptId, buttonId, pipeId; Common::Point spritePos; script->_stream->skip(0); byte op = script->_stream->readByte(); switch (op) { case kOldOpNoOp: debug(3, "kOldOpNoOp()"); running = false; break; case kOldOpReplaceSprite: if (!erasedOldSprite) { removeSprite(0, script->_id); erasedOldSprite = true; } spriteId = script->_stream->readUint16LE(); spritePos.x = script->_stream->readSint16LE(); spritePos.y = script->_stream->readSint16LE(); debug(3, "kOldOpReplaceSprite(%d, %d, %d)", spriteId, spritePos.x, spritePos.y); addSprite(spriteId, script->_id, script->_zorder, spritePos); break; case kOldOpPlayWav: uint16 wavId, prio; wavId = script->_stream->readUint16LE(); prio = script->_stream->readUint16LE(); debug(3, "kOldOpPlayWav(%d, %d)", wavId, prio); playWaveForAnim(wavId, prio, false); break; case kOldOpRunScript: scriptId = script->_stream->readUint16LE(); debug(3, "kOldOpRunScript(%d)", scriptId); if (scriptId == script->_id) { // reset ourselves removeSprite(0, script->_id); script->_stream->seek(6); } else { runScript(scriptId); } break; case kOldOpStopScript: scriptId = script->_stream->readUint16LE(); debug(3, "kOldOpStopScript(%d)", scriptId); removeSprite(0, scriptId); stopOldScript(scriptId); break; case kOldOpActivateButton: buttonId = script->_stream->readUint16LE(); debug(3, "kOldOpActivateButton(%d)", buttonId); setButtonActive(buttonId, true); break; case kOldOpDeactivateButton: buttonId = script->_stream->readUint16LE(); debug(3, "kOldOpDeactivateButton(%d)", buttonId); setButtonActive(buttonId, false); break; case kOldOpDrawSprite: spriteId = script->_stream->readUint16LE(); spritePos.x = script->_stream->readSint16LE(); spritePos.y = script->_stream->readSint16LE(); debug(3, "kOldOpDrawSprite(%d, %d, %d)", spriteId, spritePos.x, spritePos.y); addSprite(spriteId, script->_id, script->_zorder, spritePos); break; case kOldOpRemoveSprite: spriteId = script->_stream->readUint16LE(); debug(3, "kOldOpRemoveSprite(%d)", spriteId); removeSprite(spriteId, script->_id); break; case kOldOpDisableMouseInput: debug(3, "kOldOpDisableMouseInput()"); setCursorVisible(false); break; case kOldOpEnableMouseInput: debug(3, "kOldOpEnableMouseInput()"); setCursorVisible(true); break; case kOldOpWait: script->_currDelay = script->_stream->readUint16LE(); debug(3, "kOldOpWait(%d)", script->_currDelay); break; case kOldOpRandWait: uint16 min, max; min = script->_stream->readUint16LE(); max = script->_stream->readUint16LE(); debug(3, "kOldOpRandWait(%d, %d)", min, max); script->_currDelay = _rnd->getRandomNumberRng(min, max); break; case kOldOpDrawGlobalSprite: spriteId = script->_stream->readUint16LE(); spritePos.x = script->_stream->readSint16LE(); spritePos.y = script->_stream->readSint16LE(); debug(3, "kOldOpDrawGlobalSprite(%d, %d, %d)", spriteId, spritePos.x, spritePos.y); addSprite(spriteId, 0, script->_zorder, spritePos); break; case kOldOpRemoveGlobalSprite: spriteId = script->_stream->readUint16LE(); debug(3, "kOldOpRemoveGlobalSprite(%d)", spriteId); removeSprite(spriteId, 0); break; case kOldOpSetZOrder: script->_zorder = script->_stream->readUint16LE(); debug(3, "kOldOpSetZOrder(%d)", script->_zorder); break; case kOldOpPlayPipe: pipeId = script->_stream->readUint16LE(); debug(3, "kOldOpPlayPipe(%d)", pipeId); playPipe(pipeId); break; case kOldOpStopPipe: pipeId = script->_stream->readUint16LE(); debug(3, "kOldOpStopPipe(%d)", pipeId); // yes, pipeId is ignored here.. stopPipes(); break; case kOldOpNewScreen: uint16 newScreenId; newScreenId = script->_stream->readUint16LE(); debug(3, "kOldOpNewScreen(%d)", newScreenId); if (!newScreenId) { quitGame(); } else { _pendingPageChanges.clear(); _pendingPageChanges.push_back(PendingPageChange(newScreenId, false)); } break; case kOldOpRunRandom: uint16 randomId; randomId = script->_stream->readUint16LE(); debug(3, "kOldOpRunRandom(%d)", randomId); if (!_randomEvents.contains(randomId)) { warning("kOldOpRunRandom found no entries for id %d", randomId); } else { uint32 randValue = _rnd->getRandomNumberRng(0, 32767); const Common::Array<RandomEvent> &events = _randomEvents[randomId]; uint i = 0; for (i = 0; i < events.size(); i++) { if ((i + 1 == events.size()) || (randValue <= events[i].weight)) { runScript(events[i].scriptId); break; } else { randValue -= events[i].weight; } } } break; default: error("unknown oldScript op %d", op); } } if (script->_stream->pos() >= (int)script->_size) { // stop running if we ran out of script removeSprite(0, script->_id); return false; } return true; }