Added a new window that allows for bisecting a CAN log into pieces along a variety of patterns. Not quite complete but what's there works.
This commit is contained in:
+7
-3
@@ -58,7 +58,8 @@ SOURCES += main.cpp\
|
||||
connections/canconnectionmodel.cpp \
|
||||
connections/connectionwindow.cpp \
|
||||
re/graphingwindow.cpp \
|
||||
re/newgraphdialog.cpp
|
||||
re/newgraphdialog.cpp \
|
||||
bisectwindow.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
can_structs.h \
|
||||
@@ -105,7 +106,9 @@ HEADERS += mainwindow.h \
|
||||
connections/canconnectionmodel.h \
|
||||
connections/connectionwindow.h \
|
||||
re/graphingwindow.h \
|
||||
re/newgraphdialog.h
|
||||
re/newgraphdialog.h \
|
||||
ui/bisectwindow.h \
|
||||
bisectwindow.h
|
||||
|
||||
FORMS += ui/candatagrid.ui \
|
||||
ui/connectionwindow.ui \
|
||||
@@ -129,7 +132,8 @@ FORMS += ui/candatagrid.ui \
|
||||
ui/rangestatewindow.ui \
|
||||
ui/scriptingwindow.ui \
|
||||
ui/snifferwindow.ui \
|
||||
ui/udsscanwindow.ui
|
||||
ui/udsscanwindow.ui \
|
||||
ui/bisectwindow.ui
|
||||
|
||||
DISTFILES +=
|
||||
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
#include "bisectwindow.h"
|
||||
#include "ui_bisectwindow.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "framefileio.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <algorithm>
|
||||
|
||||
BisectWindow::BisectWindow(const QVector<CANFrame> *frames, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::BisectWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
modelFrames = frames;
|
||||
|
||||
connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int)));
|
||||
connect(ui->btnCalculate, &QAbstractButton::clicked, this, &BisectWindow::handleCalculateButton);
|
||||
connect(ui->btnReplaceFrames, &QAbstractButton::clicked, this, &BisectWindow::handleReplaceButton);
|
||||
connect(ui->btnSaveFrames, &QAbstractButton::clicked, this, &BisectWindow::handleSaveButton);
|
||||
connect(ui->slideFrameNumber, &QSlider::sliderReleased, this, &BisectWindow::updateFrameNumText);
|
||||
connect(ui->slidePercentage, &QSlider::sliderReleased, this, &BisectWindow::updatePercentText);
|
||||
connect(ui->editFrameNumber, &QLineEdit::editingFinished, this, &BisectWindow::updateFrameNumSlider);
|
||||
connect(ui->editPercentage, &QLineEdit::editingFinished, this, &BisectWindow::updatePercentSlider);
|
||||
}
|
||||
|
||||
BisectWindow::~BisectWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void BisectWindow::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
refreshIDList();
|
||||
refreshFrameNumbers();
|
||||
updateFrameNumText();
|
||||
updatePercentText();
|
||||
}
|
||||
|
||||
void BisectWindow::refreshIDList()
|
||||
{
|
||||
int id;
|
||||
for (int i = 0; i < modelFrames->count(); i++)
|
||||
{
|
||||
id = modelFrames->at(i).ID;
|
||||
if (!foundID.contains(id))
|
||||
{
|
||||
foundID.append(id);
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(foundID.begin(), foundID.end());
|
||||
|
||||
foreach (int id, foundID) {
|
||||
ui->cbIDLower->addItem(Utility::formatNumber(id));
|
||||
ui->cbIDUpper->addItem(Utility::formatNumber(id));
|
||||
}
|
||||
}
|
||||
|
||||
void BisectWindow::refreshFrameNumbers()
|
||||
{
|
||||
ui->labelMainListNum->setText(QString::number(modelFrames->count()));
|
||||
ui->labelSplitNum->setText(QString::number(splitFrames.count()));
|
||||
ui->slideFrameNumber->setMaximum(modelFrames->count());
|
||||
}
|
||||
|
||||
void BisectWindow::updatedFrames(int numFrames)
|
||||
{
|
||||
if (numFrames == -1) //all frames deleted
|
||||
{
|
||||
refreshFrameNumbers();
|
||||
}
|
||||
else if (numFrames == -2) //all new set of frames. Reset
|
||||
{
|
||||
refreshFrameNumbers();
|
||||
refreshIDList();
|
||||
}
|
||||
else //just got some new frames. See if they are relevant.
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void BisectWindow::handleCalculateButton()
|
||||
{
|
||||
splitFrames.clear();
|
||||
bool saveLower = ui->rbLowerSection->isChecked();
|
||||
int targetFrameNum;
|
||||
if (ui->rbFrameNumber->isChecked() || ui->rbPercentage->isChecked())
|
||||
{
|
||||
if (ui->rbFrameNumber->isChecked()) targetFrameNum = ui->slideFrameNumber->value();
|
||||
else targetFrameNum = modelFrames->count() * ui->slidePercentage->value() / 10000;
|
||||
if (saveLower)
|
||||
{
|
||||
for (int i = 0; i < targetFrameNum; i++) splitFrames.append(modelFrames->at(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = targetFrameNum; i < modelFrames->count(); i++) splitFrames.append(modelFrames->at(i));
|
||||
}
|
||||
}
|
||||
else if (ui->rbIDRange->isChecked())
|
||||
{
|
||||
int lowerID = Utility::ParseStringToNum2(ui->cbIDLower->currentText());
|
||||
int upperID = Utility::ParseStringToNum2(ui->cbIDUpper->currentText());
|
||||
for (int i = 0; i < modelFrames->count(); i++)
|
||||
{
|
||||
if (modelFrames->at(i).ID >= lowerID && modelFrames->at(i).ID <= upperID) splitFrames.append(modelFrames->at(i));
|
||||
}
|
||||
}
|
||||
refreshFrameNumbers();
|
||||
}
|
||||
|
||||
void BisectWindow::handleReplaceButton()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BisectWindow::handleSaveButton()
|
||||
{
|
||||
QMessageBox msg;
|
||||
QString filename;
|
||||
if (FrameFileIO::saveFrameFile(filename, &splitFrames))
|
||||
{
|
||||
msg.setText(tr("Successfully saved file"));
|
||||
}
|
||||
else
|
||||
{
|
||||
msg.setText(tr("Error while attempting to save."));
|
||||
}
|
||||
msg.exec();
|
||||
}
|
||||
|
||||
void BisectWindow::updateFrameNumSlider()
|
||||
{
|
||||
ui->slideFrameNumber->setValue(ui->editFrameNumber->text().toInt());
|
||||
}
|
||||
|
||||
void BisectWindow::updatePercentSlider()
|
||||
{
|
||||
ui->slidePercentage->setValue(ui->editPercentage->text().toFloat() * 100);
|
||||
}
|
||||
|
||||
void BisectWindow::updateFrameNumText()
|
||||
{
|
||||
ui->editFrameNumber->setText(QString::number(ui->slideFrameNumber->value()));
|
||||
}
|
||||
|
||||
void BisectWindow::updatePercentText()
|
||||
{
|
||||
ui->editPercentage->setText(QString::number(ui->slidePercentage->value() / 100.0f));
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#ifndef BISECTWINDOW_H
|
||||
#define BISECTWINDOW_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "can_structs.h"
|
||||
|
||||
namespace Ui {
|
||||
class BisectWindow;
|
||||
}
|
||||
|
||||
class BisectWindow : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BisectWindow(const QVector<CANFrame> *frames, QWidget *parent = 0);
|
||||
~BisectWindow();
|
||||
void showEvent(QShowEvent*);
|
||||
|
||||
signals:
|
||||
void sendCANFrame(const CANFrame *, int);
|
||||
void sendFrameBatch(const QList<CANFrame> *);
|
||||
|
||||
private slots:
|
||||
void updatedFrames(int numFrames);
|
||||
void handleSaveButton();
|
||||
void handleReplaceButton();
|
||||
void handleCalculateButton();
|
||||
void updateFrameNumSlider();
|
||||
void updatePercentSlider();
|
||||
void updateFrameNumText();
|
||||
void updatePercentText();
|
||||
|
||||
private:
|
||||
Ui::BisectWindow *ui;
|
||||
const QVector<CANFrame> *modelFrames;
|
||||
QVector<CANFrame> splitFrames;
|
||||
QList<int> foundID;
|
||||
|
||||
void refreshIDList();
|
||||
void refreshFrameNumbers();
|
||||
};
|
||||
|
||||
#endif // BISECTWINDOW_H
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
motorctrlConfigWindow = NULL;
|
||||
isoWindow = NULL;
|
||||
snifferWindow = NULL;
|
||||
bisectWindow = NULL;
|
||||
dbcHandler = new DBCHandler;
|
||||
bDirty = false;
|
||||
inhibitFilterUpdate = false;
|
||||
@@ -126,6 +127,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(ui->actionISO_TP_Decoder, &QAction::triggered, this, &MainWindow::showISOInterpreterWindow);
|
||||
connect(ui->actionSniffer, &QAction::triggered, this, &MainWindow::showSnifferWindow);
|
||||
connect(ui->actionMotorControlConfig, &QAction::triggered, this, &MainWindow::showMCConfigWindow);
|
||||
connect(ui->actionCapture_Bisector, &QAction::triggered, this, &MainWindow::showBisectWindow);
|
||||
|
||||
connect(CANConManager::getInstance(), &CANConManager::framesReceived, model, &CANFrameModel::addFrames);
|
||||
|
||||
@@ -274,6 +276,13 @@ MainWindow::~MainWindow()
|
||||
snifferWindow = NULL;
|
||||
}
|
||||
|
||||
if (bisectWindow)
|
||||
{
|
||||
bisectWindow->close();
|
||||
delete bisectWindow;
|
||||
bisectWindow = NULL;
|
||||
}
|
||||
|
||||
delete model;
|
||||
delete elapsedTime;
|
||||
delete dbcHandler;
|
||||
@@ -854,6 +863,14 @@ void MainWindow::showSnifferWindow()
|
||||
snifferWindow->show();
|
||||
}
|
||||
|
||||
void MainWindow::showBisectWindow()
|
||||
{
|
||||
if (!bisectWindow)
|
||||
{
|
||||
bisectWindow = new BisectWindow(model->getListReference());
|
||||
}
|
||||
bisectWindow->show();
|
||||
}
|
||||
|
||||
void MainWindow::showFrameSenderWindow()
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "re/graphingwindow.h"
|
||||
#include "re/frameinfowindow.h"
|
||||
#include "frameplaybackwindow.h"
|
||||
#include "bisectwindow.h"
|
||||
#include "re/flowviewwindow.h"
|
||||
#include "framesenderwindow.h"
|
||||
#include "re/filecomparatorwindow.h"
|
||||
@@ -71,6 +72,7 @@ private slots:
|
||||
void showUDSScanWindow();
|
||||
void showISOInterpreterWindow();
|
||||
void showSnifferWindow();
|
||||
void showBisectWindow();
|
||||
void exitApp();
|
||||
void handleSaveDecoded();
|
||||
void connectionFailed();
|
||||
@@ -143,6 +145,7 @@ private:
|
||||
ISOTP_InterpreterWindow *isoWindow;
|
||||
SnifferWindow* snifferWindow;
|
||||
MotorControllerConfigWindow *motorctrlConfigWindow;
|
||||
BisectWindow* bisectWindow;
|
||||
|
||||
//various private storage
|
||||
QLabel lbStatusConnected;
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>BisectWindow</class>
|
||||
<widget class="QDialog" name="BisectWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>692</width>
|
||||
<height>319</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Bisector Window</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Splitting Strategy:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbIDRange">
|
||||
<property name="text">
|
||||
<string>ID Range</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbIDLower"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>TO</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbIDUpper"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3" stretch="1,10,3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbFrameNumber">
|
||||
<property name="text">
|
||||
<string>Frame Number</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="slideFrameNumber">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editFrameNumber"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,10,3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbPercentage">
|
||||
<property name="text">
|
||||
<string>Percentage</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSlider" name="slidePercentage">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<property name="pageStep">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="editPercentage"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Save Which Side:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbLowerSection">
|
||||
<property name="text">
|
||||
<string>Lower Section</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbUpperSection">
|
||||
<property name="text">
|
||||
<string>Upper Section</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Number of Frames in Main List:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelMainListNum">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Saved Frames after split:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelSplitNum">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnCalculate">
|
||||
<property name="text">
|
||||
<string>Calculate Split</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnSaveFrames">
|
||||
<property name="text">
|
||||
<string>Save split frames to a new file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnReplaceFrames">
|
||||
<property name="text">
|
||||
<string>Replace main list with split frames</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -215,6 +215,7 @@
|
||||
<addaction name="actionSingle_Multi_State_2"/>
|
||||
<addaction name="actionISO_TP_Decoder"/>
|
||||
<addaction name="actionSniffer"/>
|
||||
<addaction name="actionCapture_Bisector"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuSend_Frames">
|
||||
<property name="title">
|
||||
@@ -413,6 +414,11 @@
|
||||
<string>MotorControlConfig</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCapture_Bisector">
|
||||
<property name="text">
|
||||
<string>Capture Bisector</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
|
||||
Reference in New Issue
Block a user