canframemodel now receives frames from CANConManager

This commit is contained in:
canpadawan
2016-06-29 11:57:52 +02:00
parent 9addf43651
commit 916ed4e657
2 changed files with 23 additions and 28 deletions
+19 -26
View File
@@ -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 */
mutex.lock();
@@ -346,6 +346,15 @@ void CANFrameModel::addFrame(CANFrame& frame, bool autoRefresh = false)
mutex.unlock();
}
void CANFrameModel::addFrames(const CANConnection*, const QVector<CANFrame>& pFrames)
{
foreach(const CANFrame& frame, pFrames)
{
addFrame(frame);
}
}
void CANFrameModel::sendRefresh()
{
qDebug() << "Sending mass refresh";
@@ -377,38 +386,22 @@ void CANFrameModel::sendRefresh(int pos)
//issue a refresh for the last num entries in the model.
//used by the serial worker to do batch updates so it doesn't
//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
//of how many by tracking the number we last knew about as opposed to how many rows there
//are now.
num = filteredFrames.count() - lastUpdateNumFrames;
int num = filteredFrames.count() - lastUpdateNumFrames;
if (num <= 0) return 0;
if (num < 0) return;
//qDebug() << "Num: " << num;
if (num == 0 && !overwriteDups) return;
if (filteredFrames.count() == 0) return;
if (num == 0 && !overwriteDups) return 0;
if (filteredFrames.count() == 0) return 0;
lastUpdateNumFrames += num; //done this way to avoid asking for filteredFrames.count() again
qDebug() << "Bulk refresh of " << num;
if (!overwriteDups)
{
//if (num > filteredFrames.count()) num = filteredFrames.count();
//qDebug() << "From " << (filteredFrames.count() - num) << " to " << (filteredFrames.count() - 1);
//beginInsertRows(QModelIndex(), filteredFrames.count() - num, filteredFrames.count() - 1);
//endInsertRows();
beginResetModel();
endResetModel();
}
else
{
beginResetModel();
endResetModel();
}
beginResetModel();
endResetModel();
return num;
}
void CANFrameModel::clearFrames()
+4 -2
View File
@@ -8,6 +8,7 @@
#include <QMutex>
#include "can_structs.h"
#include "dbchandler.h"
#include "connections/canconnection.h"
class CANFrameModel: public QAbstractTableModel
{
@@ -25,7 +26,7 @@ public:
void sendRefresh();
void sendRefresh(int);
void sendBulkRefresh(int);
int sendBulkRefresh();
void clearFrames();
void setDBCHandler(DBCHandler *);
void setInterpetMode(bool);
@@ -46,7 +47,8 @@ public:
const QMap<int, bool> *getFiltersReference() const; //this neither
public slots:
void addFrame(CANFrame&, bool);
void addFrame(const CANFrame&, bool);
void addFrames(const CANConnection*, const QVector<CANFrame>&);
signals:
void updatedFiltersList();