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