123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #pragma once
- #ifdef WIN32
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif
- #include <WS2tcpip.h>
- #include <WinSock2.h>
- #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 <unistd.h>
- #include <arpa/inet.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <netinet/tcp.h>
- #include <fcntl.h>
- #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 <stdint.h>
- #include "../common/comm.h"
- #include "../common/iobuffer.h"
- #include "../common/sensor_socket.h"
- #include <thread>
- #include <math.h>
- class CMessageQueue;
- class CPcanSensor
- {
- public:
- CPcanSensor(CMessageQueue * q);
- void Notify(TPCANMsg *buffer, int32_t size);
- void SetSensorSocket(SensorPeakCan<CPcanSensor>* 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<CPcanSensor> * _socket;
- bool _run;
-
-
- std::mutex _last_can_lock;
- bool _front_view = true;
- // TPCANMsg _msg[4];
- TPCANMsg _msg[5];
- 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;//刹车
- vehicle_status can_status;
- };
|