Apollo 10.0
自动驾驶开放平台
vcu_vehicle_status_report_101.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2020 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 neolix_edu {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Vcuvehiclestatusreport101::ID = 0x101;
32
33void Vcuvehiclestatusreport101::Parse(const std::uint8_t* bytes, int32_t length,
34 Neolix_edu* chassis) const {
35 chassis->mutable_vcu_vehicle_status_report_101()
36 ->set_drive_enable_resp(drive_enable_resp(bytes, length));
37 chassis->mutable_vcu_vehicle_status_report_101()
38 ->set_vcu_highvoltagecircuitstate(
39 vcu_highvoltagecircuitstate(bytes, length));
40 chassis->mutable_vcu_vehicle_status_report_101()
41 ->set_vcu_dcdc_enabledstates(vcu_dcdc_enabledstates(bytes, length));
42 chassis->mutable_vcu_vehicle_status_report_101()
43 ->set_control_mode_resp(control_mode_resp(bytes, length));
44 chassis->mutable_vcu_vehicle_status_report_101()
45 ->set_vcu_vehicle_speed(vcu_vehicle_speed(bytes, length));
46 chassis->mutable_vcu_vehicle_status_report_101()
47 ->set_vcu_lowbatterychargingfunctionst(
48 vcu_lowbatterychargingfunctionst(bytes, length));
49 chassis->mutable_vcu_vehicle_status_report_101()
50 ->set_vcu_display_soc(vcu_display_soc(bytes, length));
51 chassis->mutable_vcu_vehicle_status_report_101()
52 ->set_vcu_motor_speed(vcu_motor_speed(bytes, length));
53 chassis->mutable_vcu_vehicle_status_report_101()
54 ->set_vcu_motor_direction(vcu_motor_direction(bytes, length));
55 chassis->mutable_vcu_vehicle_status_report_101()
56 ->set_vcu_motor_speed_valid(vcu_motor_speed_valid(bytes, length));
57 chassis->mutable_vcu_vehicle_status_report_101()
58 ->set_vcu_statusrept_alivecounter(
59 vcu_statusrept_alivecounter(bytes, length));
60 chassis->mutable_vcu_vehicle_status_report_101()
61 ->set_vcu_statusrept_checksum(vcu_statusrept_checksum(bytes, length));
62
63 chassis->mutable_vehicle_spd()->set_vehicle_spd(
64 vcu_vehicle_speed(bytes, length));
65 chassis->mutable_battery()->set_battery_percent(
66 vcu_display_soc(bytes, length));
67}
68
69// config detail: {'description': '0x0:disable;0x1:enable', 'offset': 0.0,
70// 'precision': 1.0, 'len': 1, 'name': 'drive_enable_resp', 'is_signed_var':
71// False, 'physical_range': '[0|0]', 'bit': 0, 'type': 'bool', 'order':
72// 'motorola', 'physical_unit': ''}
73bool Vcuvehiclestatusreport101::drive_enable_resp(const std::uint8_t* bytes,
74 int32_t length) const {
75 Byte t0(bytes + 0);
76 int32_t x = t0.get_byte(0, 1);
77
78 bool ret = x;
79 return ret;
80}
81
82// config detail: {'description': '0x0:Disconnect;0x1:Connect', 'offset': 0.0,
83// 'precision': 1.0, 'len': 1, 'name': 'vcu_highvoltagecircuitstate',
84// 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 2, 'type': 'bool',
85// 'order': 'motorola', 'physical_unit': ''}
86bool Vcuvehiclestatusreport101::vcu_highvoltagecircuitstate(
87 const std::uint8_t* bytes, int32_t length) const {
88 Byte t0(bytes + 0);
89 int32_t x = t0.get_byte(2, 1);
90
91 bool ret = x;
92 return ret;
93}
94
95// config detail: {'description': '0x0: Disable;0x1:Enable', 'offset': 0.0,
96// 'precision': 1.0, 'len': 1, 'name': 'vcu_dcdc_enabledstates',
97// 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 3, 'type': 'bool',
98// 'order': 'motorola', 'physical_unit': ''}
99bool Vcuvehiclestatusreport101::vcu_dcdc_enabledstates(
100 const std::uint8_t* bytes, int32_t length) const {
101 Byte t0(bytes + 0);
102 int32_t x = t0.get_byte(3, 1);
103
104 bool ret = x;
105 return ret;
106}
107
108// config detail: {'description': '0x0:Standby;0x1:auto drive;0x2:net
109// drive;0x3:remote control;0x4:emergency brake;0x5~0x7:Reserved', 'enum': {0:
110// 'CONTROL_MODE_RESP_STANDBY', 1: 'CONTROL_MODE_RESP_AUTO_DRIVE', 2:
111// 'CONTROL_MODE_RESP_NET_DRIVE', 3: 'CONTROL_MODE_RESP_REMOTE_CONTROL', 4:
112// 'CONTROL_MODE_RESP_EMERGENCY_BRAKE'}, 'precision': 1.0, 'len': 3, 'name':
113// 'control_mode_resp', 'is_signed_var': False, 'offset': 0.0, 'physical_range':
114// '[0|7]', 'bit': 6, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
116Vcuvehiclestatusreport101::control_mode_resp(const std::uint8_t* bytes,
117 int32_t length) const {
118 Byte t0(bytes + 0);
119 int32_t x = t0.get_byte(4, 3);
120
123 return ret;
124}
125
126// config detail: {'name': 'vcu_vehicle_speed', 'offset': 0.0, 'precision':
127// 0.05625, 'len': 13, 'is_signed_var': False, 'physical_range': '[0|460.69]',
128// 'bit': 15, 'type': 'double', 'order': 'motorola', 'physical_unit': 'Km/h'}
129double Vcuvehiclestatusreport101::vcu_vehicle_speed(const std::uint8_t* bytes,
130 int32_t length) const {
131 Byte t0(bytes + 1);
132 int32_t x = t0.get_byte(0, 8);
133
134 Byte t1(bytes + 2);
135 int32_t t = t1.get_byte(3, 5);
136 x <<= 5;
137 x |= t;
138
139 double ret = x * 0.056250;
140 return ret;
141}
142
143// config detail: {'description': '0x0:Reserved;0x1:Start;0x2:Stop;0x3:Invalid
144// ', 'offset': 0.0, 'precision': 1.0, 'len': 2, 'name':
145// 'vcu_lowbatterychargingfunctionst', 'is_signed_var': False, 'physical_range':
146// '[0|0]', 'bit': 17, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
147int Vcuvehiclestatusreport101::vcu_lowbatterychargingfunctionst(
148 const std::uint8_t* bytes, int32_t length) const {
149 Byte t0(bytes + 2);
150 int32_t x = t0.get_byte(0, 2);
151
152 int ret = x;
153 return ret;
154}
155
156// config detail: {'name': 'vcu_display_soc', 'offset': 0.0, 'precision': 1.0,
157// 'len': 8, 'is_signed_var': False, 'physical_range': '[0|100]', 'bit': 31,
158// 'type': 'int', 'order': 'motorola', 'physical_unit': '%'}
159int Vcuvehiclestatusreport101::vcu_display_soc(const std::uint8_t* bytes,
160 int32_t length) const {
161 Byte t0(bytes + 3);
162 int32_t x = t0.get_byte(0, 8);
163
164 int ret = x;
165 return ret;
166}
167
168// config detail: {'name': 'vcu_motor_speed', 'offset': 0.0, 'precision': 0.25,
169// 'len': 16, 'is_signed_var': False, 'physical_range': '[0|0]', 'bit': 39,
170// 'type': 'double', 'order': 'motorola', 'physical_unit': ''}
171double Vcuvehiclestatusreport101::vcu_motor_speed(const std::uint8_t* bytes,
172 int32_t length) const {
173 Byte t0(bytes + 4);
174 int32_t x = t0.get_byte(0, 8);
175
176 Byte t1(bytes + 5);
177 int32_t t = t1.get_byte(0, 8);
178 x <<= 8;
179 x |= t;
180
181 double ret = x * 0.250000;
182 return ret;
183}
184
185// config detail: {'description': '0x0:Standby Status;0x1:Forward
186// Mode;0x2:Reverse Mode', 'offset': 0.0, 'precision': 1.0, 'len': 2, 'name':
187// 'vcu_motor_direction', 'is_signed_var': False, 'physical_range': '[0|0]',
188// 'bit': 54, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
189int Vcuvehiclestatusreport101::vcu_motor_direction(const std::uint8_t* bytes,
190 int32_t length) const {
191 Byte t0(bytes + 6);
192 int32_t x = t0.get_byte(5, 2);
193
194 int ret = x;
195 return ret;
196}
197
198// config detail: {'description': '0x0:disable;0x1:enable', 'offset': 0.0,
199// 'precision': 1.0, 'len': 1, 'name': 'vcu_motor_speed_valid', 'is_signed_var':
200// False, 'physical_range': '[0|0]', 'bit': 55, 'type': 'bool', 'order':
201// 'motorola', 'physical_unit': ''}
202bool Vcuvehiclestatusreport101::vcu_motor_speed_valid(const std::uint8_t* bytes,
203 int32_t length) const {
204 Byte t0(bytes + 6);
205 int32_t x = t0.get_byte(7, 1);
206
207 bool ret = x;
208 return ret;
209}
210
211// config detail: {'name': 'vcu_statusrept_alivecounter', 'offset': 0.0,
212// 'precision': 1.0, 'len': 4, 'is_signed_var': False, 'physical_range':
213// '[0|0]', 'bit': 51, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
214int Vcuvehiclestatusreport101::vcu_statusrept_alivecounter(
215 const std::uint8_t* bytes, int32_t length) const {
216 Byte t0(bytes + 6);
217 int32_t x = t0.get_byte(0, 4);
218
219 int ret = x;
220 return ret;
221}
222
223// config detail: {'name': 'vcu_statusrept_checksum', 'offset': 0.0,
224// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
225// '[0|0]', 'bit': 63, 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
226int Vcuvehiclestatusreport101::vcu_statusrept_checksum(
227 const std::uint8_t* bytes, int32_t length) const {
228 Byte t0(bytes + 7);
229 int32_t x = t0.get_byte(0, 8);
230
231 int ret = x;
232 return ret;
233}
234} // namespace neolix_edu
235} // namespace canbus
236} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Neolix_edu *chassis) const override
class register implement
Definition arena_queue.h:37