9eb89dfad105bc5c07ce93c12d15391044bc4a0e
[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
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,"AGL Virtual Car",
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                                                         true,
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                                                         true,
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                                                         true,
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                                         false
389                                 })}
390 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
391                                         5,
392                                         "engine.coolant.temperature",
393                                         0,
394                                         0,
395                                         UNIT::INVALID,
396                                         1.00000f,
397                                         decoder_t::decode_obd2_response,
398                                         nullptr,
399                                         true,
400                                         false
401                                 })}
402 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
403                                         10,
404                                         "fuel.pressure",
405                                         0,
406                                         0,
407                                         UNIT::INVALID,
408                                         1.00000f,
409                                         decoder_t::decode_obd2_response,
410                                         nullptr,
411                                         true,
412                                         false
413                                 })}
414 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
415                                         11,
416                                         "intake.manifold.pressure",
417                                         0,
418                                         0,
419                                         UNIT::INVALID,
420                                         1.00000f,
421                                         decoder_t::decode_obd2_response,
422                                         nullptr,
423                                         true,
424                                         false
425                                 })}
426 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
427                                         12,
428                                         "engine.speed",
429                                         0,
430                                         0,
431                                         UNIT::INVALID,
432                                         5.00000f,
433                                         decoder_t::decode_obd2_response,
434                                         nullptr,
435                                         true,
436                                         false
437                                 })}
438 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
439                                         13,
440                                         "vehicle.speed",
441                                         0,
442                                         0,
443                                         UNIT::INVALID,
444                                         5.00000f,
445                                         decoder_t::decode_obd2_response,
446                                         nullptr,
447                                         true,
448                                         false
449                                 })}
450 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
451                                         15,
452                                         "intake.air.temperature",
453                                         0,
454                                         0,
455                                         UNIT::INVALID,
456                                         1.00000f,
457                                         decoder_t::decode_obd2_response,
458                                         nullptr,
459                                         true,
460                                         false
461                                 })}
462 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
463                                         16,
464                                         "mass.airflow",
465                                         0,
466                                         0,
467                                         UNIT::INVALID,
468                                         5.00000f,
469                                         decoder_t::decode_obd2_response,
470                                         nullptr,
471                                         true,
472                                         false
473                                 })}
474 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
475                                         17,
476                                         "throttle.position",
477                                         0,
478                                         0,
479                                         UNIT::INVALID,
480                                         5.00000f,
481                                         decoder_t::decode_obd2_response,
482                                         nullptr,
483                                         true,
484                                         false
485                                 })}
486 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
487                                         31,
488                                         "running.time",
489                                         0,
490                                         0,
491                                         UNIT::INVALID,
492                                         1.00000f,
493                                         decoder_t::decode_obd2_response,
494                                         nullptr,
495                                         true,
496                                         false
497                                 })}
498 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
499                                         45,
500                                         "EGR.error",
501                                         0,
502                                         0,
503                                         UNIT::INVALID,
504                                         0.00000f,
505                                         decoder_t::decode_obd2_response,
506                                         nullptr,
507                                         true,
508                                         false
509                                 })}
510 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
511                                         47,
512                                         "fuel.level",
513                                         0,
514                                         0,
515                                         UNIT::INVALID,
516                                         1.00000f,
517                                         decoder_t::decode_obd2_response,
518                                         nullptr,
519                                         true,
520                                         false
521                                 })}
522 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
523                                         51,
524                                         "barometric.pressure",
525                                         0,
526                                         0,
527                                         UNIT::INVALID,
528                                         1.00000f,
529                                         decoder_t::decode_obd2_response,
530                                         nullptr,
531                                         true,
532                                         false
533                                 })}
534 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
535                                         70,
536                                         "ambient.air.temperature",
537                                         0,
538                                         0,
539                                         UNIT::INVALID,
540                                         1.00000f,
541                                         decoder_t::decode_obd2_response,
542                                         nullptr,
543                                         true,
544                                         false
545                                 })}
546 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
547                                         76,
548                                         "commanded.throttle.position",
549                                         0,
550                                         0,
551                                         UNIT::INVALID,
552                                         1.00000f,
553                                         decoder_t::decode_obd2_response,
554                                         nullptr,
555                                         true,
556                                         false
557                                 })}
558 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
559                                         82,
560                                         "ethanol.fuel.percentage",
561                                         0,
562                                         0,
563                                         UNIT::INVALID,
564                                         1.00000f,
565                                         decoder_t::decode_obd2_response,
566                                         nullptr,
567                                         true,
568                                         false
569                                 })}
570 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
571                                         90,
572                                         "accelerator.pedal.position",
573                                         0,
574                                         0,
575                                         UNIT::INVALID,
576                                         5.00000f,
577                                         decoder_t::decode_obd2_response,
578                                         nullptr,
579                                         true,
580                                         false
581                                 })}
582 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
583                                         91,
584                                         "hybrid.battery-pack.remaining.life",
585                                         0,
586                                         0,
587                                         UNIT::INVALID,
588                                         5.00000f,
589                                         decoder_t::decode_obd2_response,
590                                         nullptr,
591                                         true,
592                                         false
593                                 })}
594 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
595                                         92,
596                                         "engine.oil.temperature",
597                                         0,
598                                         0,
599                                         UNIT::INVALID,
600                                         1.00000f,
601                                         decoder_t::decode_obd2_response,
602                                         nullptr,
603                                         true,
604                                         false
605                                 })}
606 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
607                                         94,
608                                         "engine.fuel.rate",
609                                         0,
610                                         0,
611                                         UNIT::INVALID,
612                                         1.00000f,
613                                         decoder_t::decode_obd2_response,
614                                         nullptr,
615                                         true,
616                                         false
617                                 })}
618 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
619                                         99,
620                                         "engine.torque",
621                                         0,
622                                         0,
623                                         UNIT::INVALID,
624                                         1.00000f,
625                                         decoder_t::decode_obd2_response,
626                                         nullptr,
627                                         true,
628                                         false
629                                 })}
630
631                         } // end diagnostic_messages_ vector
632                 })} // end can_message_set entry
633         } // end can_message_set vector
634 {
635         for(auto& cms: can_message_set_)
636         {
637                 std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition();
638                 for(auto& cmd : can_messages_definition)
639                 {
640                         cmd->set_parent(cms.get());
641                         std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals();
642                         for(auto& sig: can_signals)
643                         {
644                                 sig->set_parent(cmd.get());
645                         }
646                 }
647
648                 std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages();
649                 for(auto& dm : diagnostic_messages)
650                 {
651                         dm->set_parent(cms.get());
652                 }
653         }
654                 }
655
656 const std::string application_t::get_diagnostic_bus() const
657 {
658         return "hs";
659 }
660
661