Apollo 10.0
自动驾驶开放平台
headlight_cmd_118.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 Headlightcmd118::ID = 0x118;
28
29// public
31
33 // TODO(QiL) modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Headlightcmd118::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_headlight_cmd(data, headlight_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 Headlightcmd118::set_p_ignore_overrides(uint8_t* data,
64 bool ignore_overrides) {
65 uint8_t x = ignore_overrides;
66
67 Byte to_set(data + 0);
68 to_set.set_value(static_cast<uint8_t>(x), 1, 1);
69}
70
72 enable_ = enable;
73 return this;
74}
75
76// config detail: {'name': 'ENABLE', 'offset': 0.0, 'precision': 1.0, 'len': 1,
77// 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 0, 'type': 'bool',
78// 'order': 'motorola', 'physical_unit': ''}
79void Headlightcmd118::set_p_enable(uint8_t* data, bool enable) {
80 uint8_t x = enable;
81
82 Byte to_set(data + 0);
83 to_set.set_value(static_cast<uint8_t>(x), 0, 1);
84}
85
87 clear_override_ = clear_override;
88 return this;
89}
90
91// config detail: {'name': 'CLEAR_OVERRIDE', 'offset': 0.0, 'precision': 1.0,
92// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 2,
93// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
94void Headlightcmd118::set_p_clear_override(uint8_t* data, bool clear_override) {
95 uint8_t x = clear_override;
96
97 Byte to_set(data + 0);
98 to_set.set_value(static_cast<uint8_t>(x), 2, 1);
99}
100
102 clear_faults_ = clear_faults;
103 return this;
104}
105
106// config detail: {'name': 'CLEAR_FAULTS', 'offset': 0.0, 'precision': 1.0,
107// 'len': 1, 'is_signed_var': False, 'physical_range': '[0|1]', 'bit': 3,
108// 'type': 'bool', 'order': 'motorola', 'physical_unit': ''}
109void Headlightcmd118::set_p_clear_faults(uint8_t* data, bool clear_faults) {
110 uint8_t x = clear_faults;
111
112 Byte to_set(data + 0);
113 to_set.set_value(static_cast<uint8_t>(x), 3, 1);
114}
115
118 headlight_cmd_ = headlight_cmd;
119 return this;
120}
121
122// config detail: {'name': 'HEADLIGHT_CMD', 'enum': {0:
123// 'HEADLIGHT_CMD_HEADLIGHTS_OFF', 1: 'HEADLIGHT_CMD_LOW_BEAMS', 2:
124// 'HEADLIGHT_CMD_HIGH_BEAMS'}, 'precision': 1.0, 'len': 8, 'is_signed_var':
125// False, 'offset': 0.0, 'physical_range': '[0|2]', 'bit': 15, 'type': 'enum',
126// 'order': 'motorola', 'physical_unit': ''}
127void Headlightcmd118::set_p_headlight_cmd(
128 uint8_t* data, Headlight_cmd_118::Headlight_cmdType headlight_cmd) {
129 uint8_t x = headlight_cmd;
130
131 Byte to_set(data + 1);
132 to_set.set_value(static_cast<uint8_t>(x), 0, 8);
133}
134
135} // namespace lexus
136} // namespace canbus
137} // namespace apollo
Defines the Byte class.
void UpdateData(uint8_t *data) override
Headlightcmd118 * set_clear_override(bool clear_override)
Headlightcmd118 * set_enable(bool enable)
Headlightcmd118 * set_headlight_cmd(Headlight_cmd_118::Headlight_cmdType headlight_cmd)
Headlightcmd118 * set_ignore_overrides(bool ignore_overrides)
Headlightcmd118 * set_clear_faults(bool clear_faults)
class register implement
Definition arena_queue.h:37