RunTestDlg.cpp 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  1. // RunTestDlg.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "RunTest.h"
  5. #include "RunTestDlg.h"
  6. #include "IniReader.h"
  7. #include ".\runtestdlg.h"
  8. #include "InsertDeviceDlg.h"
  9. #include "CheckProcess.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #endif
  13. // 用于应用程序“关于”菜单项的 CAboutDlg 对话框
  14. class CAboutDlg : public CDialog
  15. {
  16. public:
  17. CAboutDlg();
  18. // 对话框数据
  19. enum { IDD = IDD_ABOUTBOX };
  20. protected:
  21. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
  22. // 实现
  23. protected:
  24. DECLARE_MESSAGE_MAP()
  25. // virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
  26. };
  27. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  28. {
  29. }
  30. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialog::DoDataExchange(pDX);
  33. }
  34. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  35. END_MESSAGE_MAP()
  36. // CRunTestDlg 对话框
  37. CRunTestDlg::CRunTestDlg(CWnd* pParent /*=NULL*/)
  38. : CDialog(CRunTestDlg::IDD, pParent)
  39. {
  40. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  41. ZeroMemory(m_hItem,sizeof(m_hItem));
  42. m_nSelectPort = -1;
  43. m_nSelectAddr = -1;
  44. m_strDevice = "";
  45. m_bRunTest = FALSE;
  46. }
  47. void CRunTestDlg::DoDataExchange(CDataExchange* pDX)
  48. {
  49. CDialog::DoDataExchange(pDX);
  50. DDX_Control(pDX, IDC_TREE1, m_treeView);
  51. DDX_Control(pDX, IDC_RICHEDIT21, m_richedit);
  52. DDX_Control(pDX, IDC_BUTTON6, m_btnClearScreen);
  53. //DDX_Control(pDX, IDC_BUTTON5, m_btnModifyPort);
  54. //DDX_Control(pDX, IDC_BUTTON3, m_btnRunTest);
  55. }
  56. BEGIN_MESSAGE_MAP(CRunTestDlg, CDialog)
  57. ON_WM_SYSCOMMAND()
  58. ON_WM_PAINT()
  59. ON_WM_QUERYDRAGICON()
  60. //}}AFX_MSG_MAP
  61. ON_WM_TIMER()
  62. ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
  63. ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
  64. ON_BN_CLICKED(IDC_BUTTON3, OnBnClickedButton3)
  65. ON_MESSAGE(WM_SHOWWRITEDATA,OnShowWriteData)
  66. ON_MESSAGE(WM_SHOWREADDATA,OnShowReadData)
  67. ON_BN_CLICKED(IDC_BUTTON4, OnBnClickedButton4)
  68. ON_BN_CLICKED(IDC_BUTTON5, OnBnClickedButton5)
  69. ON_BN_CLICKED(IDC_BUTTON6, OnBnClickedButton6)
  70. END_MESSAGE_MAP()
  71. // CRunTestDlg 消息处理程序
  72. BOOL CRunTestDlg::OnInitDialog()
  73. {
  74. CDialog::OnInitDialog();
  75. // 将\“关于...\”菜单项添加到系统菜单中。
  76. // IDM_ABOUTBOX 必须在系统命令范围内。
  77. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  78. ASSERT(IDM_ABOUTBOX < 0xF000);
  79. CMenu* pSysMenu = GetSystemMenu(FALSE);
  80. if (pSysMenu != NULL)
  81. {
  82. CString strAboutMenu;
  83. strAboutMenu.LoadString(IDS_ABOUTBOX);
  84. if (!strAboutMenu.IsEmpty())
  85. {
  86. pSysMenu->AppendMenu(MF_SEPARATOR);
  87. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  88. }
  89. }
  90. // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动
  91. // 执行此操作
  92. SetIcon(m_hIcon, TRUE); // 设置大图标
  93. SetIcon(m_hIcon, FALSE); // 设置小图标
  94. // TODO: 在此添加额外的初始化代码
  95. InitSTButtons();
  96. GetMainWnd(this->m_hWnd);
  97. CreateSerialImpl();
  98. SetTimer(0,1500,NULL);
  99. //////////////////
  100. CString strPath;
  101. TCHAR szFull[_MAX_PATH];
  102. TCHAR szDrive[_MAX_DRIVE];
  103. TCHAR szDir[_MAX_DIR];
  104. ::GetModuleFileName(NULL, szFull, sizeof(szFull)/sizeof(TCHAR));
  105. _tsplitpath(szFull, szDrive, szDir, NULL, NULL);
  106. _tcscpy(szFull, szDrive);
  107. _tcscat(szFull, szDir);
  108. strPath = CString(szFull);
  109. CString strIni;
  110. strIni.Format("%s\\config.ini",strPath);
  111. CIniReader IniReader(strIni);
  112. m_strDepotPath.Format("%s\\%s",strPath,IniReader.GetKeyValueText("name","DeviceLibrary"));
  113. m_strRutDepotPath.Format("%s\\%s",strPath,IniReader.GetKeyValueText("name","RunUnitLibrary"));
  114. ////////////////////////////////
  115. m_imgList.Create(IDB_BITMAP1,16, 6, RGB(255,255,255));
  116. m_treeView.SetImageList(&m_imgList,TVSIL_NORMAL);
  117. hRunRootItem = m_treeView.InsertItem("当前运行时设备库设备",2,2);
  118. InitTreeInfo();
  119. return TRUE; // 除非设置了控件的焦点,否则返回 TRUE
  120. }
  121. void CRunTestDlg::InitTreeInfo()
  122. {
  123. CMarkup xml;
  124. if( !xml.Load(m_strRutDepotPath) )
  125. return;
  126. xml.FindElem();
  127. xml.IntoElem();
  128. while ( xml.FindElem("run_object") )
  129. {
  130. STTreeInfo tTreeInfo = {0};
  131. CString strPort;
  132. strPort.Format("COM%s",xml.GetAttrib("port"));
  133. tTreeInfo.hPort = m_treeView.InsertItem(strPort,5,5,hRunRootItem);
  134. while( xml.FindChildElem("commands") )
  135. {
  136. CString strChild;
  137. strChild.Format("addr %s:%s",xml.GetChildAttrib("addr"),xml.GetChildAttrib("name"));
  138. HTREEITEM hChild = m_treeView.InsertItem(strChild, 4,4,tTreeInfo.hPort);
  139. tTreeInfo.vthChild.push_back(hChild);
  140. }
  141. vtSTTreeInfo.push_back(tTreeInfo);
  142. }
  143. }
  144. void CRunTestDlg::InitSTButtons()
  145. {
  146. short shBtnColor = 30;
  147. m_btnClearScreen.SetIcon(IDI_ICON1);
  148. m_btnClearScreen.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  149. m_btnClearScreen.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));
  150. /*m_btnModifyPort.SetIcon(IDI_ICON2);
  151. m_btnModifyPort.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  152. m_btnModifyPort.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));
  153. m_btnRunTest.SetIcon(IDI_ICON3);
  154. m_btnRunTest.OffsetColor(CButtonST::BTNST_COLOR_BK_IN, shBtnColor);
  155. m_btnRunTest.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 128, 0));*/
  156. }
  157. LRESULT CRunTestDlg::OnShowWriteData(WPARAM wParam,LPARAM lParam)
  158. {
  159. if( lParam == NULL)
  160. return 0;
  161. BYTE szMsg[1024] = {0};
  162. memcpy(szMsg, (BYTE*)lParam, (int)wParam);
  163. LOG4C((LOG_NOTICE,"Write[%d]:%s",(int)wParam,szMsg));
  164. CString strTemp = "";
  165. CString strWriteMsg = "";
  166. for ( int i = 0; i < (int)wParam; i++)
  167. {
  168. strTemp.Format("%02X ",szMsg[i]);
  169. strWriteMsg += strTemp;
  170. }
  171. strWriteMsg += "\n\n";
  172. CTime time = CTime::GetCurrentTime();
  173. CString strTime;
  174. strTime.Format("%d-%d-%d %d:%d:%d",time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond());
  175. strTemp = "";
  176. //strTemp = "写命令 ";
  177. //strTemp += strTime;
  178. strTemp.Format("写命令 %s [长度=%d]\n",strTime,(int)wParam);
  179. #if 1
  180. CHARFORMAT cf;
  181. cf.cbSize = sizeof(CHARFORMAT);
  182. m_richedit.GetDefaultCharFormat(cf);
  183. cf.dwMask=CFM_COLOR|CFM_FACE|CFM_SIZE|CFM_BOLD;
  184. cf.dwEffects = (unsigned long)~(CFE_UNDERLINE | CFE_BOLD | CFE_AUTOCOLOR);
  185. //cf.dwEffects ^= CFE_AUTOCOLOR;
  186. cf.crTextColor = RGB(0, 0, 0);
  187. cf.yHeight = 230;
  188. memset(cf.szFaceName, 0, LF_FACESIZE);
  189. //memcpy(cf.szFaceName, "楷体_GB2312", sizeof("楷体_GB2312"));
  190. memcpy(cf.szFaceName, "宋体", sizeof("宋体"));
  191. m_richedit.SetSelectionCharFormat(cf);
  192. m_richedit.SetSel(-1,-1);
  193. m_richedit.ReplaceSel(strTemp);
  194. #endif
  195. //Sleep(10);
  196. //strTemp += "\n";
  197. //strTemp += strWriteMsg;
  198. //strTemp +="\r";
  199. LOG4C((LOG_NOTICE,"Write[%d]:%s",(int)wParam,strWriteMsg));
  200. #if 1
  201. //CHARFORMAT cf;
  202. memset(&cf,0,sizeof(CHARFORMAT));
  203. cf.cbSize = sizeof(CHARFORMAT);
  204. m_richedit.GetDefaultCharFormat(cf);
  205. cf.dwMask=CFM_COLOR|CFM_FACE|CFM_SIZE|CFM_BOLD;
  206. cf.dwEffects = (unsigned long)~(CFE_UNDERLINE | CFE_BOLD | CFE_AUTOCOLOR);
  207. //cf.dwEffects ^= CFE_AUTOCOLOR;
  208. cf.crTextColor = RGB(255, 0, 0);
  209. cf.yHeight = 220;
  210. memset(cf.szFaceName, 0, LF_FACESIZE);
  211. //memcpy(cf.szFaceName, "楷体_GB2312", sizeof("楷体_GB2312"));
  212. memcpy(cf.szFaceName, "宋体", sizeof("宋体"));
  213. m_richedit.SetSelectionCharFormat(cf);
  214. m_richedit.SetSel(-1,-1);
  215. m_richedit.ReplaceSel(strWriteMsg);
  216. // m_richedit.PostMessage(WM_VSCROLL, SB_BOTTOM, 0);
  217. //int nFirstVisible = m_richedit.GetFirstVisibleLine();
  218. //// Scroll the edit control so that the first visible line
  219. //// is the first line of text.
  220. //if (nFirstVisible > 0)
  221. //{
  222. // m_richedit.LineScroll( 1, 0);
  223. //}
  224. #endif
  225. return 0;
  226. }
  227. // ShowReadData中进行数据校验;
  228. LRESULT CRunTestDlg::OnShowReadData(WPARAM wParam,LPARAM lParam)
  229. {
  230. if ( wParam == NULL)
  231. return 0;
  232. STRecvMessage *pRecvMessage = (STRecvMessage*)wParam;
  233. int nEr = -1;
  234. if ( strcmp(pRecvMessage->szCheck,"EMERSON") == 0)
  235. {
  236. nEr = CCheckProcess::GetReturnCheck_Emerson(pRecvMessage->byRecv,pRecvMessage->iRLen);
  237. }
  238. if ( strcmp(pRecvMessage->szCheck,"RTUCRC") == 0)
  239. {
  240. nEr = CCheckProcess::GetReturnCheck_Rtu(pRecvMessage->byRecv,pRecvMessage->iRLen);
  241. }
  242. if ( strcmp(pRecvMessage->szCheck,"fad") == 0)
  243. {
  244. nEr = CCheckProcess::GetReturnCheck_fad(pRecvMessage->byRecv,pRecvMessage->iRLen);
  245. }
  246. if ( strcmp(pRecvMessage->szCheck,"newave") == 0)
  247. {
  248. nEr = CCheckProcess::GetReturnCheck_newave(pRecvMessage->byRecv,pRecvMessage->iRLen);
  249. }
  250. if ( strcmp(pRecvMessage->szCheck,"stulz6000") == 0)
  251. {
  252. nEr = CCheckProcess::GetReturnCheck_stulz6000(pRecvMessage->byRecv,pRecvMessage->iRLen);
  253. }
  254. if ( strcmp(pRecvMessage->szCheck,"cm+") == 0)
  255. {
  256. nEr = CCheckProcess::GetReturnCheck_CM(pRecvMessage->byRecv,pRecvMessage->iRLen);
  257. }
  258. BYTE szMsg[1024] = {0};
  259. memcpy(szMsg, pRecvMessage->byRecv, pRecvMessage->iRLen);
  260. CString strTemp = "";
  261. CString strWriteMsg = "";
  262. for ( int i = 0; i < pRecvMessage->iRLen; i++)
  263. {
  264. strTemp.Format("%02X ",szMsg[i]);
  265. strWriteMsg += strTemp;
  266. }
  267. strWriteMsg += "\n\n";
  268. CTime time = CTime::GetCurrentTime();
  269. CString strTime;
  270. strTime.Format("%d-%d-%d %d:%d:%d",time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond());
  271. strTemp = "";
  272. if ( nEr != 0)
  273. {
  274. strTemp.Format("读命令 %s [长度=%d],ErrorCode=返回错误\n",strTime,pRecvMessage->iRLen);
  275. }
  276. else
  277. {
  278. strTemp.Format("读命令 %s [长度=%d],ErrorCode=返回正确\n",strTime,pRecvMessage->iRLen);
  279. }
  280. #if 1
  281. CHARFORMAT cf;
  282. cf.cbSize = sizeof(CHARFORMAT);
  283. m_richedit.GetDefaultCharFormat(cf);
  284. cf.dwMask=CFM_COLOR|CFM_FACE|CFM_SIZE|CFM_BOLD;
  285. cf.dwEffects = (unsigned long)~(CFE_UNDERLINE | CFE_BOLD | CFE_AUTOCOLOR);
  286. //cf.dwEffects ^= CFE_AUTOCOLOR;
  287. cf.crTextColor = RGB(0, 0, 0);
  288. cf.yHeight = 230;
  289. memset(cf.szFaceName, 0, LF_FACESIZE);
  290. // memcpy(cf.szFaceName, "楷体_GB2312", sizeof("楷体_GB2312"));
  291. memcpy(cf.szFaceName, "宋体", sizeof("宋体"));
  292. m_richedit.SetSelectionCharFormat(cf);
  293. m_richedit.SetSel(-1,-1);
  294. m_richedit.ReplaceSel(strTemp);
  295. #endif
  296. //Sleep(10);
  297. //strTemp += "\n";
  298. //strTemp += strWriteMsg;
  299. //strTemp +="\r";
  300. LOG4C((LOG_NOTICE,"Read[%d]:%s",pRecvMessage->iRLen,strWriteMsg));
  301. #if 1
  302. //CHARFORMAT cf;
  303. memset(&cf,0,sizeof(CHARFORMAT));
  304. cf.cbSize = sizeof(CHARFORMAT);
  305. m_richedit.GetDefaultCharFormat(cf);
  306. cf.dwMask=CFM_COLOR|CFM_FACE|CFM_SIZE|CFM_BOLD;
  307. cf.dwEffects = (unsigned long)~(CFE_UNDERLINE | CFE_BOLD | CFE_AUTOCOLOR);
  308. //cf.dwEffects ^= CFE_AUTOCOLOR;
  309. cf.crTextColor = RGB(0, 0, 255);
  310. cf.yHeight = 220;
  311. memset(cf.szFaceName, 0, LF_FACESIZE);
  312. //memcpy(cf.szFaceName, "楷体_GB2312", sizeof("楷体_GB2312"));
  313. memcpy(cf.szFaceName, "宋体", sizeof("宋体"));
  314. m_richedit.SetSelectionCharFormat(cf);
  315. m_richedit.SetSel(-1,-1);
  316. m_richedit.ReplaceSel(strWriteMsg);
  317. /*int nFirstVisible = m_richedit.GetFirstVisibleLine();
  318. if (nFirstVisible > 0)
  319. {
  320. m_richedit.LineScroll( 1, 0);
  321. }*/
  322. #endif
  323. return 0;
  324. }
  325. void CRunTestDlg::OnSysCommand(UINT nID, LPARAM lParam)
  326. {
  327. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  328. {
  329. CAboutDlg dlgAbout;
  330. dlgAbout.DoModal();
  331. }
  332. else
  333. {
  334. CDialog::OnSysCommand(nID, lParam);
  335. }
  336. }
  337. // 如果向对话框添加最小化按钮,则需要下面的代码
  338. // 来绘制该图标。对于使用文档/视图模型的 MFC 应用程序,
  339. // 这将由框架自动完成。
  340. void CRunTestDlg::OnPaint()
  341. {
  342. if (IsIconic())
  343. {
  344. CPaintDC dc(this); // 用于绘制的设备上下文
  345. SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
  346. // 使图标在工作矩形中居中
  347. int cxIcon = GetSystemMetrics(SM_CXICON);
  348. int cyIcon = GetSystemMetrics(SM_CYICON);
  349. CRect rect;
  350. GetClientRect(&rect);
  351. int x = (rect.Width() - cxIcon + 1) / 2;
  352. int y = (rect.Height() - cyIcon + 1) / 2;
  353. // 绘制图标
  354. dc.DrawIcon(x, y, m_hIcon);
  355. }
  356. else
  357. {
  358. CDialog::OnPaint();
  359. }
  360. }
  361. //当用户拖动最小化窗口时系统调用此函数取得光标显示。
  362. HCURSOR CRunTestDlg::OnQueryDragIcon()
  363. {
  364. return static_cast<HCURSOR>(m_hIcon);
  365. }
  366. void CRunTestDlg::OnTimer(UINT nIDEvent)
  367. {
  368. // 获取当前树结点数量 [3/29/2013 Zero.t]
  369. int nAddrCount=0;
  370. int nPortCount = vtSTTreeInfo.size();
  371. if ( nPortCount == 0 )
  372. {
  373. GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);//禁用测试按钮;
  374. GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);//禁用删除按钮;
  375. }
  376. //else
  377. // GetDlgItem(IDC_BUTTON3)->EnableWindow();//启用测试按钮;
  378. STTreeInfo tTreeInfo;
  379. for ( int i = 0; i < nPortCount; i++)
  380. {
  381. tTreeInfo = vtSTTreeInfo[i];
  382. nAddrCount += tTreeInfo.vthChild.size();
  383. }
  384. CString strShowCount;
  385. strShowCount.Format("当前串口总数=%d个,设备总数=%d个",nPortCount,nAddrCount);
  386. CString strGet;
  387. GetDlgItemText(TX_SHOWCOUNT,strGet);
  388. if ( strGet != strShowCount )
  389. {
  390. SetDlgItemText(TX_SHOWCOUNT,strShowCount);
  391. }
  392. //UpdateData(TRUE);
  393. // 获取当前树结点数量 [3/29/2013 Zero.t]
  394. #if 0 // 使用数据池,获取数据;
  395. if ( g_vtRecv.size() == 0)
  396. {
  397. LOG4C((LOG_NOTICE,"数据池无记录"));
  398. return ;
  399. }
  400. STRecvMessage tRecvMessage = {0};
  401. CString strTemp;
  402. vector <STRecvMessage>::const_iterator it_rmg;
  403. for ( it_rmg = g_vtRecv.begin(); it_rmg != g_vtRecv.end(); it_rmg++)
  404. {
  405. strTemp = "";
  406. EnterCriticalSection( &g_cs_vt );
  407. tRecvMessage = *it_rmg;
  408. LeaveCriticalSection( &g_cs_vt );
  409. CString str;
  410. for ( int i = 0; i < tRecvMessage.iRLen; i++)
  411. {
  412. str.Format("%02X ",tRecvMessage.byRecv[i]);
  413. strTemp += str;
  414. }
  415. if ( strTemp == "" )
  416. {
  417. LOG4C((LOG_NOTICE,"数据池COM%d,Addr=%d,ID=%d:该返回NULL",tRecvMessage.iPort,tRecvMessage.iAddr,tRecvMessage.dwSID));
  418. }
  419. else
  420. {
  421. LOG4C((LOG_NOTICE,"数据池COM%d,Addr=%d,ID=%d:该返回%s\n",tRecvMessage.iPort,tRecvMessage.iAddr,tRecvMessage.dwSID,strTemp));
  422. }
  423. strTemp += "\r\n";
  424. }
  425. #endif
  426. CTime tm = CTime::GetCurrentTime();
  427. int nMinute = tm.GetMinute();
  428. if ( nMinute%10 == 0 )
  429. {
  430. int nSecond = tm.GetSecond();
  431. if ( nSecond/5 < 2 )
  432. {
  433. m_richedit.SetWindowText("");
  434. }
  435. }
  436. CDialog::OnTimer(nIDEvent);
  437. }
  438. BOOL CRunTestDlg::DestroyWindow()
  439. {
  440. // TODO: 在此添加专用代码和/或调用基类
  441. if ( pSerialImpl )
  442. {
  443. delete pSerialImpl;
  444. pSerialImpl = NULL;
  445. }
  446. return CDialog::DestroyWindow();
  447. }
  448. BOOL CRunTestDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
  449. {
  450. if ( !::IsWindow(m_treeView))
  451. {
  452. return CDialog::OnNotify(wParam, lParam, pResult);
  453. }
  454. LPNMHDR pNmhdr = (LPNMHDR)lParam;
  455. int idCtrl = LOWORD(wParam); // 获取控件ID;
  456. // 如果消息对象是该资源(树);
  457. if( idCtrl == IDC_TREE1 )
  458. {
  459. CPoint point;
  460. ::GetCursorPos(&point);
  461. m_treeView.ScreenToClient(&point);
  462. switch( pNmhdr->code )
  463. {
  464. case NM_CLICK: // 单击;
  465. {
  466. // Get Click item's
  467. UINT uFlags;
  468. HTREEITEM hItem = m_treeView.HitTest(point, &uFlags);
  469. if((hItem != NULL) && (TVHT_ONITEM & uFlags))
  470. {
  471. m_treeView.SelectItem(hItem);
  472. }
  473. // [3/26/2013 Zero.t]
  474. CString strPort = m_treeView.GetItemText(hItem);
  475. if ( strPort.Find("COM") == -1)
  476. {
  477. HTREEITEM hRoot = m_treeView.GetParentItem(hItem);
  478. if ( hRoot )
  479. {
  480. strPort = m_treeView.GetItemText(hRoot);
  481. strPort = strPort.Mid(3);
  482. m_nSelectPort = atoi(strPort.GetBuffer());
  483. strPort.ReleaseBuffer();
  484. CString strAddr = m_treeView.GetItemText(hItem);
  485. int iIndex = strAddr.FindOneOf(":");
  486. strAddr = strAddr.Mid(5,iIndex-5);
  487. m_nSelectAddr = atoi(strAddr.GetBuffer());
  488. strAddr.ReleaseBuffer();
  489. CString strDevice = m_treeView.GetItemText(hItem);
  490. iIndex = strDevice.FindOneOf(":");
  491. m_strDevice = strDevice.Mid(iIndex+1);
  492. }
  493. else
  494. {
  495. m_nSelectPort = -1;
  496. GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);//禁用测试按钮;
  497. GetDlgItem(IDC_BUTTON5)->EnableWindow(FALSE);//修改串口属性
  498. GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);//禁用删除按钮;
  499. return true;
  500. }
  501. if ( m_bRunTest == FALSE)
  502. {
  503. GetDlgItem(IDC_BUTTON2)->EnableWindow();//禁用删除按钮;
  504. GetDlgItem(IDC_BUTTON3)->EnableWindow();//禁用测试按钮;
  505. }
  506. // else
  507. // GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);//禁用删除按钮;
  508. GetDlgItem(IDC_BUTTON5)->EnableWindow(FALSE);//修改串口属性
  509. return true;
  510. }
  511. else
  512. {
  513. m_nSelectAddr = -1;
  514. strPort = strPort.Mid(3);
  515. m_nSelectPort = atoi(strPort.GetBuffer());
  516. strPort.ReleaseBuffer();
  517. CObjectdepot tag;
  518. //tag.SetDevicesDepotPath(m_strDepotPath);
  519. tag.SetRuntimeDevicesDepotPath(m_strRutDepotPath);
  520. STRunPhysical tRunPhysical = tag.LookupSubPhysical(m_nSelectPort);
  521. SetDlgItemInt(IDC_EDIT1,tRunPhysical.iRate);
  522. SetDlgItemInt(IDC_EDIT10,tRunPhysical.iRsTm);
  523. SetDlgItemInt(IDC_EDIT11,tRunPhysical.iIntl);
  524. //GetDlgItem(IDC_BUTTON2)->EnableWindow();//禁用删除按钮;
  525. if ( m_bRunTest == FALSE)
  526. GetDlgItem(IDC_BUTTON2)->EnableWindow();//禁用删除按钮;
  527. if ( !m_bRunTest )
  528. {
  529. GetDlgItem(IDC_BUTTON5)->EnableWindow(TRUE);//修改串口属性
  530. }
  531. // }else
  532. // GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);//禁用删除按钮;
  533. }
  534. if( !m_bRunTest )
  535. {
  536. GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE);
  537. }
  538. //}else
  539. // GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);//禁用删除按钮;
  540. // [3/26/2013 Zero.t]
  541. return true;//Already process the notify
  542. }
  543. case NM_RCLICK: // 右击;
  544. {
  545. // Get RightClick item's
  546. UINT uFlags;
  547. HTREEITEM hItem = m_treeView.HitTest(point, &uFlags);
  548. m_treeView.SelectItem(hItem);
  549. if((hItem != NULL) && (TVHT_ONITEM & uFlags))
  550. {
  551. GetCursorPos(&m_mousePoint); // 保存当前鼠标位置;
  552. HTREEITEM hSelectedItem = m_treeView.GetSelectedItem();
  553. if ( !m_treeView.ItemHasChildren(hSelectedItem))
  554. {
  555. }
  556. }
  557. return true;//Already process the notify
  558. }
  559. case NM_DBLCLK: // 左键 双击;
  560. {
  561. // 双击选项,
  562. // 1.如果是设备选项,应该显示设备详细信息;
  563. // 2.如果是根元素,展开选项;
  564. // showdetail();
  565. //
  566. UINT uFlags;
  567. HTREEITEM hItem = m_treeView.HitTest(point, &uFlags);
  568. m_treeView.SelectItem(hItem);
  569. if((hItem != NULL) && (TVHT_ONITEM & uFlags))
  570. {
  571. GetCursorPos(&m_mousePoint); // 保存当前鼠标位置;
  572. HTREEITEM hSelectedItem = m_treeView.GetSelectedItem();
  573. if ( !m_treeView.ItemHasChildren(hSelectedItem))
  574. {
  575. }
  576. }
  577. return true;
  578. }
  579. }
  580. return false; // no match
  581. }
  582. return CDialog::OnNotify(wParam, lParam, pResult);
  583. }
  584. // 添加设备;
  585. void CRunTestDlg::OnBnClickedButton1()//添加设备;
  586. {
  587. // TODO: 在此添加控件通知处理程序代码
  588. CInsertDeviceDlg dlg;
  589. if ( dlg.DoModal() == IDOK )
  590. {
  591. BOOL bHasPort = FALSE;
  592. STTreeInfo tSTTreeInfo = {0};
  593. // 1.查找串口是否已存在容器中;
  594. vector <STTreeInfo>::iterator it_tree;
  595. for ( it_tree = vtSTTreeInfo.begin(); it_tree != vtSTTreeInfo.end(); it_tree++)
  596. {
  597. tSTTreeInfo = *it_tree;
  598. CString strPort;
  599. strPort.Format("COM%s",dlg.m_strPort);
  600. if ( strPort == m_treeView.GetItemText(tSTTreeInfo.hPort) )
  601. {
  602. bHasPort = TRUE;
  603. break;
  604. }
  605. }
  606. // 2.不存在;
  607. if ( !bHasPort )
  608. {
  609. // ZeroMemory(&tSTTreeInfo,sizeof(STTreeInfo));//严禁使用ZeroMemory函数对容器指针进行清空;
  610. CString strPort;
  611. strPort.Format("COM%s",dlg.m_strPort);
  612. tSTTreeInfo.hPort = m_treeView.InsertItem(strPort,5,5,hRunRootItem);
  613. CString strChild;
  614. if ( dlg.m_bMulti == FALSE )
  615. {
  616. strChild.Format("addr %s:%s",dlg.m_strAddr,dlg.m_strName);
  617. HTREEITEM hChild = m_treeView.InsertItem(strChild,4,4,tSTTreeInfo.hPort);
  618. #if 1 // 此处同样出错,push_back时产生了越界行为.是因为ZeroMemory(&tSTTreeInfo,sizeof(STTreeInfo));了,
  619. // 造成容器的大小被设置为0;
  620. tSTTreeInfo.vthChild.push_back(hChild);
  621. vtSTTreeInfo.push_back(tSTTreeInfo);
  622. #endif
  623. }else
  624. {
  625. for ( int i = dlg.m_nStarAddr; i <= dlg.m_nEndAddr;i++)
  626. {
  627. strChild.Format("addr %d:%s",i,dlg.m_strName);
  628. HTREEITEM hChild = m_treeView.InsertItem(strChild,4,4,tSTTreeInfo.hPort);
  629. tSTTreeInfo.vthChild.push_back(hChild);
  630. }
  631. vtSTTreeInfo.push_back(tSTTreeInfo);
  632. }
  633. }
  634. else // 3.存在;
  635. {
  636. CString strChild;
  637. if ( dlg.m_bMulti == FALSE )
  638. {
  639. strChild.Format("addr %s:%s",dlg.m_strAddr,dlg.m_strName);
  640. HTREEITEM hChild = m_treeView.InsertItem(strChild,4,4,tSTTreeInfo.hPort);
  641. tSTTreeInfo.vthChild.push_back(hChild);
  642. }else
  643. {
  644. for ( int i = dlg.m_nStarAddr; i <= dlg.m_nEndAddr;i++)
  645. {
  646. strChild.Format("addr %d:%s",i,dlg.m_strName);
  647. HTREEITEM hChild = m_treeView.InsertItem(strChild,4,4,tSTTreeInfo.hPort);
  648. tSTTreeInfo.vthChild.push_back(hChild);
  649. }
  650. }
  651. *it_tree = tSTTreeInfo;
  652. }
  653. }
  654. GetDlgItem(IDC_BUTTON2)->EnableWindow();//测试
  655. }
  656. void CRunTestDlg::OnBnClickedButton2()// 删除选择;
  657. {
  658. // TODO: 在此添加控件通知处理程序代码
  659. HTREEITEM hChildItem = m_treeView.GetSelectedItem();
  660. HTREEITEM hParantItem = m_treeView.GetParentItem(hChildItem);
  661. CObjectdepot tag;
  662. tag.SetDevicesDepotPath(m_strDepotPath);
  663. tag.SetRuntimeDevicesDepotPath(m_strRutDepotPath);
  664. //if ( hParantItem == NULL) // 根结点,该串口下的所有设备都删除;
  665. if( m_treeView.GetParentItem(hParantItem) == NULL )
  666. {
  667. CString strPort = m_treeView.GetItemText(hChildItem);
  668. strPort = strPort.Mid(3);
  669. tag.RemoveSubElement(atoi(strPort.GetBuffer()));
  670. vector <STTreeInfo>::iterator it;
  671. for ( it = vtSTTreeInfo.begin(); it != vtSTTreeInfo.end();it++ )
  672. {
  673. STTreeInfo tTreeInfo = *it;
  674. if ( tTreeInfo.hPort != hChildItem )
  675. continue;
  676. vtSTTreeInfo.erase(it);
  677. m_treeView.DeleteItem(tTreeInfo.hPort);
  678. break;
  679. }
  680. if ( m_treeView.GetCount() == 0)
  681. {
  682. GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);//测试
  683. GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);//测试
  684. }
  685. return;
  686. }
  687. CString strPort = m_treeView.GetItemText(hParantItem);
  688. CString strAddr = m_treeView.GetItemText(hChildItem);
  689. strPort = strPort.Mid(3);
  690. int iIndex = strAddr.FindOneOf(":");
  691. strAddr = strAddr.Mid(5,iIndex-5);
  692. tag.RemoveSubElement(atoi(strPort.GetBuffer()), atoi(strAddr.GetBuffer()));
  693. strPort.ReleaseBuffer();
  694. strAddr.ReleaseBuffer();
  695. BOOL bOver = FALSE;
  696. vector <STTreeInfo>::iterator it;
  697. for ( it = vtSTTreeInfo.begin(); it != vtSTTreeInfo.end();it++ )
  698. {
  699. STTreeInfo tTreeInfo = *it;
  700. if ( tTreeInfo.hPort != hParantItem )
  701. continue;
  702. int Sum = tTreeInfo.vthChild.size();
  703. HTREEITEM hChild;
  704. vector <HTREEITEM>::iterator itChild;
  705. for ( itChild = tTreeInfo.vthChild.begin(); itChild != tTreeInfo.vthChild.end();)
  706. {
  707. hChild = *itChild;
  708. if ( hChild == hChildItem)
  709. {
  710. itChild = tTreeInfo.vthChild.erase(itChild);
  711. *it = tTreeInfo;
  712. m_treeView.DeleteItem(hChildItem);
  713. bOver = TRUE;
  714. Sum = tTreeInfo.vthChild.size();
  715. //goto End;
  716. break;
  717. }else
  718. {
  719. itChild++;
  720. }
  721. }
  722. if ( Sum == 0 )
  723. {
  724. vtSTTreeInfo.erase(it);
  725. m_treeView.DeleteItem(tTreeInfo.hPort);
  726. break;
  727. }
  728. if ( bOver )
  729. break;
  730. }
  731. //End:
  732. //;
  733. if ( m_treeView.GetCount() == 0)
  734. {
  735. GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);//停止
  736. GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);//测试
  737. }
  738. }
  739. void CRunTestDlg::OnBnClickedButton3()// 测试运行;
  740. {
  741. CObjectdepot tag;
  742. tag.SetDevicesDepotPath(m_strDepotPath);
  743. tag.SetRuntimeDevicesDepotPath(m_strRutDepotPath);
  744. #if 0
  745. vector<STRunComInfo> vtRunComInfo;
  746. tag.GetAllSendCommand(vtRunComInfo);
  747. STRunComInfo tRunComInfo;
  748. vector <STRunComInfo>::iterator it;
  749. for ( it = vtRunComInfo.begin(); it != vtRunComInfo.end(); it++ )
  750. {
  751. tRunComInfo = *it;
  752. pSerialImpl->OpenSerialPort(
  753. tRunComInfo.iPort,
  754. tRunComInfo.tRunPhysical.iRate,
  755. tRunComInfo.tRunPhysical.iDBit,
  756. tRunComInfo.tRunPhysical.iSBit,
  757. tRunComInfo.tRunPhysical.iPaty,
  758. tRunComInfo.tRunPhysical.iRsTm,
  759. tRunComInfo.tRunPhysical.iIntl);
  760. STSendCommand tSendCommand;
  761. vector<STSendCommand>::iterator itChild;
  762. for( itChild = tRunComInfo.vtSendCommand.begin(); itChild != tRunComInfo.vtSendCommand.end(); itChild++)
  763. {
  764. tSendCommand = *itChild;
  765. LOG4C((LOG_NOTICE,"插入命令:COM%d::%d",tRunComInfo.iPort,tSendCommand.iAddr));
  766. pSerialImpl->InserCommand(tRunComInfo.iPort,tSendCommand.iAddr,tSendCommand.bySend,tSendCommand.iSLen,tSendCommand.szMark,tSendCommand.szCheck,tSendCommand.bRecv);
  767. ZeroMemory(&tSendCommand,sizeof(STSendCommand));
  768. }
  769. pSerialImpl->AutoCollect(tRunComInfo.iPort);
  770. }
  771. #endif
  772. #if 1
  773. if ( m_nSelectPort == -1 || m_nSelectPort == 0)
  774. {
  775. MessageBox("串口不存在");
  776. return;
  777. }
  778. STRunComInfo tRunComInfo;
  779. tag.GetSendCommand(m_nSelectPort,m_nSelectAddr,tRunComInfo);
  780. BOOL bRet = pSerialImpl->OpenSerialPort(
  781. tRunComInfo.iPort,
  782. tRunComInfo.tRunPhysical.iRate,
  783. tRunComInfo.tRunPhysical.iDBit,
  784. tRunComInfo.tRunPhysical.iSBit,
  785. tRunComInfo.tRunPhysical.iPaty,
  786. tRunComInfo.tRunPhysical.iRsTm,
  787. tRunComInfo.tRunPhysical.iIntl);
  788. if ( bRet == FALSE)
  789. {
  790. MessageBox("串口打开失败,可能被占用或不存在");
  791. return;
  792. }
  793. STSendCommand tSendCommand;
  794. vector<STSendCommand>::iterator itChild;
  795. for( itChild = tRunComInfo.vtSendCommand.begin(); itChild != tRunComInfo.vtSendCommand.end(); itChild++)
  796. {
  797. tSendCommand = *itChild;
  798. //LOG4C((LOG_NOTICE,"插入命令:COM%d::%d",tRunComInfo.iPort,tSendCommand.iAddr));
  799. pSerialImpl->InserCommand(tRunComInfo.iPort,tSendCommand.iAddr,tSendCommand.bySend,tSendCommand.iSLen,tSendCommand.szMark,tSendCommand.szCheck,tSendCommand.bRecv);
  800. ZeroMemory(&tSendCommand,sizeof(STSendCommand));
  801. }
  802. pSerialImpl->AutoCollect(tRunComInfo.iPort);
  803. #endif
  804. // [3/26/2013 Zero.t]
  805. GetDlgItem(IDC_BUTTON1)->EnableWindow(FALSE);//添加
  806. GetDlgItem(IDC_BUTTON2)->EnableWindow(FALSE);//删除
  807. GetDlgItem(IDC_BUTTON3)->EnableWindow(FALSE);//测试
  808. GetDlgItem(IDC_BUTTON5)->EnableWindow(FALSE);//修改串口属性
  809. GetDlgItem(IDC_BUTTON4)->EnableWindow(TRUE);//停止
  810. m_bRunTest = TRUE;
  811. // [3/26/2013 Zero.t]
  812. TRACE("+++++++++++");
  813. }
  814. /*****************************************************************************
  815. * 写入日志文件
  816. * 函 数 名:WriteLogTxt
  817. * 功 能 写入日志
  818. * 说 明:
  819. * 参 数:
  820. * 创 建 人:fjf
  821. * 创建时间:2009-09-09
  822. * 修 改 人:
  823. * 修改时间:
  824. *****************************************************************************/
  825. bool CRunTestDlg::WriteLogTxt(/*CString key, CString time,*/ CString value)
  826. {
  827. //读写文件全名
  828. //CFileException &e;
  829. if (m_sFullName == _T(""))
  830. {
  831. AfxMessageBox("请设置日志保存路径!");
  832. return FALSE;
  833. }
  834. //操作文件
  835. // try
  836. // {
  837. m_sfFile.Open(m_sFullName,CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite);
  838. m_sfFile.SeekToEnd();
  839. //m_sfFile.WriteString(time + _T("/r/n"));
  840. //m_sfFile.WriteString(value + _T("/r/n"));
  841. m_sfFile.WriteString( value );
  842. m_sfFile.Close();
  843. /*}*/
  844. // catch (CFileException &e)
  845. // {
  846. // CString error;
  847. // error.Format(_T("%d"),e.m_cause);
  848. // AfxMessageBox(_T("无法写入文件!错误码:" + error));
  849. // return false;
  850. // }
  851. return true;
  852. }
  853. /*****************************************************************************
  854. * 读取日志
  855. * 函 数 名:ReadLogTxt
  856. * 功 能 读取日志内容
  857. * 说 明:
  858. * 参 数:key:读取键
  859. * rlist:日志列表控件
  860. * 创 建 人:fjf
  861. * 创建时间:2009-09-09
  862. * 修 改 人:
  863. * 修改时间:
  864. *****************************************************************************/
  865. CString CRunTestDlg::ReadLogTxt(CString key,CListCtrl&rlist)
  866. {
  867. //读写文件全名
  868. CString value ;//返回值
  869. CString myStr = _T("");
  870. CFileException e;
  871. // try
  872. // {
  873. //打开文档
  874. if (!m_sfFile.Open(m_sFullName,CFile::modeCreate | CFile::modeNoTruncate| CFile::modeRead ,&e))
  875. {
  876. CString error;
  877. error.Format(_T("%d"),e.m_cause);
  878. AfxMessageBox(_T("没有日志读取文件!错误码:" + error));
  879. return _T("");
  880. }
  881. while (this->m_sfFile.ReadString(value))
  882. {
  883. //读入并保存字符
  884. myStr = value;
  885. m_sfFile.ReadString(value);
  886. myStr += value;
  887. //添加项目
  888. rlist.InsertItem(0,_T(""),1);
  889. rlist.SetItemText(0,1,myStr);
  890. }
  891. //关闭文件句柄
  892. m_sfFile.Close();
  893. // }
  894. // catch (CFileException &e)
  895. // {
  896. // CString error;
  897. // error.Format(_T("%d"),e.m_cause);
  898. // AfxMessageBox(_T("无法读取文件!错误码:" + error));
  899. // return _T("");
  900. // }
  901. return myStr;
  902. }
  903. void CRunTestDlg::OnBnClickedButton4()//停止测试;
  904. {
  905. // TODO: 在此添加控件通知处理程序代码
  906. pSerialImpl->CloseSerialPort();
  907. // [3/26/2013 Zero.t]
  908. GetDlgItem(IDC_BUTTON1)->EnableWindow(TRUE);//添加
  909. GetDlgItem(IDC_BUTTON2)->EnableWindow(TRUE);//删除
  910. GetDlgItem(IDC_BUTTON3)->EnableWindow(TRUE);//测试
  911. //(CWnd*)GetDlgItem(IDC_BUTTON5)->EnableWindow(TRUE);//修改串口属性
  912. GetDlgItem(IDC_BUTTON4)->EnableWindow(FALSE);//停止
  913. // 清空列表;
  914. //m_richedit.SetWindowText("");
  915. m_bRunTest = FALSE;
  916. // [3/26/2013 Zero.t]
  917. }
  918. void CRunTestDlg::OnBnClickedButton5()
  919. {
  920. // TODO: 在此添加控件通知处理程序代码
  921. CString str;
  922. GetDlgItemText(IDC_BUTTON5,str);
  923. if ( str == "修改串口属性" )
  924. {
  925. GetDlgItem(IDC_EDIT1)->EnableWindow(TRUE);
  926. GetDlgItem(IDC_EDIT10)->EnableWindow(TRUE);
  927. GetDlgItem(IDC_EDIT11)->EnableWindow(TRUE);
  928. SetDlgItemText(IDC_BUTTON5,"应用串口属性");
  929. }else if ( str == "应用串口属性" )
  930. {
  931. CObjectdepot tag;
  932. tag.SetDevicesDepotPath(m_strDepotPath);
  933. tag.SetRuntimeDevicesDepotPath(m_strRutDepotPath);
  934. GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
  935. GetDlgItem(IDC_EDIT10)->EnableWindow(FALSE);
  936. GetDlgItem(IDC_EDIT11)->EnableWindow(FALSE);
  937. int iRate = GetDlgItemInt(IDC_EDIT1);
  938. int iRstm = GetDlgItemInt(IDC_EDIT10);
  939. int iAFre = GetDlgItemInt(IDC_EDIT11);
  940. tag.ModifySubPhysical(m_nSelectPort,iRate,-1,-1,-1,iRstm,iAFre);
  941. SetDlgItemText(IDC_BUTTON5,"修改串口属性");
  942. }
  943. }
  944. void CRunTestDlg::OnBnClickedButton6()
  945. {
  946. // TODO: 在此添加控件通知处理程序代码
  947. m_richedit.SetWindowText("");
  948. }
  949. void CRunTestDlg::OnOK()
  950. {
  951. // TODO: 在此添加专用代码和/或调用基类
  952. //CDialog::OnOK();
  953. }