123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- #pragma once
- #include<mutex>
- #include<memory>
- #include<string>
- #include<condition_variable>
- #include <vector>
- #include "protocol.pb.h"
- #include "../common/iobuffer.h"
- #include "../common/socket_client.h"
- #include "../common/sensor_socket.h"
- #include "../common/update_thread.h"
- #include <sys/time.h>
- #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<int32_t, cannet_frame>& 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<PointXYZI>& 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<PeerConnectionWrapper> _peer_video;
- std::vector<std::unique_ptr<CPeerConnection> > _peerArray;
- std::vector<LocalCameraInfo> _cameraArray;
- //EgoType _egoType;
- //int32_t _indexOffset;
- // std::vector<std::unique_ptr<VideoRenderer> > _windowArray;
- // std::unique_ptr<VideoRenderer> _main_window;
- // std::unique_ptr<VideoRenderer> _arm_window;
- std::unique_ptr<SocketClient> _client;
- std::unique_ptr<SensorSocket<CImuSensor>> _imu;
- std::unique_ptr<SensorMQTT<CMqttSensor>> _Mqtt_ZR;
- std::unique_ptr<SensorMQTT<CDataMqttSensor>> _Mqtt_SE;
- std::unique_ptr<SensorSocket<CRtkSensor>> _Rtk;
- std::unique_ptr<SensorCanBus<CCanBusSensor>> _CanBusVehicle;
- std::unique_ptr<SensorCanBus<CCanRadarSensor>> _CanBusRadar;
- std::unique_ptr<SensorPeakCan<CPcanSensor>> _PcanBusVehicle;
- std::unique_ptr<SensorSocket<CRadarSensor>> _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<CLidarSensor> _left;
- std::unique_ptr<CLidarSensor> _right;
- #endif
- };
|