Apollo 10.0
自动驾驶开放平台
gear_66.cc
浏览该文件的文档.
1/******************************************************************************
2 * Copyright 2017 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 lincoln {
24
25using ::apollo::drivers::canbus::Byte;
26
27// public
28const int32_t Gear66::ID = 0x66;
29
30uint32_t Gear66::GetPeriod() const {
31 // on event, so value nonsense
32 static const uint32_t PERIOD = 10 * 1000;
33 return PERIOD;
34}
35
36void Gear66::UpdateData(uint8_t *data) {
37 set_gear_p(data, gear_);
38 set_clear_driver_override_flag_p(data);
39}
40
41void Gear66::Reset() { gear_ = 0; }
42
44 gear_ = 0x00;
45 return this;
46}
47
49 gear_ = 0x01;
50 return this;
51}
52
54 gear_ = 0x02;
55 return this;
56}
57
59 gear_ = 0x03;
60 return this;
61}
62
64 gear_ = 0x04;
65 return this;
66}
67
69 gear_ = 0x05;
70 return this;
71}
72
73// private
74void Gear66::set_gear_p(uint8_t *data, int32_t gear) {
75 gear = ProtocolData::BoundedValue(0, 5, gear);
76 Byte frame(data);
77 frame.set_value(static_cast<uint8_t>(gear), 0, 3);
78}
79
80void Gear66::set_clear_driver_override_flag_p(uint8_t *bytes) {
81 Byte frame(bytes);
82 frame.set_bit_0(7);
83}
84
85} // namespace lincoln
86} // namespace canbus
87} // namespace apollo
Defines the Byte class.
one of the protocol data of lincoln vehicle
Definition gear_66.h:41
Gear66 * set_gear_low()
set gear to low
Definition gear_66.cc:68
Gear66 * set_gear_reverse()
set gear to reverse
Definition gear_66.cc:53
virtual void Reset()
reset the private variables
Definition gear_66.cc:41
static const int32_t ID
Definition gear_66.h:43
Gear66 * set_gear_park()
set gear to park
Definition gear_66.cc:48
Gear66 * set_gear_drive()
set gear to drive
Definition gear_66.cc:63
virtual uint32_t GetPeriod() const
get the data period
Definition gear_66.cc:30
virtual void UpdateData(uint8_t *data)
update the data
Definition gear_66.cc:36
Gear66 * set_gear_none()
set gear to none
Definition gear_66.cc:43
Gear66 * set_gear_neutral()
set gear to neutral
Definition gear_66.cc:58
the class of Gear66 (for lincoln vehicle)
class register implement
Definition arena_queue.h:37