Apollo 10.0
自动驾驶开放平台
license_7e.cc
浏览该文件的文档.
1/* Copyright 2017 The Apollo Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations under the License.
14==============================================================================*/
16
18
19namespace apollo {
20namespace canbus {
21namespace lincoln {
22namespace {
23
24using ::apollo::drivers::canbus::Byte;
25
26template <class T>
27inline T ByteTo(const Byte& byte) {
28 return static_cast<T>(byte.get_byte(0, 8));
29}
30
31inline std::string ByteToString(const Byte& byte) {
32 return std::string(1, ByteTo<char>(byte));
33}
34
35} // namespace
36
37const int32_t License7e::ID = 0x7E;
38
40 : vin_part0_(""),
41 vin_part1_(""),
42 vin_part2_(""),
43 vin_part0_flag_(false),
44 vin_part1_flag_(false),
45 vin_part2_flag_(false),
46 parse_success_(false) {}
47
48void License7e::Parse(const std::uint8_t* bytes, int length,
49 Lincoln* chassis_detail) const {
50 if (!parse_success_) {
51 switch (mux(bytes, length)) {
52 case 0x83:
53 vin_part0_ = vin00(bytes, length) + vin01(bytes, length) +
54 vin02(bytes, length) + vin03(bytes, length) +
55 vin04(bytes, length) + vin05(bytes, length);
56 vin_part0_flag_ = true;
57 break;
58 case 0x84:
59 vin_part1_ = vin06(bytes, length) + vin07(bytes, length) +
60 vin08(bytes, length) + vin09(bytes, length) +
61 vin10(bytes, length) + vin11(bytes, length);
62 vin_part1_flag_ = true;
63 break;
64 case 0x85:
65 vin_part2_ = vin12(bytes, length) + vin13(bytes, length) +
66 vin14(bytes, length) + vin15(bytes, length) +
67 vin16(bytes, length);
68 vin_part2_flag_ = true;
69 break;
70 }
71
72 if (vin_part0_flag_ && vin_part1_flag_ && vin_part2_flag_) {
73 parse_success_ = true;
74 chassis_detail->mutable_vehicle_id()->set_vin(
75 (vin_part0_ + vin_part1_ + vin_part2_));
76 }
77 }
78}
79
80// config detail: {'name': 'mux', 'offset': 0.0, 'precision': 1.0, 'len': 8,
81// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
82// 0, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
83int License7e::mux(const std::uint8_t* bytes, int length) const {
84 Byte frame(bytes + 0);
85 return ByteTo<int>(frame);
86}
87
88// config detail: {'name': 'ready', 'offset': 0.0, 'precision': 1.0, 'len': 1,
89// 'f_type': 'valid', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
90// 8, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}
91bool License7e::is_ready(const std::uint8_t* bytes, int length) const {
92 Byte frame(bytes + 1);
93 return frame.is_bit_1(0);
94}
95
96// config detail: {'name': 'trial', 'offset': 0.0, 'precision': 1.0, 'len': 1,
97// 'f_type': 'valid', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
98// 9, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}
99bool License7e::is_trial(const std::uint8_t* bytes, int length) const {
100 Byte frame(bytes + 1);
101 return frame.is_bit_1(1);
102}
103
104// config detail: {'name': 'expired', 'offset': 0.0, 'precision': 1.0, 'len': 1,
105// 'f_type': 'valid', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
106// 10, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}
107bool License7e::is_expired(const std::uint8_t* bytes, int length) const {
108 Byte frame(bytes + 1);
109 return frame.is_bit_1(2);
110}
111
112// config detail: {'name': 'feat_base_enabled', 'offset': 0.0, 'precision': 1.0,
113// 'len': 1, 'f_type': 'valid', 'is_signed_var': False, 'physical_range':
114// '[0|0]', 'bit': 16, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}
115bool License7e::is_feat_base_enabled(const std::uint8_t* bytes,
116 int length) const {
117 Byte frame(bytes + 2);
118 return frame.is_bit_1(0);
119}
120
121// config detail: {'name': 'date0', 'offset': 0.0, 'precision': 1.0, 'len': 8,
122// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
123// 16, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
124int License7e::date0(const std::uint8_t* bytes, int length) const {
125 Byte frame(bytes + 2);
126 return ByteTo<int>(frame);
127}
128
129// config detail: {'name': 'date6', 'offset': 0.0, 'precision': 1.0, 'len': 8,
130// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
131// 16, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
132int License7e::date6(const std::uint8_t* bytes, int length) const {
133 Byte frame(bytes + 2);
134 return ByteTo<int>(frame);
135}
136
137// config detail: {'name': 'mac0', 'offset': 0.0, 'precision': 1.0, 'len': 8,
138// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
139// 16, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
140int License7e::mac0(const std::uint8_t* bytes, int length) const {
141 Byte frame(bytes + 2);
142 return ByteTo<int>(frame);
143}
144
145// config detail: {'name': 'vin00', 'offset': 0.0, 'precision': 1.0, 'len': 8,
146// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
147// 16, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
148std::string License7e::vin00(const std::uint8_t* bytes, int length) const {
149 Byte frame(bytes + 2);
150 return ByteToString(frame);
151}
152
153// config detail: {'name': 'vin06', 'offset': 0.0, 'precision': 1.0, 'len': 8,
154// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
155// 16, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
156std::string License7e::vin06(const std::uint8_t* bytes, int length) const {
157 Byte frame(bytes + 2);
158 return ByteToString(frame);
159}
160
161// config detail: {'name': 'vin12', 'offset': 0.0, 'precision': 1.0, 'len': 8,
162// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
163// 16, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}t
164std::string License7e::vin12(const std::uint8_t* bytes, int length) const {
165 Byte frame(bytes + 2);
166 return ByteToString(frame);
167}
168
169// config detail: {'name': 'feat_base_trial', 'offset': 0.0, 'precision': 1.0,
170// 'len': 1, 'f_type': 'valid', 'is_signed_var': False, 'physical_range':
171// '[0|0]', 'bit': 17, 'type': 'bool', 'order': 'intel', 'physical_unit': '""'}
172bool License7e::is_feat_base_trial(const std::uint8_t* bytes,
173 int length) const {
174 Byte frame(bytes + 2);
175 return frame.is_bit_1(1);
176}
177
178// config detail: {'name': 'date1', 'offset': 0.0, 'precision': 1.0, 'len': 8,
179// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
180// 24, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
181int License7e::date1(const std::uint8_t* bytes, int length) const {
182 Byte frame(bytes + 3);
183 return ByteTo<int>(frame);
184}
185
186// config detail: {'name': 'date7', 'offset': 0.0, 'precision': 1.0, 'len': 8,
187// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
188// 24, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
189int License7e::date7(const std::uint8_t* bytes, int length) const {
190 Byte frame(bytes + 3);
191 return ByteTo<int>(frame);
192}
193
194// config detail: {'name': 'mac1', 'offset': 0.0, 'precision': 1.0, 'len': 8,
195// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
196// 24, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
197int License7e::mac1(const std::uint8_t* bytes, int length) const {
198 Byte frame(bytes + 3);
199 return ByteTo<int>(frame);
200}
201
202// config detail: {'name': 'vin01', 'offset': 0.0, 'precision': 1.0, 'len': 8,
203// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
204// 24, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
205std::string License7e::vin01(const std::uint8_t* bytes, int length) const {
206 Byte frame(bytes + 3);
207 return ByteToString(frame);
208}
209
210// config detail: {'name': 'vin07', 'offset': 0.0, 'precision': 1.0, 'len': 8,
211// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
212// 24, 'type': 'int', 'order': 'intel', 'physical_unit': '""'
213std::string License7e::vin07(const std::uint8_t* bytes, int32_t length) const {
214 Byte frame(bytes + 3);
215 return ByteToString(frame);
216}
217
218// config detail: {'name': 'vin13', 'offset': 0.0, 'precision': 1.0, 'len': 8,
219// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
220// 24, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
221std::string License7e::vin13(const std::uint8_t* bytes, int length) const {
222 Byte frame(bytes + 3);
223 return ByteToString(frame);
224}
225
226// config detail: {'name': 'date2', 'offset': 0.0, 'precision': 1.0, 'len': 8,
227// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
228// 32, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
229int License7e::date2(const std::uint8_t* bytes, int length) const {
230 Byte frame(bytes + 4);
231 return ByteTo<int>(frame);
232}
233
234// config detail: {'name': 'date8', 'offset': 0.0, 'precision': 1.0, 'len': 8,
235// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
236// 32, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
237int License7e::date8(const std::uint8_t* bytes, int length) const {
238 Byte frame(bytes + 4);
239 return ByteTo<int>(frame);
240}
241
242// config detail: {'name': 'mac2', 'offset': 0.0, 'precision': 1.0, 'len': 8,
243// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
244// 32, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
245int License7e::mac2(const std::uint8_t* bytes, int length) const {
246 Byte frame(bytes + 4);
247 return ByteTo<int>(frame);
248}
249
250// config detail: {'name': 'vin02', 'offset': 0.0, 'precision': 1.0, 'len': 8,
251// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
252// 32, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
253std::string License7e::vin02(const std::uint8_t* bytes, int length) const {
254 Byte frame(bytes + 4);
255 return ByteToString(frame);
256}
257
258// config detail: {'name': 'vin08', 'offset': 0.0, 'precision': 1.0, 'len': 8,
259// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
260// 32, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
261std::string License7e::vin08(const std::uint8_t* bytes, int length) const {
262 Byte frame(bytes + 4);
263 return ByteToString(frame);
264}
265
266// config detail: {'name': 'vin14', 'offset': 0.0, 'precision': 1.0, 'len': 8,
267// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
268// 32, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
269std::string License7e::vin14(const std::uint8_t* bytes, int length) const {
270 Byte frame(bytes + 4);
271 return ByteToString(frame);
272}
273
274// config detail: {'name': 'feat_base_trials_used', 'offset': 0.0,
275// 'precision': 1.0, 'len': 16, 'f_type': 'value', 'is_signed_var': False,
276// 'physical_range': '[0|0]', 'bit': 32, 'type': 'int', 'order': 'intel',
277// 'physical_unit': '""'}
278int License7e::feat_base_trials_used(const std::uint8_t* bytes,
279 int length) const {
280 Byte t0(bytes + 5);
281 int x = t0.get_byte(0, 8);
282 Byte t1(bytes + 4);
283 int t = t1.get_byte(0, 8);
284 x <<= 8;
285 x |= t;
286 return x;
287}
288
289// config detail: {'name': 'date3', 'offset': 0.0, 'precision': 1.0, 'len': 8,
290// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
291// 40, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
292int License7e::date3(const std::uint8_t* bytes, int length) const {
293 Byte frame(bytes + 5);
294 return ByteTo<int>(frame);
295}
296
297// config detail: {'name': 'date9', 'offset': 0.0, 'precision': 1.0, 'len': 8,
298// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
299// 40, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
300int License7e::date9(const std::uint8_t* bytes, int length) const {
301 Byte frame(bytes + 5);
302 return ByteTo<int>(frame);
303}
304
305// config detail: {'name': 'mac3', 'offset': 0.0, 'precision': 1.0, 'len': 8,
306// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
307// 40, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
308int License7e::mac3(const std::uint8_t* bytes, int length) const {
309 Byte frame(bytes + 5);
310 return ByteTo<int>(frame);
311}
312
313// config detail: {'name': 'vin03', 'offset': 0.0, 'precision': 1.0, 'len': 8,
314// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
315// 40, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
316std::string License7e::vin03(const std::uint8_t* bytes, int length) const {
317 Byte frame(bytes + 5);
318 return ByteToString(frame);
319}
320
321// config detail: {'name': 'vin09', 'offset': 0.0, 'precision': 1.0, 'len': 8,
322// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
323// 40, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
324std::string License7e::vin09(const std::uint8_t* bytes, int length) const {
325 Byte frame(bytes + 5);
326 return ByteToString(frame);
327}
328
329// config detail: {'name': 'vin15', 'offset': 0.0, 'precision': 1.0, 'len': 8,
330// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
331// 40, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
332std::string License7e::vin15(const std::uint8_t* bytes, int length) const {
333 Byte frame(bytes + 5);
334 return ByteToString(frame);
335}
336
337// config detail: {'name': 'date4', 'offset': 0.0, 'precision': 1.0, 'len': 8,
338// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
339// 48, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
340int License7e::date4(const std::uint8_t* bytes, int length) const {
341 Byte frame(bytes + 6);
342 return ByteTo<int>(frame);
343}
344
345// config detail: {'name': 'mac4', 'offset': 0.0, 'precision': 1.0, 'len': 8,
346// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
347// 48, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
348int License7e::mac4(const std::uint8_t* bytes, int length) const {
349 Byte frame(bytes + 6);
350 return ByteTo<int>(frame);
351}
352
353// config detail: {'name': 'vin04', 'offset': 0.0, 'precision': 1.0, 'len': 8,
354// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
355// 48, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
356std::string License7e::vin04(const std::uint8_t* bytes, int length) const {
357 Byte frame(bytes + 6);
358 return ByteToString(frame);
359}
360
361// config detail: {'name': 'vin10', 'offset': 0.0, 'precision': 1.0, 'len': 8,
362// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
363// 48, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
364std::string License7e::vin10(const std::uint8_t* bytes, int length) const {
365 Byte frame(bytes + 6);
366 return ByteToString(frame);
367}
368
369// config detail: {'name': 'vin16', 'offset': 0.0, 'precision': 1.0, 'len': 8,
370// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
371// 48, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
372std::string License7e::vin16(const std::uint8_t* bytes, int length) const {
373 Byte frame(bytes + 6);
374 return ByteToString(frame);
375}
376
377// config detail: {'name': 'feat_base_trials_remaining', 'offset': 0.0,
378// 'precision': 1.0, 'len': 16, 'f_type': 'value', 'is_signed_var': False,
379// 'physical_range': '[0|0]', 'bit': 48, 'type': 'int', 'order': 'intel',
380// 'physical_unit': '""'}
381int License7e::feat_base_trials_remaining(const std::uint8_t* bytes,
382 int length) const {
383 Byte t0(bytes + 7);
384 int x = t0.get_byte(0, 8);
385 Byte t1(bytes + 6);
386 int t = t1.get_byte(0, 8);
387 x <<= 8;
388 x |= t;
389 return x;
390}
391
392// config detail: {'name': 'date5', 'offset': 0.0, 'precision': 1.0, 'len': 8,
393// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
394// 56, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
395int License7e::date5(const std::uint8_t* bytes, int length) const {
396 Byte frame(bytes + 7);
397 return ByteTo<int>(frame);
398}
399
400// config detail: {'name': 'mac5', 'offset': 0.0, 'precision': 1.0, 'len': 8,
401// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
402// 56, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
403int License7e::mac5(const std::uint8_t* bytes, int length) const {
404 Byte frame(bytes + 7);
405 return ByteTo<int>(frame);
406}
407
408// config detail: {'name': 'vin05', 'offset': 0.0, 'precision': 1.0, 'len': 8,
409// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
410// 56, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
411std::string License7e::vin05(const std::uint8_t* bytes, int length) const {
412 Byte frame(bytes + 7);
413 return ByteToString(frame);
414}
415
416// config detail: {'name': 'vin11', 'offset': 0.0, 'precision': 1.0, 'len': 8,
417// 'f_type': 'value', 'is_signed_var': False, 'physical_range': '[0|0]', 'bit':
418// 56, 'type': 'int', 'order': 'intel', 'physical_unit': '""'}
419std::string License7e::vin11(const std::uint8_t* bytes, int length) const {
420 Byte frame(bytes + 7);
421 return ByteToString(frame);
422}
423
424} // namespace lincoln
425} // namespace canbus
426} // namespace apollo
Defines the Byte class.
int mac2(const std::uint8_t *bytes, int length) const
int date2(const std::uint8_t *bytes, int length) const
std::string vin01(const std::uint8_t *bytes, int length) const
bool is_feat_base_trial(const std::uint8_t *bytes, int length) const
bool is_trial(const std::uint8_t *bytes, int length) const
Definition license_7e.cc:99
std::string vin06(const std::uint8_t *bytes, int length) const
std::string vin05(const std::uint8_t *bytes, int length) const
int mac5(const std::uint8_t *bytes, int length) const
int date1(const std::uint8_t *bytes, int length) const
std::string vin04(const std::uint8_t *bytes, int length) const
std::string vin08(const std::uint8_t *bytes, int length) const
bool is_expired(const std::uint8_t *bytes, int length) const
std::string vin16(const std::uint8_t *bytes, int length) const
std::string vin00(const std::uint8_t *bytes, int length) const
std::string vin12(const std::uint8_t *bytes, int length) const
std::string vin15(const std::uint8_t *bytes, int length) const
int date8(const std::uint8_t *bytes, int length) const
std::string vin02(const std::uint8_t *bytes, int length) const
std::string vin14(const std::uint8_t *bytes, int length) const
int date5(const std::uint8_t *bytes, int length) const
bool is_ready(const std::uint8_t *bytes, int length) const
Definition license_7e.cc:91
std::string vin13(const std::uint8_t *bytes, int length) const
int date3(const std::uint8_t *bytes, int length) const
virtual void Parse(const std::uint8_t *bytes, int32_t length, Lincoln *chassis_detail) const
Definition license_7e.cc:48
std::string vin10(const std::uint8_t *bytes, int length) const
int date6(const std::uint8_t *bytes, int length) const
int feat_base_trials_remaining(const std::uint8_t *bytes, int length) const
int date9(const std::uint8_t *bytes, int length) const
int date4(const std::uint8_t *bytes, int length) const
int date0(const std::uint8_t *bytes, int length) const
std::string vin07(const std::uint8_t *bytes, int length) const
int mac4(const std::uint8_t *bytes, int length) const
std::string vin03(const std::uint8_t *bytes, int length) const
bool is_feat_base_enabled(const std::uint8_t *bytes, int length) const
int date7(const std::uint8_t *bytes, int length) const
int mac0(const std::uint8_t *bytes, int length) const
int feat_base_trials_used(const std::uint8_t *bytes, int length) const
int mac3(const std::uint8_t *bytes, int length) const
int mux(const std::uint8_t *bytes, int length) const
Definition license_7e.cc:83
std::string vin11(const std::uint8_t *bytes, int length) const
std::string vin09(const std::uint8_t *bytes, int length) const
int mac1(const std::uint8_t *bytes, int length) const
class register implement
Definition arena_queue.h:37