2
2
#include " helpers/formatter.h"
3
3
4
4
uint32_t MonGenerator::FillHeader (FileWriter& wr, std::vector<CiExpr_t*>& sigs,
5
- const GenDescriptor_t& gsett )
5
+ const AppSettings_t& aset )
6
6
{
7
- wr.Append (" #ifdef %s_USE_MONO_FMON" , gsett.DRVNAME .c_str ());
7
+ if (aset.gen .start_info .size () > 0 )
8
+ {
9
+ wr.Append (aset.gen .start_info );
10
+ }
11
+
12
+ wr.Append (" #pragma once" );
13
+ wr.Append ();
14
+
15
+ wr.Append (" #ifdef __cplusplus\n extern \" C\" {\n #endif" );
16
+ wr.Append ();
17
+
18
+ wr.Append (" // DBC file version" );
19
+ wr.Append (" #define %s_FMON (%uU)" , aset.gen .verhigh_def .c_str (), aset.gen .hiver );
20
+ wr.Append (" #define %s_FMON (%uU)" , aset.gen .verlow_def .c_str (), aset.gen .lowver );
8
21
wr.Append ();
9
22
10
- wr.Append (" void _FMon_MONO_%s(FrameMonitor_t* _mon, uint32_t msgid);" , gsett.drvname .c_str ());
23
+ wr.Append (" #include <%s-config.h>" , aset.gen .drvname .c_str ());
24
+ wr.Append ();
25
+
26
+ // put diagmonitor ifdef selection for including @drv-fmon header
27
+ // with FMon_* signatures to call from unpack function
28
+ wr.Append (" #ifdef %s" , aset.gen .usemon_def .c_str ());
29
+ wr.Append ();
30
+ wr.Append (" #include <canmonitorutil.h>" );
31
+ wr.Append (" /*\n \
32
+ This file contains the prototypes of all the functions that will be called\n \
33
+ from each Unpack_*name* function to detect DBC related errors\n \
34
+ It is the user responsibility to defined these functions in the\n \
35
+ separated .c file. If it won't be done the linkage error will happen\n */" );
36
+ wr.Append ();
37
+
38
+ wr.Append (" #ifdef %s_USE_MONO_FMON" , aset.gen .DRVNAME .c_str ());
39
+ wr.Append ();
40
+
41
+ wr.Append (" void _FMon_MONO_%s(FrameMonitor_t* _mon, uint32_t msgid);" , aset.gen .drvname .c_str ());
11
42
wr.Append ();
12
43
13
44
for (auto it = sigs.begin (); it != sigs.end (); ++it)
14
45
{
15
46
16
47
auto msg = &((*it)->msg );
17
48
wr.Append (" #define FMon_%s_%s(x, y) _FMon_MONO_%s((x), (y))" , msg->Name .c_str (),
18
- gsett .drvname .c_str (),
19
- gsett .drvname .c_str ());
49
+ aset. gen .drvname .c_str (),
50
+ aset. gen .drvname .c_str ());
20
51
}
21
52
22
53
wr.Append ();
@@ -27,7 +58,7 @@ uint32_t MonGenerator::FillHeader(FileWriter& wr, std::vector<CiExpr_t*>& sigs,
27
58
{
28
59
auto msg = &((*it)->msg );
29
60
wr.Append (" void _FMon_%s_%s(FrameMonitor_t* _mon, uint32_t msgid);" ,
30
- msg->Name .c_str (), gsett .drvname .c_str ());
61
+ msg->Name .c_str (), aset. gen .drvname .c_str ());
31
62
}
32
63
33
64
wr.Append ();
@@ -36,23 +67,45 @@ uint32_t MonGenerator::FillHeader(FileWriter& wr, std::vector<CiExpr_t*>& sigs,
36
67
{
37
68
auto msg = &((*it)->msg );
38
69
wr.Append (" #define FMon_%s_%s(x, y) _FMon_%s_%s((x), (y))" ,
39
- msg->Name .c_str (), gsett .drvname .c_str (),
40
- msg->Name .c_str (), gsett .drvname .c_str ());
70
+ msg->Name .c_str (), aset. gen .drvname .c_str (),
71
+ msg->Name .c_str (), aset. gen .drvname .c_str ());
41
72
}
42
73
43
74
wr.Append ();
44
75
wr.Append (" #endif" );
45
76
wr.Append ();
46
77
78
+ wr.Append (" #endif // %s" , aset.gen .usemon_def .c_str ());
79
+ wr.Append ();
80
+
81
+ wr.Append (" #ifdef __cplusplus\n }\n #endif" );
82
+
47
83
return 0 ;
48
84
}
49
85
50
86
uint32_t MonGenerator::FillSource (FileWriter& wr, std::vector<CiExpr_t*>& sigs,
51
- const GenDescriptor_t& gsett )
87
+ const AppSettings_t& aset )
52
88
{
53
- wr.Append (" #ifdef %s_USE_MONO_FMON" , gsett.DRVNAME .c_str ());
89
+ if (aset.gen .start_info .size () > 0 )
90
+ {
91
+ wr.Append (aset.gen .start_info );
92
+ }
93
+
94
+ wr.Append (" #include <%s>" , aset.file .fmon_h .fname .c_str ());
95
+ wr.Append ();
96
+ // put diagmonitor ifdef selection for including @drv-fmon header
97
+ // with FMon_* signatures to call from unpack function
98
+ wr.Append (" #ifdef %s" , aset.gen .usemon_def .c_str ());
99
+ wr.Append ();
100
+
101
+ wr.Append (" /*\n \
102
+ Put the monitor function content here, keep in mind -\n \
103
+ next generation will completely clear all manually added code (!)\n \
104
+ */\n\n " );
105
+
106
+ wr.Append (" #ifdef %s_USE_MONO_FMON" , aset.gen .DRVNAME .c_str ());
54
107
wr.Append ();
55
- wr.Append (" void _FMon_MONO_%s(FrameMonitor_t* _mon, uint32_t msgid)" , gsett .drvname .c_str ());
108
+ wr.Append (" void _FMon_MONO_%s(FrameMonitor_t* _mon, uint32_t msgid)" , aset. gen .drvname .c_str ());
56
109
wr.Append (" {" );
57
110
wr.Append (" (void)_mon;" );
58
111
wr.Append (" (void)msgid;" );
@@ -65,11 +118,13 @@ uint32_t MonGenerator::FillSource(FileWriter& wr, std::vector<CiExpr_t*>& sigs,
65
118
{
66
119
auto msg = &((*it)->msg );
67
120
wr.Append (" void _FMon_%s_%s(FrameMonitor_t* _mon, uint32_t msgid)\n {\n (void)_mon;\n (void)msgid;\n }\n\n " ,
68
- msg->Name .c_str (), gsett .drvname .c_str ());
121
+ msg->Name .c_str (), aset. gen .drvname .c_str ());
69
122
}
70
123
71
- wr.Append (" #endif // %s_USE_MONO_FMON" , gsett .DRVNAME .c_str ());
124
+ wr.Append (" #endif // %s_USE_MONO_FMON" , aset. gen .DRVNAME .c_str ());
72
125
wr.Append ();
73
126
127
+ wr.Append (" #endif // %s" , aset.gen .usemon_def .c_str ());
128
+
74
129
return 0 ;
75
130
}
0 commit comments