4fef631504d6bd09e3fe49057c19915628415495
[apps/agl-service-can-low-level.git] / examples / OBD2 / application-generated.cpp
1 #include "application.hpp"
2 #include "../can/can-decoder.hpp"
3
4 application_t::application_t()
5         : can_bus_manager_{utils::config_parser_t{"/etc/dev-mapping.conf"}}
6         , can_message_set_{
7                 {std::make_shared<can_message_set_t>(can_message_set_t{0,"example",
8                         { // beginning can_message_definition_ vector
9
10                 }, // end can_message_definition vector
11                         { // beginning diagnostic_messages_ vector
12                                 {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
13                                         4,
14                                         "engine.load",
15                                         0,
16                                         0,
17                                         UNIT::INVALID,
18                                         5.00000f,
19                                         decoder_t::decode_obd2_response,
20                                         nullptr,
21                                         true,
22                                         false
23                                 })}
24 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
25                                         5,
26                                         "engine.coolant.temperature",
27                                         0,
28                                         0,
29                                         UNIT::INVALID,
30                                         1.00000f,
31                                         decoder_t::decode_obd2_response,
32                                         nullptr,
33                                         true,
34                                         false
35                                 })}
36 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
37                                         10,
38                                         "fuel.pressure",
39                                         0,
40                                         0,
41                                         UNIT::INVALID,
42                                         1.00000f,
43                                         decoder_t::decode_obd2_response,
44                                         nullptr,
45                                         true,
46                                         false
47                                 })}
48 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
49                                         11,
50                                         "intake.manifold.pressure",
51                                         0,
52                                         0,
53                                         UNIT::INVALID,
54                                         1.00000f,
55                                         decoder_t::decode_obd2_response,
56                                         nullptr,
57                                         true,
58                                         false
59                                 })}
60 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
61                                         12,
62                                         "engine.speed",
63                                         0,
64                                         0,
65                                         UNIT::INVALID,
66                                         5.00000f,
67                                         decoder_t::decode_obd2_response,
68                                         nullptr,
69                                         true,
70                                         false
71                                 })}
72 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
73                                         13,
74                                         "vehicle.speed",
75                                         0,
76                                         0,
77                                         UNIT::INVALID,
78                                         5.00000f,
79                                         decoder_t::decode_obd2_response,
80                                         nullptr,
81                                         true,
82                                         false
83                                 })}
84 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
85                                         15,
86                                         "intake.air.temperature",
87                                         0,
88                                         0,
89                                         UNIT::INVALID,
90                                         1.00000f,
91                                         decoder_t::decode_obd2_response,
92                                         nullptr,
93                                         true,
94                                         false
95                                 })}
96 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
97                                         16,
98                                         "mass.airflow",
99                                         0,
100                                         0,
101                                         UNIT::INVALID,
102                                         5.00000f,
103                                         decoder_t::decode_obd2_response,
104                                         nullptr,
105                                         true,
106                                         false
107                                 })}
108 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
109                                         17,
110                                         "throttle.position",
111                                         0,
112                                         0,
113                                         UNIT::INVALID,
114                                         5.00000f,
115                                         decoder_t::decode_obd2_response,
116                                         nullptr,
117                                         true,
118                                         false
119                                 })}
120 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
121                                         31,
122                                         "running.time",
123                                         0,
124                                         0,
125                                         UNIT::INVALID,
126                                         1.00000f,
127                                         decoder_t::decode_obd2_response,
128                                         nullptr,
129                                         true,
130                                         false
131                                 })}
132 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
133                                         45,
134                                         "EGR.error",
135                                         0,
136                                         0,
137                                         UNIT::INVALID,
138                                         0.00000f,
139                                         decoder_t::decode_obd2_response,
140                                         nullptr,
141                                         true,
142                                         false
143                                 })}
144 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
145                                         47,
146                                         "fuel.level",
147                                         0,
148                                         0,
149                                         UNIT::INVALID,
150                                         1.00000f,
151                                         decoder_t::decode_obd2_response,
152                                         nullptr,
153                                         true,
154                                         false
155                                 })}
156 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
157                                         51,
158                                         "barometric.pressure",
159                                         0,
160                                         0,
161                                         UNIT::INVALID,
162                                         1.00000f,
163                                         decoder_t::decode_obd2_response,
164                                         nullptr,
165                                         true,
166                                         false
167                                 })}
168 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
169                                         70,
170                                         "ambient.air.temperature",
171                                         0,
172                                         0,
173                                         UNIT::INVALID,
174                                         1.00000f,
175                                         decoder_t::decode_obd2_response,
176                                         nullptr,
177                                         true,
178                                         false
179                                 })}
180 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
181                                         76,
182                                         "commanded.throttle.position",
183                                         0,
184                                         0,
185                                         UNIT::INVALID,
186                                         1.00000f,
187                                         decoder_t::decode_obd2_response,
188                                         nullptr,
189                                         true,
190                                         false
191                                 })}
192 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
193                                         82,
194                                         "ethanol.fuel.percentage",
195                                         0,
196                                         0,
197                                         UNIT::INVALID,
198                                         1.00000f,
199                                         decoder_t::decode_obd2_response,
200                                         nullptr,
201                                         true,
202                                         false
203                                 })}
204 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
205                                         90,
206                                         "accelerator.pedal.position",
207                                         0,
208                                         0,
209                                         UNIT::INVALID,
210                                         5.00000f,
211                                         decoder_t::decode_obd2_response,
212                                         nullptr,
213                                         true,
214                                         false
215                                 })}
216 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
217                                         91,
218                                         "hybrid.battery-pack.remaining.life",
219                                         0,
220                                         0,
221                                         UNIT::INVALID,
222                                         5.00000f,
223                                         decoder_t::decode_obd2_response,
224                                         nullptr,
225                                         true,
226                                         false
227                                 })}
228 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
229                                         92,
230                                         "engine.oil.temperature",
231                                         0,
232                                         0,
233                                         UNIT::INVALID,
234                                         1.00000f,
235                                         decoder_t::decode_obd2_response,
236                                         nullptr,
237                                         true,
238                                         false
239                                 })}
240 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
241                                         94,
242                                         "engine.fuel.rate",
243                                         0,
244                                         0,
245                                         UNIT::INVALID,
246                                         1.00000f,
247                                         decoder_t::decode_obd2_response,
248                                         nullptr,
249                                         true,
250                                         false
251                                 })}
252 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
253                                         99,
254                                         "engine.torque",
255                                         0,
256                                         0,
257                                         UNIT::INVALID,
258                                         1.00000f,
259                                         decoder_t::decode_obd2_response,
260                                         nullptr,
261                                         true,
262                                         false
263                                 })}
264
265                         } // end diagnostic_messages_ vector
266                 })} // end can_message_set entry
267         } // end can_message_set vector
268 {
269         for(auto& cms: can_message_set_)
270         {
271                 std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition();
272                 for(auto& cmd : can_messages_definition)
273                 {
274                         cmd->set_parent(cms.get());
275                         std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals();
276                         for(auto& sig: can_signals)
277                         {
278                                 sig->set_parent(cmd.get());
279                         }
280                 }
281
282                 std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages();
283                 for(auto& dm : diagnostic_messages)
284                 {
285                         dm->set_parent(cms.get());
286                 }
287         }
288                 }
289
290 const std::string application_t::get_diagnostic_bus() const
291 {
292         return "hs";
293 }
294
295