Apollo 10.0
自动驾驶开放平台
brake_rpt_6c.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 Brakerpt6c::ID = 0x6C;
32
33void Brakerpt6c::Parse(const std::uint8_t* bytes, int32_t length,
34 Gem* chassis) const {
35 chassis->mutable_brake_rpt_6c()->set_manual_input(
36 manual_input(bytes, length));
37 chassis->mutable_brake_rpt_6c()->set_commanded_value(
38 commanded_value(bytes, length));
39 chassis->mutable_brake_rpt_6c()->set_output_value(
40 output_value(bytes, length));
41 chassis->mutable_brake_rpt_6c()->set_brake_on_off(
42 brake_on_off(bytes, length));
43}
44
45// config detail: {'name': 'manual_input', 'offset': 0.0, 'precision': 0.001,
46// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 7,
47// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
48double Brakerpt6c::manual_input(const std::uint8_t* bytes,
49 int32_t length) const {
50 Byte t0(bytes + 0);
51 int32_t x = t0.get_byte(0, 8);
52
53 Byte t1(bytes + 1);
54 int32_t t = t1.get_byte(0, 8);
55 x <<= 8;
56 x |= t;
57
58 double ret = x * 0.001000;
59 return ret;
60}
61
62// config detail: {'name': 'commanded_value', 'offset': 0.0, 'precision': 0.001,
63// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 23,
64// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
65double Brakerpt6c::commanded_value(const std::uint8_t* bytes,
66 int32_t length) const {
67 Byte t0(bytes + 2);
68 int32_t x = t0.get_byte(0, 8);
69
70 Byte t1(bytes + 3);
71 int32_t t = t1.get_byte(0, 8);
72 x <<= 8;
73 x |= t;
74
75 double ret = x * 0.001000;
76 return ret;
77}
78
79// config detail: {'name': 'output_value', 'offset': 0.0, 'precision': 0.001,
80// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 39,
81// 'type': 'double', 'order': 'motorola', 'physical_unit': '%'}
82double Brakerpt6c::output_value(const std::uint8_t* bytes,
83 int32_t length) const {
84 Byte t0(bytes + 4);
85 int32_t x = t0.get_byte(0, 8);
86
87 Byte t1(bytes + 5);
88 int32_t t = t1.get_byte(0, 8);
89 x <<= 8;
90 x |= t;
91
92 double ret = x * 0.001000;
93 return ret;
94}
95
96// config detail: {'name': 'brake_on_off', 'enum': {0: 'BRAKE_ON_OFF_OFF', 1:
97// 'BRAKE_ON_OFF_ON'}, 'precision': 1.0, 'len': 1, 'is_signed_var': False,
98// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 48, 'type': 'enum', 'order':
99// 'motorola', 'physical_unit': ''}
100Brake_rpt_6c::Brake_on_offType Brakerpt6c::brake_on_off(
101 const std::uint8_t* bytes, int32_t length) const {
102 Byte t0(bytes + 6);
103 int32_t x = t0.get_byte(0, 1);
104
106 static_cast<Brake_rpt_6c::Brake_on_offType>(x);
107 return ret;
108}
109} // namespace gem
110} // namespace canbus
111} // 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