Apollo 10.0
自动驾驶开放平台
ads3_38e.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
18
20
21namespace apollo {
22namespace canbus {
23namespace wey {
24
25using ::apollo::drivers::canbus::Byte;
26
27const int32_t Ads338e::ID = 0x38E;
28
29// public
31
32uint32_t Ads338e::GetPeriod() const {
33 // TODO(ChaoMa) :modify every protocol's period manually
34 static const uint32_t PERIOD = 20 * 1000;
35 return PERIOD;
36}
37
38void Ads338e::UpdateData(uint8_t* data) {
39 set_p_ads_bcm_worksts(data, ads_bcm_worksts_);
40 set_p_ads_bcmworkstsvalid(data, ads_bcmworkstsvalid_);
41 set_p_ads_reqcontrolbcm(data, ads_reqcontrolbcm_);
42 set_p_highbeamton(data, highbeamton_);
43 set_p_dippedbeamon(data, dippedbeamon_);
44 set_p_turnllighton(data, turnllighton_);
45 set_p_emergencylighton(data, emergencylighton_);
46 set_p_ffoglampon(data, ffoglampon_);
47 set_p_rfoglampon(data, rfoglampon_);
48 set_p_brakelight(data, brakelight_);
49 set_p_hornon(data, hornon_);
50 set_p_fwindshieldwiper(data, fwindshieldwiper_);
51 set_p_rwindshieldwiper(data, rwindshieldwiper_);
52}
53
55 // TODO(ChaoMa) you should check this manually
56 ads_bcm_worksts_ = Ads3_38e::ADS_BCM_WORKSTS_DISABLE;
57 ads_bcmworkstsvalid_ = Ads3_38e::ADS_BCMWORKSTSVALID_INVALID;
58 ads_reqcontrolbcm_ = Ads3_38e::ADS_REQCONTROLBCM_NO_REQUEST;
59 highbeamton_ = Ads3_38e::HIGHBEAMTON_TURN_OFF;
60 dippedbeamon_ = Ads3_38e::DIPPEDBEAMON_TURN_OFF;
61 turnllighton_ = Ads3_38e::TURNLLIGHTON_TURN_OFF;
62 emergencylighton_ = Ads3_38e::EMERGENCYLIGHTON_TURN_OFF;
67 fwindshieldwiper_ = Ads3_38e::FWINDSHIELDWIPER_TURN_OFF;
68 rwindshieldwiper_ = Ads3_38e::RWINDSHIELDWIPER_TURN_OFF;
69}
70
72 Ads3_38e::Ads_bcm_workstsType ads_bcm_worksts) {
73 ads_bcm_worksts_ = ads_bcm_worksts;
74 return this;
75}
76
77// config detail: {'description': 'The work status of ADS control unit.
78// This signal should be contained in every message sent by ADS.', 'enum':
79// {0: 'ADS_BCM_WORKSTS_DISABLE', 1: 'ADS_BCM_WORKSTS_ENABLE',
80// 2: 'ADS_BCM_WORKSTS_ACTIVE', 3: 'ADS_BCM_WORKSTS_FAILED'}, 'precision': 1.0,
81// 'len': 2, 'name': 'ADS_BCM_WorkSts', 'is_signed_var': False, 'offset': 0.0,
82// 'physical_range': '[0|3]', 'bit': 6, 'type': 'enum', 'order': 'motorola',
83// 'physical_unit': ''}
84void Ads338e::set_p_ads_bcm_worksts(
85 uint8_t* data, Ads3_38e::Ads_bcm_workstsType ads_bcm_worksts) {
86 int x = ads_bcm_worksts;
87
88 Byte to_set(data + 0);
89 to_set.set_value(static_cast<uint8_t>(x), 5, 2);
90}
91
93 Ads3_38e::Ads_bcmworkstsvalidType ads_bcmworkstsvalid) {
94 ads_bcmworkstsvalid_ = ads_bcmworkstsvalid;
95 return this;
96}
97
98// config detail: {'description': 'This Signal reflect the ADS_WorkSts Signal
99// is Valid OR not', 'enum': {0: 'ADS_BCMWORKSTSVALID_INVALID',
100// 1: 'ADS_BCMWORKSTSVALID_VALID'}, 'precision': 1.0, 'len': 1, 'name':
101// 'ADS_BCMWorkStsValid','is_signed_var': False, 'offset': 0.0,'physical_range':
102// '[0|1]', 'bit': 7, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
103void Ads338e::set_p_ads_bcmworkstsvalid(
104 uint8_t* data, Ads3_38e::Ads_bcmworkstsvalidType ads_bcmworkstsvalid) {
105 int x = ads_bcmworkstsvalid;
106
107 Byte to_set(data + 0);
108 to_set.set_value(static_cast<uint8_t>(x), 7, 1);
109}
110
112 Ads3_38e::Ads_reqcontrolbcmType ads_reqcontrolbcm) {
113 ads_reqcontrolbcm_ = ads_reqcontrolbcm;
114 return this;
115}
116
117// config detail: {'description': 'Vehicle Task request.If ADS request control
118// BCM', 'enum': {0: 'ADS_REQCONTROLBCM_NO_REQUEST', 1:
119// 'ADS_REQCONTROLBCM_REQUEST'}, 'precision': 1.0, 'len': 1, 'name':
120// 'ADS_ReqControlBCM', 'is_signed_var':False, 'offset': 0.0, 'physical_range':
121// '[0|1]', 'bit': 8, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
122void Ads338e::set_p_ads_reqcontrolbcm(
123 uint8_t* data, Ads3_38e::Ads_reqcontrolbcmType ads_reqcontrolbcm) {
124 int x = ads_reqcontrolbcm;
125
126 Byte to_set(data + 1);
127 to_set.set_value(static_cast<uint8_t>(x), 0, 1);
128}
129
131 highbeamton_ = highbeamton;
132 return this;
133}
134
135// config detail: {'description': 'Open theHigh Beam light', 'enum': {0:
136// 'HIGHBEAMTON_TURN_OFF', 1: 'HIGHBEAMTON_TURN_ON'}, 'precision': 1.0,
137// 'len': 1, 'name': 'HighBeamtON', 'is_signed_var': False, 'offset': 0.0,
138// 'physical_range': '[0|1]', 'bit': 11, 'type': 'enum', 'order': 'motorola',
139// 'physical_unit': ''}
140void Ads338e::set_p_highbeamton(uint8_t* data,
141 Ads3_38e::HighbeamtonType highbeamton) {
142 int x = highbeamton;
143
144 Byte to_set(data + 1);
145 to_set.set_value(static_cast<uint8_t>(x), 3, 1);
146}
147
149 dippedbeamon_ = dippedbeamon;
150 return this;
151}
152
153// config detail: {'description': 'Open the dipped Beam light', 'enum': {0:
154// 'DIPPEDBEAMON_TURN_OFF', 1: 'DIPPEDBEAMON_TURN_ON'}, 'precision': 1.0,
155// 'len': 1, 'name': 'DippedBeamON', 'is_signed_var': False, 'offset': 0.0,
156// 'physical_range': '[0|1]', 'bit': 12, 'type': 'enum', 'order': 'motorola',
157// 'physical_unit': ''}
158void Ads338e::set_p_dippedbeamon(uint8_t* data,
159 Ads3_38e::DippedbeamonType dippedbeamon) {
160 int x = dippedbeamon;
161
162 Byte to_set(data + 1);
163 to_set.set_value(static_cast<uint8_t>(x), 4, 1);
164}
165
167 turnllighton_ = turnllighton;
168 return this;
169}
170
171// config detail: {'description': 'Open the Turn light', 'enum': {0:
172// 'TURNLLIGHTON_TURN_OFF', 1: 'TURNLLIGHTON_TURN_LEFT_ON', 2:
173// 'TURNLLIGHTON_TURN_RIGHT_ON', 3: 'TURNLLIGHTON_RESERVED'}, 'precision': 1.0,
174// 'len': 2, 'name': 'TurnlLightON', 'is_signed_var': False, 'offset': 0.0,
175// 'physical_range': '[0|3]', 'bit': 17, 'type': 'enum', 'order': 'motorola',
176// 'physical_unit': ''}
177void Ads338e::set_p_turnllighton(uint8_t* data,
178 Ads3_38e::TurnllightonType turnllighton) {
179 int x = turnllighton;
180
181 Byte to_set(data + 2);
182 to_set.set_value(static_cast<uint8_t>(x), 0, 2);
183}
184
186 Ads3_38e::EmergencylightonType emergencylighton) {
187 emergencylighton_ = emergencylighton;
188 return this;
189}
190
191// config detail: {'description': 'Open the emergency light', 'enum': {0:
192// 'EMERGENCYLIGHTON_TURN_OFF', 1: 'EMERGENCYLIGHTON_TURN_ON'},'precision':1.0,
193// 'len': 1, 'name': 'EmergencyLightON', 'is_signed_var': False, 'offset': 0.0,
194// 'physical_range': '[0|1]', 'bit': 45, 'type': 'enum', 'order': 'motorola',
195// 'physical_unit': ''}
196void Ads338e::set_p_emergencylighton(
197 uint8_t* data, Ads3_38e::EmergencylightonType emergencylighton) {
198 int x = emergencylighton;
199
200 Byte to_set(data + 5);
201 to_set.set_value(static_cast<uint8_t>(x), 5, 1);
202}
203
205 ffoglampon_ = ffoglampon;
206 return this;
207}
208
209// config detail: {'description': 'Open the front fog light', 'enum': {0:
210// 'FFOGLAMPON_TURN_OFF', 1: 'FFOGLAMPON_TURN_ON'}, 'precision': 1.0, 'len': 1,
211// 'name': 'FFogLampON', 'is_signed_var': False, 'offset': 0.0,
212// 'physical_range': '[0|1]', 'bit': 46, 'type': 'enum', 'order': 'motorola',
213// 'physical_unit': ''}
214void Ads338e::set_p_ffoglampon(uint8_t* data,
215 Ads3_38e::FfoglamponType ffoglampon) {
216 int x = ffoglampon;
217
218 Byte to_set(data + 5);
219 to_set.set_value(static_cast<uint8_t>(x), 6, 1);
220}
221
223 rfoglampon_ = rfoglampon;
224 return this;
225}
226
227// config detail: {'description': 'Open the rear fog ligh', 'enum': {0:
228// 'RFOGLAMPON_TURN_OFF', 1: 'RFOGLAMPON_TURN_ON'}, 'precision': 1.0, 'len': 1,
229// 'name': 'RFogLampON', 'is_signed_var': False, 'offset': 0.0,
230// 'physical_range': '[0|1]', 'bit': 47, 'type': 'enum', 'order': 'motorola',
231// 'physical_unit': ''}
232void Ads338e::set_p_rfoglampon(uint8_t* data,
233 Ads3_38e::RfoglamponType rfoglampon) {
234 int x = rfoglampon;
235
236 Byte to_set(data + 5);
237 to_set.set_value(static_cast<uint8_t>(x), 7, 1);
238}
239
241 brakelight_ = brakelight;
242 return this;
243}
244
245// config detail: {'description': 'Open the brake light', 'enum': {0:
246// 'BRAKELIGHT_TURN_OFF', 1: 'BRAKELIGHT_TURN_ON'}, 'precision': 1.0, 'len': 1,
247// 'name': 'BrakeLight', 'is_signed_var': False, 'offset': 0.0,
248// 'physical_range': '[0|1]', 'bit': 48, 'type': 'enum', 'order': 'motorola',
249// 'physical_unit': ''}
250void Ads338e::set_p_brakelight(uint8_t* data,
251 Ads3_38e::BrakelightType brakelight) {
252 int x = brakelight;
253
254 Byte to_set(data + 6);
255 to_set.set_value(static_cast<uint8_t>(x), 0, 1);
256}
257
259 hornon_ = hornon;
260 return this;
261}
262
263// config detail: {'description': 'Open the horn voice', 'enum': {0:
264// 'HORNON_TURN_OFF', 1: 'HORNON_TURN_ON'}, 'precision': 1.0, 'len': 1, 'name':
265// 'HornON', 'is_signed_var': False, 'offset': 0.0, 'physical_range': '[0|1]',
266// 'bit': 49, 'type': 'enum', 'order': 'motorola', 'physical_unit': ''}
267void Ads338e::set_p_hornon(uint8_t* data, Ads3_38e::HornonType hornon) {
268 int x = hornon;
269
270 Byte to_set(data + 6);
271 to_set.set_value(static_cast<uint8_t>(x), 1, 1);
272}
273
275 Ads3_38e::FwindshieldwiperType fwindshieldwiper) {
276 fwindshieldwiper_ = fwindshieldwiper;
277 return this;
278}
279
280// config detail: {'description': 'Open front window shield wiper', 'enum': {0:
281// 'FWINDSHIELDWIPER_TURN_OFF', 1: 'FWINDSHIELDWIPER_TURN_ON'},'precision':1.0,
282// 'len': 1, 'name': 'Fwindshieldwiper', 'is_signed_var': False, 'offset': 0.0,
283// 'physical_range': '[0|1]', 'bit': 50, 'type': 'enum', 'order': 'motorola',
284// 'physical_unit': ''}
285void Ads338e::set_p_fwindshieldwiper(
286 uint8_t* data, Ads3_38e::FwindshieldwiperType fwindshieldwiper) {
287 int x = fwindshieldwiper;
288
289 Byte to_set(data + 6);
290 to_set.set_value(static_cast<uint8_t>(x), 2, 1);
291}
292
294 Ads3_38e::RwindshieldwiperType rwindshieldwiper) {
295 rwindshieldwiper_ = rwindshieldwiper;
296 return this;
297}
298
299// config detail: {'description': 'Open rear window shield wiper', 'enum': {0:
300// 'RWINDSHIELDWIPER_TURN_OFF', 1: 'RWINDSHIELDWIPER_TURN_ON'},'precision':1.0,
301// 'len': 1, 'name': 'Rwindshieldwiper', 'is_signed_var': False, 'offset': 0.0,
302// 'physical_range': '[0|1]', 'bit': 60, 'type': 'enum', 'order': 'motorola',
303// 'physical_unit': ''}
304void Ads338e::set_p_rwindshieldwiper(
305 uint8_t* data, Ads3_38e::RwindshieldwiperType rwindshieldwiper) {
306 int x = rwindshieldwiper;
307
308 Byte to_set(data + 7);
309 to_set.set_value(static_cast<uint8_t>(x), 4, 1);
310}
311
312} // namespace wey
313} // namespace canbus
314} // namespace apollo
Defines the Byte class.
Ads338e * set_hornon(Ads3_38e::HornonType hornon)
Definition ads3_38e.cc:258
Ads338e * set_ads_reqcontrolbcm(Ads3_38e::Ads_reqcontrolbcmType ads_reqcontrolbcm)
Definition ads3_38e.cc:111
Ads338e * set_ffoglampon(Ads3_38e::FfoglamponType ffoglampon)
Definition ads3_38e.cc:204
Ads338e * set_ads_bcm_worksts(Ads3_38e::Ads_bcm_workstsType ads_bcm_worksts)
Definition ads3_38e.cc:71
Ads338e * set_highbeamton(Ads3_38e::HighbeamtonType highbeamton)
Definition ads3_38e.cc:130
static const int32_t ID
Definition ads3_38e.h:29
Ads338e * set_fwindshieldwiper(Ads3_38e::FwindshieldwiperType fwindshieldwiper)
Definition ads3_38e.cc:274
Ads338e * set_turnllighton(Ads3_38e::TurnllightonType turnllighton)
Definition ads3_38e.cc:166
void UpdateData(uint8_t *data) override
Definition ads3_38e.cc:38
Ads338e * set_emergencylighton(Ads3_38e::EmergencylightonType emergencylighton)
Definition ads3_38e.cc:185
Ads338e * set_brakelight(Ads3_38e::BrakelightType brakelight)
Definition ads3_38e.cc:240
Ads338e * set_rfoglampon(Ads3_38e::RfoglamponType rfoglampon)
Definition ads3_38e.cc:222
Ads338e * set_rwindshieldwiper(Ads3_38e::RwindshieldwiperType rwindshieldwiper)
Definition ads3_38e.cc:293
Ads338e * set_ads_bcmworkstsvalid(Ads3_38e::Ads_bcmworkstsvalidType ads_bcmworkstsvalid)
Definition ads3_38e.cc:92
Ads338e * set_dippedbeamon(Ads3_38e::DippedbeamonType dippedbeamon)
Definition ads3_38e.cc:148
uint32_t GetPeriod() const override
Definition ads3_38e.cc:32
class register implement
Definition arena_queue.h:37