Apollo 10.0
自动驾驶开放平台
pc_epb_203.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
19
20namespace apollo {
21namespace canbus {
22namespace ge3 {
23
24using ::apollo::drivers::canbus::Byte;
25
26const int32_t Pcepb203::ID = 0x203;
27
28// public
30
31uint32_t Pcepb203::GetPeriod() const {
32 // modify every protocol's period manually
33 static const uint32_t PERIOD = 20 * 1000;
34 return PERIOD;
35}
36
37void Pcepb203::UpdateData(uint8_t* data) {
38 set_p_pc_epbreq(data, pc_epbreq_);
39 set_p_pc_epbenable(data, pc_epbenable_);
40}
41
43 // you should check this manually
46}
47
49 pc_epbreq_ = pc_epbreq;
50 return this;
51}
52
53// config detail: {'description': 'EPB request', 'enum': {0:
54// 'PC_EPBREQ_INVALID', 1: 'PC_EPBREQ_RELEASE', 2: 'PC_EPBREQ_APPLY'},
55// 'precision': 1.0, 'len': 2, 'name': 'PC_EpbReq', 'is_signed_var': False,
56// 'offset': 0.0, 'physical_range': '[0|1]', 'bit': 1, 'type': 'enum', 'order':
57// 'motorola', 'physical_unit': ''}
58void Pcepb203::set_p_pc_epbreq(uint8_t* data,
59 Pc_epb_203::Pc_epbreqType pc_epbreq) {
60 int x = pc_epbreq;
61
62 Byte to_set(data + 0);
63 to_set.set_value(static_cast<uint8_t>(x), 0, 2);
64}
65
67 Pc_epb_203::Pc_epbenableType pc_epbenable) {
68 pc_epbenable_ = pc_epbenable;
69 return this;
70}
71
72// config detail: {'description': 'EPB control enable', 'enum': {0:
73// 'PC_EPBENABLE_DISABLE', 1: 'PC_EPBENABLE_ENABLE'}, 'precision': 1.0, 'len':
74// 1, 'name': 'PC_EpbEnable', 'is_signed_var': False, 'offset': 0.0,
75// 'physical_range': '[0|1]', 'bit': 7, 'type': 'enum', 'order': 'motorola',
76// 'physical_unit': ''}
77void Pcepb203::set_p_pc_epbenable(uint8_t* data,
78 Pc_epb_203::Pc_epbenableType pc_epbenable) {
79 int x = pc_epbenable;
80
81 Byte to_set(data + 0);
82 to_set.set_value(static_cast<uint8_t>(x), 7, 1);
83}
84
85} // namespace ge3
86} // namespace canbus
87} // namespace apollo
Defines the Byte class.
void UpdateData(uint8_t *data) override
Definition pc_epb_203.cc:37
Pcepb203 * set_pc_epbenable(Pc_epb_203::Pc_epbenableType pc_epbenable)
Definition pc_epb_203.cc:66
uint32_t GetPeriod() const override
Definition pc_epb_203.cc:31
static const int32_t ID
Definition pc_epb_203.h:29
Pcepb203 * set_pc_epbreq(Pc_epb_203::Pc_epbreqType pc_epbreq)
Definition pc_epb_203.cc:48
class register implement
Definition arena_queue.h:37