Apollo 10.0
自动驾驶开放平台
date_time_rpt_40f.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 The Apollo Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *****************************************************************************/
16
18
19#include "glog/logging.h"
20
23
24namespace apollo {
25namespace canbus {
26namespace lexus {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Datetimerpt40f::ID = 0x40F;
32
33void Datetimerpt40f::Parse(const std::uint8_t* bytes, int32_t length,
34 Lexus* chassis) const {
35 chassis->mutable_date_time_rpt_40f()->set_time_second(
36 time_second(bytes, length));
37 chassis->mutable_date_time_rpt_40f()->set_time_minute(
38 time_minute(bytes, length));
39 chassis->mutable_date_time_rpt_40f()->set_time_hour(
40 time_hour(bytes, length));
41 chassis->mutable_date_time_rpt_40f()->set_date_day(
42 date_day(bytes, length));
43 chassis->mutable_date_time_rpt_40f()->set_date_month(
44 date_month(bytes, length));
45 chassis->mutable_date_time_rpt_40f()->set_date_year(
46 date_year(bytes, length));
47}
48
49// config detail: {'name': 'time_second', 'offset': 0.0, 'precision': 1.0,
50// 'len': 8, 'is_signed_var': False, 'physical_range': '[0|60]', 'bit': 47,
51// 'type': 'int', 'order': 'motorola', 'physical_unit': 'sec'}
52int Datetimerpt40f::time_second(const std::uint8_t* bytes,
53 int32_t length) const {
54 Byte t0(bytes + 5);
55 int32_t x = t0.get_byte(0, 8);
56
57 int ret = static_cast<int>(x);
58 return ret;
59}
60
61// config detail: {'name': 'time_minute', 'offset': 0.0, 'precision': 1.0,
62// 'len': 8, 'is_signed_var': False, 'physical_range': '[0|60]', 'bit': 39,
63// 'type': 'int', 'order': 'motorola', 'physical_unit': 'min'}
64int Datetimerpt40f::time_minute(const std::uint8_t* bytes,
65 int32_t length) const {
66 Byte t0(bytes + 4);
67 int32_t x = t0.get_byte(0, 8);
68
69 int ret = static_cast<int>(x);
70 return ret;
71}
72
73// config detail: {'name': 'time_hour', 'offset': 0.0, 'precision': 1.0, 'len':
74// 8, 'is_signed_var': False, 'physical_range': '[0|23]', 'bit': 31, 'type':
75// 'int', 'order': 'motorola', 'physical_unit': 'hr'}
76int Datetimerpt40f::time_hour(const std::uint8_t* bytes, int32_t length) const {
77 Byte t0(bytes + 3);
78 int32_t x = t0.get_byte(0, 8);
79
80 int ret = x;
81 return ret;
82}
83
84// config detail: {'name': 'date_day', 'offset': 1.0, 'precision': 1.0, 'len':
85// 8, 'is_signed_var': False, 'physical_range': '[1|31]', 'bit': 23, 'type':
86// 'int', 'order': 'motorola', 'physical_unit': 'dy'}
87int Datetimerpt40f::date_day(const std::uint8_t* bytes, int32_t length) const {
88 Byte t0(bytes + 2);
89 int32_t x = t0.get_byte(0, 8);
90
91 int ret = x + 1;
92 return ret;
93}
94
95// config detail: {'name': 'date_month', 'offset': 1.0, 'precision': 1.0, 'len':
96// 8, 'is_signed_var': False, 'physical_range': '[1|12]', 'bit': 15, 'type':
97// 'int', 'order': 'motorola', 'physical_unit': 'mon'}
98int Datetimerpt40f::date_month(const std::uint8_t* bytes,
99 int32_t length) const {
100 Byte t0(bytes + 1);
101 int32_t x = t0.get_byte(0, 8);
102
103 int ret = x + 1;
104 return ret;
105}
106
107// config detail: {'name': 'date_year', 'offset': 2000.0, 'precision': 1.0,
108// 'len': 8, 'is_signed_var': False, 'physical_range': '[2000|2255]', 'bit': 7,
109// 'type': 'int', 'order': 'motorola', 'physical_unit': 'yr'}
110int Datetimerpt40f::date_year(const std::uint8_t* bytes, int32_t length) const {
111 Byte t0(bytes + 0);
112 int32_t x = t0.get_byte(0, 8);
113
114 int ret = x + 2000;
115 return ret;
116}
117} // namespace lexus
118} // namespace canbus
119} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Lexus *chassis) const override
class register implement
Definition arena_queue.h:37