// DialNew3DTask.cpp : implementation file // #include "stdafx.h" #include "GeoMative.h" #include "DialNew3DTask.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CDialNew3DTask dialog extern CGeoMativeApp theApp; extern int g_iUILanguage; extern int g_iOnLineVersion; void SplitterString(CStringArray &szArray, const CString& szSource, const CString& szSplitter); CDialNew3DTask::CDialNew3DTask(CTaskDataOper* pTaskOper,CWnd* pParent /*=NULL*/) : CDialog(CDialNew3DTask::IDD, pParent) { //{{AFX_DATA_INIT(CDialNew3DTask) //}}AFX_DATA_INIT m_strTaskName = _T(""); m_strTestPlace = _T(""); m_strSptName = _T(""); m_strArray = _T(""); m_strTestType = _T(""); m_iTestType = -1; m_iAR = -1; m_iSptID = -1; m_iStacking = -1; m_iTxWave = -1; m_iTxPeriod = -1; m_iSAInterval = -1; m_iStatrLayer = 0; m_iEndLayer = 0; m_iStartElec = 0; m_iEndElec = 0; m_iCableLayout = -1; m_iSkipCable = 0; m_pTaskOper = pTaskOper; m_iNewTaskID = 0; m_ucSptType = 2;//三维 } void CDialNew3DTask::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDialNew3DTask) DDX_Control(pDX, IDC_3D_CABLE_LAYOUT, m_cmbCLayout); DDX_Control(pDX, IDC_COMBO_3D_TEST_TYPE, m_cmbTestType); DDX_Control(pDX, IDC_COMBO_3D_TX_PERIOD, m_cmbTxPeriod); DDX_Control(pDX, IDC_COMBO_3D_SCRIPT, m_cmbSpt); DDX_Control(pDX, IDC_COMBO_3D_ARRAY, m_cmbArray); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDialNew3DTask, CDialog) //{{AFX_MSG_MAP(CDialNew3DTask) ON_CBN_SELCHANGE(IDC_COMBO_3D_ARRAY, OnSelchangeCombo3dArray) ON_CBN_SELCHANGE(IDC_COMBO_3D_TEST_TYPE, OnSelchangeCombo3dTestType) ON_CBN_SELCHANGE(IDC_COMBO_3D_SCRIPT, OnSelchangeCombo3dScript) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDialNew3DTask message handlers BOOL CDialNew3DTask::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here ((CEdit*)(GetDlgItem(IDC_3D_TASK_NAME)))->SetLimitText(50); ((CEdit*)(GetDlgItem(IDC_3D_TEST_PLACE)))->SetLimitText(50); if (LANG_ENUS == g_iUILanguage) { m_cmbTestType.AddString(_T("RES")); m_cmbTestType.AddString(_T("IP")); m_cmbTestType.AddString(_T("SP")); } else { m_cmbTestType.AddString(_T("电阻率")); m_cmbTestType.AddString(_T("激电")); m_cmbTestType.AddString(_T("自电")); } m_cmbTestType.SetCurSel(0); std::vector vtMediumInfo; vtMediumInfo.clear(); m_pTaskOper->QueryMediumInfo(2, vtMediumInfo); int i = 0; for (i = 0; i < vtMediumInfo.size(); i++) { m_cmbArray.AddString(vtMediumInfo[i].strMediumName); m_cmbArray.SetItemData(i, vtMediumInfo[i].iMediumID); } GetDlgItem(IDC_3D_STACKING)->SetWindowText("1"); GetDlgItem(IDC_3D_TX_WAVE)->SetWindowText(_T("0+0-")); GetDlgItem(IDC_3D_TX_WAVE)->EnableWindow(FALSE); m_iTxWave = 6; //表示0+0- //电缆布线方式 m_vtCLayoutInfo.clear(); m_pTaskOper->QueryCmInfo(_T("Clayout"),m_vtCLayoutInfo); for(i = 0; i < m_vtCLayoutInfo.size(); i++) { //电阻率,这里需要过滤掉激电的部分 if ((0 == (m_vtCLayoutInfo[i].iVal+1)%2) || m_vtCLayoutInfo[i].iVal > 3) { continue; } if ((theApp.m_iCableType > 0) && (m_cmbCLayout.GetCount() >0)) { break; } m_cmbCLayout.AddString(m_vtCLayoutInfo[i].strCLable); m_cmbCLayout.SetItemData(m_cmbCLayout.GetCount()-1, m_vtCLayoutInfo[i].iVal); } // // m_cmbTxPeriod.ResetContent(); // m_cmbTxPeriod.AddString(_T("64 S")); // m_cmbTxPeriod.SetItemData(0, 0); // m_cmbTxPeriod.AddString(_T("32 S")); // m_cmbTxPeriod.SetItemData(1, 9); // i = 16; // int iIndex = 1; // CString strTxPeriod = _T(""); // while(i > 0) // { // strTxPeriod.Empty(); // strTxPeriod.Format(_T("%d S"), i); // m_cmbTxPeriod.AddString(strTxPeriod); // m_cmbTxPeriod.SetItemData(i+1, i); // i = i/2; // } // m_cmbTxPeriod.SetCurSel(-1); CString strTxPeriod = _T(""); for (i = 1; i < 8; i++) { strTxPeriod.Empty(); if (i == 1) { if (LANG_ZHCN == g_iUILanguage) strTxPeriod.Format(_T("自动")); else strTxPeriod.Format(_T("Auto")); } else { strTxPeriod.Format(_T("%.0f S"), pow(2, i - 1)); } m_cmbTxPeriod.AddString(strTxPeriod); m_cmbTxPeriod.SetItemData(i - 1, i); } m_cmbTxPeriod.EnableWindow(TRUE); m_cmbTxPeriod.SetCurSel(0); if (LANG_ENUS == g_iUILanguage) { GetDlgItem(IDC_STATIC_TASK_NAME)->SetWindowText("Task Name:"); GetDlgItem(IDC_STATIC_TEST_PLACE)->SetWindowText("Location:"); GetDlgItem(IDC_STATIC_TEST_TYPE)->SetWindowText("Method:"); GetDlgItem(IDC_STATIC_CABLE_LAYOUT)->SetWindowText("Cable Deployment:"); GetDlgItem(IDC_STATIC_ARRAY_TYPE)->SetWindowText("Array:"); GetDlgItem(IDC_STATIC_SCRIPT)->SetWindowText("Script:"); GetDlgItem(IDC_STATIC_NETWORK_SIZE)->SetWindowText(_T("Grid Info:")); GetDlgItem(IDC_STATIC_STACKING)->SetWindowText("Stacking:"); GetDlgItem(IDC_STATIC_TX_WAVEFORM)->SetWindowText("Tx Wave:"); GetDlgItem(IDC_STATIC_TX_PERIOD)->SetWindowText("Tx Period:"); GetDlgItem(IDC_STATIC_SA_INTERVAL)->SetWindowText("Sampling Interval(ms):"); GetDlgItem(IDOK)->SetWindowText("Create"); GetDlgItem(IDCANCEL)->SetWindowText("Cancel"); GetDlgItem(IDC_3D_IF_TEST_GR)->SetWindowTextA("Grounding Resistance"); } ((CEdit*)(GetDlgItem(IDC_3D_SA_INTERVAL1)))->SetLimitText(7); GetDlgItem(IDC_3D_SA_INTERVAL1)->EnableWindow(TRUE); GetDlgItem(IDC_3D_SA_INTERVAL1)->SetWindowText(_T("0")); //默认测试接地电阻 ((CButton*)GetDlgItem(IDC_3D_IF_TEST_GR))->SetCheck(TRUE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDialNew3DTask::OnSelchangeCombo3dArray() { // TODO: Add your control notification handler code here int iSel = m_cmbArray.GetCurSel(); if (-1 != iSel) { m_cmbSpt.ResetContent(); std::vector vtSptInfo; vtSptInfo.clear(); m_pTaskOper->QuerySptByAR(m_cmbArray.GetItemData(iSel), vtSptInfo, 2); for (int i = 0; i < vtSptInfo.size(); i++) { m_cmbSpt.AddString(vtSptInfo[i].strSptName); m_cmbSpt.SetItemData(i, vtSptInfo[i].iSptID); } GetDlgItem(IDC_3D_NETWORKSIZE)->SetWindowTextA(_T("")); } } void CDialNew3DTask::OnSelchangeCombo3dScript() { int iPos = -1; int iNetworkX = 0; int iNetworkY = 0; int iSel = m_cmbSpt.GetCurSel(); if (-1 == iSel) { return; } CString strSptName,strRect,strPoleStep,strPoleDistance,strLineDirection; m_cmbSpt.GetLBText(iSel, strSptName); m_pTaskOper->QuerySptRectByARandSCname(m_cmbArray.GetItemData(m_cmbArray.GetCurSel()), strSptName, strRect, strPoleStep, strPoleDistance, strLineDirection,m_ucSptType); /*iPos = strRect.ReverseFind(','); iNetworkX = _ttoi(strRect.Mid(iPos + 1)); strRect = strRect.Mid(0, iPos); iPos = strRect.ReverseFind(','); iNetworkY = _ttoi(strRect.Mid(iPos + 1));*/ if (!strLineDirection.IsEmpty()) { m_byLineDirection = atoi(strLineDirection); } CString strNetworkSize; CStringArray strRectArray; SplitterString(strRectArray, strRect, ","); if (strRectArray.GetSize() >= 4) { m_rcGridSize.left = atoi(strRectArray.GetAt(0)); m_rcGridSize.top = atoi(strRectArray.GetAt(1)); m_rcGridSize.right = atoi(strRectArray.GetAt(2)); m_rcGridSize.bottom = atoi(strRectArray.GetAt(3)); strNetworkSize.Format("X:%d,Y:%d", m_rcGridSize.right + 1, m_rcGridSize.bottom + 1); } if (!strPoleStep.IsEmpty()) { iPos = strPoleStep.Find(','); if (-1 != iPos) { m_fXElecStep = atof(strPoleStep.Mid(0, iPos)); m_fYElecStep = atof(strPoleStep.Mid(iPos + 1)); } } if (!strPoleDistance.IsEmpty()) { iPos = strPoleDistance.Find(','); if (-1 != iPos) { m_fXElecDistance = atof(strPoleDistance.Mid(0, iPos)); m_fYElecDistance = atof(strPoleDistance.Mid(iPos + 1)); } } GetDlgItem(IDC_3D_NETWORKSIZE)->SetWindowTextA(strNetworkSize); GetDlgItem(IDC_3D_POLE_STEP_SIZE)->SetWindowText(strPoleStep); int iSptID = m_cmbSpt.GetItemData(iSel); if (m_pTaskOper->QuerySptElecTpMount(iSptID, m_iEndElec, m_iTPmount)) { m_iStartElec = 1; //GetDlgItem(IDC_2D_START_ELEC)->SetWindowText(_T("1")); //CString str = _T(""); //str.Format(_T("%d"), m_iEndElec); //GetDlgItem(IDC_2D_END_ELEC)->SetWindowText(str); //str.Empty(); //str.Format(_T("%d"), m_iStatrLayer); //GetDlgItem(IDC_2D_START_LAYER)->SetWindowText(str); //str.Empty(); //str.Format(_T("%d"), m_iEndLayer); //GetDlgItem(IDC_2D_END_LAYER)->SetWindowText(str); } else { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("查询脚本信息失败")); else MessageBoxEx(NULL, _T("Query script information failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); } } void CDialNew3DTask::OnSelchangeCombo3dTestType() { // TODO: Add your control notification handler code here m_cmbCLayout.ResetContent(); int i = 0; if (1 == m_cmbTestType.GetCurSel()) { GetDlgItem(IDC_3D_TX_WAVE)->SetWindowText(_T("+0-0")); m_iTxWave = 1; m_cmbTxPeriod.EnableWindow(TRUE); m_cmbTxPeriod.SetCurSel(0); for(i = 0; i < m_vtCLayoutInfo.size(); i++) { //激电,这里需要过滤掉电阻率的部分 if ((0 == (m_vtCLayoutInfo[i].iVal)%2) || m_vtCLayoutInfo[i].iVal > 3) { continue; } if ((theApp.m_iCableType > 0) && (m_cmbCLayout.GetCount() >0)) { break; } m_cmbCLayout.AddString(m_vtCLayoutInfo[i].strCLable); m_cmbCLayout.SetItemData(m_cmbCLayout.GetCount()-1, m_vtCLayoutInfo[i].iVal); } CString strTxPeriod = _T(""); m_cmbTxPeriod.ResetContent(); for (i = 1; i < 8; i++) { strTxPeriod.Empty(); strTxPeriod.Format(_T("%.0f S"), pow(2, i - 1)); m_cmbTxPeriod.AddString(strTxPeriod); m_cmbTxPeriod.SetItemData(i - 1, i); } m_cmbTxPeriod.EnableWindow(TRUE); m_cmbTxPeriod.SetCurSel(0); } else { if (0 == m_cmbTestType.GetCurSel()) { m_iTxWave = 6; GetDlgItem(IDC_3D_TX_WAVE)->SetWindowText(_T("0+0-")); for(i = 0; i < m_vtCLayoutInfo.size(); i++) { //电阻率,这里需要过滤掉激电的部分 if ((0 == (m_vtCLayoutInfo[i].iVal+1)%2) || m_vtCLayoutInfo[i].iVal > 3) { continue; } if ((theApp.m_iCableType > 0) && (m_cmbCLayout.GetCount() >0)) { break; } m_cmbCLayout.AddString(m_vtCLayoutInfo[i].strCLable); m_cmbCLayout.SetItemData(m_cmbCLayout.GetCount()-1, m_vtCLayoutInfo[i].iVal); } CString strTxPeriod = _T(""); m_cmbTxPeriod.ResetContent(); for (i = 1; i < 8; i++) { strTxPeriod.Empty(); if (i == 1) { strTxPeriod.Format(_T("自动")); } else { strTxPeriod.Format(_T("%.0f S"), pow(2, i - 1)); } m_cmbTxPeriod.AddString(strTxPeriod); m_cmbTxPeriod.SetItemData(i - 1, i); } m_cmbTxPeriod.EnableWindow(TRUE); m_cmbTxPeriod.SetCurSel(0); } else { m_iTxWave = 2; GetDlgItem(IDC_3D_TX_WAVE)->SetWindowText(_T("0")); //SP在这里布线方式全部显示 for(i = 0; i < m_vtCLayoutInfo.size(); i++) { if ((theApp.m_iCableType > 0) && i > 1) { continue;; } if (m_vtCLayoutInfo[i].iVal > 3) continue; m_cmbCLayout.AddString(m_vtCLayoutInfo[i].strCLable); m_cmbCLayout.SetItemData(m_cmbCLayout.GetCount()-1, m_vtCLayoutInfo[i].iVal); } m_cmbTxPeriod.SetCurSel(-1); m_cmbTxPeriod.EnableWindow(FALSE); } } } void CDialNew3DTask::OnOK() { // TODO: Add extra validation here //界面没有输入接口 m_strPoleStep.Empty(); GetDlgItem(IDC_3D_POLE_STEP_SIZE)->GetWindowText(m_strPoleStep); if (m_strPoleStep.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("步长不能为空")); else MessageBoxEx(NULL, _T("Please input pole step"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_strTaskName.Empty(); GetDlgItem(IDC_3D_TASK_NAME)->GetWindowText(m_strTaskName); if (m_strTaskName.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("任务名不能为空")); else MessageBoxEx(NULL, _T("Please input the name of task"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_strTestPlace.Empty(); GetDlgItem(IDC_3D_TEST_PLACE)->GetWindowText(m_strTestPlace); m_iTestType = m_cmbTestType.GetCurSel(); if (-1 == m_iTestType) { if (LANG_ZHCN ==g_iUILanguage) AfxMessageBox(_T("请选择测试方式")); else MessageBoxEx(NULL, _T("Please select test method"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_cmbTestType.GetLBText(m_iTestType, m_strTestPlace); int iSel = m_cmbCLayout.GetCurSel(); if (-1 == iSel) { if (LANG_ZHCN ==g_iUILanguage) AfxMessageBox(_T("请选择电缆布线方式")); else MessageBoxEx(NULL, _T("Please select the type of cable deployment"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_iCableLayout = m_cmbCLayout.GetItemData(iSel); iSel = m_cmbArray.GetCurSel(); if (-1 == iSel) { if (LANG_ZHCN ==g_iUILanguage) AfxMessageBox(_T("请选择装置类型")); else MessageBoxEx(NULL, _T("Please select array type"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_iAR = m_cmbArray.GetItemData(iSel); m_cmbArray.GetLBText(iSel, m_strArray); iSel = m_cmbSpt.GetCurSel(); if (-1 == iSel) { if (LANG_ZHCN ==g_iUILanguage) AfxMessageBox(_T("请选择测试脚本")); else MessageBoxEx(NULL, _T("Please select test script"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_iSptID = m_cmbSpt.GetItemData(iSel); m_cmbSpt.GetLBText(iSel, m_strSptName); CString strTmp = _T(""); GetDlgItem(IDC_3D_STACKING)->GetWindowText(strTmp); if (strTmp.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("迭代次数的取值范围为1到255")); else MessageBoxEx(NULL, _T("Number of stacking must between 1 and 255"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_iStacking = atoi(strTmp); if (m_iStacking < 1 || m_iStacking > 255) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("迭代次数的取值范围为1到255")); else MessageBoxEx(NULL, _T("Number of stacking must between 1 and 255"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_iTxPeriod = 0; if (1 == m_iTestType || 0 == m_iTestType) { iSel = m_cmbTxPeriod.GetCurSel(); if (-1 == iSel) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("请选择发射周期")); else MessageBoxEx(NULL, _T("Please select the launch cycle"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_iTxPeriod = m_cmbTxPeriod.GetItemData(iSel); } strTmp.Empty(); GetDlgItem(IDC_3D_SA_INTERVAL1)->GetWindowText(strTmp); if (strTmp.IsEmpty()) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("采样间隔的值须在0到30000之间")); else MessageBoxEx(NULL, _T("Sample value must be between 0 and 30000"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } m_iSAInterval = atoi(strTmp); if (m_iSAInterval < 0 || m_iSAInterval > 30000) { if (LANG_ZHCN == g_iUILanguage) AfxMessageBox(_T("采样间隔的值须在0到30000之间")); else MessageBoxEx(NULL, _T("Sample value must be between 0 and 30000"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); return; } BYTE ucTestGRFlag = 1; ucTestGRFlag = ((CButton*)GetDlgItem(IDC_3D_IF_TEST_GR))->GetCheck(); //跳过电缆头的功能暂时不实现 m_iSkipCable = 0; m_stTaskParam.strSptName = m_strSptName; m_stTaskParam.strTDName = m_strTaskName; m_stTaskParam.strTestPlace = m_strTestPlace; m_stTaskParam.iAR = m_iAR; m_stTaskParam.iCableLayout = m_iCableLayout; m_stTaskParam.iSAInterval = m_iSAInterval; m_stTaskParam.iSkipCable = m_iSkipCable; m_stTaskParam.iSptID = m_iSptID; m_stTaskParam.iSptType = m_ucSptType; m_stTaskParam.iStacking = m_iStacking; m_stTaskParam.iTestType = m_iTestType; m_stTaskParam.iTxPeriod = m_iTxPeriod; m_stTaskParam.iTxWave = m_iTxWave; m_stTaskParam.ucTestGRFlag = ucTestGRFlag; m_strTaskCN = m_pTaskOper->CreateTaskCN(m_stTaskParam.iTestType); //if (EN_ON_LIEN_VERSION_1 == g_iOnLineVersion) { m_iNewTaskID = m_pTaskOper->Create3DTask(m_stTaskParam, m_strTaskCN); if (m_iNewTaskID < 1) { return; } } CDialog::OnOK(); }