Simplify processing event
[apps/agl-service-can-low-level.git] / CAN-binder / 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,"example",
8                         { // beginning can_message_definition_ vector
9                                 {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3D9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
10                                         { // beginning can_signals vector
11                                                 {std::make_shared<can_signal_t> (can_signal_t{
12                                                         "engine.speed",
13                                                         16,
14                                                         16,
15                                                         0.250000f,
16                                                         0.00000,
17                                                         0,
18                                                         0,
19                                                         frequency_clock_t(0.00000f),
20                                                         true,
21                                                         false,
22                                                         {
23                                                         },
24                                                         false,
25                                                         nullptr,
26                                                         nullptr,
27                                                         false
28                                                 })},
29                                                 {std::make_shared<can_signal_t> (can_signal_t{
30                                                         "fuel.level.low",
31                                                         55,
32                                                         1,
33                                                         1.00000f,
34                                                         0.00000,
35                                                         0,
36                                                         0,
37                                                         frequency_clock_t(0.00000f),
38                                                         true,
39                                                         false,
40                                                         {
41                                                         },
42                                                         false,
43                                                         decoder_t::booleanDecoder,
44                                                         nullptr,
45                                                         false
46                                                 })},
47                                                 {std::make_shared<can_signal_t> (can_signal_t{
48                                                         "fuel.level",
49                                                         8,
50                                                         8,
51                                                         0.392157f,
52                                                         0.00000,
53                                                         0,
54                                                         0,
55                                                         frequency_clock_t(0.00000f),
56                                                         true,
57                                                         false,
58                                                         {
59                                                         },
60                                                         false,
61                                                         nullptr,
62                                                         nullptr,
63                                                         false
64                                                 })}
65                                         } // end can_signals vector
66                                 })} // end can_message_definition entry
67 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x3E9,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
68                                         { // beginning can_signals vector
69                                                 {std::make_shared<can_signal_t> (can_signal_t{
70                                                         "vehicle.average.speed",
71                                                         0,
72                                                         15,
73                                                         0.0156250f,
74                                                         0.00000,
75                                                         0,
76                                                         0,
77                                                         frequency_clock_t(0.00000f),
78                                                         true,
79                                                         false,
80                                                         {
81                                                         },
82                                                         false,
83                                                         nullptr,
84                                                         nullptr,
85                                                         false
86                                                 })}
87                                         } // end can_signals vector
88                                 })} // end can_message_definition entry
89 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x4D1,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
90                                         { // beginning can_signals vector
91                                                 {std::make_shared<can_signal_t> (can_signal_t{
92                                                         "engine.oil.temp",
93                                                         16,
94                                                         8,
95                                                         1.00000f,
96                                                         0.00000,
97                                                         0,
98                                                         0,
99                                                         frequency_clock_t(0.00000f),
100                                                         true,
101                                                         false,
102                                                         {
103                                                         },
104                                                         false,
105                                                         nullptr,
106                                                         nullptr,
107                                                         false
108                                                 })},
109                                                 {std::make_shared<can_signal_t> (can_signal_t{
110                                                         "engine.oil.temp.high",
111                                                         7,
112                                                         1,
113                                                         1.00000f,
114                                                         0.00000,
115                                                         0,
116                                                         0,
117                                                         frequency_clock_t(0.00000f),
118                                                         true,
119                                                         false,
120                                                         {
121                                                         },
122                                                         false,
123                                                         decoder_t::booleanDecoder,
124                                                         nullptr,
125                                                         false
126                                                 })}
127                                         } // end can_signals vector
128                                 })} // end can_message_definition entry
129 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x620,can_message_format_t::STANDARD,frequency_clock_t(5.00000f),true,
130                                         { // beginning can_signals vector
131                                                 {std::make_shared<can_signal_t> (can_signal_t{
132                                                         "doors.boot.open",
133                                                         56,
134                                                         1,
135                                                         1.00000f,
136                                                         0.00000,
137                                                         0,
138                                                         0,
139                                                         frequency_clock_t(0.00000f),
140                                                         true,
141                                                         false,
142                                                         {
143                                                         },
144                                                         false,
145                                                         decoder_t::booleanDecoder,
146                                                         nullptr,
147                                                         false
148                                                 })},
149                                                 {std::make_shared<can_signal_t> (can_signal_t{
150                                                         "doors.front_left.open",
151                                                         46,
152                                                         1,
153                                                         1.00000f,
154                                                         0.00000,
155                                                         0,
156                                                         0,
157                                                         frequency_clock_t(0.00000f),
158                                                         true,
159                                                         false,
160                                                         {
161                                                         },
162                                                         false,
163                                                         decoder_t::booleanDecoder,
164                                                         nullptr,
165                                                         false
166                                                 })},
167                                                 {std::make_shared<can_signal_t> (can_signal_t{
168                                                         "doors.front_right.open",
169                                                         47,
170                                                         1,
171                                                         1.00000f,
172                                                         0.00000,
173                                                         0,
174                                                         0,
175                                                         frequency_clock_t(0.00000f),
176                                                         true,
177                                                         false,
178                                                         {
179                                                         },
180                                                         false,
181                                                         decoder_t::booleanDecoder,
182                                                         nullptr,
183                                                         false
184                                                 })},
185                                                 {std::make_shared<can_signal_t> (can_signal_t{
186                                                         "doors.rear_left.open",
187                                                         54,
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::booleanDecoder,
200                                                         nullptr,
201                                                         false
202                                                 })},
203                                                 {std::make_shared<can_signal_t> (can_signal_t{
204                                                         "doors.rear_right.open",
205                                                         53,
206                                                         4,
207                                                         1.00000f,
208                                                         0.00000,
209                                                         0,
210                                                         0,
211                                                         frequency_clock_t(0.00000f),
212                                                         true,
213                                                         false,
214                                                         {
215                                                         },
216                                                         false,
217                                                         decoder_t::booleanDecoder,
218                                                         nullptr,
219                                                         false
220                                                 })}
221                                         } // end can_signals vector
222                                 })} // end can_message_definition entry
223 ,                               {std::make_shared<can_message_definition_t>(can_message_definition_t{"hs",0x799,can_message_format_t::STANDARD,frequency_clock_t(1.00000f),true,
224                                         { // beginning can_signals vector
225                                                 {std::make_shared<can_signal_t> (can_signal_t{
226                                                         "windows.front_left.open",
227                                                         46,
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::booleanDecoder,
240                                                         nullptr,
241                                                         false
242                                                 })},
243                                                 {std::make_shared<can_signal_t> (can_signal_t{
244                                                         "windows.front_right.open",
245                                                         47,
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::booleanDecoder,
258                                                         nullptr,
259                                                         false
260                                                 })},
261                                                 {std::make_shared<can_signal_t> (can_signal_t{
262                                                         "windows.rear_left.open",
263                                                         54,
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::booleanDecoder,
276                                                         nullptr,
277                                                         false
278                                                 })},
279                                                 {std::make_shared<can_signal_t> (can_signal_t{
280                                                         "windows.rear_right.open",
281                                                         53,
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::booleanDecoder,
294                                                         nullptr,
295                                                         false
296                                                 })}
297                                         } // end can_signals vector
298                                 })} // end can_message_definition entry
299                         }, // end can_message_definition vector
300                         { // beginning diagnostic_messages_ vector
301                                 {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
302                                         4,
303                                         "engine.load",
304                                         0,
305                                         0,
306                                         UNIT::INVALID,
307                                         5.00000f,
308                                         decoder_t::decode_obd2_response,
309                                         nullptr,
310                                         true
311                                 })}
312 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
313                                         5,
314                                         "engine.coolant.temperature",
315                                         0,
316                                         0,
317                                         UNIT::INVALID,
318                                         1.00000f,
319                                         decoder_t::decode_obd2_response,
320                                         nullptr,
321                                         true
322                                 })}
323 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
324                                         10,
325                                         "fuel.pressure",
326                                         0,
327                                         0,
328                                         UNIT::INVALID,
329                                         1.00000f,
330                                         decoder_t::decode_obd2_response,
331                                         nullptr,
332                                         true
333                                 })}
334 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
335                                         11,
336                                         "intake.manifold.pressure",
337                                         0,
338                                         0,
339                                         UNIT::INVALID,
340                                         1.00000f,
341                                         decoder_t::decode_obd2_response,
342                                         nullptr,
343                                         true
344                                 })}
345 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
346                                         12,
347                                         "engine.speed",
348                                         0,
349                                         0,
350                                         UNIT::INVALID,
351                                         5.00000f,
352                                         decoder_t::decode_obd2_response,
353                                         nullptr,
354                                         true
355                                 })}
356 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
357                                         13,
358                                         "vehicle.speed",
359                                         0,
360                                         0,
361                                         UNIT::INVALID,
362                                         5.00000f,
363                                         decoder_t::decode_obd2_response,
364                                         nullptr,
365                                         true
366                                 })}
367 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
368                                         15,
369                                         "intake.air.temperature",
370                                         0,
371                                         0,
372                                         UNIT::INVALID,
373                                         1.00000f,
374                                         decoder_t::decode_obd2_response,
375                                         nullptr,
376                                         true
377                                 })}
378 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
379                                         16,
380                                         "mass.airflow",
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                                         17,
391                                         "throttle.position",
392                                         0,
393                                         0,
394                                         UNIT::INVALID,
395                                         5.00000f,
396                                         decoder_t::decode_obd2_response,
397                                         nullptr,
398                                         true
399                                 })}
400 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
401                                         31,
402                                         "running.time",
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                                         45,
413                                         "EGR.error",
414                                         0,
415                                         0,
416                                         UNIT::INVALID,
417                                         0.00000f,
418                                         decoder_t::decode_obd2_response,
419                                         nullptr,
420                                         true
421                                 })}
422 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
423                                         47,
424                                         "fuel.level",
425                                         0,
426                                         0,
427                                         UNIT::INVALID,
428                                         1.00000f,
429                                         decoder_t::decode_obd2_response,
430                                         nullptr,
431                                         true
432                                 })}
433 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
434                                         51,
435                                         "barometric.pressure",
436                                         0,
437                                         0,
438                                         UNIT::INVALID,
439                                         1.00000f,
440                                         decoder_t::decode_obd2_response,
441                                         nullptr,
442                                         true
443                                 })}
444 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
445                                         70,
446                                         "ambient.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                                         76,
457                                         "commanded.throttle.position",
458                                         0,
459                                         0,
460                                         UNIT::INVALID,
461                                         1.00000f,
462                                         decoder_t::decode_obd2_response,
463                                         nullptr,
464                                         true
465                                 })}
466 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
467                                         82,
468                                         "ethanol.fuel.percentage",
469                                         0,
470                                         0,
471                                         UNIT::INVALID,
472                                         1.00000f,
473                                         decoder_t::decode_obd2_response,
474                                         nullptr,
475                                         true
476                                 })}
477 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
478                                         90,
479                                         "accelerator.pedal.position",
480                                         0,
481                                         0,
482                                         UNIT::INVALID,
483                                         5.00000f,
484                                         decoder_t::decode_obd2_response,
485                                         nullptr,
486                                         true
487                                 })}
488 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
489                                         91,
490                                         "hybrid.battery-pack.remaining.life",
491                                         0,
492                                         0,
493                                         UNIT::INVALID,
494                                         5.00000f,
495                                         decoder_t::decode_obd2_response,
496                                         nullptr,
497                                         true
498                                 })}
499 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
500                                         92,
501                                         "engine.oil.temperature",
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                                         94,
512                                         "engine.fuel.rate",
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                                         99,
523                                         "engine.torque",
524                                         0,
525                                         0,
526                                         UNIT::INVALID,
527                                         1.00000f,
528                                         decoder_t::decode_obd2_response,
529                                         nullptr,
530                                         true
531                                 })}
532                         } // end diagnostic_messages_ vector
533                 })} // end can_message_set entry
534         } // end can_message_set vector
535 {
536         for(auto& cms: can_message_set_)
537         {
538                 std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition();
539                 for(auto& cmd : can_messages_definition)
540                 {
541                         cmd->set_parent(cms.get());
542                         std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals();
543                         for(auto& sig: can_signals)
544                         {
545                                 sig->set_parent(cmd.get());
546                         }
547                 }
548
549                 std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages();
550                 for(auto& dm : diagnostic_messages)
551                 {
552                         dm->set_parent(cms.get());
553                 }
554         }
555 }
556
557 const std::string application_t::get_diagnostic_bus() const
558 {
559         return "hs";
560 }
561
562