Apollo 10.0
自动驾驶开放平台
horn_cmd_11c.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 Horncmd11c::ID = 0x11C;
28
29// public
31
32uint32_t Horncmd11c::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 Horncmd11c::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_horn_cmd(data, horn_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 Horncmd11c::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 Horncmd11c::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 Horncmd11c::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 Horncmd11c::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
116 horn_cmd_ = horn_cmd;
117 return this;
118}
119
120// config detail: {'name': 'HORN_CMD', 'enum': {0: 'HORN_CMD_OFF', 1:
121// 'HORN_CMD_ON'}, 'precision': 1.0, 'len': 1, 'is_signed_var': False, 'offset':
122// 0.0, 'physical_range': '[0|1]', 'bit': 8, 'type': 'enum', 'order':
123// 'motorola', 'physical_unit': ''}
124void Horncmd11c::set_p_horn_cmd(uint8_t* data,
126 uint8_t x = horn_cmd;
127
128 Byte to_set(data + 1);
129 to_set.set_value(static_cast<uint8_t>(x), 0, 1);
130}
131
132} // namespace lexus
133} // namespace canbus
134} // namespace apollo
Defines the Byte class.
uint32_t GetPeriod() const override
void UpdateData(uint8_t *data) override
Horncmd11c * set_clear_override(bool clear_override)
Horncmd11c * set_clear_faults(bool clear_faults)
Horncmd11c * set_horn_cmd(Horn_cmd_11c::Horn_cmdType horn_cmd)
Horncmd11c * set_ignore_overrides(bool ignore_overrides)
Horncmd11c * set_enable(bool enable)
class register implement
Definition arena_queue.h:37