TestWizardToolDlg.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // TestWizardToolDlg.h : 头文件
  2. //
  3. #pragma once
  4. #include "afxwin.h"
  5. // 按钮id起始值;
  6. #define BTNID 11000
  7. #define WM_IR_SHOT_IMG WM_USER + 10012
  8. #define NAME_LEN 32
  9. #define DESC_LEN 128
  10. #define VALUE_LEN 16
  11. typedef struct __BTN_INFO__
  12. {
  13. CMFCButton *pBTN;
  14. bool bUsed;
  15. bool bCreated;
  16. __BTN_INFO__(){
  17. pBTN = NULL;
  18. bUsed = false;
  19. bCreated = false;
  20. }
  21. }BTNInfo, *pBTNInfo;
  22. // layout.xml item;
  23. typedef struct __KEY_INFO__
  24. {
  25. bool bUse;
  26. std::string strName;
  27. std::string strDesc;
  28. std::string strValue;
  29. std::string strType;
  30. int width;
  31. int height;
  32. DWORD color;
  33. BTNInfo *pbtnInfo;
  34. __KEY_INFO__(){
  35. pbtnInfo = NULL;
  36. bUse = false;
  37. }
  38. }KeyInfo, *pKeyInfo;
  39. // CTestWizardToolDlg 对话框
  40. class CTestWizardToolDlg : public CDialog
  41. {
  42. // 构造
  43. public:
  44. CTestWizardToolDlg(CWnd* pParent = NULL); // 标准构造函数
  45. // 对话框数据
  46. enum { IDD = IDD_TESTWIZARDTOOL_DIALOG };
  47. protected:
  48. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  49. // 实现
  50. protected:
  51. HICON m_hIcon;
  52. // 生成的消息映射函数
  53. virtual BOOL OnInitDialog();
  54. afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
  55. afx_msg void OnPaint();
  56. afx_msg HCURSOR OnQueryDragIcon();
  57. afx_msg BOOL OnDeviceChange(UINT nEventType, DWORD_PTR dwData);
  58. DECLARE_MESSAGE_MAP()
  59. public:
  60. int m_nCols;
  61. int m_nRowSpacing;
  62. int m_nColSpacing;
  63. int m_nDefaultWidth;
  64. int m_nDefaultHeight;
  65. int m_nTopMargin;
  66. int m_nLeftMargin;
  67. CComboBox m_cbCOMTW;
  68. CComboBox m_cbSignals;
  69. int m_nComboHeight;
  70. std::vector<std::string> m_vtPorts;
  71. std::vector<KeyInfo> m_vtKeyInfo;
  72. std::map<UINT, KeyInfo*> m_map_key;
  73. std::vector<std::string> m_vtTWSignal;
  74. std::vector<BTNInfo*> m_vtBTNInfo;
  75. CBaseSerial m_SerialTW;
  76. CBaseSerial m_SerialUSB;
  77. CRect m_rcGroup;
  78. // 是否找到测试精灵串口;
  79. bool m_bFindTestWizardPort;
  80. // 是否找到u盘切换设备;
  81. bool m_bFindSwitcherPort;
  82. // 查找测试精灵串口;
  83. bool IsTestWizardPort(CString strCOMPort);
  84. // 查找USB切U盘设备串口
  85. bool IsUSBSwitchPort(CString strCOMPort);
  86. void SwitchUSB(BOOL bCheckA);
  87. void AdjustLayout();
  88. void InitSerialCombobox();
  89. void InitCommandCombobox();
  90. void LoadSignals();
  91. void LoadKeyInfo(std::vector<KeyInfo> &vtKeyInfo, std::string path);
  92. void ConvertOldSignalsToNew(std::string strOldSignal, std::string strNewSignal);
  93. BTNInfo *GetUnUseBTN();
  94. void SetBTNStatus(BTNInfo *pbtnInfo, BOOL bStatus = TRUE);
  95. void SetAllBTNUnUsed();
  96. void ClearAllBTNInfo();
  97. afx_msg void OnSize(UINT nType, int cx, int cy);
  98. afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
  99. afx_msg void OnGetMinMaxInfo(MINMAXINFO* lpMMI);
  100. afx_msg void OnSignalBtnClick(UINT uId);
  101. afx_msg void OnBnClickedOpenCom();
  102. afx_msg void OnCbnSelchangeSingals();
  103. afx_msg void OnBnClickedReloadSignal();
  104. afx_msg void OnDestroy();
  105. protected:
  106. virtual void OnOK();
  107. // 自动根据Combobox选项长度设置宽度;
  108. void AutoSetDroppedWidth(CComboBox* pCombobox);
  109. public:
  110. CStatic m_stGroup;
  111. CMFCButton m_btnOpenTW;
  112. CMFCButton m_btnReload;
  113. CMFCButton m_btnOpenUSB;
  114. CComboBox m_cbUSBPort;
  115. void InitBtnStyle();
  116. virtual BOOL PreTranslateMessage(MSG* pMsg);
  117. afx_msg void OnTimer(UINT_PTR nIDEvent);
  118. afx_msg void OnBnClickedOpenCom2();
  119. afx_msg void OnBnClickedCheckA();
  120. afx_msg void OnBnClickedCheckB();
  121. };