25using ::apollo::drivers::canbus::Byte;
34 static const uint32_t PERIOD = 20 * 1000;
39 set_p_turn_right_light_command(data, turn_right_light_command_);
40 set_p_turn_left_light_command(data, turn_left_light_command_);
41 set_p_horn_command(data, horn_command_);
42 set_p_beam_command(data, beam_command_);
43 ++auto_drivercmd_alivecounter_;
44 auto_drivercmd_alivecounter_ = (auto_drivercmd_alivecounter_) % 16;
45 set_p_auto_drivercmd_alivecounter(data, auto_drivercmd_alivecounter_);
46 auto_drivercmd_checksum_ =
47 data[0] ^ data[1] ^ data[2] ^ data[3] ^ data[4] ^ data[5] ^ data[6];
48 set_p_auto_drivercmd_checksum(data, auto_drivercmd_checksum_);
53 turn_right_light_command_ =
false;
54 turn_left_light_command_ =
false;
55 horn_command_ =
false;
57 auto_drivercmd_alivecounter_ = 0;
58 auto_drivercmd_checksum_ = 0;
62 bool turn_right_light_command) {
63 turn_right_light_command_ = turn_right_light_command;
71void Adslighthorncommand310::set_p_turn_right_light_command(
72 uint8_t* data,
bool turn_right_light_command) {
73 int x = turn_right_light_command;
75 Byte to_set(data + 1);
76 to_set.set_value(x, 0, 1);
80 bool turn_left_light_command) {
81 turn_left_light_command_ = turn_left_light_command;
89void Adslighthorncommand310::set_p_turn_left_light_command(
90 uint8_t* data,
bool turn_left_light_command) {
91 int x = turn_left_light_command;
93 Byte to_set(data + 1);
94 to_set.set_value(x, 1, 1);
99 horn_command_ = horn_command;
106void Adslighthorncommand310::set_p_horn_command(uint8_t* data,
108 int x = horn_command;
110 Byte to_set(data + 1);
111 to_set.set_value(x, 2, 1);
116 beam_command_ = beam_command;
124void Adslighthorncommand310::set_p_beam_command(uint8_t* data,
126 beam_command = ProtocolData::BoundedValue(0, 1, beam_command);
127 int x = beam_command;
129 Byte to_set(data + 1);
130 to_set.set_value(x, 4, 2);
134 int auto_drivercmd_alivecounter) {
135 auto_drivercmd_alivecounter_ = auto_drivercmd_alivecounter;
142void Adslighthorncommand310::set_p_auto_drivercmd_alivecounter(
143 uint8_t* data,
int auto_drivercmd_alivecounter) {
144 auto_drivercmd_alivecounter =
145 ProtocolData::BoundedValue(0, 15, auto_drivercmd_alivecounter);
146 int x = auto_drivercmd_alivecounter;
148 Byte to_set(data + 6);
149 to_set.set_value(x, 0, 4);
153 int auto_drivercmd_checksum) {
154 auto_drivercmd_checksum_ = auto_drivercmd_checksum;
161void Adslighthorncommand310::set_p_auto_drivercmd_checksum(
162 uint8_t* data,
int auto_drivercmd_checksum) {
163 auto_drivercmd_checksum =
164 ProtocolData::BoundedValue(0, 255, auto_drivercmd_checksum);
165 int x = auto_drivercmd_checksum;
167 Byte to_set(data + 7);
168 to_set.set_value(x, 0, 8);
Adslighthorncommand310 * set_turn_left_light_command(bool turn_left_light_command)
Adslighthorncommand310 * set_horn_command(bool horn_command)
Adslighthorncommand310 * set_auto_drivercmd_checksum(int auto_drivercmd_checksum)
void UpdateData(uint8_t *data) override
Adslighthorncommand310 * set_turn_right_light_command(bool turn_right_light_command)
uint32_t GetPeriod() const override
Adslighthorncommand310 * set_beam_command(int beam_command)
Adslighthorncommand310 * set_auto_drivercmd_alivecounter(int auto_drivercmd_alivecounter)