Apollo 10.0
自动驾驶开放平台
park_command_104.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
20
21namespace apollo {
22namespace canbus {
23namespace devkit {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Parkcommand104::ID = 0x104;
28
29// public
31
32uint32_t Parkcommand104::GetPeriod() const {
33 // TODO(All) : modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Parkcommand104::Parse(const std::uint8_t* bytes, int32_t length,
39 Devkit* chassis) const {
40 chassis->mutable_park_command_104()->set_park_target(
41 park_target(bytes, length));
42 chassis->mutable_park_command_104()->set_park_en_ctrl(
43 park_en_ctrl(bytes, length));
44 chassis->mutable_park_command_104()->set_checksum_104(
45 checksum_104(bytes, length));
46}
47
48void Parkcommand104::UpdateData(uint8_t* data) {
49 set_p_park_target(data, park_target_);
50 set_p_park_en_ctrl(data, park_en_ctrl_);
51 checksum_104_ =
52 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
53 set_p_checksum_104(data, checksum_104_);
54}
55
57 // TODO(All) : you should check this manually
58 checksum_104_ = 0;
61}
62
64 checksum_104_ = checksum_104;
65 return this;
66}
67
68// config detail: {'name': 'CheckSum_104', 'offset': 0.0, 'precision': 1.0,
69// 'len': 8, 'is_signed_var': False, 'physical_range': '[0|255]', 'bit': 63,
70// 'type': 'int', 'order': 'motorola', 'physical_unit': ''}
71void Parkcommand104::set_p_checksum_104(uint8_t* data, int checksum_104) {
72 checksum_104 = ProtocolData::BoundedValue(0, 255, checksum_104);
73 int x = checksum_104;
74
75 Byte to_set(data + 7);
76 to_set.set_value(x, 0, 8);
77}
78
81 park_target_ = park_target;
82 return this;
83}
84
85// config detail: {'name': 'Park_Target', 'enum': {0: 'PARK_TARGET_RELEASE', 1:
86// 'PARK_TARGET_PARKING_TRIGGER'}, 'precision': 1.0, 'len': 1, 'is_signed_var':
87// False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 8, 'type': 'enum',
88// 'order': 'motorola', 'physical_unit': ''}
89void Parkcommand104::set_p_park_target(
90 uint8_t* data, Park_command_104::Park_targetType park_target) {
91 int x = park_target;
92
93 Byte to_set(data + 1);
94 to_set.set_value(x, 0, 1);
95}
96
99 park_en_ctrl_ = park_en_ctrl;
100 return this;
101}
102
103// config detail: {'name': 'Park_EN_CTRL', 'enum': {0: 'PARK_EN_CTRL_DISABLE',
104// 1: 'PARK_EN_CTRL_ENABLE'}, 'precision': 1.0, 'len': 1, 'is_signed_var':
105// False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0, 'type': 'enum',
106// 'order': 'motorola', 'physical_unit': ''}
107void Parkcommand104::set_p_park_en_ctrl(
108 uint8_t* data, Park_command_104::Park_en_ctrlType park_en_ctrl) {
109 int x = park_en_ctrl;
110
111 Byte to_set(data + 0);
112 to_set.set_value(x, 0, 1);
113}
114
115Park_command_104::Park_targetType Parkcommand104::park_target(
116 const std::uint8_t* bytes, int32_t length) const {
117 Byte t0(bytes + 1);
118 int32_t x = t0.get_byte(0, 3);
119
121 static_cast<Park_command_104::Park_targetType>(x);
122 return ret;
123}
124
125Park_command_104::Park_en_ctrlType Parkcommand104::park_en_ctrl(
126 const std::uint8_t* bytes, int32_t length) const {
127 Byte t0(bytes + 0);
128 int32_t x = t0.get_byte(0, 1);
129
132 return ret;
133}
134
135int Parkcommand104::checksum_104(const std::uint8_t* bytes,
136 int32_t length) const {
137 Byte t0(bytes + 7);
138 int32_t x = t0.get_byte(0, 8);
139
140 int ret = x;
141 return ret;
142}
143
144} // namespace devkit
145} // namespace canbus
146} // namespace apollo
Defines the Byte class.
Parkcommand104 * set_park_en_ctrl(Park_command_104::Park_en_ctrlType park_en_ctrl)
void UpdateData(uint8_t *data) override
Parkcommand104 * set_checksum_104(int checksum_104)
void Parse(const std::uint8_t *bytes, int32_t length, Devkit *chassis) const override
Parkcommand104 * set_park_target(Park_command_104::Park_targetType park_target)
class register implement
Definition arena_queue.h:37