Reworked subscription to integrate filtering.
[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                                                         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                 }, // end can_message_definition vector
224                         { // beginning diagnostic_messages_ vector
225                                 {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
226                                         4,
227                                         "engine.load",
228                                         0,
229                                         0,
230                                         UNIT::INVALID,
231                                         5.00000f,
232                                         decoder_t::decode_obd2_response,
233                                         nullptr,
234                                         true
235                                 })}
236 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
237                                         5,
238                                         "engine.coolant.temperature",
239                                         0,
240                                         0,
241                                         UNIT::INVALID,
242                                         1.00000f,
243                                         decoder_t::decode_obd2_response,
244                                         nullptr,
245                                         true
246                                 })}
247 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
248                                         10,
249                                         "fuel.pressure",
250                                         0,
251                                         0,
252                                         UNIT::INVALID,
253                                         1.00000f,
254                                         decoder_t::decode_obd2_response,
255                                         nullptr,
256                                         true
257                                 })}
258 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
259                                         11,
260                                         "intake.manifold.pressure",
261                                         0,
262                                         0,
263                                         UNIT::INVALID,
264                                         1.00000f,
265                                         decoder_t::decode_obd2_response,
266                                         nullptr,
267                                         true
268                                 })}
269 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
270                                         12,
271                                         "engine.speed",
272                                         0,
273                                         0,
274                                         UNIT::INVALID,
275                                         5.00000f,
276                                         decoder_t::decode_obd2_response,
277                                         nullptr,
278                                         true
279                                 })}
280 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
281                                         13,
282                                         "vehicle.speed",
283                                         0,
284                                         0,
285                                         UNIT::INVALID,
286                                         5.00000f,
287                                         decoder_t::decode_obd2_response,
288                                         nullptr,
289                                         true
290                                 })}
291 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
292                                         15,
293                                         "intake.air.temperature",
294                                         0,
295                                         0,
296                                         UNIT::INVALID,
297                                         1.00000f,
298                                         decoder_t::decode_obd2_response,
299                                         nullptr,
300                                         true
301                                 })}
302 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
303                                         16,
304                                         "mass.airflow",
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                                         17,
315                                         "throttle.position",
316                                         0,
317                                         0,
318                                         UNIT::INVALID,
319                                         5.00000f,
320                                         decoder_t::decode_obd2_response,
321                                         nullptr,
322                                         true
323                                 })}
324 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
325                                         31,
326                                         "running.time",
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                                         45,
337                                         "EGR.error",
338                                         0,
339                                         0,
340                                         UNIT::INVALID,
341                                         0.00000f,
342                                         decoder_t::decode_obd2_response,
343                                         nullptr,
344                                         true
345                                 })}
346 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
347                                         47,
348                                         "fuel.level",
349                                         0,
350                                         0,
351                                         UNIT::INVALID,
352                                         1.00000f,
353                                         decoder_t::decode_obd2_response,
354                                         nullptr,
355                                         true
356                                 })}
357 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
358                                         51,
359                                         "barometric.pressure",
360                                         0,
361                                         0,
362                                         UNIT::INVALID,
363                                         1.00000f,
364                                         decoder_t::decode_obd2_response,
365                                         nullptr,
366                                         true
367                                 })}
368 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
369                                         70,
370                                         "ambient.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                                         76,
381                                         "commanded.throttle.position",
382                                         0,
383                                         0,
384                                         UNIT::INVALID,
385                                         1.00000f,
386                                         decoder_t::decode_obd2_response,
387                                         nullptr,
388                                         true
389                                 })}
390 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
391                                         82,
392                                         "ethanol.fuel.percentage",
393                                         0,
394                                         0,
395                                         UNIT::INVALID,
396                                         1.00000f,
397                                         decoder_t::decode_obd2_response,
398                                         nullptr,
399                                         true
400                                 })}
401 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
402                                         90,
403                                         "accelerator.pedal.position",
404                                         0,
405                                         0,
406                                         UNIT::INVALID,
407                                         5.00000f,
408                                         decoder_t::decode_obd2_response,
409                                         nullptr,
410                                         true
411                                 })}
412 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
413                                         91,
414                                         "hybrid.battery-pack.remaining.life",
415                                         0,
416                                         0,
417                                         UNIT::INVALID,
418                                         5.00000f,
419                                         decoder_t::decode_obd2_response,
420                                         nullptr,
421                                         true
422                                 })}
423 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
424                                         92,
425                                         "engine.oil.temperature",
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                                         94,
436                                         "engine.fuel.rate",
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                                         99,
447                                         "engine.torque",
448                                         0,
449                                         0,
450                                         UNIT::INVALID,
451                                         1.00000f,
452                                         decoder_t::decode_obd2_response,
453                                         nullptr,
454                                         true
455                                 })}
456                         } // end diagnostic_messages_ vector
457                 })} // end can_message_set entry
458         } // end can_message_set vector
459 {
460         for(auto& cms: can_message_set_)
461         {
462                 std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition();
463                 for(auto& cmd : can_messages_definition)
464                 {
465                         cmd->set_parent(cms.get());
466                         std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals();
467                         for(auto& sig: can_signals)
468                         {
469                                 sig->set_parent(cmd.get());
470                         }
471                 }
472
473                 std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages();
474                 for(auto& dm : diagnostic_messages)
475                 {
476                         dm->set_parent(cms.get());
477                 }
478         }
479 }
480
481 const std::string application_t::get_diagnostic_bus() const
482 {
483         return "hs";
484 }
485
486