Apollo
10.0
自动驾驶开放平台
horn_cmd_78.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
17
#include "
modules/canbus_vehicle/gem/protocol/horn_cmd_78.h
"
18
19
#include "
modules/drivers/canbus/common/byte.h
"
20
21
namespace
apollo
{
22
namespace
canbus {
23
namespace
gem {
24
25
using ::apollo::drivers::canbus::Byte;
26
27
const
int32_t
Horncmd78::ID
= 0x78;
28
29
// public
30
Horncmd78::Horncmd78
() {
Reset
(); }
31
32
uint32_t
Horncmd78::GetPeriod
()
const
{
33
// TODO(QiL) :modify every protocol's period manually
34
static
const
uint32_t PERIOD = 20 * 1000;
35
return
PERIOD;
36
}
37
38
void
Horncmd78::UpdateData
(uint8_t* data) { set_p_horn_cmd(data, horn_cmd_); }
39
40
void
Horncmd78::Reset
() {
41
// TODO(QiL) :you should check this manually
42
horn_cmd_ =
Horn_cmd_78::HORN_CMD_OFF
;
43
}
44
45
Horncmd78
*
Horncmd78::set_horn_cmd
(
Horn_cmd_78::Horn_cmdType
horn_cmd) {
46
horn_cmd_ = horn_cmd;
47
return
this
;
48
}
49
50
// config detail: {'name': 'HORN_CMD', 'enum': {0: 'HORN_CMD_OFF', 1:
51
// 'HORN_CMD_ON'}, 'precision': 1.0, 'len': 8, 'is_signed_var': False, 'offset':
52
// 0.0, 'physical_range': '[0|1]', 'bit': 7, 'type': 'enum', 'order':
53
// 'motorola', 'physical_unit': ''}
54
void
Horncmd78::set_p_horn_cmd(uint8_t* data,
55
Horn_cmd_78::Horn_cmdType
horn_cmd) {
56
uint8_t x = horn_cmd;
57
58
Byte to_set(data + 0);
59
to_set.set_value(
static_cast<
uint8_t
>
(x), 0, 8);
60
}
61
62
}
// namespace gem
63
}
// namespace canbus
64
}
// namespace apollo
byte.h
Defines the Byte class.
apollo::canbus::gem::Horncmd78
Definition
horn_cmd_78.h:27
apollo::canbus::gem::Horncmd78::UpdateData
void UpdateData(uint8_t *data) override
Definition
horn_cmd_78.cc:38
apollo::canbus::gem::Horncmd78::set_horn_cmd
Horncmd78 * set_horn_cmd(Horn_cmd_78::Horn_cmdType horn_cmd)
Definition
horn_cmd_78.cc:45
apollo::canbus::gem::Horncmd78::ID
static const int32_t ID
Definition
horn_cmd_78.h:29
apollo::canbus::gem::Horncmd78::GetPeriod
uint32_t GetPeriod() const override
Definition
horn_cmd_78.cc:32
apollo::canbus::gem::Horncmd78::Horncmd78
Horncmd78()
Definition
horn_cmd_78.cc:30
apollo::canbus::gem::Horncmd78::Reset
void Reset() override
Definition
horn_cmd_78.cc:40
horn_cmd_78.h
apollo
class register implement
Definition
arena_queue.h:37
apollo::canbus::Horn_cmd_78::Horn_cmdType
Horn_cmdType
Definition
gem.proto:328
apollo::canbus::Horn_cmd_78::HORN_CMD_OFF
@ HORN_CMD_OFF
Definition
gem.proto:329
modules
canbus_vehicle
gem
protocol
horn_cmd_78.cc