12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- #pragma once
- #include "../common/comm.h"
- #include "../common/notifier.h"
- #include "../common/iobuffer.h"
- #include "../common/sensor_socket.h"
- using namespace std;
- class CMessageQueue;
- class CCanBusSensor
- {
- public:
- CCanBusSensor(CMessageQueue *q);
- void Notify(struct can_frame *date);
-
- void SetCanBusSensor(SensorCanBus<CCanBusSensor>* can);
- void Start();
- void Stop();
- void OnMessage(cannet_frame* frames, int32_t count = 4);
- void Emergency();
-
- void order(cannet_frame* frame);
- void toggleLamp(cannet_frame* frame);
- void move_run(cannet_frame* frame);
- void move_rot(cannet_frame* frame);
- void car_stop(cannet_frame* frame);
- bool order_flag = false;
- bool lamp_flag = false;
- bool run_flag = false;
- bool rot_flag = false;
- bool stop_flag = false;
- private:
- void Run();
- void CanSendProc();
- void SendStatusToMSG();
-
- private:
- CMessageQueue* _message;
- SensorCanBus<CCanBusSensor> * _canbus;
- bool _run;
- std::thread _can_thread;
- std::mutex _last_can_lock;
- struct can_frame Sendframe[6];
- bool _front_view = true;
- int16_t Direction;
- int16_t Hand_Throttle;
- int16_t Foot_Throttle;
- int16_t Brake;
- int64_t count;
- FeedData _data;
- int model;
-
-
- unsigned char* data2copy;
- unsigned char order_on[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
- unsigned char headlamp_on[8] = {0x01,0x01,0x50,0x00,0x00,0x00,0x00,0x00};
- unsigned char headlamp_off[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
- unsigned char taillamp_on[8] = {0x01,0x00,0x00,0x01,0x50,0x00,0x00,0x00};
- unsigned char taillamp_off[8] = {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
- unsigned char move_forward[8] = {0x00,0x96,0x00,0x00,0x00,0x00,0x00,0x00};
- unsigned char move_backward[8] = {0x00,0xcc,0x00,0x00,0x00,0x00,0x00,0x00};
- unsigned char move_rotation[8] = {0x00,0x00,0x00,0xc8,0x00,0x00,0x00,0x00};
- unsigned char stop_on[8] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
-
-
- };
|