| 713 | } |
| 714 | |
| 715 | void MainWindow::saveDecodedTextFile(QString filename) |
| 716 | { |
| 717 | QFile *outFile = new QFile(filename); |
| 718 | const QVector<CANFrame> *frames = model->getFilteredListReference(); |
| 719 | |
| 720 | if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text)) |
| 721 | return; |
| 722 | /* |
| 723 | Time: 205.173000 ID: 0x20E Std Bus: 0 Len: 8 |
| 724 | Data Bytes: 88 10 00 13 BB 00 06 00 |
| 725 | SignalName Value |
| 726 | */ |
| 727 | for (int c = 0; c < frames->count(); c++) |
| 728 | { |
| 729 | CANFrame thisFrame = frames->at(c); |
| 730 | QString builderString; |
| 731 | builderString += tr("Time: ") + QString::number((thisFrame.timestamp / 1000000.0), 'f', 6); |
| 732 | builderString += tr(" ID: ") + Utility::formatCANID(thisFrame.ID, thisFrame.extended); |
| 733 | if (thisFrame.extended) builderString += tr(" Ext "); |
| 734 | else builderString += tr(" Std "); |
| 735 | builderString += tr("Bus: ") + QString::number(thisFrame.bus); |
| 736 | builderString += " Len: " + QString::number(thisFrame.len) + "\n"; |
| 737 | outFile->write(builderString.toUtf8()); |
| 738 | |
| 739 | builderString = tr("Data Bytes: "); |
| 740 | for (unsigned int temp = 0; temp < thisFrame.len; temp++) |
| 741 | { |
| 742 | builderString += Utility::formatNumber(thisFrame.data[temp]) + " "; |
| 743 | } |
| 744 | builderString += "\n"; |
| 745 | outFile->write(builderString.toUtf8()); |
| 746 | |
| 747 | builderString = ""; |
| 748 | if (dbcHandler != nullptr) |
| 749 | { |
| 750 | DBC_MESSAGE *msg = dbcHandler->findMessage(thisFrame); |
| 751 | if (msg != nullptr) |
| 752 | { |
| 753 | for (int j = 0; j < msg->sigHandler->getCount(); j++) |
| 754 | { |
| 755 | |
| 756 | QString temp; |
| 757 | if (msg->sigHandler->findSignalByIdx(j)->processAsText(thisFrame, temp)) |
| 758 | { |
| 759 | builderString.append("\t" + temp); |
| 760 | builderString.append("\n"); |
| 761 | } |
| 762 | } |
| 763 | } |
| 764 | builderString.append("\n"); |
| 765 | outFile->write(builderString.toUtf8()); |
| 766 | } |
| 767 | } |
| 768 | outFile->close(); |
| 769 | } |
| 770 | |
| 771 | void MainWindow::toggleCapture() |
| 772 | { |
nothing calls this directly
no test coverage detected