Merge pull request #534 from qurrent-llc/add_reformatdecodeddatafile
Add mainmenu option to export decoded data as csv
This commit is contained in:
@@ -321,8 +321,8 @@ QString SocketCANd::decodeFrames(QString data, int busNum)
|
|||||||
getQueue().queue();
|
getQueue().queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
//else
|
||||||
qDebug() << "can't get a frame, capture suspended";
|
// qDebug() << "can't get a frame, capture suspended";
|
||||||
|
|
||||||
//take out the data that we just processed and anything that is in front of it
|
//take out the data that we just processed and anything that is in front of it
|
||||||
//this should keep broken frames from accumulating at in the data buffer
|
//this should keep broken frames from accumulating at in the data buffer
|
||||||
|
|||||||
+172
@@ -119,6 +119,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||||||
connect(ui->actionFuzzy_Scope, &QAction::triggered, this, &MainWindow::showFuzzyScopeWindow);
|
connect(ui->actionFuzzy_Scope, &QAction::triggered, this, &MainWindow::showFuzzyScopeWindow);
|
||||||
connect(ui->actionRange_State_2, &QAction::triggered, this, &MainWindow::showRangeWindow);
|
connect(ui->actionRange_State_2, &QAction::triggered, this, &MainWindow::showRangeWindow);
|
||||||
connect(ui->actionSave_Decoded_Frames, &QAction::triggered, this, &MainWindow::handleSaveDecoded);
|
connect(ui->actionSave_Decoded_Frames, &QAction::triggered, this, &MainWindow::handleSaveDecoded);
|
||||||
|
connect(ui->actionSave_Decoded_Frames_CSV, &QAction::triggered, this, &MainWindow::handleSaveDecodedCsv);
|
||||||
connect(ui->actionSingle_Multi_State_2, &QAction::triggered, this, &MainWindow::showSingleMultiWindow);
|
connect(ui->actionSingle_Multi_State_2, &QAction::triggered, this, &MainWindow::showSingleMultiWindow);
|
||||||
connect(ui->actionFile_Comparison, &QAction::triggered, this, &MainWindow::showComparisonWindow);
|
connect(ui->actionFile_Comparison, &QAction::triggered, this, &MainWindow::showComparisonWindow);
|
||||||
connect(ui->actionDBC_Comparison, &QAction::triggered, this, &MainWindow::showDBCComparisonWindow);
|
connect(ui->actionDBC_Comparison, &QAction::triggered, this, &MainWindow::showDBCComparisonWindow);
|
||||||
@@ -988,6 +989,16 @@ void MainWindow::handleLoadFilters()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::handleSaveDecoded()
|
void MainWindow::handleSaveDecoded()
|
||||||
|
{
|
||||||
|
handleSaveDecodedMethod(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::handleSaveDecodedCsv()
|
||||||
|
{
|
||||||
|
handleSaveDecodedMethod(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::handleSaveDecodedMethod(bool csv)
|
||||||
{
|
{
|
||||||
QString filename;
|
QString filename;
|
||||||
QFileDialog dialog(this);
|
QFileDialog dialog(this);
|
||||||
@@ -1006,11 +1017,172 @@ void MainWindow::handleSaveDecoded()
|
|||||||
{
|
{
|
||||||
filename = dialog.selectedFiles()[0];
|
filename = dialog.selectedFiles()[0];
|
||||||
if (!filename.contains('.')) filename += ".txt";
|
if (!filename.contains('.')) filename += ".txt";
|
||||||
|
|
||||||
|
if(csv)
|
||||||
|
saveDecodedTextFileAsColumns(filename);
|
||||||
|
else
|
||||||
saveDecodedTextFile(filename);
|
saveDecodedTextFile(filename);
|
||||||
|
|
||||||
settings.setValue("FileIO/LoadSaveDirectory", dialog.directory().path());
|
settings.setValue("FileIO/LoadSaveDirectory", dialog.directory().path());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveDecodedTextFileAsColumns(QString filename)
|
||||||
|
{
|
||||||
|
QFile *outFile = new QFile(filename);
|
||||||
|
const QVector<CANFrame> *frames = model->getFilteredListReference();
|
||||||
|
|
||||||
|
const unsigned char *data;
|
||||||
|
int dataLen;
|
||||||
|
const CANFrame *frame;
|
||||||
|
|
||||||
|
if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text))
|
||||||
|
return;
|
||||||
|
/*
|
||||||
|
Time: 205.173000 ID: 0x20E Std Bus: 0 Len: 8
|
||||||
|
Data Bytes: 88 10 00 13 BB 00 06 00
|
||||||
|
SignalName Value
|
||||||
|
*/
|
||||||
|
QList<QPair<int, int>> msgsAndColumns;
|
||||||
|
int columnsAdded = 0;
|
||||||
|
int dataStartCol = 0;
|
||||||
|
|
||||||
|
QString builderString;
|
||||||
|
//time
|
||||||
|
builderString += tr("Time") + ",";
|
||||||
|
dataStartCol++;
|
||||||
|
//id
|
||||||
|
builderString += tr("ID") + ",";
|
||||||
|
dataStartCol++;
|
||||||
|
//if (frame->hasExtendedFrameFormat()) builderString += tr(" Ext ");
|
||||||
|
//else builderString += tr(" Std ");
|
||||||
|
//bus
|
||||||
|
builderString += tr("Bus") + ",";
|
||||||
|
dataStartCol++;
|
||||||
|
//len
|
||||||
|
builderString += tr("DataLen") + ",";
|
||||||
|
dataStartCol++;
|
||||||
|
|
||||||
|
columnsAdded = dataStartCol;
|
||||||
|
|
||||||
|
//loop through all the frames and the message data therein
|
||||||
|
for (int c = 0; c < frames->count(); c++)
|
||||||
|
{
|
||||||
|
frame = &frames->at(c);
|
||||||
|
data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
|
||||||
|
dataLen = frame->payload().count();
|
||||||
|
|
||||||
|
//add all column names
|
||||||
|
if (dbcHandler != nullptr)
|
||||||
|
{
|
||||||
|
DBC_MESSAGE *msg = dbcHandler->findMessage(*frame);
|
||||||
|
if (msg != nullptr)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for (int j = 0; j < msg->sigHandler->getCount(); j++)
|
||||||
|
{
|
||||||
|
if(j==0)
|
||||||
|
{
|
||||||
|
for(int m=0; m<msgsAndColumns.count(); m++)
|
||||||
|
{
|
||||||
|
if(msgsAndColumns[m].first == msg->ID)
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
if(found == false)
|
||||||
|
msgsAndColumns.append(QPair<int,int>(msg->ID, columnsAdded));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(found == false)
|
||||||
|
{
|
||||||
|
QString temp;
|
||||||
|
if (msg->sigHandler->findSignalByIdx(j)->processAsText(*frame, temp))
|
||||||
|
{
|
||||||
|
builderString.append(msg->sigHandler->findSignalByIdx(j)->name);
|
||||||
|
builderString.append(",");
|
||||||
|
columnsAdded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//add EOL
|
||||||
|
builderString += "\n";
|
||||||
|
//write out the header row
|
||||||
|
outFile->write(builderString.toUtf8());
|
||||||
|
|
||||||
|
//builderString = tr("Data Bytes: ");
|
||||||
|
//for (int temp = 0; temp < dataLen; temp++)
|
||||||
|
//{
|
||||||
|
// builderString += Utility::formatNumber(data[temp]) + " ";
|
||||||
|
//}
|
||||||
|
//builderString += "\n";
|
||||||
|
//outFile->write(builderString.toUtf8());
|
||||||
|
|
||||||
|
int dataColumnsAdded = 0;
|
||||||
|
builderString = "";
|
||||||
|
for (int c = 0; c < frames->count(); c++)
|
||||||
|
{
|
||||||
|
dataColumnsAdded = 0;
|
||||||
|
frame = &frames->at(c);
|
||||||
|
data = reinterpret_cast<const unsigned char *>(frame->payload().constData());
|
||||||
|
dataLen = frame->payload().count();
|
||||||
|
|
||||||
|
QString builderString;
|
||||||
|
builderString += QString::number((frame->timeStamp().microSeconds() / 1000000.0), 'f', 6) + ",";
|
||||||
|
dataColumnsAdded++;
|
||||||
|
//id
|
||||||
|
builderString += Utility::formatCANID(frame->frameId(), frame->hasExtendedFrameFormat()) + ",";
|
||||||
|
dataColumnsAdded++;
|
||||||
|
//if (frame->hasExtendedFrameFormat()) builderString += tr(" Ext ");
|
||||||
|
//else builderString += tr(" Std ");
|
||||||
|
//bus
|
||||||
|
builderString += QString::number(frame->bus) + ",";
|
||||||
|
dataColumnsAdded++;
|
||||||
|
//len
|
||||||
|
builderString += QString::number(dataLen) + ",";
|
||||||
|
dataColumnsAdded++;
|
||||||
|
|
||||||
|
if (dbcHandler != nullptr)
|
||||||
|
{
|
||||||
|
DBC_MESSAGE *msg = dbcHandler->findMessage(*frame);
|
||||||
|
if (msg != nullptr)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < msg->sigHandler->getCount(); j++)
|
||||||
|
{
|
||||||
|
if(j==0)
|
||||||
|
{
|
||||||
|
for(int i = 0; i<msgsAndColumns.count(); i++)
|
||||||
|
{
|
||||||
|
if(msgsAndColumns[i].first == msg->ID)
|
||||||
|
{
|
||||||
|
int startCol = msgsAndColumns[i].second;
|
||||||
|
while(dataColumnsAdded < startCol)
|
||||||
|
{
|
||||||
|
builderString += ",";
|
||||||
|
dataColumnsAdded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString temp;
|
||||||
|
if (msg->sigHandler->findSignalByIdx(j)->processAsText(*frame, temp, false))
|
||||||
|
{
|
||||||
|
builderString.append(temp);
|
||||||
|
builderString.append(",");
|
||||||
|
dataColumnsAdded++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builderString.append("\n");
|
||||||
|
outFile->write(builderString.toUtf8());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outFile->close();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::saveDecodedTextFile(QString filename)
|
void MainWindow::saveDecodedTextFile(QString filename)
|
||||||
{
|
{
|
||||||
QFile *outFile = new QFile(filename);
|
QFile *outFile = new QFile(filename);
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ private slots:
|
|||||||
void showDBCComparisonWindow();
|
void showDBCComparisonWindow();
|
||||||
void exitApp();
|
void exitApp();
|
||||||
void handleSaveDecoded();
|
void handleSaveDecoded();
|
||||||
|
void handleSaveDecodedCsv();
|
||||||
void connectionStatusUpdated(int conns);
|
void connectionStatusUpdated(int conns);
|
||||||
void gridClicked(QModelIndex);
|
void gridClicked(QModelIndex);
|
||||||
void gridDoubleClicked(QModelIndex);
|
void gridDoubleClicked(QModelIndex);
|
||||||
@@ -195,7 +196,9 @@ private:
|
|||||||
//private methods
|
//private methods
|
||||||
QString getSignalNameFromPosition(QPoint pos);
|
QString getSignalNameFromPosition(QPoint pos);
|
||||||
uint32_t getMessageIDFromPosition(QPoint pos);
|
uint32_t getMessageIDFromPosition(QPoint pos);
|
||||||
|
void handleSaveDecodedMethod(bool csv);
|
||||||
void saveDecodedTextFile(QString);
|
void saveDecodedTextFile(QString);
|
||||||
|
void saveDecodedTextFileAsColumns(QString);
|
||||||
void addFrameToDisplay(CANFrame &, bool);
|
void addFrameToDisplay(CANFrame &, bool);
|
||||||
void updateFileStatus();
|
void updateFileStatus();
|
||||||
void closeEvent(QCloseEvent *event);
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ void GraphingWindow::changeEvent(QEvent *event)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setWindowOpacity(0.25);
|
//setWindowOpacity(0.25);
|
||||||
// widget is now inactive
|
// widget is now inactive
|
||||||
qDebug() << "Hide";
|
qDebug() << "Hide";
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-1
@@ -368,7 +368,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>800</width>
|
||||||
<height>22</height>
|
<height>21</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menu_RE_Tools">
|
<widget class="QMenu" name="menu_RE_Tools">
|
||||||
@@ -415,6 +415,7 @@
|
|||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionDBC_File_Manager"/>
|
<addaction name="actionDBC_File_Manager"/>
|
||||||
<addaction name="actionSave_Decoded_Frames"/>
|
<addaction name="actionSave_Decoded_Frames"/>
|
||||||
|
<addaction name="actionSave_Decoded_Frames_CSV"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionPreferences"/>
|
<addaction name="actionPreferences"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
@@ -615,6 +616,11 @@
|
|||||||
<string>DBC Comparison</string>
|
<string>DBC Comparison</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionSave_Decoded_Frames_CSV">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save Decoded Frames CSV</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
Reference in New Issue
Block a user