#pragma once #include #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 "message.h" int8_t hi_byte(int16_t value); int8_t lo_byte(int16_t value); class CRadarSensor; class CEncoderSensor; class CCarSensor; class SocketClient; class CPeerConnection; //class VideoRenderer; //class CAutoSensor; enum MessageType:int32_t { ReqVideo, RepVideo, Connected, Leave, StopSensor, Ping, AsyncMessage, }; enum class ParkingState:int32_t { None, Turn, Reverse, Restore, RiseDown,//举升 // Down, //下降 TipOut, //倾翻倒出 TipIn, // 倾倒收回 TipRise, //倾翻上升 TipDown,//倾翻下降 }; struct Message { MessageType cmd; int64_t param_l; int64_t param_r; }; struct LocalCameraInfo { int32_t index; std::string label; }; struct radar_node; class CIOBuffer; enum TurnSide { Left, Right, Other }; enum ROUT_LIST { FRONT_IN_1, BACK_IN_1, FRONT_OUT_1, FRONT_IN_2, BACK_IN_2, FRONT_OUT_2, FRONT_IN_3, BACK_IN_3, FRONT_OUT_3, ROUT_ALL }; class CMessageQueue:public INativeNotify { public: CMessageQueue(); virtual ~CMessageQueue(); void Create(); void EnQueue(CIOBuffer* pBuffer); void Process(); virtual void OnAdd(int32_t uid,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; virtual void OnMoveBegin(WorkArea area, int32_t no) 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 OnSwitchDriver() override; virtual void OnMessageFrameNotify(ChannelType type,int16_t cmd,int16_t length,const void * data) override; void OnNotifyConnected(bool bRet); void OnNotifyReq(int32_t index); void OnNotifyRep(int32_t index); void OnNotifyStopSensor(); void OnNotifyLeave(); void OnNotifyMessage(); void SetNdtPos(ARNdtPos* pos); void SetSteerAngle(int16_t); void SetLeftAngle(int16_t); void SetRightAngle(int16_t); void OnGoalFinish(WorkArea are,int32_t no); void OnTip(int16_t value); void GetParkCanMessage(TPCANMsg* msg); void OnNotifyPing(int64_t value); void InitPeerConnection(int32_t peer,int32_t index); void WriteBuffer(ChannelType type,CIOBuffer& pBufer); void WriteBuffer(CIOBuffer& pBuffer); void WriteSensor(radar_node* node,int32_t count); // void WriteRadarData(radar_node* data); void SetAutomous(bool value,int32_t delay); void SwitchCamera(bool front); // void WriteRobotStatus(int32_t value,int32_t desc); const radar_node* GetRadar(); void StopAutomous(); ParkingState GetParkingState(); void SetParkingState(ParkingState state); CarType GetCarType(); //#ifdef LIDAR_SENSOR // void WriteLidarPoint(const PointCloudMsg& msg,ChannelType side); //#endif // void StopCar(); // void StartCar(); void CheckSignal(); void ChangeState(UserState state); int32_t GetPeer(); void TestPark(); void OnRiseDown(TPCANMsg* msg); void OnTipRise(TPCANMsg* msg); void OnTipDown(TPCANMsg* msg); void OnTipOut(TPCANMsg* msg); void OnTipIn(TPCANMsg* msg); void OnTurn(TPCANMsg* msg); void OnReverse(TPCANMsg* msg); void OnRestore(TPCANMsg* msg); public: // void BegRecord(); // void EndRecord(); // void PlayRecord(ROUT_LIST index); // bool IsRecord(){ return _start_record;} // void WriteRecord(TPCANMsg * msg); private: // void LoadRecord(ROUT_LIST dir,const char * file); // void OnPlayrecord(TPCANMsg* msg); // bool _start_record=false; //bool _start_play=false; // ROUT_LIST _rout_index; // std::fstream _ofile; // std::vector frames[ROUT_LIST::ROUT_ALL]; // int32_t _play_index=0; private: std::mutex _mlock; std::condition_variable _cv; CIOBuffer* Head; CIOBuffer* Tail; // 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> _radar; std::unique_ptr> _encoder; // std::unique_ptr> _lidar; std::unique_ptr> _robot; //std::unique_ptr> _auto; int32_t _peerId; // int32_t _canport; // int32_t _hostport; // int32_t _lidarport; // std::string _canip; std::string _serial; std::string _name; CarType _car; bool _camera_inited=false; bool bStopedCar; CUpdateThread _updatethread; std::mutex _canLock; int64_t _curTick; int32_t _uid=0; ParkingState _parking=ParkingState::None; std::mutex _pose_lock; ARNdtPos _curpos; int16_t _steer_angle; FVector3d _initpos; WorkArea _workarea=WorkArea::Area_A; Metal_Area _metalArea=Metal_Area::Put_Wait; int32_t _no=0; TurnSide _side=TurnSide::Left; int16_t _left_length=0; int16_t _right_length=0; int16_t pre_left_length=-1; int16_t pre_right_length=-1; //int16_t _tip_length=0; int16_t max_left_length=0; int16_t max_right_length=0; int16_t min_left_length=0; int16_t min_right_length=0; int32_t tipin_time=0; int32_t tipout_time=0; int32_t _start_time=0; int32_t _diff_degree=30; int32_t _angle_value=10; int32_t _sq_length=102; int32_t _turn_base=1000; bool _start_check=false; };