Examples reorganization
[apps/agl-service-can-low-level.git] / examples / agl-vcar / 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{"ls",0x30,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                                                         "hvac.fan.speed",
13                                                         32,
14                                                         8,
15                                                         23.5294f,
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                                                         "hvac.temperature.left",
31                                                         0,
32                                                         8,
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                                                         nullptr,
44                                                         nullptr,
45                                                         false
46                                                 })},
47                                                 {std::make_shared<can_signal_t> (can_signal_t{
48                                                         "hvac.temperature.right",
49                                                         8,
50                                                         8,
51                                                         1.00000f,
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                                                 {std::make_shared<can_signal_t> (can_signal_t{
66                                                         "hvac.temperature.average",
67                                                         16,
68                                                         8,
69                                                         1.00000f,
70                                                         0.00000,
71                                                         0,
72                                                         0,
73                                                         frequency_clock_t(0.00000f),
74                                                         true,
75                                                         false,
76                                                         {
77                                                         },
78                                                         false,
79                                                         nullptr,
80                                                         nullptr,
81                                                         false
82                                                 })}
83                                         } // end can_signals vector
84                                 })} // end can_message_definition entry
85 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3D9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
86                                         { // beginning can_signals vector
87                                                 {std::make_shared<can_signal_t> (can_signal_t{
88                                                         "engine.speed",
89                                                         16,
90                                                         16,
91                                                         0.250000f,
92                                                         0.00000,
93                                                         0,
94                                                         0,
95                                                         frequency_clock_t(0.00000f),
96                                                         true,
97                                                         false,
98                                                         {
99                                                         },
100                                                         false,
101                                                         nullptr,
102                                                         nullptr,
103                                                         false
104                                                 })},
105                                                 {std::make_shared<can_signal_t> (can_signal_t{
106                                                         "fuel.level.low",
107                                                         55,
108                                                         1,
109                                                         1.00000f,
110                                                         0.00000,
111                                                         0,
112                                                         0,
113                                                         frequency_clock_t(0.00000f),
114                                                         true,
115                                                         false,
116                                                         {
117                                                         },
118                                                         false,
119                                                         decoder_t::decode_boolean,
120                                                         nullptr,
121                                                         false
122                                                 })},
123                                                 {std::make_shared<can_signal_t> (can_signal_t{
124                                                         "fuel.level",
125                                                         8,
126                                                         8,
127                                                         0.392157f,
128                                                         0.00000,
129                                                         0,
130                                                         0,
131                                                         frequency_clock_t(0.00000f),
132                                                         true,
133                                                         false,
134                                                         {
135                                                         },
136                                                         false,
137                                                         nullptr,
138                                                         nullptr,
139                                                         false
140                                                 })}
141                                         } // end can_signals vector
142                                 })} // end can_message_definition entry
143 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3E9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
144                                         { // beginning can_signals vector
145                                                 {std::make_shared<can_signal_t> (can_signal_t{
146                                                         "vehicle.average.speed",
147                                                         0,
148                                                         15,
149                                                         0.0156250f,
150                                                         0.00000,
151                                                         0,
152                                                         0,
153                                                         frequency_clock_t(0.00000f),
154                                                         true,
155                                                         false,
156                                                         {
157                                                         },
158                                                         false,
159                                                         nullptr,
160                                                         nullptr,
161                                                         false
162                                                 })}
163                                         } // end can_signals vector
164                                 })} // end can_message_definition entry
165 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x4D1,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
166                                         { // beginning can_signals vector
167                                                 {std::make_shared<can_signal_t> (can_signal_t{
168                                                         "engine.oil.temp",
169                                                         16,
170                                                         8,
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                                                         nullptr,
182                                                         nullptr,
183                                                         false
184                                                 })},
185                                                 {std::make_shared<can_signal_t> (can_signal_t{
186                                                         "engine.oil.temp.high",
187                                                         7,
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                                         } // end can_signals vector
204                                 })} // end can_message_definition entry
205 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x620,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
206                                         { // beginning can_signals vector
207                                                 {std::make_shared<can_signal_t> (can_signal_t{
208                                                         "doors.boot.open",
209                                                         47,
210                                                         1,
211                                                         1.00000f,
212                                                         0.00000,
213                                                         0,
214                                                         0,
215                                                         frequency_clock_t(0.00000f),
216                                                         true,
217                                                         false,
218                                                         {
219                                                         },
220                                                         false,
221                                                         decoder_t::decode_boolean,
222                                                         nullptr,
223                                                         false
224                                                 })},
225                                                 {std::make_shared<can_signal_t> (can_signal_t{
226                                                         "doors.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                                                         "doors.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                                                         "doors.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                                                         "doors.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 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x799,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
300                                         { // beginning can_signals vector
301                                                 {std::make_shared<can_signal_t> (can_signal_t{
302                                                         "windows.front_left.open",
303                                                         43,
304                                                         1,
305                                                         1.00000f,
306                                                         0.00000,
307                                                         0,
308                                                         0,
309                                                         frequency_clock_t(0.00000f),
310                                                         true,
311                                                         false,
312                                                         {
313                                                         },
314                                                         false,
315                                                         decoder_t::decode_boolean,
316                                                         nullptr,
317                                                         false
318                                                 })},
319                                                 {std::make_shared<can_signal_t> (can_signal_t{
320                                                         "windows.front_right.open",
321                                                         44,
322                                                         1,
323                                                         1.00000f,
324                                                         0.00000,
325                                                         0,
326                                                         0,
327                                                         frequency_clock_t(0.00000f),
328                                                         true,
329                                                         false,
330                                                         {
331                                                         },
332                                                         false,
333                                                         decoder_t::decode_boolean,
334                                                         nullptr,
335                                                         false
336                                                 })},
337                                                 {std::make_shared<can_signal_t> (can_signal_t{
338                                                         "windows.rear_left.open",
339                                                         46,
340                                                         1,
341                                                         1.00000f,
342                                                         0.00000,
343                                                         0,
344                                                         0,
345                                                         frequency_clock_t(0.00000f),
346                                                         true,
347                                                         false,
348                                                         {
349                                                         },
350                                                         false,
351                                                         decoder_t::decode_boolean,
352                                                         nullptr,
353                                                         false
354                                                 })},
355                                                 {std::make_shared<can_signal_t> (can_signal_t{
356                                                         "windows.rear_right.open",
357                                                         45,
358                                                         4,
359                                                         1.00000f,
360                                                         0.00000,
361                                                         0,
362                                                         0,
363                                                         frequency_clock_t(0.00000f),
364                                                         true,
365                                                         false,
366                                                         {
367                                                         },
368                                                         false,
369                                                         decoder_t::decode_boolean,
370                                                         nullptr,
371                                                         false
372                                                 })}
373                                         } // end can_signals vector
374                                 })} // end can_message_definition entry
375
376                 }, // end can_message_definition vector
377                         { // beginning diagnostic_messages_ vector
378                                 {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
379                                         4,
380                                         "engine.load",
381                                         0,
382                                         0,
383                                         UNIT::INVALID,
384                                         5.00000f,
385                                         decoder_t::decode_obd2_response,
386                                         nullptr,
387                                         true
388                                 })}
389 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
390                                         5,
391                                         "engine.coolant.temperature",
392                                         0,
393                                         0,
394                                         UNIT::INVALID,
395                                         1.00000f,
396                                         decoder_t::decode_obd2_response,
397                                         nullptr,
398                                         true
399                                 })}
400 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
401                                         10,
402                                         "fuel.pressure",
403                                         0,
404                                         0,
405                                         UNIT::INVALID,
406                                         1.00000f,
407                                         decoder_t::decode_obd2_response,
408                                         nullptr,
409                                         true
410                                 })}
411 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
412                                         11,
413                                         "intake.manifold.pressure",
414                                         0,
415                                         0,
416                                         UNIT::INVALID,
417                                         1.00000f,
418                                         decoder_t::decode_obd2_response,
419                                         nullptr,
420                                         true
421                                 })}
422 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
423                                         12,
424                                         "engine.speed",
425                                         0,
426                                         0,
427                                         UNIT::INVALID,
428                                         5.00000f,
429                                         decoder_t::decode_obd2_response,
430                                         nullptr,
431                                         true
432                                 })}
433 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
434                                         13,
435                                         "vehicle.speed",
436                                         0,
437                                         0,
438                                         UNIT::INVALID,
439                                         5.00000f,
440                                         decoder_t::decode_obd2_response,
441                                         nullptr,
442                                         true
443                                 })}
444 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
445                                         15,
446                                         "intake.air.temperature",
447                                         0,
448                                         0,
449                                         UNIT::INVALID,
450                                         1.00000f,
451                                         decoder_t::decode_obd2_response,
452                                         nullptr,
453                                         true
454                                 })}
455 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
456                                         16,
457                                         "mass.airflow",
458                                         0,
459                                         0,
460                                         UNIT::INVALID,
461                                         5.00000f,
462                                         decoder_t::decode_obd2_response,
463                                         nullptr,
464                                         true
465                                 })}
466 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
467                                         17,
468                                         "throttle.position",
469                                         0,
470                                         0,
471                                         UNIT::INVALID,
472                                         5.00000f,
473                                         decoder_t::decode_obd2_response,
474                                         nullptr,
475                                         true
476                                 })}
477 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
478                                         31,
479                                         "running.time",
480                                         0,
481                                         0,
482                                         UNIT::INVALID,
483                                         1.00000f,
484                                         decoder_t::decode_obd2_response,
485                                         nullptr,
486                                         true
487                                 })}
488 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
489                                         45,
490                                         "EGR.error",
491                                         0,
492                                         0,
493                                         UNIT::INVALID,
494                                         0.00000f,
495                                         decoder_t::decode_obd2_response,
496                                         nullptr,
497                                         true
498                                 })}
499 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
500                                         47,
501                                         "fuel.level",
502                                         0,
503                                         0,
504                                         UNIT::INVALID,
505                                         1.00000f,
506                                         decoder_t::decode_obd2_response,
507                                         nullptr,
508                                         true
509                                 })}
510 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
511                                         51,
512                                         "barometric.pressure",
513                                         0,
514                                         0,
515                                         UNIT::INVALID,
516                                         1.00000f,
517                                         decoder_t::decode_obd2_response,
518                                         nullptr,
519                                         true
520                                 })}
521 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
522                                         70,
523                                         "ambient.air.temperature",
524                                         0,
525                                         0,
526                                         UNIT::INVALID,
527                                         1.00000f,
528                                         decoder_t::decode_obd2_response,
529                                         nullptr,
530                                         true
531                                 })}
532 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
533                                         76,
534                                         "commanded.throttle.position",
535                                         0,
536                                         0,
537                                         UNIT::INVALID,
538                                         1.00000f,
539                                         decoder_t::decode_obd2_response,
540                                         nullptr,
541                                         true
542                                 })}
543 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
544                                         82,
545                                         "ethanol.fuel.percentage",
546                                         0,
547                                         0,
548                                         UNIT::INVALID,
549                                         1.00000f,
550                                         decoder_t::decode_obd2_response,
551                                         nullptr,
552                                         true
553                                 })}
554 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
555                                         90,
556                                         "accelerator.pedal.position",
557                                         0,
558                                         0,
559                                         UNIT::INVALID,
560                                         5.00000f,
561                                         decoder_t::decode_obd2_response,
562                                         nullptr,
563                                         true
564                                 })}
565 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
566                                         91,
567                                         "hybrid.battery-pack.remaining.life",
568                                         0,
569                                         0,
570                                         UNIT::INVALID,
571                                         5.00000f,
572                                         decoder_t::decode_obd2_response,
573                                         nullptr,
574                                         true
575                                 })}
576 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
577                                         92,
578                                         "engine.oil.temperature",
579                                         0,
580                                         0,
581                                         UNIT::INVALID,
582                                         1.00000f,
583                                         decoder_t::decode_obd2_response,
584                                         nullptr,
585                                         true
586                                 })}
587 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
588                                         94,
589                                         "engine.fuel.rate",
590                                         0,
591                                         0,
592                                         UNIT::INVALID,
593                                         1.00000f,
594                                         decoder_t::decode_obd2_response,
595                                         nullptr,
596                                         true
597                                 })}
598 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
599                                         99,
600                                         "engine.torque",
601                                         0,
602                                         0,
603                                         UNIT::INVALID,
604                                         1.00000f,
605                                         decoder_t::decode_obd2_response,
606                                         nullptr,
607                                         true
608                                 })}
609
610                         } // end diagnostic_messages_ vector
611                 })} // end can_message_set entry
612         } // end can_message_set vector
613 {
614         for(auto& cms: can_message_set_)
615         {
616                 std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition();
617                 for(auto& cmd : can_messages_definition)
618                 {
619                         cmd->set_parent(cms.get());
620                         std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals();
621                         for(auto& sig: can_signals)
622                         {
623                                 sig->set_parent(cmd.get());
624                         }
625                 }
626
627                 std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages();
628                 for(auto& dm : diagnostic_messages)
629                 {
630                         dm->set_parent(cms.get());
631                 }
632         }
633                 }
634
635 const std::string application_t::get_diagnostic_bus() const
636 {
637         return "hs";
638 }
639
640