Examples reorganization
[apps/agl-service-can-low-level.git] / examples / OBD2 / 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
10                 }, // end can_message_definition vector
11                         { // beginning diagnostic_messages_ vector
12                                 {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
13                                         4,
14                                         "engine.load",
15                                         0,
16                                         0,
17                                         UNIT::INVALID,
18                                         5.00000f,
19                                         decoder_t::decode_obd2_response,
20                                         nullptr,
21                                         true
22                                 })}
23 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
24                                         5,
25                                         "engine.coolant.temperature",
26                                         0,
27                                         0,
28                                         UNIT::INVALID,
29                                         1.00000f,
30                                         decoder_t::decode_obd2_response,
31                                         nullptr,
32                                         true
33                                 })}
34 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
35                                         10,
36                                         "fuel.pressure",
37                                         0,
38                                         0,
39                                         UNIT::INVALID,
40                                         1.00000f,
41                                         decoder_t::decode_obd2_response,
42                                         nullptr,
43                                         true
44                                 })}
45 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
46                                         11,
47                                         "intake.manifold.pressure",
48                                         0,
49                                         0,
50                                         UNIT::INVALID,
51                                         1.00000f,
52                                         decoder_t::decode_obd2_response,
53                                         nullptr,
54                                         true
55                                 })}
56 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
57                                         12,
58                                         "engine.speed",
59                                         0,
60                                         0,
61                                         UNIT::INVALID,
62                                         5.00000f,
63                                         decoder_t::decode_obd2_response,
64                                         nullptr,
65                                         true
66                                 })}
67 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
68                                         13,
69                                         "vehicle.speed",
70                                         0,
71                                         0,
72                                         UNIT::INVALID,
73                                         5.00000f,
74                                         decoder_t::decode_obd2_response,
75                                         nullptr,
76                                         true
77                                 })}
78 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
79                                         15,
80                                         "intake.air.temperature",
81                                         0,
82                                         0,
83                                         UNIT::INVALID,
84                                         1.00000f,
85                                         decoder_t::decode_obd2_response,
86                                         nullptr,
87                                         true
88                                 })}
89 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
90                                         16,
91                                         "mass.airflow",
92                                         0,
93                                         0,
94                                         UNIT::INVALID,
95                                         5.00000f,
96                                         decoder_t::decode_obd2_response,
97                                         nullptr,
98                                         true
99                                 })}
100 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
101                                         17,
102                                         "throttle.position",
103                                         0,
104                                         0,
105                                         UNIT::INVALID,
106                                         5.00000f,
107                                         decoder_t::decode_obd2_response,
108                                         nullptr,
109                                         true
110                                 })}
111 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
112                                         31,
113                                         "running.time",
114                                         0,
115                                         0,
116                                         UNIT::INVALID,
117                                         1.00000f,
118                                         decoder_t::decode_obd2_response,
119                                         nullptr,
120                                         true
121                                 })}
122 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
123                                         45,
124                                         "EGR.error",
125                                         0,
126                                         0,
127                                         UNIT::INVALID,
128                                         0.00000f,
129                                         decoder_t::decode_obd2_response,
130                                         nullptr,
131                                         true
132                                 })}
133 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
134                                         47,
135                                         "fuel.level",
136                                         0,
137                                         0,
138                                         UNIT::INVALID,
139                                         1.00000f,
140                                         decoder_t::decode_obd2_response,
141                                         nullptr,
142                                         true
143                                 })}
144 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
145                                         51,
146                                         "barometric.pressure",
147                                         0,
148                                         0,
149                                         UNIT::INVALID,
150                                         1.00000f,
151                                         decoder_t::decode_obd2_response,
152                                         nullptr,
153                                         true
154                                 })}
155 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
156                                         70,
157                                         "ambient.air.temperature",
158                                         0,
159                                         0,
160                                         UNIT::INVALID,
161                                         1.00000f,
162                                         decoder_t::decode_obd2_response,
163                                         nullptr,
164                                         true
165                                 })}
166 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
167                                         76,
168                                         "commanded.throttle.position",
169                                         0,
170                                         0,
171                                         UNIT::INVALID,
172                                         1.00000f,
173                                         decoder_t::decode_obd2_response,
174                                         nullptr,
175                                         true
176                                 })}
177 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
178                                         82,
179                                         "ethanol.fuel.percentage",
180                                         0,
181                                         0,
182                                         UNIT::INVALID,
183                                         1.00000f,
184                                         decoder_t::decode_obd2_response,
185                                         nullptr,
186                                         true
187                                 })}
188 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
189                                         90,
190                                         "accelerator.pedal.position",
191                                         0,
192                                         0,
193                                         UNIT::INVALID,
194                                         5.00000f,
195                                         decoder_t::decode_obd2_response,
196                                         nullptr,
197                                         true
198                                 })}
199 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
200                                         91,
201                                         "hybrid.battery-pack.remaining.life",
202                                         0,
203                                         0,
204                                         UNIT::INVALID,
205                                         5.00000f,
206                                         decoder_t::decode_obd2_response,
207                                         nullptr,
208                                         true
209                                 })}
210 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
211                                         92,
212                                         "engine.oil.temperature",
213                                         0,
214                                         0,
215                                         UNIT::INVALID,
216                                         1.00000f,
217                                         decoder_t::decode_obd2_response,
218                                         nullptr,
219                                         true
220                                 })}
221 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
222                                         94,
223                                         "engine.fuel.rate",
224                                         0,
225                                         0,
226                                         UNIT::INVALID,
227                                         1.00000f,
228                                         decoder_t::decode_obd2_response,
229                                         nullptr,
230                                         true
231                                 })}
232 ,                               {std::make_shared<diagnostic_message_t>(diagnostic_message_t{
233                                         99,
234                                         "engine.torque",
235                                         0,
236                                         0,
237                                         UNIT::INVALID,
238                                         1.00000f,
239                                         decoder_t::decode_obd2_response,
240                                         nullptr,
241                                         true
242                                 })}
243
244                         } // end diagnostic_messages_ vector
245                 })} // end can_message_set entry
246         } // end can_message_set vector
247 {
248         for(auto& cms: can_message_set_)
249         {
250                 std::vector<std::shared_ptr<can_message_definition_t> >& can_messages_definition = cms->get_can_message_definition();
251                 for(auto& cmd : can_messages_definition)
252                 {
253                         cmd->set_parent(cms.get());
254                         std::vector<std::shared_ptr<can_signal_t> >& can_signals = cmd->get_can_signals();
255                         for(auto& sig: can_signals)
256                         {
257                                 sig->set_parent(cmd.get());
258                         }
259                 }
260
261                 std::vector<std::shared_ptr<diagnostic_message_t> >& diagnostic_messages = cms->get_diagnostic_messages();
262                 for(auto& dm : diagnostic_messages)
263                 {
264                         dm->set_parent(cms.get());
265                 }
266         }
267                 }
268
269 const std::string application_t::get_diagnostic_bus() const
270 {
271         return "hs";
272 }
273
274