diff --git a/framesenderobject.cpp b/framesenderobject.cpp index 92127474..f9eb4688 100644 --- a/framesenderobject.cpp +++ b/framesenderobject.cpp @@ -154,12 +154,15 @@ void FrameSenderObject::timerTriggered() sendingList.clear(); if(mutex.tryLock()) { - //get elapsed microseconds since last tick (in case timer skips or is otherwise inaccurate, though there are no guarantees about elapsed timer either) - quint64 elapsed = sendingElapsed.nsecsElapsed() / 1000; + /* + * Requested tick interval was 1ms but the actual interval could be wildly different. So, we track + * by counting microseconds and accumulating. This creates decent stability even for long intervals + */ + quint64 elapsed = sendingElapsed.nsecsElapsed() / 1000ul; if (elapsed == 0) elapsed = 1; sendingElapsed.start(); sendingLastTimeStamp += elapsed; - //qDebug() << playbackLastTimeStamp; + //qDebug() << sendingLastTimeStamp; //qDebug() << "El: " << elapsed; statusCounter++; for (int i = 0; i < sendingData.count(); i++) @@ -178,19 +181,20 @@ void FrameSenderObject::timerTriggered() } if (sendData->triggers.count() == 0) { - qDebug() << "No triggers to process"; + //qDebug() << "No triggers to process"; break; } for (int j = 0; j < sendData->triggers.count(); j++) { trigger = &sendData->triggers[j]; - if (trigger->currCount >= trigger->maxCount) continue; //don't process if we've sent max frames we were supposed to + //if ( (trigger->currCount >= trigger->maxCount) || (trigger->maxCount == -1) ) continue; //don't process if we've sent max frames we were supposed to if (!trigger->readyCount) continue; //don't tick if not ready to tick //is it time to fire? trigger->msCounter += elapsed; //gives proper tracking even if timer doesn't fire as fast as it should - if (trigger->msCounter >= trigger->milliseconds) + //qDebug() << trigger->msCounter; + if (trigger->msCounter >= (trigger->milliseconds * 1000)) { - trigger->msCounter -= trigger->milliseconds; + trigger->msCounter -= (trigger->milliseconds * 1000); sendData->count++; trigger->currCount++; doModifiers(i); diff --git a/mainwindow.cpp b/mainwindow.cpp index bcc65cf7..9e6fea3a 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -230,13 +230,12 @@ MainWindow::MainWindow(QWidget *parent) : ui->actionSingle_Multi_State_2->setVisible(false); QStringList headers; - headers << "En" << "Bus" << "ID" << "Len" << "Ext" << "Rem" << "Data" + headers << "En" << "Bus" << "ID" << "Ext" << "Rem" << "Data" << "Interval" << "Count"; - ui->tableSimpleSender->setColumnCount(9); + ui->tableSimpleSender->setColumnCount(8); ui->tableSimpleSender->setColumnWidth(SIMP_COL::SC_COL_EN, 70); ui->tableSimpleSender->setColumnWidth(SIMP_COL::SC_COL_BUS, 70); ui->tableSimpleSender->setColumnWidth(SIMP_COL::SC_COL_ID, 70); - ui->tableSimpleSender->setColumnWidth(SIMP_COL::SC_COL_LEN, 70); ui->tableSimpleSender->setColumnWidth(SIMP_COL::SC_COL_EXT, 70); ui->tableSimpleSender->setColumnWidth(SIMP_COL::SC_COL_REM, 70); ui->tableSimpleSender->setColumnWidth(SIMP_COL::SC_COL_DATA, 300); @@ -489,7 +488,12 @@ void MainWindow::processSenderCellChange(int line, int col) if (!tempData) { + qDebug() << "Need to set up a new entry in senders"; FrameSendData dat; + dat.enabled = false; + dat.count = 0; + dat.frameCount = 0; + dat.bus = 0; frameSender->addSendRecord(dat); tempData = frameSender->getSendRecordRef(line); } @@ -530,13 +534,6 @@ void MainWindow::processSenderCellChange(int line, int col) } qDebug() << "setting ID to " << tempVal; break; - case SIMP_COL::SC_COL_LEN: - tempVal = Utility::ParseStringToNum(ui->tableSimpleSender->item(line, SIMP_COL::SC_COL_LEN)->text()); - if (tempVal < 0) tempVal = 0; - if (tempVal > 8) tempVal = 8; - arr.resize(tempVal); - tempData->setPayload(arr); - break; case SIMP_COL::SC_COL_EXT: if (ui->tableSimpleSender->item(line, SIMP_COL::SC_COL_EXT)->checkState() == Qt::Checked) { tempData->setExtendedFrameFormat(true); @@ -555,9 +552,9 @@ void MainWindow::processSenderCellChange(int line, int col) for (int i = 0; i < 8; i++) tempData->payload().data()[i] = 0; #if QT_VERSION >= QT_VERSION_CHECK( 5, 14, 0 ) - tokens = ui->tableSimpleSender->item(line, ST_COLS::SENDTAB_COL_DATA)->text().split(" ", Qt::SkipEmptyParts); + tokens = ui->tableSimpleSender->item(line, SIMP_COL::SC_COL_DATA)->text().split(" ", Qt::SkipEmptyParts); #else - tokens = ui->tableSender->item(line, ST_COLS::SENDTAB_COL_DATA)->text().split(" ", QString::SkipEmptyParts); + tokens = ui->tableSimpleSender->item(line, SIMP_COL::SC_COL_DATA)->text().split(" ", QString::SkipEmptyParts); #endif arr.clear(); arr.reserve(tokens.count()); @@ -569,7 +566,7 @@ void MainWindow::processSenderCellChange(int line, int col) break; case SIMP_COL::SC_COL_INTERVAL: //interval in ms - QString trigger = ui->tableSimpleSender->item(line, ST_COLS::SENDTAB_COL_TRIGGER)->text().toUpper(); + QString trigger = ui->tableSimpleSender->item(line, SIMP_COL::SC_COL_INTERVAL)->text().toUpper(); Trigger thisTrigger; thisTrigger.bus = -1; //-1 means we don't care which @@ -598,7 +595,6 @@ void MainWindow::processSenderCellChange(int line, int col) } } - void MainWindow::createSenderRow() { int row = ui->tableSimpleSender->rowCount(); @@ -1018,6 +1014,18 @@ void MainWindow::tickGUIUpdate() } } + //refresh the count for all the frame senders + FrameSendData *tempData; + int numRows = ui->tableSimpleSender->rowCount(); + for (int i = 0; i < numRows; i++) + { + tempData = frameSender->getSendRecordRef(i); + if (tempData) + { + ui->tableSimpleSender->item(i, SIMP_COL::SC_COL_COUNT)->setText(QString::number( tempData->count )); + } + } + rxFrames = 0; //} } diff --git a/mainwindow.h b/mainwindow.h index 29daf73e..31df02c1 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -45,12 +45,11 @@ enum SIMP_COL SC_COL_EN = 0, SC_COL_BUS = 1, SC_COL_ID = 2, - SC_COL_LEN = 3, - SC_COL_EXT = 4, - SC_COL_REM = 5, - SC_COL_DATA = 6, - SC_COL_INTERVAL = 7, - SC_COL_COUNT = 8, + SC_COL_EXT = 3, + SC_COL_REM = 4, + SC_COL_DATA = 5, + SC_COL_INTERVAL = 6, + SC_COL_COUNT = 7, }; namespace Ui { diff --git a/ui/mainwindow.ui b/ui/mainwindow.ui index 80af4a8f..8828f21b 100644 --- a/ui/mainwindow.ui +++ b/ui/mainwindow.ui @@ -26,27 +26,34 @@ SavvyCAN - + - + - - - - 11 - false - - - - true - - - QAbstractItemView::ScrollPerPixel - - - false - - + + + + + + 11 + false + + + + true + + + QAbstractItemView::ScrollPerPixel + + + false + + + + + + + @@ -364,9 +371,6 @@ - - -