Apollo 10.0
自动驾驶开放平台
shift_cmd_128.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2018 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 lexus {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Shiftcmd128::ID = 0x128;
28
29// public
31
32uint32_t Shiftcmd128::GetPeriod() const {
33 // TODO(QiL) modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Shiftcmd128::UpdateData(uint8_t* data) {
39 set_p_ignore_overrides(data, ignore_overrides_);
40 set_p_enable(data, enable_);
41 set_p_clear_override(data, clear_override_);
42 set_p_clear_faults(data, clear_faults_);
43 set_p_shift_cmd(data, shift_cmd_);
44}
45
47 // TODO(QiL) you should check this manually
48 ignore_overrides_ = false;
49 enable_ = false;
50 clear_override_ = false;
51 clear_faults_ = false;
53}
54
56 ignore_overrides_ = ignore_overrides;
57 return this;
58}
59
60// config detail: {'name': 'IGNORE_OVERRIDES', 'offset': 0.0, 'precision': 1.0,
61// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 1,
62// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
63void Shiftcmd128::set_p_ignore_overrides(uint8_t* data, bool ignore_overrides) {
64 uint8_t x = ignore_overrides;
65
66 Byte to_set(data + 0);
67 to_set.set_value(static_cast<uint8_t>(x), 1, 1);
68}
69
71 enable_ = enable;
72 return this;
73}
74
75// config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': 1,
76// 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool',
77// 'order': 'motorola', 'physical_unit': ''}
78void Shiftcmd128::set_p_enable(uint8_t* data, bool enable) {
79 uint8_t x = enable;
80
81 Byte to_set(data + 0);
82 to_set.set_value(static_cast<uint8_t>(x), 0, 1);
83}
84
86 clear_override_ = clear_override;
87 return this;
88}
89
90// config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0,
91// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2,
92// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
93void Shiftcmd128::set_p_clear_override(uint8_t* data, bool clear_override) {
94 uint8_t x = clear_override;
95
96 Byte to_set(data + 0);
97 to_set.set_value(static_cast<uint8_t>(x), 2, 1);
98}
99
101 clear_faults_ = clear_faults;
102 return this;
103}
104
105// config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0,
106// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3,
107// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
108void Shiftcmd128::set_p_clear_faults(uint8_t* data, bool clear_faults) {
109 uint8_t x = clear_faults;
110
111 Byte to_set(data + 0);
112 to_set.set_value(static_cast<uint8_t>(x), 3, 1);
113}
114
117 shift_cmd_ = shift_cmd;
118 return this;
119}
120
121// config detail: {'description': 'FORWARD is also HIGH on vehicles with
122// LOW/HIGH, PARK and LOW only available on certain Vehicles.', 'enum': {0:
123// 'SHIFT_CMD_PARK', 1: 'SHIFT_CMD_REVERSE', 2: 'SHIFT_CMD_NEUTRAL', 3:
124// 'SHIFT_CMD_FORWARD_HIGH', 4: 'SHIFT_CMD_LOW', 7: 'SHIFT_CMD_NONE'},
125// 'precision': 1.0, 'len': 8, 'name': 'SHIFT_CMD', 'is_signed_var': False,
126// 'offset': 0.0, 'physical_range': '[0|4]', 'bit': 15, 'type': 'enum', 'order':
127// 'motorola', 'physical_unit': ''}
128void Shiftcmd128::set_p_shift_cmd(uint8_t* data,
130 uint8_t x = shift_cmd;
131
132 Byte to_set(data + 1);
133 to_set.set_value(static_cast<uint8_t>(x), 0, 8);
134}
135
136} // namespace lexus
137} // namespace canbus
138} // namespace apollo
Defines the Byte class.
Shiftcmd128 * set_enable(bool enable)
Shiftcmd128 * set_clear_faults(bool clear_faults)
uint32_t GetPeriod() const override
Shiftcmd128 * set_clear_override(bool clear_override)
Shiftcmd128 * set_shift_cmd(Shift_cmd_128::Shift_cmdType shift_cmd)
void UpdateData(uint8_t *data) override
Shiftcmd128 * set_ignore_overrides(bool ignore_overrides)
class register implement
Definition arena_queue.h:37