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