MainDlg.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // MainDlg.h : interface of the CMainDlg class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #pragma once
  5. #include "api.h"
  6. #include "Protocol.pb.h"
  7. #include "../common/socket_client.h"
  8. #include "../common/update_thread.h"
  9. //#include "../common/FeedBack.h"
  10. #include "../common/radar_deal.h"
  11. //#include "MonitorThread.h"
  12. //#define WM_NOTIFY_STATE WM_APP+10
  13. //#define MSG_WM_NOTIFY_STATE(func) if(uMsg==WM_NOTIFY_STATE){SetMsgHandled(TRUE); func((FeedbackData::Feedback *)wParam); lResult = 0; if(IsMsgHandled()) return TRUE;}
  14. //#define WM_NOTIFY_REP WM_APP+2
  15. //#define MSG_WM_NOTIFY_REP(func) if(uMsg==WM_NOTIFY_REP){SetMsgHandled(TRUE); func((int32_t)wParam); lResult = 0; if(IsMsgHandled()) return TRUE;}
  16. //#define WM_NOTIFY_ADDTRACK WM_APP+3
  17. //#define MSG_WM_NOTIFY_ADDTRACK(func) if(uMsg==WM_NOTIFY_ADDTRACK){SetMsgHandled(TRUE); func(); lResult = 0; if(IsMsgHandled()) return TRUE;}
  18. // #define WM_NOTIFY_ANSWER WM_APP+4
  19. // #define MSG_WM_NOTIFY_ANSWER(func) if(uMsg==WM_NOTIFY_ANSWER){SetMsgHandled(TRUE); func((IOBuffer *)wParam); lResult = 0; if(IsMsgHandled()) return TRUE;}
  20. // #define WM_NOTIFY_INITWEBRTC WM_APP+5
  21. // #define MSG_WM_NOTIFY_INITWEBRTC if(uMsg==WM_NOTIFY_INITWEBRTC){SetMsgHandled(TRUE); func(); lResult = 0; if(IsMsgHandled()) return TRUE;}
  22. #define WM_NOTIFYCONNECTED WM_APP+100
  23. #define MSG_WM_NOTIFYCONNECTED(func) if(uMsg==WM_NOTIFYCONNECTED){SetMsgHandled(TRUE); func((bool)wParam); lResult = 0; if(IsMsgHandled()) return TRUE;}
  24. #define WM_NOTIFYSIGIN WM_APP+101
  25. #define MSG_WM_NOTIFYSIGIN(func) if(uMsg==WM_NOTIFYSIGIN){SetMsgHandled(TRUE); func((bool)wParam); lResult = 0; if(IsMsgHandled()) return TRUE;}
  26. #define WM_NOTIFYREADY WM_APP+102
  27. #define MSG_WM_NOTIFYREADY(func) if(uMsg==WM_NOTIFYREADY){SetMsgHandled(TRUE); func(); lResult = 0; if(IsMsgHandled()) return TRUE;}
  28. #define WM_NOTIFYSTOP WM_APP+103
  29. #define MSG_WM_NOTIFYSTOP(func) if(uMsg==WM_NOTIFYSTOP){SetMsgHandled(TRUE); func(); lResult = 0; if(IsMsgHandled()) return TRUE;}
  30. #define WM_NOTIFYCONNECT WM_APP+104
  31. #define MSG_WM_NOTIFYCONNECT(func) if(uMsg==WM_NOTIFYCONNECT){SetMsgHandled(TRUE); func((int32_t)wParam); lResult = 0; if(IsMsgHandled()) return TRUE;}
  32. #define WM_NOTIFYDISCONNECT WM_APP+105
  33. #define MSG_WM_NOTIFYDISCONNECT(func) if(uMsg==WM_NOTIFYDISCONNECT){SetMsgHandled(TRUE); func((int32_t)wParam); lResult = 0; if(IsMsgHandled()) return TRUE;}
  34. //#define IDC_STATETIMER 0x1002
  35. #define WM_STOP_ACK WM_APP+106
  36. #define MSG_STOP_ACK(func) if(uMsg==WM_STOP_ACK){SetMsgHandled(TRUE); func(); lResult = 0; if(IsMsgHandled()) return TRUE;}
  37. class CThreadWindow;
  38. class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>,
  39. public CMessageFilter, public CIdleHandler,public INativeNotify
  40. {
  41. public:
  42. enum { IDD = IDD_MAINDLG };
  43. virtual BOOL PreTranslateMessage(MSG* pMsg) override;
  44. virtual BOOL OnIdle() override;
  45. BEGIN_UPDATE_UI_MAP(CMainDlg)
  46. END_UPDATE_UI_MAP()
  47. BEGIN_MSG_MAP(CMainDlg)
  48. MSG_WM_INITDIALOG(OnInitDialog)
  49. MSG_WM_DESTROY(OnDestroy)
  50. MSG_WM_NOTIFYCONNECTED(OnNotifyConnected)
  51. MSG_WM_NOTIFYSIGIN(OnNotifySigin)
  52. MSG_WM_TIMER(OnTimer)
  53. MSG_STOP_ACK(OnStopAck)
  54. //MSG_WM_NOTIFYREADY(OnNotifyReady)
  55. //MSG_WM_NOTIFYCONNECT(OnNotifyConnect)
  56. //MSG_WM_NOTIFYDISCONNECT(OnNotifyDisconnect)
  57. //MSG_WM_NOTIFYSTOP(OnNotifyStop)
  58. //MSG_WM_NOTIFY_STATE(OnNotifyState)
  59. //MSG_WM_NOTIFY_REP(OnNotifyRep)
  60. COMMAND_ID_HANDLER_EX(IDC_CARDISCONNECT, OnCarLeave)
  61. COMMAND_ID_HANDLER_EX(IDC_FRONT, OnFront)
  62. COMMAND_ID_HANDLER_EX(IDC_BACK, OnBack)
  63. COMMAND_ID_HANDLER_EX(IDC_CARCONNECT,OnCarConnect)
  64. COMMAND_ID_HANDLER_EX(IDC_SEND,OnSend)
  65. COMMAND_ID_HANDLER_EX(IDCANCEL, OnCancel)
  66. END_MSG_MAP()
  67. // Handler prototypes (uncomment arguments if needed):
  68. // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  69. // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
  70. // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
  71. LRESULT OnInitDialog(HWND, LPARAM);
  72. void OnFront(WORD, WORD, HWND);
  73. void OnBack(WORD, WORD, HWND);
  74. void OnCarConnect(WORD, WORD, HWND);
  75. void OnCarLeave(WORD, WORD, HWND);
  76. void OnSend(WORD, WORD, HWND);
  77. void OnDestroy(void);
  78. void OnStopAck(void);
  79. void OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/);
  80. void CloseDialog(int nVal);
  81. // void OnNotifyReady();
  82. // void OnNotifyStop();
  83. // void OnNotifyConnect(int32_t uid);
  84. // void OnNotifyDisconnect(int32_t uid);
  85. virtual void OnSigin(bool bRet) override;
  86. void OnNotifySigin(bool bRet);
  87. virtual void OnRobot(const RemoNet::Robot& robot) override;
  88. virtual void OnConnected(bool bRet) override;
  89. void OnNotifyConnected(bool bRet);
  90. void OnTimer(UINT id);
  91. //void OnNotifyState(FeedbackData::Feedback* data);
  92. #ifndef WIN32
  93. virtual void OnVideoReq(int32_t index, int32_t peer) override;
  94. #endif
  95. virtual void OnVideoRep(int32_t index, int32_t peer) override;
  96. virtual void OnVideoOffer(int32_t index, const char* type, const char* sdp) override;
  97. virtual void OnVideoAnswer(int32_t index, const char* type, const char* sdp) override;
  98. virtual void OnVideoCandidate(int32_t index, const char* candidate, int32_t sdp_mline_index, const char* sdp_mid) override;
  99. //virtual void OnCancelReq(int32_t index) override;
  100. virtual void OnVideoLeave(int32_t peer,EgoType type) override;
  101. virtual void OnMessageFrameNotify(ChannelType type, int16_t cmd, int16_t length, const void* data) override;
  102. virtual void OnNotifyKick() override;
  103. virtual void OnNotifyDel(int32_t peer, EgoType type) override;
  104. RadarDeal radarDeal;
  105. private:
  106. std::shared_ptr<UserCamera> _cameraInfo;
  107. std::shared_ptr<SocketClient> _client;
  108. //std::unique_ptr<SocketCan> _can;
  109. // std::unique_ptr<MonitorThread> _monitor;
  110. std::string _name;
  111. std::string _account;
  112. std::string _password;
  113. std::vector<std::unique_ptr<CThreadWindow>> _WindowArray;
  114. /*std::vector<std::unique_ptr<CRadarWindow>> _RadarArray;*/
  115. //std::vector<Coord> _ptArray[3];
  116. bool bUpdated = false;
  117. //bool bNotifyReady = false;
  118. std::unique_ptr<SensorSocket<CControlSensor>> _control;
  119. private:
  120. int32_t _carpeer;
  121. std::vector<std::unique_ptr<UserCamera> > _userInfo;
  122. CUpdateThread _updateThread;
  123. };