#pragma once #ifdef WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include #include #define socketerrno WSAGetLastError() #define SOCKET_EAGAIN_EINPROGRESS WSAEINPROGRESS #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK #ifndef _SSIZE_T_DEFINED typedef int ssize_t; #define _SSIZE_T_DEFINED #endif #ifndef _SOCKET_T_DEFINED typedef SOCKET socket_t; #define _SOCKET_T_DEFINED #endif #else #include #include #include #include #include #include #include #define socketerrno errno #define SOCKET_EAGAIN_EINPROGRESS EAGAIN #define SOCKET_EWOULDBLOCK EWOULDBLOCK #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 #ifndef _SOCKET_T_DEFINED typedef int socket_t; #define _SOCKET_T_DEFINED #endif #endif #include "../common/notifier.h" #include #include "../common/comm.h" #include "../common/iobuffer.h" #include "../common/sensor_socket.h" #include #include class CMessageQueue; class CPcanSensor { public: CPcanSensor(CMessageQueue * q); void Notify(TPCANMsg *buffer, int32_t size); void SetSensorSocket(SensorPeakCan* can); void OnMessage(cannet_frame* frames, int32_t count = 4); void Start(); void Stop(); bool Emergency(); //急停 只局限于程序 和网络 void Run(); private: void SendStatusToMSG(); private: CMessageQueue * _message; SensorPeakCan * _socket; bool _run; std::mutex _last_can_lock; bool _front_view = true; TPCANMsg _msg[4]; FeedData _data; //int b_ready; //int b_over; int model;//0本地,1远程 int16_t Direction;//方向 int16_t Hand_Throttle;//手油门 int16_t Foot_Throttle;//脚油门 int16_t Brake;//刹车 };