Apollo 10.0
自动驾驶开放平台
date_time_rpt_83.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 gem {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Datetimerpt83::ID = 0x83;
32
33void Datetimerpt83::Parse(const std::uint8_t* bytes, int32_t length,
34 Gem* chassis) const {
35 chassis->mutable_date_time_rpt_83()->set_time_second(
36 time_second(bytes, length));
37 chassis->mutable_date_time_rpt_83()->set_time_minute(
38 time_minute(bytes, length));
39 chassis->mutable_date_time_rpt_83()->set_time_hour(
40 time_hour(bytes, length));
41 chassis->mutable_date_time_rpt_83()->set_date_day(
42 date_day(bytes, length));
43 chassis->mutable_date_time_rpt_83()->set_date_month(
44 date_month(bytes, length));
45 chassis->mutable_date_time_rpt_83()->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 Datetimerpt83::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 = 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 Datetimerpt83::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 = 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 Datetimerpt83::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 Datetimerpt83::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 Datetimerpt83::date_month(const std::uint8_t* bytes, int32_t length) const {
99 Byte t0(bytes + 1);
100 int32_t x = t0.get_byte(0, 8);
101
102 int ret = x + 1;
103 return ret;
104}
105
106// config detail: {'name': 'date_year', 'offset': 2000.0, 'precision': 1.0,
107// 'len': 8, 'is_signed_var': False, 'physical_range': '[2000|2255]', 'bit': 7,
108// 'type': 'int', 'order': 'motorola', 'physical_unit': 'yr'}
109int Datetimerpt83::date_year(const std::uint8_t* bytes, int32_t length) const {
110 Byte t0(bytes + 0);
111 int32_t x = t0.get_byte(0, 8);
112
113 int ret = x + 2000;
114 return ret;
115}
116} // namespace gem
117} // namespace canbus
118} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Gem *chassis) const override
class register implement
Definition arena_queue.h:37