123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- #pragma once
- #ifndef _IV_CONTROL_CAN_
- #define _IV_CONTROL_CAN_
- #include <control/controlcan.h>
- #include <common/boost.h>
- #include <common/car_status.h>
- #include <boost/serialization/singleton.hpp>
- #include <common/obstacle_type.h>
- #include <control/mobileye.h>
- #ifdef WIN32
- #include <control/can_card.h>
- #endif
- //#define USE_MOBILEYE
- namespace iv {
- namespace control {
- class CanUtil : public boost::noncopyable
- {
- public:
- CanUtil();
- ~CanUtil();
- void openCanCard();
- void closeCanCard();
- void receive();
- void send();
- void initial();
- void pack_command();
- void receive_radar(); //毫米波雷达接收数据线程执行方法
- #ifdef USE_MOBILEYE
- void receive_mobileye();
- #endif
- /* 获取毫米波雷达传输数据*/
- void getRadarData(iv::ObsRadar & obs_radar);
- //zsl 2018.06.19
- void Ui_GetRadarDate(iv::ObsRadar & obs_radar);
- // void Ui_GetRadarDate(iv::ObsRadarPointer & obs_radar);
- bool did_radar_ok();
- void startsend(bool start_or_stop);
- void set_trumpet_on();
- void set_trumpet_off();
- void set_handbrake_on();
- void set_handbrake_off();
- void impl_0x700(VCI_CAN_OBJ receivedata);
- void impl_0x737(VCI_CAN_OBJ receivedata);
- void impl_0x738(VCI_CAN_OBJ receivedata);
- obstacle_data_a impl_0x739(VCI_CAN_OBJ receivedata);
- obstacle_data_b impl_0x73a(VCI_CAN_OBJ receivedata);
- obstacle_data_c impl_0x73b(VCI_CAN_OBJ receivedata);
- void impl_0x669(VCI_CAN_OBJ receivedata);
- void impl_0x766(VCI_CAN_OBJ receivedata);
- void impl_0x767(VCI_CAN_OBJ receivedata);
- void impl_0x768(VCI_CAN_OBJ receivedata);
- void impl_0x769(VCI_CAN_OBJ receivedata);
- next_lane_a impl_0x76c(VCI_CAN_OBJ receivedata);
- next_lane_b impl_0x76d(VCI_CAN_OBJ receivedata);
- void impl_0x76a(VCI_CAN_OBJ receivedata);
- void impl_0x76b(VCI_CAN_OBJ receivedata);
- void obs_print(std::vector<obstacle_data_a> obstacleStatusA, std::vector<obstacle_data_b> obstacleStatusB, std::vector<obstacle_data_c> obstacleStatusC);
- bool is_stop = false;
- bool is_trumpet_duang = false;
- bool remotecontrol_is_stop = false;
- bool remotecontrol_is_start = false;
- private:
- boost::shared_ptr<boost::thread> thread_receive; //接收控制板数据线程
- boost::shared_ptr<boost::thread> thread_radar_receive; //接收毫米波雷达数据线程
- boost::shared_ptr<boost::thread> thread_mobileye_receive; //mobileye
- boost::shared_ptr<boost::thread> thread_send; //发送数据线程 每10毫秒发送一次
- iv::ObsRadar obs_radar1;
- iv::ObsRadar obs_radar_; //毫米波雷达障碍物数据
- iv::ObsRadar obs_radar_ui; //专门用来给GUI读毫米波雷达的数据
- bool obs_find_flag = false; //采集内容标志位,有内容就是true
- boost::mutex mutex_;
- #ifdef WIN32
- HINSTANCE m_hDLL;//用来保存打开的动态库句柄
- LPVCI_OpenDevice VCI_OpenDevice; //接口函数指针
- LPVCI_CloseDevice VCI_CloseDevice;
- LPVCI_InitCan VCI_InitCAN;
- LPVCI_ReadBoardInfo VCI_ReadBoardInfo;
- LPVCI_ReadErrInfo VCI_ReadErrInfo;
- LPVCI_ReadCanStatus VCI_ReadCanStatus;
- LPVCI_GetReference VCI_GetReference;
- LPVCI_SetReference VCI_SetReference;
- LPVCI_GetReceiveNum VCI_GetReceiveNum;
- LPVCI_ClearBuffer VCI_ClearBuffer;
- LPVCI_StartCAN VCI_StartCAN;
- LPVCI_ResetCAN VCI_ResetCAN;
- LPVCI_Transmit VCI_Transmit;
- LPVCI_Receive VCI_Receive;
- LPVCI_GetReference2 VCI_GetReference2;
- LPVCI_SetReference2 VCI_SetReference2;
- LPVCI_ResumeConfig VCI_ResumeConfig;
- LPVCI_ConnectDevice VCI_ConnectDevice;
- LPVCI_UsbDeviceReset VCI_UsbDeviceReset;
- LPVCI_FindUsbDevice VCI_FindUsbDevice;
- #endif
- DWORD m_devtype = 4;//USBCAN2类型号
- DWORD m_devind = 0; //can卡设备号 第一个插入的是0 第二个是1
- DWORD m_cannum = 0; //can通道号
- DWORD m_cannum_radar = 1; //毫米波雷达can通道号
- #ifdef USE_MOBILEYE
- DWORD m_devindmob = 1;
- #endif
- BYTE m_sendtype = 0;
- BYTE m_frameflag = 0;
- BYTE m_frameformat = 0;
- bool send_connect = false;
- bool is_repeat = false;
- int m_connect = 0;
- };
- typedef boost::serialization::singleton<iv::control::CanUtil> CanUtilSingleton;
- }
- }
- #define ServiceCanUtil iv::control::CanUtilSingleton::get_mutable_instance()
- #endif // !_IV_CONTROL_CAN_
|