9bf7c9550c0038a8529661e4f771e555b9ec39a1
[apps/agl-service-can-low-level.git] / examples / toyota / auris / 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                                 {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3D9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
10                                         { // beginning can_signals vector
11                                                 {std::make_shared<can_signal_t> (can_signal_t{
12                                                         "engine.speed",
13                                                         16,
14                                                         16,
15                                                         0.250000f,
16                                                         0.00000,
17                                                         0,
18                                                         0,
19                                                         frequency_clock_t(0.00000f),
20                                                         true,
21                                                         false,
22                                                         {
23                                                         },
24                                                         false,
25                                                         nullptr,
26                                                         nullptr,
27                                                         false
28                                                 })},
29                                                 {std::make_shared<can_signal_t> (can_signal_t{
30                                                         "fuel.level.low",
31                                                         55,
32                                                         1,
33                                                         1.00000f,
34                                                         0.00000,
35                                                         0,
36                                                         0,
37                                                         frequency_clock_t(0.00000f),
38                                                         true,
39                                                         false,
40                                                         {
41                                                         },
42                                                         false,
43                                                         decoder_t::decode_boolean,
44                                                         nullptr,
45                                                         false
46                                                 })},
47                                                 {std::make_shared<can_signal_t> (can_signal_t{
48                                                         "fuel.level",
49                                                         8,
50                                                         8,
51                                                         0.392157f,
52                                                         0.00000,
53                                                         0,
54                                                         0,
55                                                         frequency_clock_t(0.00000f),
56                                                         true,
57                                                         false,
58                                                         {
59                                                         },
60                                                         false,
61                                                         nullptr,
62                                                         nullptr,
63                                                         false
64                                                 })}
65                                         } // end can_signals vector
66                                 })} // end can_message_definition entry
67 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3E9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
68                                         { // beginning can_signals vector
69                                                 {std::make_shared<can_signal_t> (can_signal_t{
70                                                         "vehicle.average.speed",
71                                                         0,
72                                                         15,
73                                                         0.0156250f,
74                                                         0.00000,
75                                                         0,
76                                                         0,
77                                                         frequency_clock_t(0.00000f),
78                                                         true,
79                                                         false,
80                                                         {
81                                                         },
82                                                         false,
83                                                         nullptr,
84                                                         nullptr,
85                                                         false
86                                                 })}
87                                         } // end can_signals vector
88                                 })} // end can_message_definition entry
89 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x4D1,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
90                                         { // beginning can_signals vector
91                                                 {std::make_shared<can_signal_t> (can_signal_t{
92                                                         "engine.oil.temp",
93                                                         16,
94                                                         8,
95                                                         1.00000f,
96                                                         0.00000,
97                                                         0,
98                                                         0,
99                                                         frequency_clock_t(0.00000f),
100                                                         true,
101                                                         false,
102                                                         {
103                                                         },
104                                                         false,
105                                                         nullptr,
106                                                         nullptr,
107                                                         false
108                                                 })},
109                                                 {std::make_shared<can_signal_t> (can_signal_t{
110                                                         "engine.oil.temp.high",
111                                                         7,
112                                                         1,
113                                                         1.00000f,
114                                                         0.00000,
115                                                         0,
116                                                         0,
117                                                         frequency_clock_t(0.00000f),
118                                                         true,
119                                                         false,
120                                                         {
121                                                         },
122                                                         false,
123                                                         decoder_t::decode_boolean,
124                                                         nullptr,
125                                                         false
126                                                 })}
127                                         } // end can_signals vector
128                                 })} // end can_message_definition entry
129 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x620,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
130                                         { // beginning can_signals vector
131                                                 {std::make_shared<can_signal_t> (can_signal_t{
132                                                         "doors.boot.open",
133                                                         47,
134                                                         1,
135                                                         1.00000f,
136                                                         0.00000,
137                                                         0,
138                                                         0,
139                                                         frequency_clock_t(0.00000f),
140                                                         true,
141                                                         false,
142                                                         {
143                                                         },
144                                                         false,
145                                                         decoder_t::decode_boolean,
146                                                         nullptr,
147                                                         false
148                                                 })},
149                                                 {std::make_shared<can_signal_t> (can_signal_t{
150                                                         "doors.front_left.open",
151                                                         43,
152                                                         1,
153                                                         1.00000f,
154                                                         0.00000,
155                                                         0,
156                                                         0,
157                                                         frequency_clock_t(0.00000f),
158                                                         true,
159                                                         false,
160                                                         {
161                                                         },
162                                                         false,
163                                                         decoder_t::decode_boolean,
164                                                         nullptr,
165                                                         false
166                                                 })},
167                                                 {std::make_shared<can_signal_t> (can_signal_t{
168                                                         "doors.front_right.open",
169                                                         44,
170                                                         1,
171                                                         1.00000f,
172                                                         0.00000,
173                                                         0,
174                                                         0,
175                                                         frequency_clock_t(0.00000f),
176                                                         true,
177                                                         false,
178                                                         {
179                                                         },
180                                                         false,
181                                                         decoder_t::decode_boolean,
182                                                         nullptr,
183                                                         false
184                                                 })},
185                                                 {std::make_shared<can_signal_t> (can_signal_t{
186                                                         "doors.rear_left.open",
187                                                         46,
188                                                         1,
189                                                         1.00000f,
190                                                         0.00000,
191                                                         0,
192                                                         0,
193                                                         frequency_clock_t(0.00000f),
194                                                         true,
195                                                         false,
196                                                         {
197                                                         },
198                                                         false,
199                                                         decoder_t::decode_boolean,
200                                                         nullptr,
201                                                         false
202                                                 })},
203                                                 {std::make_shared<can_signal_t> (can_signal_t{
204                                                         "doors.rear_right.open",
205                                                         45,
206                                                         4,
207                                                         1.00000f,
208                                                         0.00000,
209                                                         0,
210                                                         0,
211                                                         frequency_clock_t(0.00000f),
212                                                         true,
213                                                         false,
214                                                         {
215                                                         },
216                                                         false,
217                                                         decoder_t::decode_boolean,
218                                                         nullptr,
219                                                         false
220                                                 })}
221                                         } // end can_signals vector
222                                 })} // end can_message_definition entry
223 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x799,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
224                                         { // beginning can_signals vector
225                                                 {std::make_shared<can_signal_t> (can_signal_t{
226                                                         "windows.front_left.open",
227                                                         43,
228                                                         1,
229                                                         1.00000f,
230                                                         0.00000,
231                                                         0,
232                                                         0,
233                                                         frequency_clock_t(0.00000f),
234                                                         true,
235                                                         false,
236                                                         {
237                                                         },
238                                                         false,
239                                                         decoder_t::decode_boolean,
240                                                         nullptr,
241                                                         false
242                                                 })},
243                                                 {std::make_shared<can_signal_t> (can_signal_t{
244                                                         "windows.front_right.open",
245                                                         44,
246                                                         1,
247                                                         1.00000f,
248                                                         0.00000,
249                                                         0,
250                                                         0,
251                                                         frequency_clock_t(0.00000f),
252                                                         true,
253                                                         false,
254                                                         {
255                                                         },
256                                                         false,
257                                                         decoder_t::decode_boolean,
258                                                         nullptr,
259                                                         false
260                                                 })},
261                                                 {std::make_shared<can_signal_t> (can_signal_t{
262                                                         "windows.rear_left.open",
263                                                         46,
264                                                         1,
265                                                         1.00000f,
266                                                         0.00000,
267                                                         0,
268                                                         0,
269                                                         frequency_clock_t(0.00000f),
270                                                         true,
271                                                         false,
272                                                         {
273                                                         },
274                                                         false,
275                                                         decoder_t::decode_boolean,
276                                                         nullptr,
277                                                         false
278                                                 })},
279                                                 {std::make_shared<can_signal_t> (can_signal_t{
280                                                         "windows.rear_right.open",
281                                                         45,
282                                                         4,
283                                                         1.00000f,
284                                                         0.00000,
285                                                         0,
286                                                         0,
287                                                         frequency_clock_t(0.00000f),
288                                                         true,
289                                                         false,
290                                                         {
291                                                         },
292                                                         false,
293                                                         decoder_t::decode_boolean,
294                                                         nullptr,
295                                                         false
296                                                 })}
297                                         } // end can_signals vector
298                                 })} // end can_message_definition entry
299
300                 }, // end can_message_definition vector
301                         { // beginning diagnostic_messages_ vector
302                                 {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
303                                         4,
304                                         "engine.load",
305                                         0,
306                                         0,
307                                         UNIT::INVALID,
308                                         5.00000f,
309                                         decoder_t::decode_obd2_response,
310                                         nullptr,
311                                         true,
312                                         false
313                                 })}
314 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
315                                         5,
316                                         "engine.coolant.temperature",
317                                         0,
318                                         0,
319                                         UNIT::INVALID,
320                                         1.00000f,
321                                         decoder_t::decode_obd2_response,
322                                         nullptr,
323                                         true,
324                                         false
325                                 })}
326 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
327                                         10,
328                                         "fuel.pressure",
329                                         0,
330                                         0,
331                                         UNIT::INVALID,
332                                         1.00000f,
333                                         decoder_t::decode_obd2_response,
334                                         nullptr,
335                                         true,
336                                         false
337                                 })}
338 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
339                                         11,
340                                         "intake.manifold.pressure",
341                                         0,
342                                         0,
343                                         UNIT::INVALID,
344                                         1.00000f,
345                                         decoder_t::decode_obd2_response,
346                                         nullptr,
347                                         true,
348                                         false
349                                 })}
350 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
351                                         12,
352                                         "engine.speed",
353                                         0,
354                                         0,
355                                         UNIT::INVALID,
356                                         5.00000f,
357                                         decoder_t::decode_obd2_response,
358                                         nullptr,
359                                         true,
360                                         false
361                                 })}
362 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
363                                         13,
364                                         "vehicle.speed",
365                                         0,
366                                         0,
367                                         UNIT::INVALID,
368                                         5.00000f,
369                                         decoder_t::decode_obd2_response,
370                                         nullptr,
371                                         true,
372                                         false
373                                 })}
374 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
375                                         15,
376                                         "intake.air.temperature",
377                                         0,
378                                         0,
379                                         UNIT::INVALID,
380                                         1.00000f,
381                                         decoder_t::decode_obd2_response,
382                                         nullptr,
383                                         true,
384                                         false
385                                 })}
386 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
387                                         16,
388                                         "mass.airflow",
389                                         0,
390                                         0,
391                                         UNIT::INVALID,
392                                         5.00000f,
393                                         decoder_t::decode_obd2_response,
394                                         nullptr,
395                                         true,
396                                         false
397                                 })}
398 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
399                                         17,
400                                         "throttle.position",
401                                         0,
402                                         0,
403                                         UNIT::INVALID,
404                                         5.00000f,
405                                         decoder_t::decode_obd2_response,
406                                         nullptr,
407                                         true,
408                                         false
409                                 })}
410 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
411                                         31,
412                                         "running.time",
413                                         0,
414                                         0,
415                                         UNIT::INVALID,
416                                         1.00000f,
417                                         decoder_t::decode_obd2_response,
418                                         nullptr,
419                                         true,
420                                         false
421                                 })}
422 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
423                                         45,
424                                         "EGR.error",
425                                         0,
426                                         0,
427                                         UNIT::INVALID,
428                                         0.00000f,
429                                         decoder_t::decode_obd2_response,
430                                         nullptr,
431                                         true,
432                                         false
433                                 })}
434 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
435                                         47,
436                                         "fuel.level",
437                                         0,
438                                         0,
439                                         UNIT::INVALID,
440                                         1.00000f,
441                                         decoder_t::decode_obd2_response,
442                                         nullptr,
443                                         true,
444                                         false
445                                 })}
446 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
447                                         51,
448                                         "barometric.pressure",
449                                         0,
450                                         0,
451                                         UNIT::INVALID,
452                                         1.00000f,
453                                         decoder_t::decode_obd2_response,
454                                         nullptr,
455                                         true,
456                                         false
457                                 })}
458 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
459                                         70,
460                                         "ambient.air.temperature",
461                                         0,
462                                         0,
463                                         UNIT::INVALID,
464                                         1.00000f,
465                                         decoder_t::decode_obd2_response,
466                                         nullptr,
467                                         true,
468                                         false
469                                 })}
470 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
471                                         76,
472                                         "commanded.throttle.position",
473                                         0,
474                                         0,
475                                         UNIT::INVALID,
476                                         1.00000f,
477                                         decoder_t::decode_obd2_response,
478                                         nullptr,
479                                         true,
480                                         false
481                                 })}
482 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
483                                         82,
484                                         "ethanol.fuel.percentage",
485                                         0,
486                                         0,
487                                         UNIT::INVALID,
488                                         1.00000f,
489                                         decoder_t::decode_obd2_response,
490                                         nullptr,
491                                         true,
492                                         false
493                                 })}
494 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
495                                         90,
496                                         "accelerator.pedal.position",
497                                         0,
498                                         0,
499                                         UNIT::INVALID,
500                                         5.00000f,
501                                         decoder_t::decode_obd2_response,
502                                         nullptr,
503                                         true,
504                                         false
505                                 })}
506 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
507                                         91,
508                                         "hybrid.battery-pack.remaining.life",
509                                         0,
510                                         0,
511                                         UNIT::INVALID,
512                                         5.00000f,
513                                         decoder_t::decode_obd2_response,
514                                         nullptr,
515                                         true,
516                                         false
517                                 })}
518 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
519                                         92,
520                                         "engine.oil.temperature",
521                                         0,
522                                         0,
523                                         UNIT::INVALID,
524                                         1.00000f,
525                                         decoder_t::decode_obd2_response,
526                                         nullptr,
527                                         true,
528                                         false
529                                 })}
530 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
531                                         94,
532                                         "engine.fuel.rate",
533                                         0,
534                                         0,
535                                         UNIT::INVALID,
536                                         1.00000f,
537                                         decoder_t::decode_obd2_response,
538                                         nullptr,
539                                         true,
540                                         false
541                                 })}
542 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
543                                         99,
544                                         "engine.torque",
545                                         0,
546                                         0,
547                                         UNIT::INVALID,
548                                         1.00000f,
549                                         decoder_t::decode_obd2_response,
550                                         nullptr,
551                                         true,
552                                         false
553                                 })}
554
555                         } // end diagnostic_messages_ vector
556                 })} // end can_message_set entry
557         } // end can_message_set vector
558 {
559         for(auto& cms: can_message_set_)
560         {
561                 std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition();
562                 for(auto& cmd : can_messages_definition)
563                 {
564                         cmd->set_parent(cms.get());
565                         std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals();
566                         for(auto& sig: can_signals)
567                         {
568                                 sig->set_parent(cmd.get());
569                         }
570                 }
571
572                 std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages();
573                 for(auto& dm : diagnostic_messages)
574                 {
575                         dm->set_parent(cms.get());
576                 }
577         }
578                 }
579
580 const std::string application_t::get_diagnostic_bus() const
581 {
582         return "hs";
583 }
584
585