// DevOperator.cpp: implementation of the CDevOperator class. // ////////////////////////////////////////////////////////////////////// #include "geomative.h" #include "DevOperator.h" #include "navdevview.h" #include "Constant.h" #include "checkupdate.h" #include "appdevview.h" #include "appdevolview.h" #include "appdevolgrlistview.h" #include "appdevolacview.h" #include "appdevdetaillistview.h" #include "appdatatdlistview.h" #include "InputPasswordDial.h" #include "DialUpgDeviceInfo.h" #ifdef _DEBUG #undef THIS_FILE static char THIS_FILE[]=__FILE__; #define new DEBUG_NEW #endif extern CGeoMativeApp theApp; extern CString g_szMacAddress; extern int g_UIOffset; ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// extern HHOOK hHook; extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam); extern BOOL GetSubStringInHeadAndTail(const CString& szSource, CString& szSub, const CString& szHead, const CString& szTail); extern CString GetGrCodeText(int iCode); extern int g_iUILanguage; extern DWORD g_dwDeviceSN; extern DWORD g_dwPLCID; CDevOperator::CDevOperator(_ConnectionPtr& pConnection) { ASSERT(NULL != pConnection); m_pConnection = pConnection; m_hOLRegDevRootItem = NULL; m_hOLNewDevRootItem = NULL; m_hFLDevRootItem = NULL; m_strLocalFilePath = _T(""); m_strProCN = _T(""); m_strTzCN = _T(""); } CDevOperator::~CDevOperator() { } bool CDevOperator::InitialNavDevView(CNavDevView* pNavDevView) { ASSERT(NULL != pNavDevView); _RecordsetPtr pRecDev = NULL; HTREEITEM hOLRegDevItem = NULL; // HTREEITEM hOLRegDevRootItem = NULL; HTREEITEM hOLActDevItem = NULL; HTREEITEM hOLActDevRootItem = NULL; HTREEITEM hOLNewDevItem = NULL; // HTREEITEM hOLNewDevRootItem = NULL; HTREEITEM hOLDevRootItem = NULL; HTREEITEM hFLRegDevItem = NULL; HTREEITEM hFLRegDevRootItem = NULL; HTREEITEM hFLActDevItem = NULL; HTREEITEM hFLActDevRootItem = NULL; // HTREEITEM hFLDevRootItem = NULL; DWORD dwHandle = (DWORD)VAL_ZERO; UINT uImageState = (UINT)VAL_ZERO; CString strRootLabel; int iIndex = (int)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CDevice* pDev = NULL; pRecDev.CreateInstance(_uuidof(Recordset)); CTreeCtrl& devTree = pNavDevView->m_devTree; devTree.DeleteAllItems(); uImageState = m_stateProcessor.ChangeToImageState((UINT)VAL_ZERO); strRootLabel.Empty(); strRootLabel.LoadString(IDS_ONLINE_DEV+g_UIOffset); hOLDevRootItem = devTree.InsertItem((LPCTSTR)strRootLabel); devTree.SetItemData(hOLDevRootItem, (DWORD)VAL_ZERO); devTree.SetItemState(hOLDevRootItem, TVIS_BOLD, TVIS_BOLD); CString strLog; strLog.Format(_T("zm:插入在线设备 根节点 名:%s\n"), strRootLabel); OutputDebugString(strLog); strRootLabel.Empty(); strRootLabel.LoadString(IDS_REGISTER_DEV+g_UIOffset); m_hOLRegDevRootItem = devTree.InsertItem((LPCTSTR)strRootLabel, hOLDevRootItem); devTree.SetItemData(m_hOLRegDevRootItem, (DWORD)VAL_ZERO); devTree.SetItemState(m_hOLRegDevRootItem, TVIS_BOLD, TVIS_BOLD); strLog.Format(_T("zm:插入在线设备 子节点 名:%s------\n"), strRootLabel); OutputDebugString(strLog); strRootLabel.Empty(); strRootLabel.LoadString(IDS_NEW_DEV+g_UIOffset); m_hOLNewDevRootItem = devTree.InsertItem((LPCTSTR)strRootLabel, hOLDevRootItem); strLog.Format(_T("zm:插入在线设备 子节点 名:%s\n"), strRootLabel); OutputDebugString(strLog); devTree.SetItemData(m_hOLNewDevRootItem, (DWORD)VAL_ZERO); devTree.SetItemState(m_hOLNewDevRootItem, TVIS_BOLD, TVIS_BOLD); devTree.Expand(hOLDevRootItem, TVE_EXPAND); strRootLabel.Empty(); strRootLabel.LoadString(IDS_OFFLINE_DEV+g_UIOffset); m_hFLDevRootItem = devTree.InsertItem((LPCTSTR)strRootLabel); dwHandle = m_handleProcessor.GenerateHandle((UINT)VAL_ZERO, PZ_STYLE_DEV); devTree.SetItemData(m_hFLDevRootItem, (DWORD)VAL_ZERO); devTree.SetItemState(m_hFLDevRootItem, TVIS_BOLD, TVIS_BOLD); strLog.Format(_T("zm:插入 根节点 名:%s\n"), strRootLabel); OutputDebugString(strLog); /* strRootLabel.Empty(); strRootLabel.LoadString(IDS_ACCTIVE_DEV); hFLActDevRootItem = devTree.InsertItem((LPCTSTR)strRootLabel, hFLDevRootItem); dwHandle = m_handleProcessor.GenerateHandle((UINT)VAL_ZERO, PZ_STYLE_DEV_ACT); devTree.SetItemData(hFLActDevRootItem, dwHandle); devTree.SetItemState(hFLActDevRootItem, TVIS_BOLD, TVIS_BOLD); strRootLabel.Empty(); strRootLabel.LoadString(IDS_REGISTER_DEV); m_hFLRegDevRootItem = devTree.InsertItem((LPCTSTR)strRootLabel, hFLDevRootItem); dwHandle = m_handleProcessor.GenerateHandle((UINT)VAL_ZERO, PZ_STYLE_DEV_REG); devTree.SetItemData(hFLRegDevRootItem, dwHandle); devTree.SetItemState(hFLRegDevRootItem, TVIS_BOLD, TVIS_BOLD); */ devTree.Expand(m_hFLDevRootItem, TVE_EXPAND); /* uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_OFFLINE); pRecDev->Open(_T("select ID,DEname,SN from device"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText); while ((short)VAL_ZERO == pRecDev->adoEOF) { hFLActDevItem = devTree.InsertItem(pRecDev->GetCollect(_T("SN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("SN")), m_hFLDevRootItem); dwHandle = m_handleProcessor.GenerateHandle((DWORD)pRecDev->GetCollect(_T("ID")).ulVal, PZ_STYLE_DEV_FL); devTree.SetItemData(hFLActDevItem, dwHandle); devTree.SetItemState(hFLActDevItem, uImageState, TVIS_STATEIMAGEMASK); dwHandle = (DWORD)VAL_ZERO; pRecDev->MoveNext(); } pRecDev->Close(); */ devTree.Expand(m_hFLDevRootItem, TVE_EXPAND); //获取远端在线设备 std::set setRemoteDev = theApp.m_pDevManager->GetRemoteDeviceInfo(); CString strSN; int iDevStyle=0; std::set::iterator iter; for (iter = setRemoteDev.begin(); iter != setRemoteDev.end(); iter++) { strSN.Empty(); if (iter->ucDevType == EN_DEV_GD10) { strSN.Format(_T("SN%u(Remote)"),iter->uiDevID); g_dwDeviceSN = iter->uiDevID; strLog.Format(_T("zm: 当前全局 DevSN=%d\n"), g_dwDeviceSN); //OutputDebugString(strLog); CFileOperTools::GetInstance()->WriteComLog(strLog); iDevStyle = PZ_STYLE_REMOTE_GD10; } else if(iter->ucDevType == EN_DEV_PLC) { strSN.Format(_T("PLC%u(Remote)"),iter->uiDevID); g_dwPLCID = iter->uiDevID; strLog.Format(_T("zm: 当前全局PLCID = %d\n"), g_dwPLCID); //OutputDebugString(strLog); CFileOperTools::GetInstance()->WriteComLog(strLog); iDevStyle = PZ_STYLE_REMOTE_PLC; } else { strSN.Format(_T("Unknow device type(%d)"),iter->ucDevType); MessageBoxEx(NULL, strSN, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); continue; } hOLRegDevItem = devTree.InsertItem(strSN, m_hOLRegDevRootItem); CString strLog; strLog.Format(_T("zm:CDevOperator::InitialNavDevView 插入注册设备 子节点%s\n"), strSN); OutputDebugString(strLog); if(iDevStyle == PZ_STYLE_REMOTE_GD10 || iDevStyle == PZ_STYLE_REMOTE_PLC) dwHandle = m_handleProcessor.GenerateNewHandle((DWORD)iter->uiDevID, iDevStyle); else dwHandle = m_handleProcessor.GenerateHandle((DWORD)iter->uiDevID, iDevStyle); devTree.SetItemData(hOLRegDevItem, dwHandle); // devTree.SetItemState(hOLRegDevItem, uImageState, TVIS_STATEIMAGEMASK); } // devTree.Expand(m_hFLDevRootItem, TVE_EXPAND); ExpandTree(&devTree, m_hOLRegDevRootItem); CPtrArray* pDevList = new CPtrArray; theApp.m_pDevManager->GetOLDevList(pDevList); iIndex = (int)VAL_ZERO; pDev = NULL; if ((int)VAL_ZERO != pDevList->GetSize()) { // pDev = (CDevice*)pDevList->GetAt(iIndex); // iIndex++; while (iIndex < pDevList->GetSize()) { pDev = NULL; pDev = (CDevice*)pDevList->GetAt(iIndex); if (NULL != pDev) { uImageState = m_stateProcessor.ChangeToImageState(pDev->m_uState); if (PZ_STATE_NEW == pDev->m_uState) { hOLNewDevItem = devTree.InsertItem(pDev->m_szDevSN, m_hOLNewDevRootItem); CString strLog; strLog.Format(_T("zm:插入 新设备 子节点%s\n"), pDev->m_szDevSN); OutputDebugString(strLog); dwHandle = m_handleProcessor.GenerateHandle((DWORD)pDev->m_dwID, PZ_STYLE_DEV); devTree.SetItemData(hOLNewDevItem, dwHandle); devTree.SetItemState(hOLNewDevItem, uImageState, TVIS_STATEIMAGEMASK); } else if (PZ_STATE_ONLINE == pDev->m_uState) { /* pUpdate = NULL; pUpdate = new Ccheckupdate(&pDev->m_sComPort); try { if (pUpdate->checkDevice()) { hOLRegDevItem = devTree.InsertItem(pDev->m_szDevSN+_T("*"), m_hOLRegDevRootItem); } else { hOLRegDevItem = devTree.InsertItem(pDev->m_szDevSN, m_hOLRegDevRootItem); } } catch (...) { hOLRegDevItem = devTree.InsertItem(pDev->m_szDevSN, m_hOLRegDevRootItem); } delete pUpdate; */ hOLRegDevItem = devTree.InsertItem(pDev->m_szDevSN, m_hOLRegDevRootItem); CString strLog; strLog.Format(_T("zm:CDevOperator::InitialNavDevView( 插入注册设备 子节点%s"), pDev->m_szDevSN); OutputDebugString(strLog); dwHandle = m_handleProcessor.GenerateHandle((DWORD)pDev->m_dwID, PZ_STYLE_DEV); devTree.SetItemData(hOLRegDevItem, dwHandle); devTree.SetItemState(hOLRegDevItem, uImageState, TVIS_STATEIMAGEMASK); } } iIndex++; } devTree.Expand(m_hOLRegDevRootItem, TVE_EXPAND); devTree.Expand(m_hOLNewDevRootItem, TVE_EXPAND); } theApp.m_pDevManager->GetFLDevList(pDevList); uImageState = m_stateProcessor.ChangeToImageState(PZ_STATE_OFFLINE); iIndex = (int)VAL_ZERO; pDev = NULL; if ((int)VAL_ZERO != pDevList->GetSize()) { // pDev = (CDevice*)pDevList->GetAt(iIndex); while (iIndex < pDevList->GetSize()) { pDev = NULL; pDev = (CDevice*)pDevList->GetAt(iIndex); if (NULL != pDev) { hFLRegDevItem = devTree.InsertItem(pDev->m_szDevSN ,m_hFLDevRootItem); CString strLog; strLog.Format(_T("zm: 插入离线设备 子节点%s\n"), pDev->m_szDevSN); OutputDebugString(strLog); dwHandle = m_handleProcessor.GenerateHandle((DWORD)pDev->m_dwID, PZ_STYLE_DEV); devTree.SetItemData(hFLRegDevItem, dwHandle); devTree.SetItemState(hFLRegDevItem, uImageState, TVIS_STATEIMAGEMASK); } iIndex++; } devTree.Expand(m_hFLDevRootItem, TVE_EXPAND); } delete pDevList; return true; } void CDevOperator::ShowFLDeviceInfo(DWORD dwDevHandle, CView *pAppFLDevView) { theApp.m_pDevManager->GetDevice(dwDevHandle)->ShowFLDetailInfo(((CAppDevDetailListView*)(((CAppDevView*)pAppFLDevView)->m_pDevDetailListView))->GetListCtrl()); theApp.m_pTdManager->ShowTdListByDev(dwDevHandle, ((CAppDataTdListView*)(((CAppDevView*)pAppFLDevView)->m_pDevContentListView))->GetListCtrl()); } void CDevOperator::ShowOLDeviceInfo(DWORD dwDevHandle, CView *pAppOLDevView) { DWORD dwDeID = (DWORD)VAL_ZERO; dwDeID = m_handleProcessor.GetIDFromHandle(dwDevHandle); CDevice* pDev = NULL; pDev = (CDevice*)theApp.m_pDevManager->GetDevice(dwDevHandle); pDev->ShowOLDetailInfo(((CAppDevDetailListView*)(((CAppDevOLView*)pAppOLDevView)->m_pDevOLDetailListView))->GetListCtrl()); pDev->ShowGRInfo(((CAppDevOLGRListView*)(((CAppDevOLView*)pAppOLDevView)->m_pDevOLGRListView))->GetListCtrl()); pDev->ShowACInfo(((CAppDevOLACView*)(((CAppDevOLView*)pAppOLDevView)->m_pDevOLACListView))->GetListCtrl()); // theApp.m_pTdManager->ShowTdListByDev(dwDevHandle, ((CAppDataTdListView*)(((CAppDevView*)pAppOLDevView)->m_pDevContentListView))->GetListCtrl()); } void CDevOperator::ExpandTree(CTreeCtrl* pTreeCtrl,HTREEITEM hItem) { HTREEITEM hChild,hNext,hParent; if((!hItem)||(!pTreeCtrl)) return; //存在则展开节点 pTreeCtrl->Expand(hItem,TVE_EXPAND); hChild = pTreeCtrl->GetNextItem(hItem,TVGN_CHILD); if(hChild) {//如果有子节点,展开子节点 ExpandTree(pTreeCtrl,hChild); } else {//没有子节点,寻找其兄弟节点 hNext = pTreeCtrl->GetNextItem(hItem,TVGN_NEXT); if(hNext) {//存在兄弟节点 ExpandTree(pTreeCtrl,hNext); } else {//不存在兄弟节点,继续找父节点 hParent = pTreeCtrl->GetParentItem(hItem); hNext = pTreeCtrl->GetNextItem(hParent,TVGN_NEXT); if(hNext) ExpandTree(pTreeCtrl,hNext); } } } UINT CDevOperator::DevieUpgrade(CNavDevView *pNavDevView) { HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szDevItem = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle); szDevItem = pNavDevView->m_devTree.GetItemText(hDevItem); // if (_T("*") == szDevItem.Mid(szDevItem.GetLength()-1, 1)) // { pDev = NULL; pDev = theApp.m_pDevManager->GetDeviceByID(dwDevID); if (NULL != pDev) { ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_SHOW_DEV_UPG_INFO, 0,0); DWORD dwScanThreadID = 0; HANDLE hScanThread = NULL; hScanThread = ::CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)StartDeviceUpgrade, (LPVOID)pDev, 0, &dwScanThreadID); if (INVALID_HANDLE_VALUE == hScanThread) { ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_CLEAR_DEV_UPG_INFO, 0,0); hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL); if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("创建线程失败")); else MessageBoxEx(NULL, _T("To create thread fail!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return FALSE; } CloseHandle(hScanThread); } else { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("解析设备信息失败")); else MessageBoxEx(NULL, _T("Parser device info failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return APP_FAIL; } return APP_SUCCESS; } UINT CDevOperator::ModifyDeviceParameter(CNavDevView *pNavDevView, CListCtrl &detailList) { HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szDevItem = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle); pDev = NULL; pDev = theApp.m_pDevManager->GetDeviceByID(dwDevID); if (NULL != pDev) { pDev->ModifyParameter(); pDev->ShowOLDetailInfo(detailList); } else { return APP_FAIL; } return APP_SUCCESS; } void CDevOperator::ShowCableHeadDlg(CNavDevView *pNavDevView) { HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szDevItem = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle); pDev = NULL; pDev = theApp.m_pDevManager->GetDeviceByID(dwDevID); if (NULL != pDev) { pDev->ShowCableHeadInfoDlg(); } } UINT CDevOperator::RefreshGRRec(CNavDevView *pNavDevView, CListCtrl &grList, int iItemIndex) { CString szCaption = _T(""); HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szSN = _T(""); int iSN = (int)VAL_ZERO; CString szRs = _T(""); // int iRs = (int)VAL_ZERO; // CString szDevSN = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); // szDevSN = pNavDevView->m_devTree.GetItemText(hDevItem); pDev = NULL; pDev = theApp.m_pDevManager->GetDevice(dwDevHandle); if (NULL != pDev) { if ((int)-5 == pDev->GetPoleCount()) { szCaption.Empty(); szCaption.LoadString(IDS_CAPTION_0002+g_UIOffset); hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL); AfxMessageBox(szCaption); return APP_FAIL; } if (TRUE == pDev->IsTheNumofPoleChanged()) { szCaption.Empty(); szCaption.LoadString(IDS_CAPTION_0001+g_UIOffset); hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL); AfxMessageBox(szCaption); return APP_FAIL; } else { szSN = grList.GetItemText(iItemIndex, 0); iSN = atoi(szSN); CStringArray strArray; strArray.RemoveAll(); if (TRUE == pDev->TestGRForPerPole(iSN, strArray)) { if (strArray.GetSize() < 4) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("TestGRForPerPole的结果格式错误")); else MessageBoxEx(NULL, _T("The result format of TestGRForPerPole is error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return APP_FAIL; } grList.SetItemText(iItemIndex, 3, strArray.GetAt(0)); grList.SetItemText(iItemIndex, 4, GetGrCodeText(atoi(strArray.GetAt(1)))); grList.SetItemText(iItemIndex, 5, strArray.GetAt(2)); grList.SetItemText(iItemIndex, 6, GetGrCodeText(atoi(strArray.GetAt(3)))); } } } else { return APP_FAIL; } return APP_SUCCESS; } UINT CDevOperator::RefreshAllGRRec(CNavDevView *pNavDevView, CListCtrl &grList) { CString szCaption = _T(""); HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szSN = _T(""); int iSN = (int)VAL_ZERO; CString szRs = _T(""); int iRs = (int)VAL_ZERO; // CString szDevSN = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); // szDevSN = pNavDevView->m_devTree.GetItemText(hDevItem); pDev = NULL; pDev = theApp.m_pDevManager->GetDevice(dwDevHandle); if (NULL != pDev) { if ((int)-5 == pDev->GetPoleCount()) { szCaption.Empty(); szCaption.LoadString(IDS_CAPTION_0002+g_UIOffset); hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL); AfxMessageBox(szCaption); return APP_FAIL; } else { pDev->DelGRInfo(); pDev->TestGRForAllPole(); pDev->GetGRInfo(); pDev->ShowGRInfo(grList); } } else { return APP_FAIL; } return APP_SUCCESS; } /* bool CDevOperator::GetTestTaskToDB(CDevice* pDev, CString strVesInfo) { // CString strHostTdFile = _T(""); // strHostTdFile.Format(_T("%s%s.xml"),strTzHostPathInfo,strVesInfo); // CString strShowInfo = _T(""); // if (TRUE != pDev->ReceiveFile(m_strLocalFilePath, strHostTdFile)) // { // strShowInfo.Format(_T("Receive td file %s.xml failed!"), strVesInfo); // AfxMessageBox(strShowInfo); // return false; // } // // strHostTdFile.Empty(); // strHostTdFile.Format(_T("%s%s.dat"),strTzHostPathInfo,strVesInfo); // strShowInfo.Empty(); // if (TRUE != pDev->ReceiveFile(m_strLocalFilePath, strHostTdFile)) // { // strShowInfo.Format(_T("Receive td file %s.dat failed!"), strVesInfo); // AfxMessageBox(strShowInfo); // return false; // } // // strHostTdFile.Empty(); // strHostTdFile.Format(_T("%s%s.org"),strTzHostPathInfo,strVesInfo); // strShowInfo.Empty(); // if (TRUE != pDev->ReceiveFile(m_strLocalFilePath, strHostTdFile)) // { // strShowInfo.Format(_T("Receive td file %s.org failed!"), strVesInfo); // AfxMessageBox(strShowInfo); // return false; // } CString strShow = _T(""); if (_T("VES") == strVesInfo.Left(3)) { if (TRUE != theApp.m_pTdManager->UploadCETdFromDev(m_strProCN, m_strTzCN, strVesInfo, pDev)) { strShow.Format(_T("upload testtask %s failed!"), strVesInfo); AfxMessageBox(strShow); return false; } } else if (_T("ERI") == strVesInfo.Left(3)) { if (TRUE != theApp.m_pTdManager->Upload2DTdFromDev(m_strProCN, m_strTzCN, strVesInfo, pDev)) { strShow.Format(_T("upload testtask %s failed!"), strVesInfo); AfxMessageBox(strShow); return false; } } else if (_T("ERT") == strVesInfo.Left(3)) { if (TRUE != theApp.m_pTdManager->Upload3DTdFromDev(m_strProCN, m_strTzCN, strVesInfo, pDev)) { strShow.Format(_T("upload testtask %s failed!"), strVesInfo); AfxMessageBox(strShow); return false; } } else { strShow.Format(_T("testtask %s illeagal!"), strVesInfo); AfxMessageBox(strShow); return false; } return true; } */ /* bool CDevOperator::GetTestZoneToDB(CDevice* pDev,DWORD dwProID, CString strTZ ,CString strPrHostPathInfo) { CString strHostTZPath = _T(""); strHostTZPath.Format(_T("%s%s/"),strPrHostPathInfo, strTZ); CString strHostTZFile = strHostTZPath + _T("testzone.xml"); CString strShowInfo = _T(""); if (TRUE != pDev->ReceiveFile(m_strLocalFilePath, strHostTZFile)) { strShowInfo.Format(_T("Receive testzone file %s failed!"), strTZ); AfxMessageBox(strShowInfo); return false; } //进行文件的改名 CString strOldFileName = m_strLocalFilePath + _T("testzone.xml"); CString strNewFileName = _T(""); strNewFileName.Format(_T("%s%s.xml"),m_strLocalFilePath, strTZ); DeleteFile(strNewFileName); if (!MoveFile(strOldFileName,strNewFileName)) { strShowInfo.Empty(); strShowInfo.Format(_T("rename testzone file to %s failed!"),strTZ); AfxMessageBox(strShowInfo); return false; } CMarkup xmlTz; if (!xmlTz.Load(strNewFileName)) { strShowInfo.Format(_T("Load testzone file %s failed!"), strTZ); AfxMessageBox(strShowInfo); return false; } //获取测区信息的数据 CString strCN = _T(""); CString strTzName = _T(""); CString strLocation = _T(""); CString strTzDate = _T(""); CString strDesc = _T(""); CString strType = _T(""); if (!xmlTz.FindElem(_T("testzone"))) { AfxMessageBox(_T("find testzone failed!")); return false; } xmlTz.IntoElem(); if (!xmlTz.FindElem(_T("type"))) { AfxMessageBox(_T("find type failed!")); return false; } strType = xmlTz.GetData(); if (!xmlTz.FindElem(_T("location"))) { AfxMessageBox(_T("find location element failed!")); return false; } strLocation = xmlTz.GetData(); if (!xmlTz.FindElem(_T("desc"))) { AfxMessageBox(_T("find desc failed!")); return false; } strDesc = xmlTz.GetData(); if (!xmlTz.FindElem(_T("create_date"))) { AfxMessageBox(_T("find create_date failed!")); return false; } strTzDate = xmlTz.GetData(); if (!xmlTz.FindElem(_T("cn"))) { AfxMessageBox(_T("find cn failed!")); return false; } strCN = xmlTz.GetData(); if (!xmlTz.FindElem(_T("testzone_name"))) { AfxMessageBox(_T("find testzone_name failed!")); return false; } strTzName = xmlTz.GetData(); _RecordsetPtr pRecTzID = NULL; _CommandPtr pCmdInsPro = NULL; pRecTzID.CreateInstance(_uuidof(Recordset)); pCmdInsPro.CreateInstance(_uuidof(Command)); //插入测区信息 CString strSql = _T(""); int nType = atoi(strType); DWORD dwTzID = 0; pCmdInsPro->ActiveConnection = m_pConnection; strSql.Format(_T("insert into tz(PRID,CN,TZname,TZtype,Cdate,TZdesc,location) values(%d,'%s','%s',%d,#%s#,'%s','%s')"), dwProID,strCN, strTzName, nType, strTzDate, strDesc, strLocation); pCmdInsPro->CommandText = strSql.AllocSysString(); pCmdInsPro->Execute(NULL, NULL, adCmdText); //得到该测区的ID pRecTzID->Open(_T("select max(ID) as ID from tz"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText); if ((long)VAL_ZERO != pRecTzID->GetRecordCount()) { dwTzID = pRecTzID->GetCollect(_T("ID")).ulVal; } pRecTzID->Close(); m_strTzCN = strCN; //获取测试任务的数据 if (!xmlTz.FindElem(_T("vess"))) { AfxMessageBox(_T("find vess failed!")); return false; } CString strVes; while(xmlTz.FindChildElem(_T("ves"))) { strVes.Empty(); strVes = xmlTz.GetChildData(); if (!strVes.IsEmpty()) { //在这里及时传输失败,也要继续下一个任务的传输 GetTestTaskToDB(pDev, strVes); } } if (!xmlTz.FindElem(_T("eris"))) { AfxMessageBox(_T("find eris failed!")); return false; } while(xmlTz.FindChildElem(_T("eri"))) { strVes.Empty(); strVes = xmlTz.GetChildData(); if (!strVes.IsEmpty()) { //在这里及时传输失败,也要继续下一个任务的传输 GetTestTaskToDB(pDev, strVes); } } if (!xmlTz.FindElem(_T("erts"))) { AfxMessageBox(_T("find erts failed!")); return false; } while(xmlTz.FindChildElem(_T("ert"))) { strVes.Empty(); strVes = xmlTz.GetChildData(); if (!strVes.IsEmpty()) { //在这里及时传输失败,也要继续下一个任务的传输 GetTestTaskToDB(pDev, strVes); } } //删除TestZone文件 DeleteFile(strNewFileName); return true; } */ /* //GetProjectDataToDB函数中,当加载XML错误时,有事务打开没有关闭,但是由于此函数已经不调用 //所有也就没有去修改 bool CDevOperator::GetProjectDataToDB(CDevice* pDev,CString strProject, CString strMacAddr) { CString strHostFile = _T(""); CString strHostPath = _T(""); strHostPath.Format(_T("/sd/projects/%s/"),strProject); strHostFile = strHostPath + _T("project.xml"); CString strShowInfo = _T(""); if (TRUE != pDev->ReceiveFile(m_strLocalFilePath, strHostFile)) { strShowInfo.Format(_T("Receive prject file %s failed!"), strProject); AfxMessageBox(strShowInfo); return false; } //进行文件的改名 CString strOldFileName = m_strLocalFilePath + _T("project.xml"); CString strNewFileName = _T(""); strNewFileName.Format(_T("%s%s.xml"),m_strLocalFilePath, strProject); DeleteFile(strNewFileName); if (!MoveFile(strOldFileName,strNewFileName)) { strShowInfo.Empty(); strShowInfo.Format(_T("rename project to %s failed!"),strProject); AfxMessageBox(strShowInfo); return false; } CMarkup xmlPro; if (!xmlPro.Load(strNewFileName)) { strShowInfo.Format(_T("Load prject file %s failed!"), strProject); AfxMessageBox(strShowInfo); return false; } if (!xmlPro.FindElem(_T("project"))) { AfxMessageBox(_T("find project failed!")); return false; } xmlPro.IntoElem(); //获取工程信息的数据 CString strCN = _T(""); CString strPRName = _T(""); CString strLocation = _T(""); CString strPRdesc = _T(""); CString strCreateDate = _T(""); CString strDuration= _T(""); CString strPS = _T(""); CString strCS = _T(""); CString strPM = _T(""); CString strQAS = _T(""); CString strStandard = _T(""); if (!xmlPro.FindElem(_T("project_name"))) { AfxMessageBox(_T("find project_name failed!")); return false; } strPRName = xmlPro.GetData(); strPRName += _T("(#)"); if (!xmlPro.FindElem(_T("cn"))) { AfxMessageBox(_T("find cn element failed!")); return false; } strCN = xmlPro.GetData(); if (!xmlPro.FindElem(_T("description"))) { AfxMessageBox(_T("find description failed!")); return false; } strPRdesc = xmlPro.GetData(); if (!xmlPro.FindElem(_T("location"))) { AfxMessageBox(_T("find location failed!")); return false; } strLocation = xmlPro.GetData(); if (!xmlPro.FindElem(_T("create_date"))) { AfxMessageBox(_T("find create_date failed!")); return false; } strCreateDate = xmlPro.GetData(); if (!xmlPro.FindElem(_T("duration"))) { AfxMessageBox(_T("find duration failed!")); return false; } strDuration = xmlPro.GetData(); if (!xmlPro.FindElem(_T("PS"))) { AfxMessageBox(_T("find PS failed!")); return false; } strPS = xmlPro.GetData(); if (!xmlPro.FindElem(_T("CS"))) { AfxMessageBox(_T("find CS failed!")); return false; } strCS = xmlPro.GetData(); if (!xmlPro.FindElem(_T("PM"))) { AfxMessageBox(_T("find PM failed!")); return false; } strPM = xmlPro.GetData(); if (!xmlPro.FindElem(_T("QA"))) { AfxMessageBox(_T("find QA failed!")); return false; } strQAS = xmlPro.GetData(); if (!xmlPro.FindElem(_T("standard"))) { AfxMessageBox(_T("find standard failed!")); return false; } strStandard = xmlPro.GetData(); _RecordsetPtr pRecPrID = NULL; _RecordsetPtr pRecQuery = NULL; _CommandPtr pCmdInsPro = NULL; pRecPrID.CreateInstance(_uuidof(Recordset)); pRecQuery.CreateInstance(_uuidof(Recordset)); pCmdInsPro.CreateInstance(_uuidof(Command)); try { CString strSql = _T(""); int nDuration = atoi(strDuration); DWORD dwPrID = 0; m_pConnection->BeginTrans(); pCmdInsPro->ActiveConnection = m_pConnection; //首先查询是否有已经存在的,如果存在就先删除 strSql.Format(_T("select PRname from project where CN = '%s'"),strCN); pRecQuery->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText); if ((long)VAL_ZERO != pRecQuery->GetRecordCount()) { //如果不等于0,则需要删除之前的工程 strSql.Empty(); strSql.Format(_T("delete from project where CN = '%s'"),strCN); pCmdInsPro->CommandText = strSql.AllocSysString(); pCmdInsPro->Execute(NULL, NULL, adCmdText); } pRecQuery->Close(); strSql.Empty(); strSql.Format(_T("insert into project(CN,PRname,PRdesc,location,PRdate,duration,PS,CS,PM,QAS,standard,owner) values('%s','%s','%s','%s',#%s#,%d,'%s','%s','%s','%s','%s','%s')"), strCN, strPRName, strPRdesc, strLocation, strCreateDate, nDuration, strPS, strCS, strPM, strQAS, strStandard, strMacAddr); pCmdInsPro->CommandText = strSql.AllocSysString(); pCmdInsPro->Execute(NULL, NULL, adCmdText); pRecPrID->Open(_T("select max(ID) as ID from project"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText); if ((long)VAL_ZERO != pRecPrID->GetRecordCount()) { dwPrID = pRecPrID->GetCollect(_T("ID")).ulVal; } pRecPrID->Close(); m_strProCN = strCN; if (!xmlPro.FindElem(_T("testzones"))) { AfxMessageBox(_T("find testzones failed!")); return false; } CString strTzCN; while(xmlPro.FindChildElem(_T("testzone"))) { strTzCN.Empty(); strTzCN = xmlPro.GetChildData(); if (!strTzCN.IsEmpty()) { GetTestZoneToDB(pDev, dwPrID, strTzCN,strHostPath); } } m_pConnection->CommitTrans(); } catch (_com_error e) { hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL); AfxMessageBox((LPCTSTR)e.Description()); m_pConnection->RollbackTrans(); DeleteFile(strNewFileName); return false; } DeleteFile(strNewFileName); return true; } */ /* bool CDevOperator::GetOtherDevData(CDevice* pDevInfo) { //首先获取LocalHost.xml CString strHostFileName= _T("/sd/users/LOCALHOST.XML"); m_strLocalFilePath.Empty(); m_strLocalFilePath.GetBufferSetLength(256); ::GetCurrentDirectory(m_strLocalFilePath.GetLength(), m_strLocalFilePath.GetBuffer(m_strLocalFilePath.GetLength())); m_strLocalFilePath.ReleaseBuffer(); m_strLocalFilePath = m_strLocalFilePath + _T("\\CACHE\\otherdata\\"); CString strErr = _T(""); if (!MakeSureDirectoryPathExists(m_strLocalFilePath)) { strErr.Format(_T("The Path %s is illeagal"),m_strLocalFilePath); AfxMessageBox(strErr); return false; } if (TRUE != pDevInfo->ReceiveFile(m_strLocalFilePath, strHostFileName)) { hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL); AfxMessageBox(_T("Receive file HostInfo file failed!")); return false; } CString strLocFileName = m_strLocalFilePath + _T("LOCALHOST.XML"); CMarkup xmlParser; if (!xmlParser.Load(strLocFileName)) { AfxMessageBox(_T("Load HostInfo file failed! ")); return false; } CStringArray strProArray; strProArray.RemoveAll(); if (!xmlParser.FindChildElem(_T("user_info"))) { AfxMessageBox(_T("There is not userinfo in file!")); return false; } xmlParser.IntoElem(); if (!xmlParser.FindChildElem(_T("path_dictionary"))) { AfxMessageBox(_T("There is not path_dictionary in file!")); return false; } xmlParser.IntoElem(); CString strPro,strMac; while (xmlParser.FindChildElem(_T("path"))) { strPro.Empty(); strMac.Empty(); strPro = xmlParser.GetChildData(); strMac = xmlParser.GetChildAttrib(_T("mac")); if (0 == strMac.Compare(g_szMacAddress)) { continue; } if (strMac.IsEmpty()) { return false; } if (strPro.IsEmpty()) { AfxMessageBox(_T("Parser Infomation Error!ProjectCN is Empty!")); return false; } GetProjectDataToDB(pDevInfo, strPro, strMac); } return true; } */ UINT CDevOperator::RegisterNewDevice(CNavDevView *pNavDevView) { HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; UINT uImageState = (UINT)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szDevSN = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); szDevSN = pNavDevView->m_devTree.GetItemText(hDevItem); pDev = NULL; pDev = theApp.m_pDevManager->GetDevice(szDevSN); if (NULL != pDev) { if (TRUE == pDev->Register()) { theApp.m_pDevManager->AddDevice(pDev); pDev->DelSynInfo(); pDev->DelGRInfo(); if (pDev->GetSynInfo() == TRUE) { pDev->m_uState = PZ_STATE_ONLINE; uImageState = m_stateProcessor.ChangeToImageState(pDev->m_uState); pNavDevView->m_devTree.DeleteItem(hDevItem); hDevItem = pNavDevView->m_devTree.InsertItem(pDev->m_szDevSN, m_hOLRegDevRootItem); CString strLog; strLog.Format(_T("zm:CDevOperator::RegisterNewDevice() 插入注册设备 子节点%s"), pDev->m_szDevSN); OutputDebugString(strLog); dwDevHandle = m_handleProcessor.GenerateHandle((DWORD)pDev->m_dwID, PZ_STYLE_DEV); pNavDevView->m_devTree.SetItemData(hDevItem, dwDevHandle); pNavDevView->m_devTree.SetItemState(hDevItem, uImageState, TVIS_STATEIMAGEMASK); pNavDevView->m_devTree.Expand(m_hOLRegDevRootItem, TVE_EXPAND); pNavDevView->m_devTree.SelectItem(hDevItem); //added by lsq 20160406 //在这里由于开放数据权限时所采用的统一MAC地址,所以其他MAC地址创建的信息都不会再要。 //所以将这段代码进行屏蔽 /* //查看是否有其他用户的数据 if (enExistOtherData == pDev->IsExistOtherUserData()) { //如果存在的话,则需要校验密码 if (IDYES != AfxMessageBox(_T("Found other user's data,Do you want to upload ?"), MB_YESNO)) { return APP_SUCCESS; } AfxMessageBox(_T("Upload those data will take a few minutes! please wait...")); CString strPassword = _T(""); STDBPasswordInfo stDBPass; theApp.GetDevPassword(pDev->m_szDevSN, stDBPass); strPassword = stDBPass.strPassword; switch (pDev->CheckGD10Password(strPassword)) { case enPasswordError: while(1) { //创建密码输入框 CInputPasswordDial InputPassDial; InputPassDial.SetGD10VerifyModel(); //如果用户选择了取消,则不再进行校验,并且不再获取其它数据 if (IDOK != InputPassDial.DoModal()) return APP_SUCCESS; strPassword = InputPassDial.GetInputPassword(); int nRes = pDev->CheckGD10Password(strPassword); if (enPasswordSucc == nRes) { //将输入的密码保存到数据库当中去 SaveGD10PassowordToDB(pDev->m_szDevSN, strPassword, stDBPass); theApp.GetDBPasswordInfo(); break; } else if (enPasswordError == nRes) { AfxMessageBox(_T("Password Error!")); } else { AfxMessageBox(_T("excute check_password failed!!!")); } } //在这里流程已经走到了通过输入密码对话框并且校验密码成功的步骤了, //所以此时可以直接执行密码校验成功的步骤,而不用进行break了 case enPasswordSucc: //在这进行数据的获取工作 GetOtherDevData(pDev); break; default: AfxMessageBox(_T("excute check_password failed!!!")); return APP_SUCCESS; } } */ } else { pDev->m_uState = PZ_STATE_OFFLINE; } } } else { return APP_FAIL; } return APP_SUCCESS; } bool CDevOperator::SaveGD10PassowordToDB(CString strDevName,CString strPassword,STDBPasswordInfo stOldDBPassInfo) { CString strSql = _T(""); if (stOldDBPassInfo.strPassword.IsEmpty()) { strSql.Format(_T("insert into password_info(DevType,DevPassword,DevName) values(2,'%s','%s')"), strPassword, strDevName); } else { strSql.Format(_T("update password_info set DevPassword = '%s' where ID = %d"), strPassword, stOldDBPassInfo.nTableID); } _CommandPtr pCmdPro = NULL; pCmdPro.CreateInstance(_uuidof(Command)); pCmdPro->ActiveConnection = m_pConnection; try { m_pConnection->BeginTrans(); pCmdPro->CommandText = strSql.AllocSysString(); pCmdPro->Execute(NULL, NULL, adCmdText); m_pConnection->CommitTrans(); } catch (_com_error e) { hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL); AfxMessageBox(e.Description()); m_pConnection->RollbackTrans(); return false; } return true; } UINT CDevOperator::UnregisterDevice(CNavDevView *pNavDevView) { HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szDevSN = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); // szDevSN = pNavDevView->m_devTree.GetItemText(hDevItem); pDev = NULL; pDev = theApp.m_pDevManager->GetDevice(dwDevHandle); if (NULL != pDev) { if (TRUE == pDev->Unregister()) { pDev->DelSynInfo(); pDev->DelGRInfo(); theApp.m_pDevManager->DeleteDevice(dwDevHandle); pNavDevView->m_devTree.DeleteItem(hDevItem); } } else { return APP_FAIL; } return APP_SUCCESS; } UINT CDevOperator::ModifyWindowTime(CNavDevView *pNavDevView) { // HTREEITEM hDevItem = NULL; // DWORD dwDevHandle = (DWORD)VAL_ZERO; // DWORD dwDevID = (DWORD)VAL_ZERO; // Ccheckupdate *pUpdate = NULL; // CString szDevSN = _T(""); // CDevice* pDev = NULL; // // hDevItem = pNavDevView->m_devTree.GetSelectedItem(); // dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); // // // szDevSN = pNavDevView->m_devTree.GetItemText(hDevItem); // // pDev = NULL; // pDev = theApp.m_pDevManager->GetDevice(dwDevHandle); // if (NULL != pDev) // { // theApp.m_pDevManager->ModifyTimeWindow(dwDevHandle); // } HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szDevItem = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle); pDev = NULL; pDev = theApp.m_pDevManager->GetDeviceByID(dwDevID); if (NULL != pDev) { if (!pDev->ModifyTimeWindow()) { return APP_FAIL; } } else { return APP_FAIL; } return APP_SUCCESS; } /* UINT CDevOperator::DevieFuncCardUpgrade(CNavDevView *pNavDevView) { HTREEITEM hDevItem = NULL; DWORD dwDevHandle = (DWORD)VAL_ZERO; DWORD dwDevID = (DWORD)VAL_ZERO; Ccheckupdate *pUpdate = NULL; CString szDevItem = _T(""); CDevice* pDev = NULL; hDevItem = pNavDevView->m_devTree.GetSelectedItem(); dwDevHandle = pNavDevView->m_devTree.GetItemData(hDevItem); dwDevID = m_handleProcessor.GetIDFromHandle(dwDevHandle); szDevItem = pNavDevView->m_devTree.GetItemText(hDevItem); // if (_T("*") == szDevItem.Mid(szDevItem.GetLength()-1, 1)) // { pDev = NULL; pDev = theApp.m_pDevManager->GetDeviceByID(dwDevID); if (NULL != pDev) { pUpdate = NULL; pUpdate = new Ccheckupdate(&pDev->m_sComPort,UPG_FUNCTION_CARD_TYPE); ((CMainFrame*)AfxGetMainWnd())->SetStatusText("ready to update ,please wait..."); int nRes = pUpdate->StartUpdateSoft(""); if (enUpdateFail == nRes ) { return APP_FAIL; } if (enNoNeedUpdate == nRes) { return APP_SUCCESS; } if (enUpdateSucc != nRes) { AfxMessageBox(_T("Unknow Result when start update soft, res = %d "), nRes); return APP_FAIL; } ((CMainFrame*)AfxGetMainWnd())->SetStatusText("ready to update firmware to device function board,please wait..."); std::vector vtFuncFileInfo; if (!pUpdate->GetFunctionBoardInfo(vtFuncFileInfo)) { return APP_FAIL; } //_T(".\\firmware\\%s"), CString strFuncFileInfo = _T(""); CString strOrder = _T(""); CString strResBuffer = _T(""); CString strResult = _T(""); CString strErrInfo = _T(""); for (int i = 0; i < vtFuncFileInfo.size(); i++) { strFuncFileInfo.Empty(); strOrder.Empty(); strResBuffer.Empty(); strFuncFileInfo.Format(_T("/SD/%s"),vtFuncFileInfo[i]); strOrder.Format(_T("rm(\"%s\")\r\n")); if (!pDev->ExecuteOrder(strOrder, ">", &strResBuffer)) { strErrInfo.Empty(); strErrInfo.Format(_T("excute remove %s failed!!!")); AfxMessageBox(strErrInfo); return APP_FAIL; } if (!pDev->SendFile(_T("/SD/"), _T(".\\firmware\\"), vtFuncFileInfo[i])) { strErrInfo.Empty(); strErrInfo.Format(_T("send file %s failed!!!"),vtFuncFileInfo[i]); AfxMessageBox(strErrInfo); return APP_FAIL; } strOrder.Empty(); strResBuffer.Empty(); strResult.Empty(); if(-1 != vtFuncFileInfo[i].Find(_T("TXB"))) { strOrder.Format(_T("upgrade(\"TXB\")\r\n")); } else if (-1 != vtFuncFileInfo[i].Find(_T("RXB"))) { strOrder.Format(_T("upgrade(\"RXB\")\r\n")); } else { AfxMessageBox(_T("Find Neither TXB nor RXB in upgrade information!")); return APP_FAIL; } if (!pDev->ExecuteOrder(strOrder, ">", &strResBuffer)) { strErrInfo.Empty(); strErrInfo.Format(_T("excute remove %s failed!!!")); AfxMessageBox(strErrInfo); return APP_FAIL; } if (-1 == strResBuffer.Find("]")) { AfxMessageBox(_T("this function is not supported in device, please check your gd-10 version!")); return false; } GetSubStringInHeadAndTail(strResBuffer, strResult, _T("["), _T("]")); if (_T("1") != strResult) { strErrInfo.Empty(); strErrInfo.Format(_T("upgrade %s to function board failed!!!"),vtFuncFileInfo[i]); AfxMessageBox(strErrInfo); return APP_FAIL; } } AfxMessageBox(_T("Upgrade function board success!")); } else { AfxMessageBox(_T("Get device ptr failed!!!")); return APP_FAIL; } return APP_SUCCESS; } */ UINT CDevOperator::StartDeviceUpgrade(LPVOID lParam) { CDevice* pDev = (CDevice*)lParam; if (NULL != pDev) { Ccheckupdate *pUpdate = NULL; pUpdate = new Ccheckupdate(pDev); int nRes = pUpdate->StartUpdateSoft(); if (enUpdateFail == nRes ) { pUpdate->DeleteDevUpgFile(); ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_CLEAR_DEV_UPG_INFO, 0,0); delete pUpdate; return APP_FAIL; } if (enNoNeedUpdate == nRes) { ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_CLEAR_DEV_UPG_INFO, 0,0); delete pUpdate; return APP_SUCCESS; } if (enUpdateSucc != nRes) { ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_CLEAR_DEV_UPG_INFO, 0,0); delete pUpdate; CString strLog; strLog.Format(_T("Unknow Result when start upgrade soft, res = %d "), nRes); MessageBoxEx(NULL, strLog, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return APP_FAIL; } //刷固件 CString strTmp = _T(""); if (pUpdate->UpdateGD10Dev()) { //如果需要更新Geomative if (pUpdate->IsNeedUpgGeo()) { delete pUpdate; CString strTipInfo = _T(""); int nRet = 0; if (LANG_ZHCN == g_iUILanguage) { strTipInfo = _T("Geomative Studio的版本和GD20的主机可能不匹配,是否要检查并升级Geomative Studio?"); nRet = AfxMessageBox(strTipInfo, MB_YESNO); } else { strTipInfo = _T("Geomative Studio maybe not match to the software of GD-20 mainframe;\r\n Do you want to check and upgrade new Geomative Studio?"); nRet = MessageBoxEx(NULL, strTipInfo, STRING_MESSAGEBOXEX_TITLE, MB_YESNO, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); } if (IDYES == nRet) ((CMainFrame*)AfxGetMainWnd())->PostMessage(WM_UPG_GEOMATIVE, (WPARAM)0, (LPARAM)0); } else delete pUpdate; ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_CLEAR_DEV_UPG_INFO, 0,0); if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("升级成功!")); else MessageBoxEx(NULL, _T("Upgrade successfully!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return APP_SUCCESS; } else { ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_CLEAR_DEV_UPG_INFO, 0,0); if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("升级失败!")); else MessageBoxEx(NULL, _T("Upgrade failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); delete pUpdate; return APP_FAIL; } if (pUpdate != NULL) { delete pUpdate; pUpdate = NULL; } } else { ((CMainFrame*)AfxGetMainWnd())->SendMessage(WM_CLEAR_DEV_UPG_INFO, 0,0); return APP_FAIL; } }