Merge branch 'master' of github.com:collin80/SavvyCAN into WIP2
This commit is contained in:
+19
-6
@@ -43,8 +43,21 @@ int CANFrameModel::columnCount(const QModelIndex &index) const
|
||||
CANFrameModel::CANFrameModel(QObject *parent)
|
||||
: QAbstractTableModel(parent)
|
||||
{
|
||||
frames.reserve(50000000); //yes, preallocating a huge number of frames.
|
||||
filteredFrames.reserve(50000000); //the goal is to prevent a reallocation from ever happening
|
||||
|
||||
if (QSysInfo::WordSize > 32)
|
||||
{
|
||||
qDebug() << "64 bit OS detected. Requesting a large preallocation";
|
||||
preallocSize = 50000000;
|
||||
}
|
||||
else //if compiling for 32 bit you can't ask for gigabytes of preallocation so tone it down.
|
||||
{
|
||||
qDebug() << "32 bit OS detected. Requesting a much restricted prealloc";
|
||||
preallocSize = 5000000;
|
||||
}
|
||||
|
||||
frames.reserve(preallocSize);
|
||||
filteredFrames.reserve(preallocSize); //the goal is to prevent a reallocation from ever happening
|
||||
|
||||
dbcHandler = NULL;
|
||||
interpretFrames = false;
|
||||
overwriteDups = false;
|
||||
@@ -168,7 +181,7 @@ void CANFrameModel::recalcOverwrite()
|
||||
while (frames.count() > lastUnique) frames.removeLast();
|
||||
|
||||
filteredFrames.clear();
|
||||
filteredFrames.reserve(50000000);
|
||||
filteredFrames.reserve(preallocSize);
|
||||
|
||||
for (int i = 0; i < frames.count(); i++)
|
||||
{
|
||||
@@ -380,7 +393,7 @@ void CANFrameModel::sendRefresh()
|
||||
beginResetModel();
|
||||
filteredFrames.clear();
|
||||
filteredFrames.append(tempContainer);
|
||||
filteredFrames.reserve(50000000);
|
||||
filteredFrames.reserve(preallocSize);
|
||||
lastUpdateNumFrames = filteredFrames.count();
|
||||
endResetModel();
|
||||
mutex.unlock();
|
||||
@@ -420,8 +433,8 @@ void CANFrameModel::clearFrames()
|
||||
frames.clear();
|
||||
filteredFrames.clear();
|
||||
filters.clear();
|
||||
frames.reserve(50000000);
|
||||
filteredFrames.reserve(50000000);
|
||||
frames.reserve(preallocSize);
|
||||
filteredFrames.reserve(preallocSize);
|
||||
this->endResetModel();
|
||||
lastUpdateNumFrames = 0;
|
||||
mutex.unlock();
|
||||
|
||||
@@ -67,6 +67,7 @@ private:
|
||||
bool needFilterRefresh;
|
||||
uint64_t timeOffset;
|
||||
int lastUpdateNumFrames;
|
||||
uint32_t preallocSize;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-11
@@ -34,7 +34,6 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
|
||||
ui->tableConnections->setColumnWidth(7, 75);
|
||||
ui->ckSingleWire->setChecked(settings.value("Main/SingleWireMode", false).toBool());
|
||||
|
||||
ui->cbSpeed->addItem(tr("<Default>"));
|
||||
ui->cbSpeed->addItem(tr("125000"));
|
||||
ui->cbSpeed->addItem(tr("250000"));
|
||||
ui->cbSpeed->addItem(tr("500000"));
|
||||
@@ -176,15 +175,7 @@ void ConnectionWindow::handleOKButton()
|
||||
bus.setListenOnly(ui->ckListenOnly->isChecked());
|
||||
bus.setSingleWire(ui->ckSingleWire->isChecked());
|
||||
bus.setEnabled(ui->ckEnabled->isChecked());
|
||||
if (ui->cbSpeed->currentIndex() == 0)
|
||||
{
|
||||
bus.speed = 0;
|
||||
bus.setEnabled(false);
|
||||
}
|
||||
else if (ui->cbSpeed->currentIndex() >= 1)
|
||||
{
|
||||
bus.setSpeed(ui->cbSpeed->currentText().toInt());
|
||||
}
|
||||
/* update bus settings */
|
||||
conn_p->setBusSettings(busId, bus);
|
||||
|
||||
@@ -204,8 +195,7 @@ void ConnectionWindow::handleOKButton()
|
||||
bus.listenOnly = ui->ckListenOnly->isChecked();
|
||||
bus.singleWire = ui->ckSingleWire->isChecked();
|
||||
|
||||
if (ui->cbSpeed->currentIndex() < 1) bus.speed = 0;
|
||||
else bus.speed = ui->cbSpeed->currentText().toInt();
|
||||
bus.speed = ui->cbSpeed->currentText().toInt();
|
||||
|
||||
/* update bus settings */
|
||||
conn_p->setBusSettings(i, bus);
|
||||
|
||||
+55
-15
@@ -158,9 +158,9 @@ void FlowViewWindow::writeSettings()
|
||||
|
||||
/*
|
||||
* Keyboard shortcuts to allow for quick work without needing to move around a mouse.
|
||||
* E = resume or pause playback
|
||||
* Q = go back one frame
|
||||
* W = go forward one frame
|
||||
* R = resume or pause playback
|
||||
* T = go back one frame
|
||||
* Y = go forward one frame
|
||||
*/
|
||||
bool FlowViewWindow::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
@@ -371,27 +371,64 @@ void FlowViewWindow::updatedFrames(int numFrames)
|
||||
else //just got some new frames. See if they are relevant.
|
||||
{
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
int refID = frameCache[0].ID;
|
||||
int refID;
|
||||
if (frameCache.count() > 0) refID = frameCache[0].ID;
|
||||
else refID = 0;
|
||||
bool needRefresh = false;
|
||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||
{
|
||||
thisFrame = modelFrames->at(i);
|
||||
|
||||
if (!foundID.contains(thisFrame.ID))
|
||||
{
|
||||
foundID.append(thisFrame.ID);
|
||||
QListWidgetItem* item = new QListWidgetItem(Utility::formatNumber(thisFrame.ID), ui->listFrameID);
|
||||
}
|
||||
|
||||
if (thisFrame.ID == refID)
|
||||
{
|
||||
frameCache.append(thisFrame);
|
||||
if (ui->cbLiveMode->checkState() == Qt::Checked)
|
||||
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
currentPosition = frameCache.count() - 1;
|
||||
if (ui->cbTimeGraph->isChecked())
|
||||
{
|
||||
if (secondsMode){
|
||||
x[k].append((double)(thisFrame.timestamp) / 1000000.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
x[k].append(thisFrame.timestamp);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x[k].append(x[k].count());
|
||||
}
|
||||
y[k].append(thisFrame.data[k]);
|
||||
needRefresh = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ui->cbLiveMode->checkState() == Qt::Checked)
|
||||
{
|
||||
currentPosition = frameCache.count() - 1;
|
||||
memcpy(currBytes, frameCache.at(currentPosition).data, 8);
|
||||
memcpy(refBytes, currBytes, 8);
|
||||
|
||||
}
|
||||
if (needRefresh)
|
||||
{
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
graphRef[k]->setData(x[k], y[k]);
|
||||
}
|
||||
ui->graphView->replot();
|
||||
updateDataView();
|
||||
if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].ID, frameCache[currentPosition].timestamp / 1000000.0);
|
||||
}
|
||||
}
|
||||
updateFrameLabel();
|
||||
}
|
||||
|
||||
void FlowViewWindow::removeAllGraphs()
|
||||
@@ -409,7 +446,10 @@ void FlowViewWindow::createGraph(int byteNum)
|
||||
|
||||
int numEntries = frameCache.count();
|
||||
|
||||
QVector<double> x(numEntries), y(numEntries);
|
||||
x[byteNum].clear();
|
||||
y[byteNum].clear();
|
||||
x[byteNum].resize(numEntries);
|
||||
y[byteNum].resize(numEntries);
|
||||
|
||||
for (int j = 0; j < numEntries; j++)
|
||||
{
|
||||
@@ -418,26 +458,26 @@ void FlowViewWindow::createGraph(int byteNum)
|
||||
if (graphByTime)
|
||||
{
|
||||
if (secondsMode){
|
||||
x[j] = (double)(frameCache[j].timestamp) / 1000000.0;
|
||||
x[byteNum][j] = (double)(frameCache[j].timestamp) / 1000000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
x[j] = frameCache[j].timestamp;
|
||||
x[byteNum][j] = frameCache[j].timestamp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
x[j] = j;
|
||||
x[byteNum][j] = j;
|
||||
}
|
||||
|
||||
y[j] = tempVal;
|
||||
if (y[j] < minval) minval = y[j];
|
||||
if (y[j] > maxval) maxval = y[j];
|
||||
y[byteNum][j] = tempVal;
|
||||
if (y[byteNum][j] < minval) minval = y[byteNum][j];
|
||||
if (y[byteNum][j] > maxval) maxval = y[byteNum][j];
|
||||
}
|
||||
|
||||
ui->graphView->addGraph();
|
||||
graphRef[byteNum] = ui->graphView->addGraph();
|
||||
ui->graphView->graph()->setName(QString("Graph %1").arg(ui->graphView->graphCount()-1));
|
||||
ui->graphView->graph()->setData(x,y);
|
||||
ui->graphView->graph()->setData(x[byteNum],y[byteNum]);
|
||||
ui->graphView->graph()->setLineStyle(QCPGraph::lsLine); //connect points with lines
|
||||
QPen graphPen;
|
||||
graphPen.setColor(graphColors[byteNum]);
|
||||
|
||||
@@ -55,6 +55,8 @@ private:
|
||||
bool playbackForward;
|
||||
static const QColor graphColors[8];
|
||||
bool secondsMode;
|
||||
QVector<double> x[8], y[8];
|
||||
QCPGraph *graphRef[8];
|
||||
|
||||
void refreshIDList();
|
||||
void updateFrameLabel();
|
||||
|
||||
@@ -394,10 +394,12 @@ void FramePlaybackWindow::btnLoadLive()
|
||||
|
||||
void FramePlaybackWindow::btnBackOneClick()
|
||||
{
|
||||
sendingBuffer.clear();
|
||||
playbackTimer->stop(); //pushing this button halts automatic playback
|
||||
playbackActive = false;
|
||||
|
||||
updatePosition(false);
|
||||
emit sendFrameBatch(&sendingBuffer);
|
||||
}
|
||||
|
||||
void FramePlaybackWindow::btnPauseClick()
|
||||
@@ -444,9 +446,11 @@ void FramePlaybackWindow::btnPlayClick()
|
||||
|
||||
void FramePlaybackWindow::btnFwdOneClick()
|
||||
{
|
||||
sendingBuffer.clear();
|
||||
playbackTimer->stop();
|
||||
playbackActive = false;
|
||||
updatePosition(true);
|
||||
emit sendFrameBatch(&sendingBuffer);
|
||||
}
|
||||
|
||||
void FramePlaybackWindow::changePlaybackSpeed(int newSpeed)
|
||||
|
||||
+11
-5
@@ -142,6 +142,7 @@ void GraphingWindow::updatedFrames(int numFrames)
|
||||
}
|
||||
else //just got some new frames. See if they are relevant.
|
||||
{
|
||||
bool appendedToGraph = false;
|
||||
if (numFrames > modelFrames->count()) return;
|
||||
for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++)
|
||||
{
|
||||
@@ -151,11 +152,18 @@ void GraphingWindow::updatedFrames(int numFrames)
|
||||
if (graphParams[j].ID == thisFrame.ID)
|
||||
{
|
||||
appendToGraph(graphParams[j], thisFrame);
|
||||
appendedToGraph = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (appendedToGraph) {
|
||||
for (int j = 0; j < graphParams.count(); j++)
|
||||
{
|
||||
graphParams[j].ref->setData(graphParams[j].x, graphParams[j].y);
|
||||
}
|
||||
ui->graphingView->replot();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphingWindow::plottableDoubleClick(QCPAbstractPlottable* plottable, QMouseEvent* event)
|
||||
@@ -829,7 +837,7 @@ void GraphingWindow::loadDefinitions()
|
||||
|
||||
for (int b = 0; b < 8; b++)
|
||||
{
|
||||
if (oldMask & (1 << b))
|
||||
if (oldMask & (1ull << b))
|
||||
{
|
||||
gp.startBit = (8 * oldEnd) + b;
|
||||
break;
|
||||
@@ -838,7 +846,7 @@ void GraphingWindow::loadDefinitions()
|
||||
|
||||
for (int c = 7; c >= 0; c--)
|
||||
{
|
||||
if ( oldMask & (1<<(((numBytes - 1) * 8) + c)) )
|
||||
if ( oldMask & (1ull << (((numBytes - 1) * 8) + c)) )
|
||||
{
|
||||
gp.numBits -= (7-c);
|
||||
break;
|
||||
@@ -857,7 +865,7 @@ void GraphingWindow::loadDefinitions()
|
||||
gp.numBits = 8;
|
||||
for (int b = 0; b < 8; b++)
|
||||
{
|
||||
if (oldMask & (1 << b))
|
||||
if (oldMask & (1ull << b))
|
||||
{
|
||||
gp.startBit = 8 * oldStart + b;
|
||||
gp.numBits = 8 - b;
|
||||
@@ -931,8 +939,6 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame)
|
||||
params.x.append(frame.timestamp - params.xbias);
|
||||
}
|
||||
params.y.append((tempVal * params.scale) + params.bias);
|
||||
|
||||
params.ref->setData(params.x,params.y);
|
||||
}
|
||||
|
||||
void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||
|
||||
Reference in New Issue
Block a user