Apollo 10.0
自动驾驶开放平台
gear_control_a1.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2019 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 zhongyun {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Gearcontrola1::ID = 0xA1;
28
29// public
31
32uint32_t Gearcontrola1::GetPeriod() const {
33 // TODO(ChaoM) : modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Gearcontrola1::UpdateData(uint8_t* data) {
39 set_p_gear_state_target(data, gear_state_target_);
40 set_p_gear_enable_control(data, gear_enable_control_);
41}
42
44 // TODO(ChaoM) : you should check this manually
45 gear_state_target_ = Gear_control_a1::GEAR_STATE_TARGET_P;
46 gear_enable_control_ =
48}
49
52 gear_state_target_ = gear_state_target;
53 return this;
54}
55
56// config detail: {'name': 'Gear_state_target', 'enum': {1:
57// 'GEAR_STATE_TARGET_P', 2: 'GEAR_STATE_TARGET_N', 3: 'GEAR_STATE_TARGET_D', 4:
58// 'GEAR_STATE_TARGET_R', 5: 'GEAR_STATE_TARGET_INVALID'}, 'precision': 1.0,
59// 'len': 8, 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[1|5]',
60// 'bit': 8, 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
61void Gearcontrola1::set_p_gear_state_target(
62 uint8_t* data, Gear_control_a1::Gear_state_targetType gear_state_target) {
63 int x = gear_state_target;
64
65 Byte to_set(data + 1);
66 to_set.set_value(static_cast<uint8_t>(x), 0, 8);
67}
68
70 Gear_control_a1::Gear_enable_controlType gear_enable_control) {
71 gear_enable_control_ = gear_enable_control;
72 return this;
73}
74
75// config detail: {'name': 'Gear_Enable_control', 'enum': {0:
76// 'GEAR_ENABLE_CONTROL_GEAR_MANUALCONTROL', 1:
77// 'GEAR_ENABLE_CONTROL_GEAR_AUTOCONTROL'}, 'precision': 1.0, 'len': 8,
78// 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 0,
79// 'type': 'enum', 'order': 'intel', 'physical_unit': ''}
80void Gearcontrola1::set_p_gear_enable_control(
81 uint8_t* data,
82 Gear_control_a1::Gear_enable_controlType gear_enable_control) {
83 int x = gear_enable_control;
84
85 Byte to_set(data + 0);
86 to_set.set_value(static_cast<uint8_t>(x), 0, 8);
87}
88
89} // namespace zhongyun
90} // namespace canbus
91} // namespace apollo
Defines the Byte class.
Gearcontrola1 * set_gear_enable_control(Gear_control_a1::Gear_enable_controlType gear_enable_control)
void UpdateData(uint8_t *data) override
Gearcontrola1 * set_gear_state_target(Gear_control_a1::Gear_state_targetType gear_state_target)
class register implement
Definition arena_queue.h:37