Update doc revision and pdf cover.
[apps/low-level-can-service.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                                                         47,
134                                                         1,
135                                                         1.00000f,
136                                                         0.00000,
137                                                         0,
138                                                         0,
139                                                         frequency_clock_t(0.00000f),
140                                                         true,
141                                                         false,
142                                                         {
143                                                         },
144                                                         false,
145                                                         decoder_t::booleanDecoder,
146                                                         nullptr,
147                                                         false
148                                                 })},
149                                                 {std::make_shared<can_signal_t> (can_signal_t{
150                                                         "doors.front_left.open",
151                                                         43,
152                                                         1,
153                                                         1.00000f,
154                                                         0.00000,
155                                                         0,
156                                                         0,
157                                                         frequency_clock_t(0.00000f),
158                                                         true,
159                                                         false,
160                                                         {
161                                                         },
162                                                         false,
163                                                         decoder_t::booleanDecoder,
164                                                         nullptr,
165                                                         false
166                                                 })},
167                                                 {std::make_shared<can_signal_t> (can_signal_t{
168                                                         "doors.front_right.open",
169                                                         44,
170                                                         1,
171                                                         1.00000f,
172                                                         0.00000,
173                                                         0,
174                                                         0,
175                                                         frequency_clock_t(0.00000f),
176                                                         true,
177                                                         false,
178                                                         {
179                                                         },
180                                                         false,
181                                                         decoder_t::booleanDecoder,
182                                                         nullptr,
183                                                         false
184                                                 })},
185                                                 {std::make_shared<can_signal_t> (can_signal_t{
186                                                         "doors.rear_left.open",
187                                                         46,
188                                                         1,
189                                                         1.00000f,
190                                                         0.00000,
191                                                         0,
192                                                         0,
193                                                         frequency_clock_t(0.00000f),
194                                                         true,
195                                                         false,
196                                                         {
197                                                         },
198                                                         false,
199                                                         decoder_t::booleanDecoder,
200                                                         nullptr,
201                                                         false
202                                                 })},
203                                                 {std::make_shared<can_signal_t> (can_signal_t{
204                                                         "doors.rear_right.open",
205                                                         45,
206                                                         4,
207                                                         1.00000f,
208                                                         0.00000,
209                                                         0,
210                                                         0,
211                                                         frequency_clock_t(0.00000f),
212                                                         true,
213                                                         false,
214                                                         {
215                                                         },
216                                                         false,
217                                                         decoder_t::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(5.00000f),true,
224                                         { // beginning can_signals vector
225                                                 {std::make_shared<can_signal_t> (can_signal_t{
226                                                         "windows.front_left.open",
227                                                         43,
228                                                         1,
229                                                         1.00000f,
230                                                         0.00000,
231                                                         0,
232                                                         0,
233                                                         frequency_clock_t(0.00000f),
234                                                         true,
235                                                         false,
236                                                         {
237                                                         },
238                                                         false,
239                                                         decoder_t::booleanDecoder,
240                                                         nullptr,
241                                                         false
242                                                 })},
243                                                 {std::make_shared<can_signal_t> (can_signal_t{
244                                                         "windows.front_right.open",
245                                                         44,
246                                                         1,
247                                                         1.00000f,
248                                                         0.00000,
249                                                         0,
250                                                         0,
251                                                         frequency_clock_t(0.00000f),
252                                                         true,
253                                                         false,
254                                                         {
255                                                         },
256                                                         false,
257                                                         decoder_t::booleanDecoder,
258                                                         nullptr,
259                                                         false
260                                                 })},
261                                                 {std::make_shared<can_signal_t> (can_signal_t{
262                                                         "windows.rear_left.open",
263                                                         46,
264                                                         1,
265                                                         1.00000f,
266                                                         0.00000,
267                                                         0,
268                                                         0,
269                                                         frequency_clock_t(0.00000f),
270                                                         true,
271                                                         false,
272                                                         {
273                                                         },
274                                                         false,
275                                                         decoder_t::booleanDecoder,
276                                                         nullptr,
277                                                         false
278                                                 })},
279                                                 {std::make_shared<can_signal_t> (can_signal_t{
280                                                         "windows.rear_right.open",
281                                                         45,
282                                                         4,
283                                                         1.00000f,
284                                                         0.00000,
285                                                         0,
286                                                         0,
287                                                         frequency_clock_t(0.00000f),
288                                                         true,
289                                                         false,
290                                                         {
291                                                         },
292                                                         false,
293                                                         decoder_t::booleanDecoder,
294                                                         nullptr,
295                                                         false
296                                                 })}
297                                         } // end can_signals vector
298                                 })} // end can_message_definition entry
299
300                 }, // end can_message_definition vector
301                         { // beginning diagnostic_messages_ vector
302                                 {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
303                                         4,
304                                         "engine.load",
305                                         0,
306                                         0,
307                                         UNIT::INVALID,
308                                         5.00000f,
309                                         decoder_t::decode_obd2_response,
310                                         nullptr,
311                                         true
312                                 })}
313 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
314                                         5,
315                                         "engine.coolant.temperature",
316                                         0,
317                                         0,
318                                         UNIT::INVALID,
319                                         1.00000f,
320                                         decoder_t::decode_obd2_response,
321                                         nullptr,
322                                         true
323                                 })}
324 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
325                                         10,
326                                         "fuel.pressure",
327                                         0,
328                                         0,
329                                         UNIT::INVALID,
330                                         1.00000f,
331                                         decoder_t::decode_obd2_response,
332                                         nullptr,
333                                         true
334                                 })}
335 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
336                                         11,
337                                         "intake.manifold.pressure",
338                                         0,
339                                         0,
340                                         UNIT::INVALID,
341                                         1.00000f,
342                                         decoder_t::decode_obd2_response,
343                                         nullptr,
344                                         true
345                                 })}
346 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
347                                         12,
348                                         "engine.speed",
349                                         0,
350                                         0,
351                                         UNIT::INVALID,
352                                         5.00000f,
353                                         decoder_t::decode_obd2_response,
354                                         nullptr,
355                                         true
356                                 })}
357 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
358                                         13,
359                                         "vehicle.speed",
360                                         0,
361                                         0,
362                                         UNIT::INVALID,
363                                         5.00000f,
364                                         decoder_t::decode_obd2_response,
365                                         nullptr,
366                                         true
367                                 })}
368 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
369                                         15,
370                                         "intake.air.temperature",
371                                         0,
372                                         0,
373                                         UNIT::INVALID,
374                                         1.00000f,
375                                         decoder_t::decode_obd2_response,
376                                         nullptr,
377                                         true
378                                 })}
379 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
380                                         16,
381                                         "mass.airflow",
382                                         0,
383                                         0,
384                                         UNIT::INVALID,
385                                         5.00000f,
386                                         decoder_t::decode_obd2_response,
387                                         nullptr,
388                                         true
389                                 })}
390 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
391                                         17,
392                                         "throttle.position",
393                                         0,
394                                         0,
395                                         UNIT::INVALID,
396                                         5.00000f,
397                                         decoder_t::decode_obd2_response,
398                                         nullptr,
399                                         true
400                                 })}
401 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
402                                         31,
403                                         "running.time",
404                                         0,
405                                         0,
406                                         UNIT::INVALID,
407                                         1.00000f,
408                                         decoder_t::decode_obd2_response,
409                                         nullptr,
410                                         true
411                                 })}
412 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
413                                         45,
414                                         "EGR.error",
415                                         0,
416                                         0,
417                                         UNIT::INVALID,
418                                         0.00000f,
419                                         decoder_t::decode_obd2_response,
420                                         nullptr,
421                                         true
422                                 })}
423 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
424                                         47,
425                                         "fuel.level",
426                                         0,
427                                         0,
428                                         UNIT::INVALID,
429                                         1.00000f,
430                                         decoder_t::decode_obd2_response,
431                                         nullptr,
432                                         true
433                                 })}
434 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
435                                         51,
436                                         "barometric.pressure",
437                                         0,
438                                         0,
439                                         UNIT::INVALID,
440                                         1.00000f,
441                                         decoder_t::decode_obd2_response,
442                                         nullptr,
443                                         true
444                                 })}
445 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
446                                         70,
447                                         "ambient.air.temperature",
448                                         0,
449                                         0,
450                                         UNIT::INVALID,
451                                         1.00000f,
452                                         decoder_t::decode_obd2_response,
453                                         nullptr,
454                                         true
455                                 })}
456 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
457                                         76,
458                                         "commanded.throttle.position",
459                                         0,
460                                         0,
461                                         UNIT::INVALID,
462                                         1.00000f,
463                                         decoder_t::decode_obd2_response,
464                                         nullptr,
465                                         true
466                                 })}
467 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
468                                         82,
469                                         "ethanol.fuel.percentage",
470                                         0,
471                                         0,
472                                         UNIT::INVALID,
473                                         1.00000f,
474                                         decoder_t::decode_obd2_response,
475                                         nullptr,
476                                         true
477                                 })}
478 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
479                                         90,
480                                         "accelerator.pedal.position",
481                                         0,
482                                         0,
483                                         UNIT::INVALID,
484                                         5.00000f,
485                                         decoder_t::decode_obd2_response,
486                                         nullptr,
487                                         true
488                                 })}
489 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
490                                         91,
491                                         "hybrid.battery-pack.remaining.life",
492                                         0,
493                                         0,
494                                         UNIT::INVALID,
495                                         5.00000f,
496                                         decoder_t::decode_obd2_response,
497                                         nullptr,
498                                         true
499                                 })}
500 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
501                                         92,
502                                         "engine.oil.temperature",
503                                         0,
504                                         0,
505                                         UNIT::INVALID,
506                                         1.00000f,
507                                         decoder_t::decode_obd2_response,
508                                         nullptr,
509                                         true
510                                 })}
511 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
512                                         94,
513                                         "engine.fuel.rate",
514                                         0,
515                                         0,
516                                         UNIT::INVALID,
517                                         1.00000f,
518                                         decoder_t::decode_obd2_response,
519                                         nullptr,
520                                         true
521                                 })}
522 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
523                                         99,
524                                         "engine.torque",
525                                         0,
526                                         0,
527                                         UNIT::INVALID,
528                                         1.00000f,
529                                         decoder_t::decode_obd2_response,
530                                         nullptr,
531                                         true
532                                 })}
533
534                         } // end diagnostic_messages_ vector
535                 })} // end can_message_set entry
536         } // end can_message_set vector
537 {
538         for(auto& cms: can_message_set_)
539         {
540                 std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition();
541                 for(auto& cmd : can_messages_definition)
542                 {
543                         cmd->set_parent(cms.get());
544                         std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals();
545                         for(auto& sig: can_signals)
546                         {
547                                 sig->set_parent(cmd.get());
548                         }
549                 }
550
551                 std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages();
552                 for(auto& dm : diagnostic_messages)
553                 {
554                         dm->set_parent(cms.get());
555                 }
556         }
557                 }
558
559 const std::string application_t::get_diagnostic_bus() const
560 {
561         return "hs";
562 }
563
564