Files
giesCANne/canframemodel.h
T
mjuhanne 428b19c5c4 - Save DBC file configuration when changed, and restore it when restarting the application (no need for manual entry everytime app is launched)
- Add GMLAN 29bit filtering feature. In addition to J1939 matching, it is now possible to match DBC messages using only the Arbitration Id (bits 14-26 of CAN Address), since  Priority id (higher bits) and Sender Id (lowest 13 bits) are not relevant when interpreting the CAN message content. This allows to use the excellent GM Global A DBC files on https://github.com/commaai/opendbc. Just remember to select the "GMLAN" matching criteria on DBC File manager.
- Add "Filter labeling" feature. Using loaded DBC files, it matches the filter Ids with DBC messages and shows them in filter windows. Labeling works in the main window (no need to set "Frame interpret" on, since this is a separate feature), as well as in Flow view, Frame data analysis, Playback and Fuzzzing windows. This makes it so much easier to concentrate on those CAN messages that matter. To use this feature, select global "Label filters using messages from DBC files" on Main Configuration page, and then enable the feature on individual DBC files (on DBC file manager) as needed. This is needed if there's overlap in CAN addresses between DBC files, and because the filter labeler cannot tell apart anymore which Filter ID is associated to which bus, it might label them incorrectly. But usually it's ok to just enable the labeling with all the DBC files.
- In Frame data analysis window, in addition to J1939 decoding show also GMLAN (Priority bits, Arbitration Id, Sender Id) decoding.
- FilterUtility static class used for centralized ListWidgetItem creation and for other helper functions
- DBC handler: To allow setting bus numbers even before connection is configured, do not enforce "valid" bus numbers
2019-08-11 23:16:02 +03:00

100 lines
3.3 KiB
C++

#ifndef CANFRAMEMODEL_H
#define CANFRAMEMODEL_H
#include <QAbstractTableModel>
#include <QList>
#include <QVector>
#include <QDebug>
#include <QMutex>
#include "can_structs.h"
#include "dbc/dbchandler.h"
#include "connections/canconnection.h"
enum class Column {
TimeStamp = 0, ///< The timestamp when the frame was transmitted or received
FrameId = 1, ///< The frames CAN identifier (Standard: 11 or Extended: 29 bit)
Extended = 2, ///< True if the frames CAN identifier is 29 bit
Remote = 3, ///< True if the frames is a remote frame
Direction = 4, ///< Whether the frame was transmitted or received
Bus = 5, ///< The bus where the frame was transmitted or received
Length = 6, ///< The frames payload data length
ASCII = 7, ///< The payload interpreted as ASCII characters
Data = 8, ///< The frames payload data
NUM_COLUMN
};
class CANFrameModel: public QAbstractTableModel
{
Q_OBJECT
public:
CANFrameModel(QObject *parent = 0);
virtual ~CANFrameModel();
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
int columnCount(const QModelIndex &) const;
int totalFrameCount();
void sendRefresh();
void sendRefresh(int);
int sendBulkRefresh();
void clearFrames();
void setInterpretMode(bool);
bool getInterpretMode();
void setOverwriteMode(bool);
void setHexMode(bool);
void setSysTimeMode(bool);
void setFilterState(unsigned int ID, bool state);
void setAllFilters(bool state);
void setSecondsMode(bool);
void setTimeFormat(QString);
void loadFilterFile(QString filename);
void saveFilterFile(QString filename);
void normalizeTiming();
void recalcOverwrite();
bool needsFilterRefresh();
void insertFrames(const QVector<CANFrame> &newFrames);
void sortByColumn(int column);
int getIndexFromTimeID(unsigned int ID, double timestamp);
const QVector<CANFrame> *getListReference() const; //thou shalt not modify these frames externally!
const QVector<CANFrame> *getFilteredListReference() const; //Thus saith the Lord, NO.
const QMap<int, bool> *getFiltersReference() const; //this neither
public slots:
void addFrame(const CANFrame&, bool);
void addFrames(const CANConnection*, const QVector<CANFrame>&);
signals:
void updatedFiltersList();
private:
void qSortCANFrameAsc(QVector<CANFrame>* frames, Column column, int lowerBound, int upperBound);
void qSortCANFrameDesc(QVector<CANFrame>* frames, Column column, int lowerBound, int upperBound);
uint64_t getCANFrameVal(int row, Column col);
bool any_filters_are_configured(void);
QVector<CANFrame> frames;
QVector<CANFrame> filteredFrames;
QMap<int, bool> filters;
DBCHandler *dbcHandler;
QMutex mutex;
bool interpretFrames; //should we use the dbcHandler?
bool overwriteDups; //should we display all frames or only the newest for each ID?
QString timeFormat;
bool useHexMode;
bool timeSeconds;
bool useSystemTime;
bool needFilterRefresh;
uint64_t timeOffset;
int lastUpdateNumFrames;
uint32_t preallocSize;
bool sortDirAsc;
};
#endif // CANFRAMEMODEL_H