HRESULT CTryData4Dlg::OnClickOnce(IHTMLElement* pElement) { if(m_State == RUNNING) return S_OK; if(m_sDataUrl.IsEmpty()) //no result has been generated yet, so can't do re-test, return S_OK; CString sel = this->GetAttribute(pElement,m_elemTypes[5]); if(sel.IsEmpty() || (sel.Find("ONCE") != 0) || (m_sDataSel.Find("测量结果") != 0)) //only running test scheme can be re-test return S_OK; //title will contain two part, one is function name, another is parameter sel = this->GetAttribute(pElement,m_elemTypes[3]); if(sel.IsEmpty()) return this->GetEventError(pElement,m_elemTypes[3]); CString func=sel.Left(sel.Find(':')); sel = sel.Right(sel.GetLength()-(func.GetLength()+1)); m_Program.m_iStackDepth = 0; if(m_Program.SetFunctionPointer(func) && m_Program.SetFunctionParameter(sel)) { OnMouseOutOnce(pElement); CString str("暂停测量"); g_TesterConf.m_iRetestID = -1; m_State = RUNNING; SetElementText("pause",str.AllocSysString()); m_bAddData = true; } return S_OK; }
// CTryData4Dlg 消息处理程序 HRESULT CTryData4Dlg::OnClickCmd(IHTMLElement* pElement) { if(m_State == RUNNING) return S_OK; if(m_sDataUrl.IsEmpty()) //no result has been generated yet, so can't do re-test, return S_OK; CString sel = this->GetAttribute(pElement,m_elemTypes[5]); if(sel.IsEmpty() || (sel.Find("CMD") != 0) || (m_sDataSel.Find("测量结果") != 0)) //only running test scheme can be re-test return S_OK; sel = this->GetAttribute(pElement,m_elemTypes[2]); if(sel.IsEmpty()) return this->GetEventError(pElement,m_elemTypes[2]); int pos = atoi(sel.Right(sel.GetLength()-1)); if(pos <= 0) return S_OK; if(IDYES == ::AfxMessageBox("确定要重测吗?",MB_YESNO)) { if(m_Program.SetFunctionPointer("MAIN")) { CString str("暂停测量"); g_TesterConf.m_iRetestID = pos; m_State = RUNNING; SetElementText("pause",str.AllocSysString()); m_bAddData = true; } } return S_OK; }
void cListBox::SetElementText(int ID, string data) { string datarray[] = { data }; SetElementText(ID, datarray, 1); }
void CTryData4Dlg::OnTimer(UINT nIDEvent) { static bool bTwice = false; if(m_currPage == 0) //is quiting return; if(bTwice) return; bTwice = true; SWISTATUS ss; CDHtmlDialog::OnTimer(nIDEvent); if (nIDEvent == 1) { CString status; m_CheckTicks++; if(m_CheckTicks == 1){ status.Format("正在进行License检查"); SetElementText(_T("checking"),status.AllocSysString()); } if(m_CheckTicks == 2){ if(!CheckLicense()) { MessageBox("本软件无法在本机上使用,请联系供应商"); m_currPage = 0; ::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0); } status.Format("正在连接控制板"); SetElementText(_T("checking"),status.AllocSysString()); } if(m_CheckTicks == 3){ if(!m_Switch.Open(SPORT_SWITCH)) { MessageBox("连接控制板失败","电阻校验",MB_OK); m_currPage = 0; ::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0); } status.Format("正在连接纳伏计"); SetElementText(_T("checking"),status.AllocSysString()); } if(m_CheckTicks == 4){ if(!m_Navmeter.Open(SPORT_NAVMETER)) { MessageBox("连接纳伏计失败","电阻校验",MB_OK); m_currPage = 0; ::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0); } status.Format("正在连接数据库"); SetElementText(_T("checking"),status.AllocSysString()); } if(m_CheckTicks == 5){ if(!SqlInit(g_Path+_T("\\Data\\test.mdb"))) { MessageBox("连接数据库失败","电阻校验",MB_OK); m_currPage = 0; ::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0); } status.Format("正在装载程序"); SetElementText(_T("checking"),status.AllocSysString()); } if(m_CheckTicks == 6){ if(!m_Program.InstallScheme(PathQuery2(CLSGROUP,IDTYPE))) { MessageBox("程序装载失败","电阻校验",MB_OK); m_currPage = 0; ::AfxGetMainWnd()->PostMessage(WM_CLOSE,1,0); } } if(m_CheckTicks == 7){ m_currPage = INDEX; Handler("init",m_sRegSel,m_sRegLst,true); // m_currPage = CONFIG; Handler("init",m_sConfSel,m_sConfLst,true); // m_currPage = DATA; Handler("init",m_sDataSel,m_sDataLst,true); // m_currPage = JIAOHE; Handler("init",m_sJhSel,m_sJhLst,true); KillTimer(1); m_currPage = INDEX; m_cmdStep = CMD_LOADHTML; //create the chart dialog m_pChartDlg = new CChartDlg(this); m_pChartDlg->Create(IDD_DIALOG2,this); m_pChartDlg->ShowWindow(SW_HIDE); //create the wait dialog m_pWaitDlg = new CWaitDialog(this); m_pWaitDlg->Create(IDD_DIALOG3,this); m_pWaitDlg->ShowWindow(SW_HIDE); SetTimer(2,30,NULL); } } if(nIDEvent == 2) { if(m_cmdStep == CMD_INITHTML){ IHTMLElement* newElement; if((m_currPage == INDEX) && (S_OK == GetElement("idvals",&newElement))) { m_sRegvals = this->GetAttribute(newElement,m_elemTypes[1]); Handler("init",m_sRegSel,m_sRegLst); } if((m_currPage == CONFIG) && (S_OK == GetElement("idvals",&newElement))) { m_sConfigvals = this->GetAttribute(newElement,m_elemTypes[1]); Handler("init",m_sConfSel,m_sConfLst); } if((m_currPage == JIAOHE) && (S_OK == GetElement("idvals",&newElement))) { m_sJhvals = this->GetAttribute(newElement,m_elemTypes[1]); Handler("init",m_sJhSel,m_sJhLst); } if((m_currPage == DATA) && (S_OK == GetElement("idvals",&newElement))) { if(g_TesterConf.m_Ps.iTimes == 0) //come to the data page directly from reg page { m_currPage = CONFIG; m_sConfigvals = CString(",cklt9,rstdlt9,alphalt9,betalt9,cklt8,rstdlt8,alphalt8,betalt8,cklt1,rstdlt1,alphalt1,betalt1,cklt2,rstdlt2,alphalt2,betalt2,cklt3,rstdlt3,alphalt3,betalt3,cklt4,rstdlt4,alphalt4,betalt4,cklt5,rstdlt5,alphalt5,betalt5,cklt6,rstdlt6,alphalt6,betalt6,cklt7,rstdlt7,alphalt7,betalt7,confdxcl,zdpselect,lcselect,confcysj,confcycs,confwd,"); Handler("init",m_sConfSel,m_sConfLst,true); m_currPage = JIAOHE; m_sJhvals = CString(",jhsel19,jhsel18,jhsel17,jhsel16,jhsel15,jhsel14,jhsel13,jhsel12,jhsel11,jhsel10,jhsel9,jhsel8,jhsel7,jhsel6,jhsel5,jhsel4,jhsel3,jhsel2,jhsel1,jhsel0,"); Handler("init",m_sJhSel,m_sJhLst,true); m_sJhvals.Empty(); m_currPage = DATA; } m_sDatavals = this->GetAttribute(newElement,m_elemTypes[1]); Handler("init",m_sDataSel,m_sDataLst); if(m_sDataLst.IsEmpty() || (m_sDataLst == " ,")) { InternalRoutines('9');//update value to page } Handler("update",m_sDataSel,m_sDataLst); } if(m_currPage == REPORT) { Handler("init",m_sReportSel,m_sReportLst); } m_cmdStep = CMD_IDLEHTML; } if((m_cmdStep == CMD_CONTHTML)||(m_cmdStep == CMD_CONTHTML2)){ int group = -1; switch(m_currPage) { case JIAOHE: group=IDJH;break; case DATA: group=IDTEST;break; default: break; } if(group >= 0) { CStdioFile csf; if(csf.Open(g_Path+CString(PathQuery2(CLSJS,group)),CFile::modeRead)) { CString content(""),line; while(csf.ReadString(line)) { content += line; } csf.Close(); SetElementHtml("cont",content.AllocSysString()); } } if(m_cmdStep == CMD_CONTHTML2) m_cmdStep = CMD_INITHTML; else m_cmdStep = CMD_CONTHTML2; } if(m_cmdStep == CMD_LOADHTML && m_currPage > 0){ LoadFromResource(m_currPage); m_cmdStep = CMD_CONTHTML; } CString str; CTime t = CTime::GetCurrentTime(); str = t.Format("%H:%M:%S"); SetElementText("curtime",str.AllocSysString()); if(m_State == SUSPEND) m_State = IDLE; if(m_State == BEERROR) m_State = SUSPEND; if((m_State == IDLE)||(m_State == BEERROR)) { if(m_CheckTicks++ > CHECKWAIT) { m_CheckTicks = 0; #if 1 SWISTATUS ss = m_Switch.GetSwitchStatus(); while(ss.bOl1) { MessageBox("发生过载","电阻校验",MB_OK); ss = m_Switch.GetSwitchStatus(); } CString str; str.Format("外标准[%s],被测[%s]",ss.bKN[0]?"接通":"未接",ss.bRn?"接通":"未接"); SetElementText("swistatus",str.AllocSysString()); #endif; } } if(m_State == RUNNING) { char type; CString line; // m_State = SUSPEND; while((m_Program.m_iStackDepth > 0) ) { if(m_Program.NextLine(type,line))//loop until some pausable command { if((type == 'z') || (type == 'd') || (type == 'w')) { HandleCommand(type,line); continue; } break; } } if(m_Program.m_iStackDepth <= 0) { Abort(); }else{ if(!HandleCommand(type,line)) { m_State = BEERRO; Abort(); } } } } bTwice = false; return; }
HRESULT CTryData4Dlg::OnClickUrl(IHTMLElement* pElement) { CString sel = this->GetAttribute(pElement,m_elemTypes[0]); UINT newPage=0xffff; while(m_cmdStep != CMD_IDLEHTML) DoEvents(); if(sel.Find("#page_") > 0) { if(m_State == RUNNING) return S_OK; if(m_bAddData) InternalRoutines('9'); //update the 测量结果 if(sel.Find("#page_reg") > 0) newPage = INDEX; if(sel.Find("#page_data") > 0) newPage = DATA; if(sel.Find("#page_config")>0) newPage = CONFIG; if(sel.Find("#page_jh")>0) newPage = JIAOHE; if(sel.Find("#page_report")>0) newPage = REPORT; if(sel.Find("#page_quit") > 0 ) { if(IDYES != MessageBox("是否确定退出?","电阻校验",MB_YESNO)) return S_OK; m_currPage = 0; PostMessage(WM_CLOSE,1,0); return S_OK; } if((newPage != 0xffff)&&(newPage != m_currPage)) { m_cmdStep = CMD_LOADHTML; m_currPage = newPage; } } if(sel.Find("prg_") > 0) { if(sel.Find("#prg_start") > 0) { if(m_State == RUNNING) { CString str("暂停测量"); SetElementText("pause",str.AllocSysString()); if(IDNO == MessageBox("是否继续测量?","电阻校验",MB_YESNO)) { m_State = BEERROR; Abort(); } return S_OK; } if(m_bAddData) InternalRoutines('9'); //update the 测量结果 if(!m_Program.InstallScheme(PathQuery2(CLSGROUP,IDTYPE))) { MessageBox("程序装载失败","电阻校验",MB_OK); return S_OK; } if(m_Program.SetFunctionPointer("MAIN")) { CString str("暂停测量"); m_pChartDlg->DeleteAll(); g_TesterConf.m_iRetestID = -1; m_State = RUNNING; SetElementText("pause",str.AllocSysString()); m_bAddData = true; }; } } if(sel.Find("data_") > 0) { if(sel.Find("data_chart") > 0) { m_pChartDlg->ShowWindow(SW_NORMAL); } if(sel.Find("data_modnbz") > 0) { if(m_State == RUNNING) return S_OK; InternalRoutines('a'); AfxMessageBox("内标准设置修改成功"); } } return S_OK; }