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