Apollo 10.0
自动驾驶开放平台
bms_report_512.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2023 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 demo {
27
28using ::apollo::drivers::canbus::Byte;
29
31const int32_t Bmsreport512::ID = 0x512;
32
33void Bmsreport512::Parse(const std::uint8_t* bytes, int32_t length,
34 Demo* chassis) const {
35 chassis->mutable_bms_report_512()->set_battery_flt_overtemp(
36 battery_flt_overtemp(bytes, length));
37 chassis->mutable_bms_report_512()->set_battery_flt_lowtemp(
38 battery_flt_lowtemp(bytes, length));
39 chassis->mutable_bms_report_512()->set_battery_inside_temperature(
40 battery_inside_temperature(bytes, length));
41 chassis->mutable_bms_report_512()->set_battery_current(
42 battery_current(bytes, length));
43 chassis->mutable_bms_report_512()->set_battery_voltage(
44 battery_voltage(bytes, length));
45 chassis->mutable_bms_report_512()->set_battery_soc(
46 battery_soc(bytes, length));
47}
48
49// config detail: {'bit': 49, 'enum': {0: 'BATTERY_FLT_OVERTEMP_NO', 1:
50// 'BATTERY_FLT_OVERTEMP_FAULT'}, 'is_signed_var': False, 'len': 1, 'name':
51// 'battery_flt_overtemp', 'offset': 0.0, 'order': 'motorola', 'physical_range':
52// '[0|15]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
53Bms_report_512::Battery_flt_overtempType Bmsreport512::battery_flt_overtemp(
54 const std::uint8_t* bytes, int32_t length) const {
55 Byte t0(bytes + 6);
56 int32_t x = t0.get_byte(1, 1);
57
60 return ret;
61}
62
63// config detail: {'bit': 48, 'enum': {0: 'BATTERY_FLT_LOWTEMP_NO', 1:
64// 'BATTERY_FLT_LOWTEMP_FAULT'}, 'is_signed_var': False, 'len': 1, 'name':
65// 'battery_flt_lowtemp', 'offset': 0.0, 'order': 'motorola', 'physical_range':
66// '[0|15]', 'physical_unit': '', 'precision': 1.0, 'type': 'enum'}
67Bms_report_512::Battery_flt_lowtempType Bmsreport512::battery_flt_lowtemp(
68 const std::uint8_t* bytes, int32_t length) const {
69 Byte t0(bytes + 6);
70 int32_t x = t0.get_byte(0, 1);
71
74 return ret;
75}
76
77// config detail: {'bit': 47, 'description': 'Battery Total Voltage',
78// 'is_signed_var': False, 'len': 8, 'name': 'battery_inside_temperature',
79// 'offset': -40.0, 'order': 'motorola', 'physical_range': '[-40|215]',
80// 'physical_unit': '', 'precision': 1.0, 'type': 'int'}
81int Bmsreport512::battery_inside_temperature(const std::uint8_t* bytes,
82 int32_t length) const {
83 Byte t0(bytes + 5);
84 int32_t x = t0.get_byte(0, 8);
85
86 int ret = x + -40.000000;
87 return ret;
88}
89
90// config detail: {'bit': 23, 'description': 'Battery Total Current',
91// 'is_signed_var': False, 'len': 16, 'name': 'battery_current', 'offset':
92// -3200.0, 'order': 'motorola', 'physical_range': '[-3200|3353.5]',
93// 'physical_unit': 'A', 'precision': 0.1, 'type': 'double'}
94double Bmsreport512::battery_current(const std::uint8_t* bytes,
95 int32_t length) const {
96 Byte t0(bytes + 2);
97 int32_t x = t0.get_byte(0, 8);
98
99 Byte t1(bytes + 3);
100 int32_t t = t1.get_byte(0, 8);
101 x <<= 8;
102 x |= t;
103
104 double ret = x * 0.100000 + -3200.000000;
105 return ret;
106}
107
108// config detail: {'bit': 7, 'description': 'Battery Total Voltage',
109// 'is_signed_var': False, 'len': 16, 'name': 'battery_voltage', 'offset': 0.0,
110// 'order': 'motorola', 'physical_range': '[0|300]', 'physical_unit': 'V',
111// 'precision': 0.01, 'type': 'double'}
112double Bmsreport512::battery_voltage(const std::uint8_t* bytes,
113 int32_t length) const {
114 Byte t0(bytes + 0);
115 int32_t x = t0.get_byte(0, 8);
116
117 Byte t1(bytes + 1);
118 int32_t t = t1.get_byte(0, 8);
119 x <<= 8;
120 x |= t;
121
122 double ret = x * 0.010000;
123 return ret;
124}
125
126// config detail: {'bit': 39, 'description': 'Battery Soc percentage',
127// 'is_signed_var': False, 'len': 8, 'name': 'battery_soc', 'offset': 0.0,
128// 'order': 'motorola', 'physical_range': '[0|100]', 'physical_unit': '%',
129// 'precision': 1.0, 'type': 'int'}
130int Bmsreport512::battery_soc(const std::uint8_t* bytes, int32_t length) const {
131 Byte t0(bytes + 4);
132 int32_t x = t0.get_byte(0, 8);
133
134 int ret = x;
135 return ret;
136}
137} // namespace demo
138} // namespace canbus
139} // namespace apollo
Defines the Byte class.
void Parse(const std::uint8_t *bytes, int32_t length, Demo *chassis) const override
class register implement
Definition arena_queue.h:37