Apollo 10.0
自动驾驶开放平台
vcu_powerstatus_214.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 Vcupowerstatus214::ID = 0x214;
32
33void Vcupowerstatus214::Parse(const std::uint8_t* bytes, int32_t length,
34 Neolix_edu* chassis) const {
35 chassis->mutable_vcu_powerstatus_214()->set_vcu_powermode(
36 vcu_powermode(bytes, length));
37 chassis->mutable_vcu_powerstatus_214()->set_vcu_powermodevalid(
38 vcu_powermodevalid(bytes, length));
39 chassis->mutable_vcu_powerstatus_214()->set_replacebatterystateindication(
40 replacebatterystateindication(bytes, length));
41 chassis->mutable_vcu_powerstatus_214()->set_forbidden_aeb_signal(
42 forbidden_aeb_signal(bytes, length));
43 chassis->mutable_vcu_powerstatus_214()->set_bcu_chargedischargecurrent(
44 bcu_chargedischargecurrent(bytes, length));
45 chassis->mutable_vcu_powerstatus_214()->set_bcu_batt_internalvoltage(
46 bcu_batt_internalvoltage(bytes, length));
47 chassis->mutable_vcu_powerstatus_214()->set_vcu_driverinfo_alivecounter(
48 vcu_driverinfo_alivecounter(bytes, length));
49 chassis->mutable_vcu_powerstatus_214()->set_vcu_driverinfo_checksum(
50 vcu_driverinfo_checksum(bytes, length));
51}
52
53// config detail: {'description':
54// '0x0:OFF;0x1:IG_ON;0x2:Power_ON;0x3:Auto_ON;0x4:Reserved;0x5:Reserved;0x6:Reserved;0x7:Reserved',
55// 'offset': 0.0, 'precision': 1.0, 'len': 3, 'name': 'vcu_powermode',
56// 'is_signed_var': False, 'physical_range': '[0|7]', 'bit': 11, 'type': 'int',
57// 'order': 'motorola', 'physical_unit': 'bit'}
58int Vcupowerstatus214::vcu_powermode(const std::uint8_t* bytes,
59 int32_t length) const {
60 Byte t0(bytes + 1);
61 int32_t x = t0.get_byte(1, 3);
62
63 int ret = x;
64 return ret;
65}
66
67// config detail: {'description': '0x0:Not
68// Available;0x1:Invalid;0x2:Valid;0x3:Reserved', 'offset': 0.0,
69// 'precision': 1.0, 'len': 2, 'name': 'vcu_powermodevalid', 'is_signed_var':
70// False, 'physical_range': '[0|3]', 'bit': 13, 'type': 'int', 'order':
71// 'motorola', 'physical_unit': 'bit'}
72int Vcupowerstatus214::vcu_powermodevalid(const std::uint8_t* bytes,
73 int32_t length) const {
74 Byte t0(bytes + 1);
75 int32_t x = t0.get_byte(4, 2);
76
77 int ret = x;
78 return ret;
79}
80
81// config detail: {'description': '0x0:NotActivate;0x1:Activate', 'offset': 0.0,
82// 'precision': 1.0, 'len': 1, 'name': 'replacebatterystateindication',
83// 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 14, 'type': 'bool',
84// 'order': 'motorola', 'physical_unit': 'bit'}
85bool Vcupowerstatus214::replacebatterystateindication(const std::uint8_t* bytes,
86 int32_t length) const {
87 Byte t0(bytes + 1);
88 int32_t x = t0.get_byte(6, 1);
89
90 bool ret = x;
91 return ret;
92}
93
94bool Vcupowerstatus214::forbidden_aeb_signal(const std::uint8_t* bytes,
95 const int32_t length) const {
96 Byte t0(bytes + 1);
97 int32_t x = t0.get_byte(7, 1);
98
99 bool ret = x;
100 return ret;
101}
102
103float Vcupowerstatus214::bcu_chargedischargecurrent(
104 const std::uint8_t* bytes, const int32_t length) const {
105 Byte t0(bytes + 2);
106 Byte t1(bytes + 3);
107 int32_t x1 = t0.get_byte(0, 8);
108 int32_t x2 = t1.get_byte(0, 8);
109
110 int ret = (x1 << 8 | x2) * 0.02 - 400;
111 return ret;
112}
113
114float Vcupowerstatus214::bcu_batt_internalvoltage(const std::uint8_t* bytes,
115 const int32_t length) const {
116 Byte t0(bytes + 4);
117 Byte t1(bytes + 5);
118 int32_t x1 = t0.get_byte(0, 8);
119 int32_t x2 = t1.get_byte(0, 8);
120
121 int ret = (x1 << 8 | x2) * 0.01;
122 return ret;
123}
124
125// config detail: {'name': 'vcu_driverinfo_alivecounter', 'offset': 0.0,
126// 'precision': 1.0, 'len': 4, 'is_signed_var': False, 'physical_range':
127// '[0|15]', 'bit': 55, 'type': 'int', 'order': 'motorola', 'physical_unit':
128// 'bit'}
129int Vcupowerstatus214::vcu_driverinfo_alivecounter(const std::uint8_t* bytes,
130 int32_t length) const {
131 Byte t0(bytes + 6);
132 int32_t x = t0.get_byte(4, 4);
133
134 int ret = x;
135 return ret;
136}
137
138// config detail: {'name': 'vcu_driverinfo_checksum', 'offset': 0.0,
139// 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'physical_range':
140// '[0|255]', 'bit': 63, 'type': 'int', 'order': 'motorola', 'physical_unit':
141// 'bit'}
142int Vcupowerstatus214::vcu_driverinfo_checksum(const std::uint8_t* bytes,
143 int32_t length) const {
144 Byte t0(bytes + 7);
145 int32_t x = t0.get_byte(0, 8);
146
147 int ret = x;
148 return ret;
149}
150} // namespace neolix_edu
151} // namespace canbus
152} // 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