Fix for a variety of small issues with sniffer window.

This commit is contained in:
Collin Kidder
2018-10-23 20:42:05 -04:00
parent dd1c6b8a6e
commit fbc71103af
3 changed files with 13 additions and 7 deletions
+7 -3
View File
@@ -3,18 +3,21 @@
#include "snifferitem.h" #include "snifferitem.h"
SnifferItem::SnifferItem(const CANFrame& pFrame): SnifferItem::SnifferItem(const CANFrame& pFrame, quint32 seq):
mID(pFrame.ID) mID(pFrame.ID)
{ {
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
mNotch[i] =0; mNotch[i] =0;
mMarker.data[i] = 0; mMarker.data[i] = 0;
mMarker.dataTimestamp[i] = 0; mMarker.dataTimestamp[i] = 0;
mCurrent.data[i] = pFrame.data[i];
mCurrent.dataTimestamp[i] = seq;
} }
mLastMarker = mMarker; mLastMarker = mMarker;
mCurrent.len = pFrame.len;
/* that's dirty */ /* that's dirty */
update(pFrame, 0); update(pFrame, seq);
update(pFrame, 0); update(pFrame, seq);
} }
@@ -84,6 +87,7 @@ int SnifferItem::elapsed() const
//called when a new frame comes in that matches our same ID //called when a new frame comes in that matches our same ID
void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq) void SnifferItem::update(const CANFrame& pFrame, quint32 timeSeq)
{ {
//qDebug() << "update with ts: " << timeSeq;
/* copy current to last */ /* copy current to last */
mLast = mCurrent; mLast = mCurrent;
mLastTime = mCurrentTime; mLastTime = mCurrentTime;
+1 -1
View File
@@ -23,7 +23,7 @@ enum dc
class SnifferItem class SnifferItem
{ {
public: public:
explicit SnifferItem(const CANFrame& pFrame); explicit SnifferItem(const CANFrame& pFrame, quint32 seq);
virtual ~SnifferItem(); virtual ~SnifferItem();
quint64 getId() const; quint64 getId() const;
+5 -3
View File
@@ -68,8 +68,10 @@ QVariant SnifferModel::data(const QModelIndex &index, int role) const
case Qt::ForegroundRole: case Qt::ForegroundRole:
{ {
if (!mFadeInactive || col < 2) return QBrush(Qt::black); if (!mFadeInactive || col < 2) return QBrush(Qt::black);
int v = (mTimeSequence - item->getDataTimestamp(col - 2)) * 20; int v = (mTimeSequence - item->getDataTimestamp(col - 2)) * 10;
if (v > 215) v = 215; //qDebug() << "mTS: " << mTimeSequence << " gDT(" << (col - 2) << ") " << item->getDataTimestamp(col - 2);
if (v > 225) v = 225;
if (v < 0) v = 0;
return QBrush(QColor(v,v,v,255)); return QBrush(QColor(v,v,v,255));
break; break;
} }
@@ -281,7 +283,7 @@ void SnifferModel::update(CANConnection*, QVector<CANFrame>& pFrames)
int index = std::distance(mMap.begin(), mMap.lowerBound(frame.ID)); int index = std::distance(mMap.begin(), mMap.lowerBound(frame.ID));
/* add the frame */ /* add the frame */
beginInsertRows(QModelIndex(), index, index); beginInsertRows(QModelIndex(), index, index);
mMap[frame.ID] = new SnifferItem(frame); mMap[frame.ID] = new SnifferItem(frame, mTimeSequence);
mMap[frame.ID]->update(frame, mTimeSequence); mMap[frame.ID]->update(frame, mTimeSequence);
endInsertRows(); endInsertRows();