canframemodel now receives frames from CANConManager
This commit is contained in:
+19
-26
@@ -282,7 +282,7 @@ QVariant CANFrameModel::headerData(int section, Qt::Orientation orientation,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CANFrameModel::addFrame(CANFrame& frame, bool autoRefresh = false)
|
void CANFrameModel::addFrame(const CANFrame& frame, bool autoRefresh = false)
|
||||||
{
|
{
|
||||||
/*TODO: remove mutex */
|
/*TODO: remove mutex */
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
@@ -346,6 +346,15 @@ void CANFrameModel::addFrame(CANFrame& frame, bool autoRefresh = false)
|
|||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CANFrameModel::addFrames(const CANConnection*, const QVector<CANFrame>& pFrames)
|
||||||
|
{
|
||||||
|
foreach(const CANFrame& frame, pFrames)
|
||||||
|
{
|
||||||
|
addFrame(frame);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CANFrameModel::sendRefresh()
|
void CANFrameModel::sendRefresh()
|
||||||
{
|
{
|
||||||
qDebug() << "Sending mass refresh";
|
qDebug() << "Sending mass refresh";
|
||||||
@@ -377,38 +386,22 @@ void CANFrameModel::sendRefresh(int pos)
|
|||||||
//issue a refresh for the last num entries in the model.
|
//issue a refresh for the last num entries in the model.
|
||||||
//used by the serial worker to do batch updates so it doesn't
|
//used by the serial worker to do batch updates so it doesn't
|
||||||
//have to send thousands of messages per second
|
//have to send thousands of messages per second
|
||||||
void CANFrameModel::sendBulkRefresh(int num)
|
int CANFrameModel::sendBulkRefresh()
|
||||||
{
|
{
|
||||||
//yes, num was sent to us by the serial worker but we actually have a better idea
|
int num = filteredFrames.count() - lastUpdateNumFrames;
|
||||||
//of how many by tracking the number we last knew about as opposed to how many rows there
|
if (num <= 0) return 0;
|
||||||
//are now.
|
|
||||||
num = filteredFrames.count() - lastUpdateNumFrames;
|
|
||||||
|
|
||||||
if (num < 0) return;
|
if (num == 0 && !overwriteDups) return 0;
|
||||||
|
if (filteredFrames.count() == 0) return 0;
|
||||||
//qDebug() << "Num: " << num;
|
|
||||||
|
|
||||||
if (num == 0 && !overwriteDups) return;
|
|
||||||
if (filteredFrames.count() == 0) return;
|
|
||||||
|
|
||||||
lastUpdateNumFrames += num; //done this way to avoid asking for filteredFrames.count() again
|
lastUpdateNumFrames += num; //done this way to avoid asking for filteredFrames.count() again
|
||||||
|
|
||||||
qDebug() << "Bulk refresh of " << num;
|
qDebug() << "Bulk refresh of " << num;
|
||||||
|
|
||||||
if (!overwriteDups)
|
beginResetModel();
|
||||||
{
|
endResetModel();
|
||||||
//if (num > filteredFrames.count()) num = filteredFrames.count();
|
|
||||||
//qDebug() << "From " << (filteredFrames.count() - num) << " to " << (filteredFrames.count() - 1);
|
return num;
|
||||||
//beginInsertRows(QModelIndex(), filteredFrames.count() - num, filteredFrames.count() - 1);
|
|
||||||
//endInsertRows();
|
|
||||||
beginResetModel();
|
|
||||||
endResetModel();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
beginResetModel();
|
|
||||||
endResetModel();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CANFrameModel::clearFrames()
|
void CANFrameModel::clearFrames()
|
||||||
|
|||||||
+4
-2
@@ -8,6 +8,7 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include "can_structs.h"
|
#include "can_structs.h"
|
||||||
#include "dbchandler.h"
|
#include "dbchandler.h"
|
||||||
|
#include "connections/canconnection.h"
|
||||||
|
|
||||||
class CANFrameModel: public QAbstractTableModel
|
class CANFrameModel: public QAbstractTableModel
|
||||||
{
|
{
|
||||||
@@ -25,7 +26,7 @@ public:
|
|||||||
|
|
||||||
void sendRefresh();
|
void sendRefresh();
|
||||||
void sendRefresh(int);
|
void sendRefresh(int);
|
||||||
void sendBulkRefresh(int);
|
int sendBulkRefresh();
|
||||||
void clearFrames();
|
void clearFrames();
|
||||||
void setDBCHandler(DBCHandler *);
|
void setDBCHandler(DBCHandler *);
|
||||||
void setInterpetMode(bool);
|
void setInterpetMode(bool);
|
||||||
@@ -46,7 +47,8 @@ public:
|
|||||||
const QMap<int, bool> *getFiltersReference() const; //this neither
|
const QMap<int, bool> *getFiltersReference() const; //this neither
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addFrame(CANFrame&, bool);
|
void addFrame(const CANFrame&, bool);
|
||||||
|
void addFrames(const CANConnection*, const QVector<CANFrame>&);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updatedFiltersList();
|
void updatedFiltersList();
|
||||||
|
|||||||
Reference in New Issue
Block a user