1 #ifndef FRAMEFILEIO_H
2 #define FRAMEFILEIO_H
3 
4 //Class full of static methods that load and save canbus frames to/from various file formats
5 
6 #include "config.h"
7 #include <Qt>
8 #include <QApplication>
9 #include <QObject>
10 #include <QVector>
11 #include <QFile>
12 #include <QString>
13 #include <QStringList>
14 #include <QFileDialog>
15 #include "can_structs.h"
16 #include "utility.h"
17 
18 class FrameFileIO: public QObject
19 {
20     Q_OBJECT
21 
22 public:
23     FrameFileIO();
24 
25     //these present a GUI to the user and allow them to pick the file to load/save
26     //The QString returns the filename that was selected and so is really a sort of return value
27     //The QVector is used as either the target for loading or the source for saving.
28     //These routines call the below loading/saving functions so no need to use them directly if you don't want.
29     static bool loadFrameFile(QString &, QVector<CANFrame>*);
30     static bool saveFrameFile(QString &, const QVector<CANFrame>*);
31 
32     //These do the actual loading and saving and can be used directly if you'd prefer
33     static bool autoDetectLoadFile(QString, QVector<CANFrame>*);
34     static bool loadCRTDFile(QString, QVector<CANFrame>*);
35     static bool loadNativeCSVFile(QString, QVector<CANFrame>*);
36     static bool loadGenericCSVFile(QString, QVector<CANFrame>*);
37     static bool loadLogFile(QString, QVector<CANFrame>*);
38     static bool loadMicrochipFile(QString, QVector<CANFrame>*);
39     static bool loadTraceFile(QString, QVector<CANFrame>*);
40     static bool loadIXXATFile(QString, QVector<CANFrame>*);
41     static bool loadCANDOFile(QString, QVector<CANFrame>*);
42     static bool loadVehicleSpyFile(QString, QVector<CANFrame>*);
43     static bool loadCanDumpFile(QString, QVector<CANFrame>*);
44     static bool loadLawicelFile(QString, QVector<CANFrame>*);
45     static bool loadPCANFile(QString, QVector<CANFrame>*);
46     static bool loadKvaserFile(QString, QVector<CANFrame>*, bool);
47     static bool loadCanalyzerASC(QString, QVector<CANFrame>*);
48     static bool loadCanalyzerBLF(QString, QVector<CANFrame>*);
49     static bool loadCARBUSAnalyzerFile(QString filename, QVector<CANFrame>* frames);
50     static bool loadCANHackerFile(QString filename, QVector<CANFrame>* frames);
51     static bool loadCabanaFile(QString filename, QVector<CANFrame>* frames);
52     static bool loadCANOpenFile(QString filename, QVector<CANFrame>* frames);
53     static bool loadTeslaAPFile(QString filename, QVector<CANFrame>* frames);
54     static bool loadCLX000File(QString filename, QVector<CANFrame>* frames);
55     static bool loadCANServerFile(QString filename, QVector<CANFrame>* frames);
56 
57     //functions that pre-scan a file to try to figure out if they could read it. Used to automatically determine
58     //file type and load it.
59     static bool isCRTDFile(QString);
60     static bool isNativeCSVFile(QString);
61     static bool isGenericCSVFile(QString);
62     static bool isLogFile(QString);
63     static bool isMicrochipFile(QString);
64     static bool isTraceFile(QString);
65     static bool isIXXATFile(QString);
66     static bool isCANDOFile(QString);
67     static bool isVehicleSpyFile(QString);
68     static bool isCanDumpFile(QString);
69     static bool isLawicelFile(QString);
70     static bool isPCANFile(QString);
71     static bool isKvaserFile(QString);
72     static bool isCanalyzerASC(QString);
73     static bool isCanalyzerBLF(QString);
74     static bool isCARBUSAnalyzerFile(QString filename);
75     static bool isCANHackerFile(QString filename);
76     static bool isCabanaFile(QString filename);
77     static bool isCANOpenFile(QString filename);
78     static bool isTeslaAPFile(QString filename);
79     static bool isCLX000File(QString filename);
80     static bool isCANServerFile(QString filename);
81 
82     static bool saveCRTDFile(QString, const QVector<CANFrame>*);
83     static bool saveNativeCSVFile(QString, const QVector<CANFrame>*);
84     static bool saveGenericCSVFile(QString, const QVector<CANFrame>*);
85     static bool saveLogFile(QString, const QVector<CANFrame>*);
86     static bool saveMicrochipFile(QString, const QVector<CANFrame>*);
87     static bool saveTraceFile(QString, const QVector<CANFrame>*);
88     static bool saveIXXATFile(QString, const QVector<CANFrame>*);
89     static bool saveCANDOFile(QString, const QVector<CANFrame>*);
90     static bool saveVehicleSpyFile(QString, const QVector<CANFrame>*);
91     static bool saveCanDumpFile(QString filename, const QVector<CANFrame> * frames);
92     static bool saveCabanaFile(QString filename, const QVector<CANFrame>* frames);
93     static bool saveCanalyzerASC(QString filename, const QVector<CANFrame>* frames);
94     static bool saveCARBUSAnalzyer(QString filename, const QVector<CANFrame>* frames);
95 
96     static bool openContinuousNative();
97     static bool closeContinuousNative();
98     static bool writeContinuousNative(const QVector<CANFrame>*, int);
99     static bool flushContinuousNative();
100 
101 private:
102     static QFile continuousFile;
103 };
104 
105 #endif // FRAMEFILEIO_H
106