| 1538 | } |
| 1539 | |
| 1540 | bool FrameFileIO::saveNativeCSVFile(QString filename, const QVector<CANFrame>* frames) |
| 1541 | { |
| 1542 | QFile *outFile = new QFile(filename); |
| 1543 | int lineCounter = 0; |
| 1544 | |
| 1545 | if (!outFile->open(QIODevice::WriteOnly | QIODevice::Text)) |
| 1546 | { |
| 1547 | delete outFile; |
| 1548 | return false; |
| 1549 | } |
| 1550 | |
| 1551 | outFile->write("Time Stamp,ID,Extended,Dir,Bus,LEN,D1,D2,D3,D4,D5,D6,D7,D8"); |
| 1552 | outFile->write("\n"); |
| 1553 | |
| 1554 | for (int c = 0; c < frames->count(); c++) |
| 1555 | { |
| 1556 | lineCounter++; |
| 1557 | if (lineCounter > 100) |
| 1558 | { |
| 1559 | qApp->processEvents(); |
| 1560 | lineCounter = 0; |
| 1561 | } |
| 1562 | |
| 1563 | outFile->write(QString::number(frames->at(c).timestamp).toUtf8()); |
| 1564 | outFile->putChar(44); |
| 1565 | |
| 1566 | outFile->write(QString::number(frames->at(c).ID, 16).toUpper().rightJustified(8, '0').toUtf8()); |
| 1567 | outFile->putChar(44); |
| 1568 | |
| 1569 | if (frames->at(c).extended) outFile->write("true,"); |
| 1570 | else outFile->write("false,"); |
| 1571 | |
| 1572 | if (frames->at(c).isReceived) outFile->write("Rx,"); |
| 1573 | else outFile->write("Tx,"); |
| 1574 | |
| 1575 | outFile->write(QString::number(frames->at(c).bus).toUtf8()); |
| 1576 | outFile->putChar(44); |
| 1577 | |
| 1578 | outFile->write(QString::number(frames->at(c).len).toUtf8()); |
| 1579 | outFile->putChar(44); |
| 1580 | |
| 1581 | for (unsigned int temp = 0; temp < 8; temp++) |
| 1582 | { |
| 1583 | if (temp < frames->at(c).len) |
| 1584 | outFile->write(QString::number(frames->at(c).data[temp], 16).toUpper().rightJustified(2, '0').toUtf8()); |
| 1585 | else |
| 1586 | outFile->write("00"); |
| 1587 | outFile->putChar(44); |
| 1588 | } |
| 1589 | |
| 1590 | outFile->write("\n"); |
| 1591 | |
| 1592 | } |
| 1593 | outFile->close(); |
| 1594 | delete outFile; |
| 1595 | return true; |
| 1596 | } |
| 1597 | |