1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
|
---|
2 | // DBC Decriptor //
|
---|
3 | // //
|
---|
4 | // Made by Pierre Hudelaine //
|
---|
5 | // //
|
---|
6 | // Contact: pierre.hudelaine@hds.utc.fr //
|
---|
7 | // //
|
---|
8 | // Translate a DBC file to Pacpus code //
|
---|
9 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
|
---|
10 |
|
---|
11 | #ifndef STRUCTURE_H
|
---|
12 | #define STRUCTURE_H
|
---|
13 |
|
---|
14 | #include <QMap>
|
---|
15 | #include <QFile>
|
---|
16 |
|
---|
17 |
|
---|
18 | /// Structure of a complete signal
|
---|
19 | typedef struct {
|
---|
20 | QString signalName; /// Signal name
|
---|
21 | int startBit; /// Startbit of the signal
|
---|
22 | int length; /// Length of the signal
|
---|
23 | bool order; /// Encoding type; true bigEndian; false littleEndian
|
---|
24 | bool valueType; /// Signe type; true signed; false unsigned
|
---|
25 | double gain; /// Gain of the signal
|
---|
26 | double offset; /// Offset of the signal
|
---|
27 | double max; /// Max of the value
|
---|
28 | double min; /// Min of the value
|
---|
29 | QString unit; /// Unit of the signal
|
---|
30 | QString comment; /// Associate comment of the signal
|
---|
31 | QString description;/// Value description
|
---|
32 | } StructSignal;
|
---|
33 |
|
---|
34 |
|
---|
35 | /// Strucure of a complete frame
|
---|
36 | typedef struct {
|
---|
37 | int numberOfSignals; /// Number of signal per frame
|
---|
38 | int frameID; /// Frame ID
|
---|
39 | QString frameName; /// Frame name
|
---|
40 | QVector<StructSignal> signalsVector; /// Signals of the frame
|
---|
41 | } StructFrame;
|
---|
42 |
|
---|
43 |
|
---|
44 | /// Structure of a complete dbc file
|
---|
45 | typedef struct {
|
---|
46 | QVector<StructFrame> canFrames; /// Frames of the file
|
---|
47 | QString fileName; /// Path to the dbc file
|
---|
48 | QStringList content; /// Content of the dbc file
|
---|
49 | } StructDBCFile;
|
---|
50 |
|
---|
51 |
|
---|
52 | static const QString templateHFile =
|
---|
53 | "/*******************************************************************************\n" \
|
---|
54 | "// created:\n" \
|
---|
55 | "//\n" \
|
---|
56 | "// author: Generated automatically with DBC decriptor\n" \
|
---|
57 | "// Copyright Heudiasyc UMR UTC/CNRS 7253\n" \
|
---|
58 | "//\n" \
|
---|
59 | "// version: $Id: $\n" \
|
---|
60 | "//\n" \
|
---|
61 | "// purpose:\n" \
|
---|
62 | "//\n" \
|
---|
63 | "*******************************************************************************/\n" \
|
---|
64 | "\n" \
|
---|
65 | "#ifndef __CanFrame_h__\n" \
|
---|
66 | "#define __CanFrame_h__\n" \
|
---|
67 | "\n" \
|
---|
68 | "#include \"CanGateway/CanFrameBase.h\"\n" \
|
---|
69 | "#include \"structureCan.h\"\n" \
|
---|
70 | "\n" \
|
---|
71 | "namespace pacpus {\n" \
|
---|
72 | "\n" \
|
---|
73 | "class CAN_API CanFrame\n" \
|
---|
74 | " : public CanFrameBase\n" \
|
---|
75 | "{\n" \
|
---|
76 | "public:\n" \
|
---|
77 | " CanFrame() {}\n" \
|
---|
78 | " ~CanFrame() {}\n" \
|
---|
79 | " void decode();\n" \
|
---|
80 | " void * data() { return &data_; }\n" \
|
---|
81 | " int size() { return sizeof(Struct); }\n" \
|
---|
82 | "\n" \
|
---|
83 | "protected:\n" \
|
---|
84 | "\n" \
|
---|
85 | "private:\n" \
|
---|
86 | " Struct data_;\n" \
|
---|
87 | "};\n" \
|
---|
88 | "\n" \
|
---|
89 | "}\n" \
|
---|
90 | "\n" \
|
---|
91 | "#endif;";
|
---|
92 |
|
---|
93 | static const QString templateCPPFile =
|
---|
94 | "/*******************************************************************************\n" \
|
---|
95 | "// created:\n" \
|
---|
96 | "//\n" \
|
---|
97 | "// author: Generated automatically with DBC decriptor\n" \
|
---|
98 | "// Copyright Heudiasyc UMR UTC/CNRS 7253\n" \
|
---|
99 | "//\n" \
|
---|
100 | "// version: $Id: $\n" \
|
---|
101 | "//\n" \
|
---|
102 | "// purpose:\n" \
|
---|
103 | "//\n" \
|
---|
104 | "*******************************************************************************/\n" \
|
---|
105 | "\n" \
|
---|
106 | "\n" \
|
---|
107 | "#include \"CanFrame.h\"\n" \
|
---|
108 | "#include <iostream>\n" \
|
---|
109 | "\n" \
|
---|
110 | "using namespace pacpus;\n" \
|
---|
111 | "\n" \
|
---|
112 | "void CanFrame::decode()\n" \
|
---|
113 | "{\n" \
|
---|
114 | " long long lltmp = 0;\n" \
|
---|
115 | " unsigned long long ulltmp = 0;\n" \
|
---|
116 | " long ltmp = 0;\n" \
|
---|
117 | " unsigned long ultmp = 0;\n" \
|
---|
118 | " short stmp = 0;\n" \
|
---|
119 | " unsigned short ustmp = 0;\n" \
|
---|
120 | " char ctmp = 0;\n" \
|
---|
121 | " unsigned char uctmp = 0;\n" \
|
---|
122 | "};";
|
---|
123 |
|
---|
124 | static const QString templateStructFile =
|
---|
125 | "/*******************************************************************************\n" \
|
---|
126 | "// created:\n" \
|
---|
127 | "//\n" \
|
---|
128 | "// author: Generated automatically with DBC decriptor\n" \
|
---|
129 | "// Copyright Heudiasyc UMR UTC/CNRS 7253\n" \
|
---|
130 | "//\n" \
|
---|
131 | "// version: $Id: $\n" \
|
---|
132 | "//\n" \
|
---|
133 | "// purpose:\n" \
|
---|
134 | "//\n" \
|
---|
135 | "*******************************************************************************/\n" \
|
---|
136 | "\n" \
|
---|
137 | "#ifndef __STRUCTURECAN_H__\n" \
|
---|
138 | "#define __STRUCTURECAN_H__\n" \
|
---|
139 | "\n" \
|
---|
140 | "#include <cstddef>\n" \
|
---|
141 | "\n" \
|
---|
142 | "#include \"Pacpus/kernel/cstdint.h\"\n" \
|
---|
143 | "#include \"Pacpus/kernel/road_time.h\"\n" \
|
---|
144 | "\n" \
|
---|
145 | "\n" \
|
---|
146 | "#endif";
|
---|
147 |
|
---|
148 | #endif // STRUCTURE_H
|
---|