#pragma once #include #include #include #include #include #include "protocol.pb.h" #include "../common/iobuffer.h" #include "../common/socket_client.h" #include "../common/sensor_socket.h" #include "../common/update_thread.h" #include #include "MqttClient.h" #include "DataMqttClient.h" #include "can_bus.h" #include "radar_can.h" #include "pcan_sensor.h" #include "radar_ip.h" #ifdef LIDAR_SENSOR #include "./lidar/lidar_sensor.h" #endif class CImuSensor; class SocketClient; class CPeerConnection; class VideoRenderer; class CMqttSensor; class CRtkSensor; class CDataMqttSensor; class CCanBusSensor; class CCanRadarSensor; class CPcanSensor; class CRadarSensor; struct ImuData; enum MessageType:int32_t { ReqVideo, RepVideo, Connected, Leave, StopSensor, Ping, AsyncMessage, //BootStrap, //Startup, }; struct Message { MessageType cmd; int64_t param_l; int64_t param_r; }; struct LocalCameraInfo { int32_t index; std::string label; }; enum RA { RA_Boot, RA_Stop, RA_Goal, RA_Encode, }; class CIOBuffer; struct RadarData; class CMessageQueue:public INativeNotify { public: CMessageQueue(); virtual ~CMessageQueue(); void Create(); void EnQueue(CIOBuffer* pBuffer); void Process(); //virtual void OnAdd(bool bRet) override; virtual void OnAdd(bool bRet) override; virtual void OnConnected(bool bRet) override; // virtual bool IsCarId(int32_t value) override; // virtual void WriteCanMessage(std::unordered_map& node,bool islidar) override; #ifdef WIN32 virtual void OnVideoRep(int32_t index,int32_t peer) override; #else virtual void OnVideoReq(int32_t index,int32_t peer) override; #endif virtual void OnVideoOffer(int32_t index,const char* type, const char* sdp) override; virtual void OnVideoAnswer(int32_t index, const char* type, const char* sdp) override; virtual void OnVideoCandidate(int32_t index,const char* candidate, int32_t sdp_mline_index, const char* sdp_mid) override; /*virtual void OnVideoAddTrack(RemoteVideoTrackWrapper* ptr) = 0;*/ //virtual void OnCancelReq(int32_t index) override; virtual void OnVideoLeave(int32_t peer,EgoType type) override; virtual void OnMessageFrameNotify(ChannelType type,int16_t cmd,int16_t length,const void * data) override; virtual void OnMqttUser(std::string user_uid,int32_t cockpitId,int32_t vehicleId) override;//增加 void OnNotifyConnected(bool bRet); void OnNotifyReq(int32_t index); void OnNotifyRep(int32_t index); void OnNotifyStopSensor(); void OnNotifyLeave(); void OnNotifyMessage(); void OnNotifyPing(int64_t value); void InitPeerConnection(int32_t peer,int32_t index); void WriteIMUData(ImuData* data); void WriteRadarData(RadarData& data); void WriteRobotStatus(int32_t value,int32_t desc); void WritePacket(ChannelType type, CIOBuffer & pBuffer); void SwitchCamera(bool front); void SetTick(long long tick); void ChangeState(UserState state); void OnSwitchDriver(); #ifdef LIDAR_SENSOR void WriteLidarPoint(const PointCloudMsg& msg,ChannelType side); #endif void StopCar(); // void StartCar(); void CheckSignal(); void SendZGJStatus(int status); void SendVehicleStatus(vehicle_control_cv control_can); void SendStatusToServer(int32_t travelSpeed, int fGear, int bGear, int gearStatus) ; //发送底盘状态给服务器 bool bStopedCar; long long _curStopTick; bool btimeStopedCar; long long DataMqtt_curTick; bool DataMqtt_SendDate; FILE *File_fd; int32_t _Version; void SerichFile(char *filename); long long _source = 0; long long _dst = 0; //增加 std::string user_uuid; int32_t cockpit_id; int32_t vehicle_id; private: std::mutex _lock; std::condition_variable _cv; CIOBuffer* Head; CIOBuffer* Tail; //add-3-7 //CRobotSensor *cs; // std::unique_ptr _peer_video; std::vector > _peerArray; std::vector _cameraArray; //EgoType _egoType; //int32_t _indexOffset; // std::vector > _windowArray; // std::unique_ptr _main_window; // std::unique_ptr _arm_window; std::unique_ptr _client; std::unique_ptr> _imu; std::unique_ptr> _Mqtt_ZR; std::unique_ptr> _Mqtt_SE; std::unique_ptr> _Rtk; std::unique_ptr> _CanBusVehicle; std::unique_ptr> _CanBusRadar; std::unique_ptr> _PcanBusVehicle; std::unique_ptr> _RadarIp; int32_t _peerId; std::string _serial; std::string _name; int32_t _uid=0; int32_t _UdpMinPort; int32_t _UdpMaxPort; CUpdateThread _updatethread; std::mutex _canLock; long long _curTick; //////////////////////////////////////////////////////////////// #ifdef LIDAR_SENSOR std::unique_ptr _left; std::unique_ptr _right; #endif };