1879 lines
59 KiB
C++
1879 lines
59 KiB
C++
// DialRealTimeMeasureData.cpp : implementation file
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "GeoMative.h"
|
||
#include "DialRealTimeMeasureData.h"
|
||
#include "CtrlProtocolDef.h"
|
||
#include "FileOperTools.h"
|
||
#include "DialMeasuLoopTest.h"
|
||
#include "DialMeasureDetailInfo.h"
|
||
#include <math.h>
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CDialRealTimeMeasureData dialog
|
||
#define MODULE_NAME "CDialRealTimeMeasureData"
|
||
extern SYSTEMTIME g_sysCurTime;
|
||
extern int g_UIOffset;
|
||
extern int g_iUILanguage;
|
||
extern int g_iOnLineVersion;
|
||
extern CGeoMativeApp theApp;
|
||
extern CString GetGRStatus(int iStatus);
|
||
extern int GetSigTxPeriod(int iTestType, int iTestPeriod);
|
||
extern float tcp_htonf(float f);
|
||
extern float tcp_ntohf(float f);
|
||
extern DWORD g_dwPLCID;
|
||
extern EN_TASK_TESTING_METHOD g_eTestingMethod;
|
||
extern CString GetGrCodeText(int iCode);
|
||
extern CString GetMeasuStatusByAlarm(BYTE ucAlarm);
|
||
extern CString g_strSaveTestingTaskID;
|
||
extern CString g_strSaveSuspendedTaskID;
|
||
CDialRealTimeMeasureData::CDialRealTimeMeasureData(CWnd* pParent /*=NULL*/)
|
||
: CNetRequestDialog(CDialRealTimeMeasureData::IDD, pParent)
|
||
{
|
||
//{{AFX_DATA_INIT(CDialRealTimeMeasureData)
|
||
// NOTE: the ClassWizard will add member initialization here
|
||
//}}AFX_DATA_INIT
|
||
// m_iStartElec = 0;
|
||
// m_iEndElec = 0;
|
||
// m_bIsNetOper = false;
|
||
m_iRecvElecID = 0;
|
||
memset(m_ucData, 0, sizeof(m_ucData));
|
||
m_iRecvDataLen = 0;
|
||
m_iMeasuType = 0;
|
||
m_bIsDownLoadTask = false;
|
||
m_ucCmd = 0;
|
||
m_bIsSigMeasuring = false;
|
||
m_bIsOpenTbData = false;
|
||
// m_iMeasuMethod = 0;
|
||
m_iMeasureDataID= -1;
|
||
m_iSigDataMeasuTimeout = -1;
|
||
// m_iTaskCurTsn = -1;
|
||
// m_iListDataID = 0;
|
||
memset(&m_stTaskBasicData, 0, sizeof(m_stTaskBasicData));
|
||
/* m_bIsSuspend = false;*/
|
||
memset(&m_ucMeasuBtnStatus, 0, sizeof(m_ucMeasuBtnStatus));
|
||
// memset(&m_bIsSuspenMeasu, 0, sizeof(m_bIsSuspenMeasu));
|
||
m_bIsRunning = false;
|
||
// m_pReadBuf = NULL;
|
||
// m_pWriteBuf = NULL;
|
||
m_pThread = NULL;
|
||
// m_ucDevType = 0;
|
||
m_uiDevID = 0;
|
||
m_bIsSuspend = false;
|
||
m_vtMeasureData.clear();
|
||
m_iCurTsn = -1;
|
||
m_pThread = NULL;
|
||
m_bIsThreadFinshed = true;
|
||
m_iSelMeasuIndex = -1;
|
||
m_iRepeatSndCnt = -1;
|
||
m_iGRAttionalVal = 0;
|
||
m_iLoopCnt = 0;
|
||
m_iCurLoop= 0;
|
||
m_ucLastBtnStatus = 0;
|
||
m_iSptType = -1;
|
||
g_eTestingMethod = EN_TASK_NOT_TESTTING;
|
||
InitializeCriticalSection(&m_MutexSec);
|
||
|
||
}
|
||
|
||
|
||
void CDialRealTimeMeasureData::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CNetRequestDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CDialRealTimeMeasureData)
|
||
DDX_Control(pDX, IDC_TAB_CHG, m_tabChange);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CDialRealTimeMeasureData, CNetRequestDialog)
|
||
//{{AFX_MSG_MAP(CDialRealTimeMeasureData)
|
||
ON_BN_CLICKED(IDB_MEASURE_ALL, OnMeasureAll)
|
||
ON_BN_CLICKED(IDB_MEASURE_CUR_PT, OnMeasureCurPt)
|
||
//ON_BN_CLICKED(IDB_MEASURE_DOWNLOAD_MEASU_CFG, OnMeasureDownloadMeasuCfg)
|
||
ON_BN_CLICKED(IDB_MEASURE_FROM_CUR, OnMeasureFromCur)
|
||
ON_BN_CLICKED(IDB_DETAIL_MEASURE_DATA, OnShowDetailMeasureData)
|
||
ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_CHG, OnSelchangeTabChg)
|
||
ON_BN_CLICKED(IDB_MEASURE_SUSPEND_MEAU, OnMeasureSuspendMeau)
|
||
ON_WM_CLOSE()
|
||
ON_WM_TIMER()
|
||
ON_NOTIFY(TCN_SELCHANGING, IDC_TAB_CHG, OnSelchangingTabChg)
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CDialRealTimeMeasureData message handlers
|
||
|
||
BOOL CDialRealTimeMeasureData::OnInitDialog()
|
||
{
|
||
CNetRequestDialog::OnInitDialog();
|
||
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
m_tabChange.InsertItem(0, _T("数据"));
|
||
m_tabChange.InsertItem(1, _T("接地电阻"));
|
||
}
|
||
else
|
||
{
|
||
m_tabChange.InsertItem(0, _T("DATA"));
|
||
m_tabChange.InsertItem(1, _T("GR"));
|
||
}
|
||
m_tabChange.SetCurSel(0);
|
||
/*if (EN_ON_LIEN_VERSION_1 == g_iOnLineVersion)
|
||
{
|
||
// m_dialListMeasuGR.m_listData.MoveWindow(&rect);
|
||
CTaskDataOper taskOper;
|
||
|
||
// char chTType[][10]={{"RES"},{"IP"},{"SP"}};
|
||
|
||
if (taskOper.QueryTdBasicInfo(m_iTaskID, &m_stQueryTdInfo))
|
||
{
|
||
// GetDlgItem(IDC_EDIT_TASK_NAME)->SetWindowText(m_stQueryTdInfo.strTaskName);
|
||
// GetDlgItem(IDC_EDIT_TEST_TYPE)->SetWindowText(chTType[m_stQueryTdInfo.iTestType]);
|
||
// GetDlgItem(IDC_EDIT_ARRAY_TYPE)->SetWindowText(m_stQueryTdInfo.strARName);
|
||
// GetDlgItem(IDC_EDIT_SCRIPT)->SetWindowText(m_stQueryTdInfo.strSptName);
|
||
m_iSigDataMeasuTimeout = GetSigTxPeriod(m_stQueryTdInfo.iTestType, m_stQueryTdInfo.iTestPeriod);
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
m_iRecvElecID = m_stQueryTdInfo.iStartElec;
|
||
}
|
||
else
|
||
{
|
||
AfxMessageBox(_T("查询任务信息失败"));
|
||
}
|
||
}*/
|
||
|
||
CRect rect;
|
||
m_tabChange.GetClientRect(&rect);
|
||
m_dialListMeasuTask.SetSptType(m_stQueryTdInfo.iSptType);
|
||
m_dialListMeasuTask.SetTaskID(m_iTaskID);
|
||
m_dialListMeasuTask.Create(IDD_DIALOG_REAL_TIME_MEASURE_LIST_DATA, &m_tabChange);
|
||
rect.top = rect.top + 25;
|
||
rect.left = rect.left + 2;
|
||
rect.right = rect.right -2;
|
||
rect.bottom = rect.bottom - 2;
|
||
m_dialListMeasuTask.MoveWindow(&rect);
|
||
|
||
// m_dialListMeasuGR.SetMeasureType(1);
|
||
m_dialListMeasuGR.SetSptType(m_stQueryTdInfo.iSptType);
|
||
m_dialListMeasuGR.Create(IDD_DIALOG_REAL_TIME_MEASURE_LIST_GR, &m_tabChange);
|
||
m_dialListMeasuGR.MoveWindow(&rect);
|
||
m_dialListMeasuTask.SetMeasuStatus(&m_bIsSigMeasuring);
|
||
m_dialListMeasuTask.ShowWindow(SW_SHOW);
|
||
m_dialListMeasuGR.ShowWindow(SW_HIDE);
|
||
|
||
//隐藏循环任务停止测试按钮
|
||
//GetDlgItem(IDB_BTN_STOP_LOOP_TEST)->ShowWindow(FALSE);
|
||
|
||
m_iMeasuType = EN_MEASURE_DATA;
|
||
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
GetDlgItem(IDB_MEASURE_ALL)->SetWindowText(_T("开始测量"));
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->SetWindowText(_T("从当前测量"));
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("暂停测量"));
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->SetWindowText(_T("单点测量"));
|
||
GetDlgItem(IDB_DETAIL_MEASURE_DATA)->SetWindowText(_T("查看测试数据"));
|
||
//GetDlgItem(IDB_BTN_STOP_LOOP_TEST)->SetWindowText(_T("Stop Test"));
|
||
|
||
//GetDlgItem(IDB_MEASURE_DOWNLOAD_MEASU_CFG)->SetWindowText("Download");
|
||
}
|
||
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
|
||
bool CDialRealTimeMeasureData::MeasureAllGR()
|
||
{
|
||
CString strInfo = _T("");
|
||
if (m_stQueryTdInfo.iStartElec > m_stQueryTdInfo.iEndElec)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strInfo.Format(_T("电极信息紊乱,起始电极= %d,结束电极=%d"), m_stQueryTdInfo.iStartElec, m_stQueryTdInfo.iEndElec);
|
||
AfxMessageBox(strInfo);
|
||
}
|
||
else
|
||
{
|
||
strInfo.Format(_T("Electrode information was disordered, starting electrode =%d, ending electrode =%d"), m_stQueryTdInfo.iStartElec, m_stQueryTdInfo.iEndElec);
|
||
MessageBoxEx(NULL, strInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
|
||
return false;
|
||
}
|
||
// STMeasuGRRequest stMeasuGr;
|
||
// memset(&stMeasuGr, 0, sizeof(STMeasuGRRequest));
|
||
// for (int i = m_iStartElec; i <= m_iEndElec; i++)
|
||
// {
|
||
//
|
||
// }
|
||
// if (false == theApp.m_NetWorkOper.TransferOper(EN_CTRL_MEASURE_GR,))
|
||
// {
|
||
// }
|
||
|
||
|
||
|
||
}
|
||
|
||
// bool CDialRealTimeMeasureData::SendData(const BYTE* pData, int iLen)
|
||
// {
|
||
// bool bRes;
|
||
// EnterCriticalSection(&m_MutexSec);
|
||
// bRes = (m_pWriteBuf->Write(pData, iLen) > 0) ? true : false;
|
||
// LeaveCriticalSection(&m_MutexSec);
|
||
// return bRes;
|
||
// }
|
||
void CDialRealTimeMeasureData::SetBtnStatus(BYTE ucBtnStatus)
|
||
{
|
||
CWnd* pWnd = NULL;
|
||
switch (ucBtnStatus)
|
||
{
|
||
case EN_MEASU_BTN_MEASU_ALL:
|
||
case EN_MEASU_BTN_MEASU_FROM_CUR:
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
if ((EN_MEASURE_DATA == m_iMeasuType) || (EN_MEASURE_GR == m_iMeasuType && m_stQueryTdInfo.iSptType > 0))
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
{
|
||
pWnd->EnableWindow(TRUE);
|
||
if (LANG_ENUS == g_iUILanguage)
|
||
pWnd->SetWindowText(_T("Suspend"));
|
||
else
|
||
pWnd->SetWindowText(_T("暂停测量"));
|
||
}
|
||
}
|
||
}
|
||
//if (EN_MEASURE_DATA == m_iMeasuType)
|
||
// m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
break;
|
||
case EN_MEASU_BTN_MEASU_SIG:
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
//if (EN_MEASURE_DATA == m_iMeasuType)
|
||
// m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
}
|
||
break;
|
||
case EN_MEASU_BTN_SUSPEND:
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
pWnd = GetDlgItem(IDB_DETAIL_MEASURE_DATA);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
//GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("继续测量"));
|
||
//if (EN_MEASURE_DATA == m_iMeasuType)
|
||
// m_dialListMeasuTask.EnablePreviewBtn(true);
|
||
}
|
||
break;
|
||
case EN_MEASU_BTN_COUNTINE:
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
{
|
||
pWnd->EnableWindow(TRUE);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
pWnd->SetWindowText(_T("暂停测试"));
|
||
else
|
||
pWnd->SetWindowText(_T("Suspend"));
|
||
}
|
||
//if (EN_MEASURE_DATA == m_iMeasuType)
|
||
// m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
}
|
||
break;
|
||
case EN_MEASU_BTN_MEASU_FIN:
|
||
case EN_MEASU_BTN_MEASU_TERIMI:
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
if ((EN_MEASURE_DATA == m_iMeasuType) || (EN_MEASURE_GR == m_iMeasuType && m_stQueryTdInfo.iSptType > 0))
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
{
|
||
pWnd->EnableWindow(FALSE);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
pWnd->SetWindowText(_T("暂停测量"));
|
||
else
|
||
pWnd->SetWindowText(_T("Suspend"));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd && 0 == theApp.m_ucIsMultiChannel)
|
||
pWnd->EnableWindow(FALSE);
|
||
}
|
||
|
||
//if (EN_MEASURE_DATA == m_iMeasuType)
|
||
// m_dialListMeasuTask.EnablePreviewBtn(true);
|
||
}
|
||
break;
|
||
case EM_MEASU_BTN_INITI:
|
||
break;
|
||
case EN_MEASU_BTN_NOT_SELECT_TASK:
|
||
{
|
||
//未选中任务时,所有按钮灰掉
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_DETAIL_MEASURE_DATA);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
}
|
||
break;
|
||
case EN_MEASU_BTN_SELECT_TASK:
|
||
{
|
||
//选中任务时,更新按钮状态
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
|
||
pWnd = GetDlgItem(IDB_DETAIL_MEASURE_DATA);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
}
|
||
break;
|
||
case EN_MEASU_BTN_NOT_TESTING_TASK:
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if(NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if(NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_DETAIL_MEASURE_DATA);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
}
|
||
break;
|
||
case EN_MEASU_BTN_OFFLINE_DEVICE:
|
||
{
|
||
pWnd = GetDlgItem(IDB_MEASURE_ALL);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_FROM_CUR);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_SUSPEND_MEAU);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_MEASURE_CUR_PT);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(FALSE);
|
||
|
||
pWnd = GetDlgItem(IDB_DETAIL_MEASURE_DATA);
|
||
if (NULL != pWnd)
|
||
pWnd->EnableWindow(TRUE);
|
||
}
|
||
break;
|
||
default:
|
||
CString strErr = _T("");
|
||
strErr.Format(_T("Unknow button status(%d)"),ucBtnStatus);
|
||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
|
||
}
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::OnMeasureAll()
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
if (EN_TASK_NO_UPLOAD == m_stTaskItem.eSynStatus)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("未上传的本地任务不支持此操作,只支持调试测试"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Unuploaded local tasks do not support this operation, only debug tests"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
//获取当前正在测量的任务,如果有,则不允许测试
|
||
if (!m_strTestingTaskID.IsEmpty() && (strcmp(m_strTaskCN, m_strTestingTaskID) != 0))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("暂时无法测量,有正常测量的任务"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Temporarily unable to measure, there are normal measurement tasks"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
g_eTestingMethod = EN_TASK_ALL_POINT_TEST;
|
||
STTrusteeTaskTable stTaskTable;
|
||
memset(stTaskTable.Task.stManualTask.ucTaskID, 0, MAX_NAME_LEN);
|
||
|
||
stTaskTable.uiGD10Id = htonl(m_uiDevID);
|
||
stTaskTable.uiPlcId = htonl(m_uiPlcID);
|
||
stTaskTable.ucTeatMode = EN_MANUAL_TASK;
|
||
strncpy(stTaskTable.Task.stManualTask.ucTaskID, m_stTaskArg.ucTaskID, MAX_NAME_LEN);
|
||
stTaskTable.Task.stManualTask.uiStartPoint = htonl(1);
|
||
stTaskTable.Task.stManualTask.uiEndPoint = htonl(m_stTaskArg.uiTotalNum);
|
||
|
||
theApp.m_NetWorkOper.SetSuspendForThread(true);
|
||
PostNetRequest(EN_REQ_COLLOCATION, this->m_hWnd, (char*)&stTaskTable, sizeof(STTrusteeTaskTable));
|
||
// if (!theApp.m_NetWorkOper.SendCtrlMsgDirect(EN_REQ_COLLOCATION, 0xFFFFFFFF, 1, (char*)&stTaskTable, sizeof(STTrusteeTaskTable)))
|
||
// {
|
||
// theApp.m_NetWorkOper.SetSuspendForThread(false);
|
||
// AfxMessageBox(_T("Trust task info send failed."));
|
||
// return;
|
||
// }
|
||
// if (EN_RECV_SUCCESS == theApp.m_NetWorkOper.RecvMsgDirect(chStr, &iLen, 10, 5000))
|
||
// {
|
||
// if ((iLen <= 0) || (1 == chStr[0]))
|
||
// {
|
||
// theApp.m_NetWorkOper.SetSuspendForThread(false);
|
||
// CString szMsg;
|
||
// szMsg.Format(_T("Task start test to failed."), stTaskTable.Task.stManualTask.ucTaskID);
|
||
// AfxMessageBox(szMsg);
|
||
// return;
|
||
// }
|
||
// }
|
||
theApp.m_NetWorkOper.SetSuspendForThread(false);
|
||
//GetParent()->SendMessage(WM_TASK_LIST_TASK_INFO_SYN, (WPARAM)&vtSaveSynTaskArg, (LPARAM)&pThis->m_vtNeedSynTaskID);
|
||
|
||
}
|
||
|
||
|
||
void CDialRealTimeMeasureData::OnMeasureCurPt()
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
|
||
if (EN_TASK_NO_UPLOAD == m_stTaskItem.eSynStatus)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("未上传的本地任务不支持此操作,只支持调试测试"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Unuploaded local tasks do not support this operation, only debug tests"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
return;
|
||
}
|
||
/*else if (0 != strcmp(m_stTaskArg.ucTaskID,m_stTaskItem.szTaskID))
|
||
{
|
||
AfxMessageBox(_T("此种状态下不支持"));
|
||
return;
|
||
}*/
|
||
//获取当前正在测量的任务,如果有,则不允许测试
|
||
if (!m_strTestingTaskID.IsEmpty() && (strcmp(m_strTaskCN, m_strTestingTaskID) != 0))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("暂时无法测量,有正常测量的任务"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Temporarily unable to measure, there are normal measurement tasks"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
int iCurSel = -1;
|
||
iCurSel = m_dialListMeasuTask.m_listData.GetSelectionMark();
|
||
if (-1 == iCurSel)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("请先选择当前位置"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Please select position firstly"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
g_eTestingMethod = EN_TASK_CURRENT_ONE_POINT_TEST;
|
||
m_iSelMeasuIndex = iCurSel;
|
||
int iTsn = m_dialListMeasuTask.m_listData.GetItemData(iCurSel);
|
||
|
||
char chStr[200] = { 0 };
|
||
char chSendStr[MAX_NAME_LEN + sizeof(UINT32)* 2] = { 0 };
|
||
int iLen = 0;
|
||
UINT32 uiStartPoint = htonl(iTsn);
|
||
UINT32 uiEndPoint = htonl(iTsn);
|
||
strncpy(chSendStr, m_stTaskItem.szTaskID, MAX_NAME_LEN * sizeof(BYTE));
|
||
memcpy(&chSendStr[MAX_NAME_LEN], &uiStartPoint, sizeof(UINT32));
|
||
memcpy(&chSendStr[MAX_NAME_LEN + sizeof(UINT32)], &uiEndPoint, sizeof(UINT32));
|
||
theApp.m_NetWorkOper.SetSuspendForThread(true);
|
||
PostNetRequest(EN_REQ_TASK_CONTINUE, this->m_hWnd, (char*)chSendStr, sizeof(chSendStr));
|
||
|
||
theApp.m_NetWorkOper.SetSuspendForThread(false);
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_SIG);
|
||
// //开始测量成功后,更新列表控件
|
||
g_strSaveTestingTaskID = m_stTaskItem.szTaskID;
|
||
g_strSaveSuspendedTaskID.Empty();
|
||
GetParent()->SendMessage(WM_MSG_UPDATE_TASK_LIST, 0, 0);
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::OnMeasureFromCur()
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
|
||
if (EN_TASK_NO_UPLOAD == m_stTaskItem.eSynStatus)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("未上传的本地任务不支持此操作,只支持调试测试"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Unuploaded local tasks do not support this operation, only debug tests"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
return;
|
||
}
|
||
|
||
//获取当前正在测量的任务,如果有,则不允许测试
|
||
if (!m_strTestingTaskID.IsEmpty() && (strcmp(m_strTaskCN, m_strTestingTaskID) != 0))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("暂时无法测量,有正常测量的任务"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Temporarily unable to measure, there are normal measurement tasks"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
int iCurSel = -1;
|
||
iCurSel = m_dialListMeasuTask.m_listData.GetSelectionMark();
|
||
if (-1 == iCurSel)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("请先选择当前位置"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Please select position firstly"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
return;
|
||
}
|
||
g_eTestingMethod = EN_TASK_FROM_CURRENT_POINT_TEST;
|
||
m_iSelMeasuIndex = iCurSel;
|
||
int iTsn = m_dialListMeasuTask.m_listData.GetItemData(iCurSel);
|
||
|
||
char chStr[200] = { 0 };
|
||
char chSendStr[MAX_NAME_LEN + sizeof(UINT32)*2] = { 0 };
|
||
int iLen = 0;
|
||
UINT32 uiStartPoint = htonl(iTsn);
|
||
UINT32 uiEndPoint = htonl(m_stTaskArg.uiTotalNum);
|
||
strncpy(chSendStr, m_stTaskItem.szTaskID, MAX_NAME_LEN * sizeof(BYTE));
|
||
memcpy(&chSendStr[MAX_NAME_LEN],&uiStartPoint,sizeof(UINT32));
|
||
memcpy(&chSendStr[MAX_NAME_LEN + sizeof(UINT32)], &uiEndPoint, sizeof(UINT32));
|
||
theApp.m_NetWorkOper.SetSuspendForThread(true);
|
||
PostNetRequest(EN_REQ_TASK_CONTINUE, this->m_hWnd, (char*)chSendStr, sizeof(chSendStr));
|
||
|
||
theApp.m_NetWorkOper.SetSuspendForThread(false);
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_FROM_CUR);
|
||
//开始测量成功后,更新列表控件
|
||
g_strSaveTestingTaskID = m_stTaskItem.szTaskID;
|
||
g_strSaveSuspendedTaskID.Empty();
|
||
GetParent()->SendMessage(WM_MSG_UPDATE_TASK_LIST, 0, 0);
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::SetTaskListSelectItem(STTaskListItem* pSelectTaskItem)
|
||
{
|
||
memcpy(&m_stTaskItem, pSelectTaskItem, sizeof(STTaskListItem));
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::OnShowDetailMeasureData()
|
||
{
|
||
CDialMeasureDetailInfo detailInfo(m_stTaskArg);
|
||
detailInfo.SetSptType(m_iSptType);
|
||
detailInfo.DoModal();
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::ClearRecvBuffer()
|
||
{
|
||
memset(m_ucData, 0, sizeof(m_ucData));
|
||
m_iRecvDataLen = 0;
|
||
}
|
||
|
||
bool CDialRealTimeMeasureData::RecvMeasureGRData()
|
||
{
|
||
// BYTE ucCnt = m_ucData[0];
|
||
// CString strInfo = _T("");
|
||
// if (ucCnt != 1)
|
||
// {
|
||
// strInfo.Empty();
|
||
// strInfo.Format(_T("接收接地电阻数量错误,测试数量 = 1, 实际测试数量 = %d"), ucCnt);
|
||
// AfxMessageBox(strInfo);
|
||
// return false;
|
||
// }
|
||
// if (m_iRecvDataLen != sizeof(STMeasuGRResult))
|
||
// {
|
||
// strInfo.Empty();
|
||
// strInfo.Format(_T("接地电阻数据长度错误,协议长度 = %d, 实际接收长度 = %d"), sizeof(STMeasuGRResult), m_iRecvDataLen);
|
||
// AfxMessageBox(strInfo);
|
||
// return false;
|
||
// }
|
||
// STMeasuGRResult* pMeasuResult = (STMeasuGRResult*)m_ucData;
|
||
return true;
|
||
|
||
}
|
||
|
||
/*void CDialRealTimeMeasureData::GetMeasuDataSendInfo()*/
|
||
|
||
void CDialRealTimeMeasureData::StopMeasuDataInfo(bool bIsNormalExit)
|
||
{
|
||
int iID = 0;
|
||
if(EN_MEASURE_DATA == m_iMeasuType)
|
||
{
|
||
/* iID = 1;*/
|
||
//只有处在这2中模式下才会连续打开表
|
||
// if (EN_MEASURE_ALL == m_iMeasuMethod || EM_MEASURE_FROM_ID == m_iMeasuMethod)
|
||
// {
|
||
if (m_bIsOpenTbData)
|
||
{
|
||
m_TaskdDBOper.CloseTdData();
|
||
m_bIsOpenTbData = false;
|
||
}
|
||
// }
|
||
}
|
||
else
|
||
{
|
||
// iID = 2;
|
||
m_iRecvElecID = 0;
|
||
}
|
||
// KillTimer(iID);
|
||
m_bIsSigMeasuring = false;
|
||
m_iRepeatSndCnt = -1;
|
||
// m_bIsNetOper = false;
|
||
if (bIsNormalExit)
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_FIN;
|
||
else
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_TERIMI;
|
||
// if (bIsSigMeasu)
|
||
// m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_FIN;
|
||
// else
|
||
// m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_TERIMI;
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::ProcRcvData(const STCtrlProtoHeader& stCtrlInfo, const char* pData)
|
||
{
|
||
if (stCtrlInfo.wIDCode == CTRL_GD10_CODE)
|
||
ProcGD10Data(stCtrlInfo, pData);
|
||
else if (stCtrlInfo.wIDCode == CTRL_PLC_CODE)
|
||
ProcPLCData(stCtrlInfo,pData);
|
||
else
|
||
{
|
||
CString strErr = _T("");
|
||
strErr.Format(_T("Unknow ID Code(%08x)"), stCtrlInfo.wIDCode);
|
||
AfxMessageBox(strErr);
|
||
}
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::ProcGD10Data(const STCtrlProtoHeader& stCtrlHeader, const char* pPayload)
|
||
{
|
||
if (0 == stCtrlHeader.ucCMD && 1 == stCtrlHeader.ucDataType)
|
||
{
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
|
||
}
|
||
void CDialRealTimeMeasureData::ProcPLCData(const STCtrlProtoHeader& stCtrlHeader, const char* pPayload)
|
||
{
|
||
|
||
}
|
||
int CDialRealTimeMeasureData::ProcRcvMeasuData()
|
||
{
|
||
CString strErr;
|
||
if (m_iRecvDataLen < 1)
|
||
{
|
||
strErr.Empty();
|
||
strErr.Format(_T("[%s][%d]接收数据错误,接收字节数不能小于1"),MODULE_NAME, __LINE__);
|
||
CFileOperTools::GetInstance()->WriteComLog(strErr);
|
||
return EN_MEASU_PROC_DATA_ERR;
|
||
}
|
||
BYTE ucPacketNum = *((BYTE*)m_ucData+sizeof(m_stQueryTdInfo.ucTaskID));
|
||
|
||
if (ucPacketNum != m_vtMeasureData.size())
|
||
{
|
||
strErr.Empty();
|
||
strErr.Format(_T("[%s][%d]recv packet number error,should be %d,but actually is %d"), MODULE_NAME, __LINE__,m_vtMeasureData.size(),ucPacketNum);
|
||
CFileOperTools::GetInstance()->WriteComLog(strErr);
|
||
return EN_MEASU_PROC_DATA_ERR;
|
||
}
|
||
LPSTMeasuBasicDataRes pMeasuBasicRes = NULL;
|
||
int iAttachLen = (1 == m_stQueryTdInfo.iTestType) ? sizeof(STMeasuDataResAttachIP) : 0;
|
||
//这里暂时没有对粘包或者分包做处理
|
||
if (m_iRecvDataLen != (1 + sizeof(m_stQueryTdInfo.ucTaskID) + ucPacketNum*(sizeof(STMeasuDataResBasic)+iAttachLen)))
|
||
{
|
||
strErr.Empty();
|
||
strErr.Format(_T("[%s][%d]recv packet length error,should be %d,but actually is %d"), MODULE_NAME, __LINE__, 1 + sizeof(m_stQueryTdInfo.ucTaskID) + ucPacketNum*(sizeof(STMeasuDataResBasic)+iAttachLen), m_iRecvDataLen);
|
||
CFileOperTools::GetInstance()->WriteComLog(strErr);
|
||
return EN_MEASU_PROC_DATA_ERR;
|
||
}
|
||
for (int i = 0; i < ucPacketNum; i++)
|
||
{
|
||
pMeasuBasicRes = (LPSTMeasuBasicDataRes)(m_ucData + 1 + sizeof(m_stQueryTdInfo.ucTaskID) + i*(sizeof(STMeasuDataResBasic)+iAttachLen));
|
||
pMeasuBasicRes->iID = ntohl(pMeasuBasicRes->iID);//by quyx 20180902
|
||
if (pMeasuBasicRes->iID != m_vtMeasureData[i].dwTsn)
|
||
{
|
||
strErr.Empty();
|
||
strErr.Format(_T("[%s][%d]recv data TSN disorder,should be %d,but actually is %d"), MODULE_NAME, __LINE__,m_vtMeasureData[i].dwTsn, pMeasuBasicRes->iID);
|
||
CFileOperTools::GetInstance()->WriteComLog(strErr);
|
||
return EN_MEASU_PROC_DATA_ERR;
|
||
}
|
||
//处理告警
|
||
CString strMeasuStaus = _T("");
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
strMeasuStaus.Format(_T("测量状态: %s"), GetMeasuStatusByAlarm(pMeasuBasicRes->ucAlram));
|
||
else
|
||
strMeasuStaus.Format(_T("Status: %s"), GetMeasuStatusByAlarm(pMeasuBasicRes->ucAlram));
|
||
|
||
m_dialListMeasuTask.ShowMeasuStatus(strMeasuStaus);
|
||
//如果碰到下面告警,则测量必须要停下来
|
||
//modifyed by lsq 20171019 这里应张杰的要求,修改临时版本,允许过流保护和短路保护时,继续测量
|
||
// if ((pMeasuBasicRes->ucAlram > 0 && pMeasuBasicRes->ucAlram < 3) ||
|
||
// (pMeasuBasicRes->ucAlram > 3 && pMeasuBasicRes->ucAlram < 7))
|
||
if (2 == pMeasuBasicRes->ucAlram)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("遇到严重告警,暂停测量"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Stop measurement when serious warning is encountered"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return EN_MEASU_PROC_WARINNG;
|
||
}
|
||
//网络序转本机序 by quyx 20180902
|
||
pMeasuBasicRes->fI = tcp_ntohf(pMeasuBasicRes->fI);
|
||
pMeasuBasicRes->fK = tcp_ntohf(pMeasuBasicRes->fK);
|
||
pMeasuBasicRes->fR0 = tcp_ntohf(pMeasuBasicRes->fR0);
|
||
pMeasuBasicRes->fR0_LC = tcp_ntohf(pMeasuBasicRes->fR0_LC);
|
||
pMeasuBasicRes->fSP = tcp_ntohf(pMeasuBasicRes->fSP);
|
||
pMeasuBasicRes->fV = tcp_ntohf(pMeasuBasicRes->fV);
|
||
if (m_TaskdDBOper.UpdateTdBasicData(m_stQueryTdInfo.iSptType, m_stQueryTdInfo.iTestType,m_stQueryTdInfo.iTdChannelID,
|
||
m_vtMeasureData[i].dwTsn, pMeasuBasicRes, m_ucData + 1 + sizeof(m_stQueryTdInfo.ucTaskID) + (i + 1)*sizeof(STMeasuDataResBasic)+i*iAttachLen))
|
||
{
|
||
// m_iListDataID++;
|
||
bool bIsNeedInsert = true;
|
||
int iItemIndex;
|
||
if (m_iSelMeasuIndex>=0 && m_iSelMeasuIndex < m_dialListMeasuTask.m_listData.GetItemCount() )
|
||
{
|
||
iItemIndex = m_iSelMeasuIndex++;
|
||
bIsNeedInsert = false;
|
||
}
|
||
else
|
||
{
|
||
m_iSelMeasuIndex = -1;
|
||
if (m_dialListMeasuTask.m_listData.GetItemCount() >= MAX_LIST_SHOW_NUM)
|
||
m_dialListMeasuTask.m_listData.DeleteAllItems();
|
||
iItemIndex = m_dialListMeasuTask.m_listData.GetItemCount();
|
||
}
|
||
CString strTxt = _T("");
|
||
// if (EN_MEASU_BTN_MEASU_SIG == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
// {
|
||
// iItemIndex = m_dialListMeasuTask.m_listData.GetSelectionMark();
|
||
// }
|
||
// else
|
||
// {
|
||
if (bIsNeedInsert)
|
||
{
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%d"), m_vtMeasureData[i].dwTsn);
|
||
m_dialListMeasuTask.m_listData.InsertItem(iItemIndex,strTxt);
|
||
}
|
||
|
||
|
||
int iColIndex = 1;
|
||
strTxt.Empty();
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
strTxt.Format(_T("%.2f"), m_vtMeasureData[i].fA);
|
||
else
|
||
strTxt.Format(_T("%d"), (int)m_vtMeasureData[i].fA);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
strTxt.Format(_T("%.2f"), m_vtMeasureData[i].fB);
|
||
else
|
||
strTxt.Format(_T("%d"), (int)m_vtMeasureData[i].fB);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
strTxt.Format(_T("%.2f"), m_vtMeasureData[i].fM);
|
||
else
|
||
strTxt.Format(_T("%d"), (int)m_vtMeasureData[i].fM);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
strTxt.Format(_T("%.2f"), m_vtMeasureData[i].fN);
|
||
else
|
||
strTxt.Format(_T("%d"), (int)m_vtMeasureData[i].fN);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%d"), pMeasuBasicRes->ucStack);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%.2f"), pMeasuBasicRes->fK);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%.2f"), pMeasuBasicRes->fV);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%.2f"), pMeasuBasicRes->fI);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
//如果警告为超量程的话,则此时R0的显示为空
|
||
if (7 != pMeasuBasicRes->ucAlram)
|
||
strTxt.Format(_T("%.2f"), pMeasuBasicRes->fR0);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%.2f"), pMeasuBasicRes->fSP);
|
||
m_dialListMeasuTask.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
m_dialListMeasuTask.m_listData.SetItemData(iItemIndex, m_vtMeasureData[i].dwTsn);
|
||
// m_dialListMeasuTask.m_listData.SetItemState(m_dialListMeasuTask.m_listData.GetItemCount()-1,LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
|
||
// m_dialListMeasuTask.m_listData.EnsureVisible(m_dialListMeasuTask.m_listData.GetItemCount()-1,false);
|
||
}
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("插入测量数据信息失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Failed to insert measurement data information"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return EN_MEASU_PROC_DB_ERR;
|
||
}
|
||
}
|
||
return EN_MEASU_PROC_SUCCESS;
|
||
}
|
||
bool CDialRealTimeMeasureData::ProcRcvGrData()
|
||
{
|
||
if (m_iRecvDataLen < 1)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("接收数据错误,接收字节数不能小于1"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Error receiving data. The number of bytes received must not be less than 1"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return false;
|
||
}
|
||
CString strErr = _T("");
|
||
BYTE ucElecNum = m_ucData[0];
|
||
if (ucElecNum != 1)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strErr.Format(_T("接地电阻测量的个数(%d)不等于1"), ucElecNum);
|
||
AfxMessageBox(strErr);
|
||
}
|
||
else
|
||
{
|
||
strErr.Format(_T("The number of grounding resistance measurements (%d) is not equal to 1"), ucElecNum);
|
||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return false;
|
||
}
|
||
|
||
if (ucElecNum* sizeof(STMeasuSigGRResult) != (m_iRecvDataLen-1))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strErr.Format(_T("接收数据错误,实际接收=%d, 本该接收= %d"), m_iRecvDataLen, ucElecNum* sizeof(STMeasuSigGRResult) + 1);
|
||
AfxMessageBox(strErr);
|
||
}
|
||
else
|
||
{
|
||
strErr.Format(_T("Received data error, actual received =%d, should have received =%d"), m_iRecvDataLen, ucElecNum* sizeof(STMeasuSigGRResult) + 1);
|
||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return false;
|
||
}
|
||
int iItemIndex = 0;
|
||
STMeasuSigGRResult* pSigGr = NULL;
|
||
CString strTxt = _T("");
|
||
if (EN_MEASU_BTN_MEASU_SIG == m_ucMeasuBtnStatus[m_iMeasuType] || EN_MEASU_BTN_MEASU_FROM_CUR == m_ucMeasuBtnStatus[m_iMeasuType] ||
|
||
(EN_MEASU_BTN_SUSPEND == m_ucMeasuBtnStatus[m_iMeasuType] && (EN_MEASU_BTN_MEASU_SIG == m_ucLastBtnStatus ||
|
||
EN_MEASU_BTN_MEASU_FROM_CUR == m_ucLastBtnStatus)))
|
||
{
|
||
int iAddedID = 0;
|
||
if ((0 == m_stQueryTdInfo.iSptType) && (m_dialListMeasuGR.m_listData.GetSelectionMark() > 0))
|
||
iAddedID = 1;
|
||
if (m_TaskdDBOper.UpdateGrData(m_iTaskID, (const char*)(m_ucData + MAX_NAME_LEN + sizeof(INT32)), m_stQueryTdInfo.iSptType, iAddedID))
|
||
{
|
||
bool bIsNeedInsert = true;
|
||
if (m_iSelMeasuIndex>=0 && m_iSelMeasuIndex < m_dialListMeasuGR.m_listData.GetItemCount() )
|
||
{
|
||
iItemIndex = m_iSelMeasuIndex++;
|
||
bIsNeedInsert = false;
|
||
}
|
||
else
|
||
{
|
||
m_iSelMeasuIndex = -1;
|
||
if (m_dialListMeasuGR.m_listData.GetItemCount() >= MAX_LIST_SHOW_NUM_GR)
|
||
m_dialListMeasuGR.m_listData.DeleteAllItems();
|
||
iItemIndex = m_dialListMeasuGR.m_listData.GetItemCount();
|
||
}
|
||
|
||
// iItemIndex = m_dialListMeasuGR.m_listData.GetSelectionMark();
|
||
CString strTxt;
|
||
pSigGr = (STMeasuSigGRResult*)(m_ucData+1);
|
||
m_iRecvElecID = pSigGr->ucElecID;
|
||
if (bIsNeedInsert)
|
||
{
|
||
strTxt.Empty();
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
{
|
||
m_iRecvElecID = (char)pSigGr->ucElecID; //由于这里一维电极上传的会有负数,所以需要将从BYTE字节转换为CHAR类型,在
|
||
//赋值给m_iRecvElecID
|
||
if (-1 == m_iRecvElecID)
|
||
strTxt = "AB";
|
||
else if (-2 == m_iRecvElecID)
|
||
strTxt = (theApp.m_ucIsMultiChannel > 0) ? _T("MN1") : _T("MN");
|
||
else
|
||
{
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("MN%d"),abs(m_iRecvElecID)-1);
|
||
}
|
||
}
|
||
else
|
||
strTxt.Format(_T("%d"), pSigGr->ucElecID);
|
||
m_dialListMeasuGR.m_listData.InsertItem(iItemIndex,strTxt);
|
||
}
|
||
int iColIndex = 1;
|
||
|
||
|
||
pSigGr->iP1 = ntohl(pSigGr->iP1);
|
||
pSigGr->iP2 = ntohl(pSigGr->iP2);
|
||
if (-1 != pSigGr->iP1)
|
||
{
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%d"),pSigGr->iP1);
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
strTxt = GetGRStatus(pSigGr->ucP1Status);
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
}
|
||
else
|
||
iColIndex += 2;
|
||
|
||
if (-1 != pSigGr->iP2)
|
||
{
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%d"),pSigGr->iP2);
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
|
||
strTxt = GetGRStatus(pSigGr->ucP2Status);
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex, iColIndex++, strTxt);
|
||
}
|
||
|
||
return true;
|
||
}
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("更新接地电阻信息失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Failed to update grounding resistance information"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return false;
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
if (m_TaskdDBOper.InsertGrData(m_iTaskID, ucElecNum, (const char*)(m_ucData+MAX_NAME_LEN+sizeof(INT32)), m_stQueryTdInfo.iSptType) )
|
||
{
|
||
if (m_dialListMeasuGR.m_listData.GetItemCount() >= MAX_LIST_SHOW_NUM_GR)
|
||
{
|
||
m_dialListMeasuGR.m_listData.DeleteAllItems();
|
||
}
|
||
iItemIndex = m_dialListMeasuGR.m_listData.GetItemCount();
|
||
|
||
for (int i = 0; i < ucElecNum; i++)
|
||
{
|
||
pSigGr = (STMeasuSigGRResult*)(m_ucData+1+i*sizeof(STMeasuSigGRResult));
|
||
m_dialListMeasuGR.m_listData.InsertItem(iItemIndex+i, _T(""));
|
||
int iColIndex = 0;
|
||
strTxt.Empty();
|
||
m_iRecvElecID = pSigGr->ucElecID;
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
{
|
||
m_iRecvElecID = (char)pSigGr->ucElecID;
|
||
if (-1 == m_iRecvElecID)
|
||
strTxt = "AB";
|
||
else if (-2 == m_iRecvElecID)
|
||
strTxt = (theApp.m_ucIsMultiChannel > 0) ? _T("MN1") : _T("MN");
|
||
else
|
||
{
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("MN%d"),abs(m_iRecvElecID)-1);
|
||
}
|
||
}
|
||
// strTxt = (-1 == pSigGr->ucElecID) ? _T("AB") : _T("MN");
|
||
else
|
||
strTxt.Format(_T("%d"), pSigGr->ucElecID);
|
||
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex+i, iColIndex++, strTxt);
|
||
pSigGr->iP1 = ntohl(pSigGr->iP1);
|
||
pSigGr->iP2 = ntohl(pSigGr->iP2);
|
||
if (-1 != pSigGr->iP1)
|
||
{
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%d"),pSigGr->iP1);
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex+i, iColIndex++, strTxt);
|
||
strTxt = GetGRStatus(pSigGr->ucP1Status);
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex+i, iColIndex++, strTxt);
|
||
}
|
||
else
|
||
iColIndex += 2;
|
||
|
||
if (-1 != pSigGr->iP2)
|
||
{
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%d"),pSigGr->iP2);
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex+i, iColIndex++, strTxt);
|
||
|
||
strTxt = GetGRStatus(pSigGr->ucP2Status);
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex+i, iColIndex++, strTxt);
|
||
}
|
||
m_dialListMeasuGR.m_listData.SetItemState(m_dialListMeasuGR.m_listData.GetItemCount()-1,LVNI_FOCUSED | LVIS_SELECTED, LVNI_FOCUSED | LVIS_SELECTED);
|
||
m_dialListMeasuGR.m_listData.EnsureVisible(m_dialListMeasuGR.m_listData.GetItemCount()-1,false);
|
||
|
||
}
|
||
return true;
|
||
|
||
}
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("插入接地电阻信息失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Failed to insert grounding resistance information"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return false;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::NotifyResFunc(LPARAM lOperType, LPARAM lOperRes, LPVOID lpWnd)
|
||
{
|
||
if (NULL == lpWnd)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("通知窗口指针不能为空"));
|
||
else
|
||
MessageBoxEx(NULL, _T("The pointer to the notification window cannot be empty"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
// pDialMeasu->m_bIsSigMeasuring = false;
|
||
return;
|
||
}
|
||
CDialRealTimeMeasureData* pDialMeasu = (CDialRealTimeMeasureData*)lpWnd;
|
||
CString strTips = _T("");
|
||
//如果是发送失败,或者是下发任务失败的话,则直接进行提示
|
||
if (EN_RECV_SUCCESS != lOperRes && EN_CTRL_MEASURE_DATA != pDialMeasu->m_ucCmd)
|
||
{
|
||
pDialMeasu->StopMeasuDataInfo(false);
|
||
// pDialMeasu->ClearRecvBuffer();
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strTips.Format(_T("测量失败,出错代码为(%d,%d)"), lOperType, lOperRes);
|
||
AfxMessageBox(strTips);
|
||
}
|
||
else
|
||
{
|
||
strTips.Format(_T("Test failed, error ID(%d,%d)"), lOperType, lOperRes);
|
||
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
|
||
|
||
// GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
|
||
return;
|
||
}
|
||
|
||
if (EN_CTRL_SET_TASK_PARAM == pDialMeasu->m_ucCmd)
|
||
{
|
||
pDialMeasu->m_bIsDownLoadTask = true;
|
||
// pDialMeasu->m_bIsNetOper = false;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("下发成功"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Set up successfully"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
//pDialMeasu->GetDlgItem(IDB_MEASURE_DOWNLOAD_MEASU_CFG)->EnableWindow(FALSE);
|
||
pDialMeasu->GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(TRUE);
|
||
pDialMeasu->GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(TRUE);
|
||
pDialMeasu->GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(TRUE);
|
||
if ((0 == pDialMeasu->m_stQueryTdInfo.iSptType) && (EN_MEASURE_GR == pDialMeasu->m_iMeasuType))
|
||
{
|
||
pDialMeasu->GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(FALSE);
|
||
if (0 == theApp.m_ucIsMultiChannel)
|
||
pDialMeasu->GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(FALSE);
|
||
|
||
}
|
||
return;
|
||
}
|
||
CString strLog = _T("");
|
||
if(EN_MEASURE_DATA == pDialMeasu->m_iMeasuType)
|
||
{
|
||
//如果是超时或者是数据错误的话,则运行进行重测
|
||
if (lOperRes == EN_RECV_TIMEOUT || lOperRes == EN_RECV_DATA_ERROR|| lOperRes == EN_RECV_DATA_DISORDER ||
|
||
EN_CLOUND_SND_FAILED == lOperRes)
|
||
{
|
||
if (-1 == pDialMeasu->m_iRepeatSndCnt)
|
||
{
|
||
strLog.Empty();
|
||
strLog.Format(_T("[%s][%d]Is being trigger repeat measure, tripper reason = %d"), MODULE_NAME, __LINE__, lOperRes);
|
||
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
||
pDialMeasu->m_iRepeatSndCnt = MAX_REPEAT_SND_CNT+1;
|
||
}
|
||
else
|
||
{
|
||
strLog.Empty();
|
||
strLog.Format(_T("[%s][%d]measure data failed, OperType = %d,OperRes = %d,NeedRepeatCnt = %d"),
|
||
MODULE_NAME, __LINE__,lOperType,lOperRes, pDialMeasu->m_iRepeatSndCnt);
|
||
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
||
}
|
||
|
||
|
||
}
|
||
else if (lOperRes == EN_RECV_SUCCESS)
|
||
{
|
||
int iRes = pDialMeasu->ProcRcvMeasuData();
|
||
if (iRes == EN_MEASU_PROC_DB_ERR || iRes == EN_MEASU_PROC_WARINNG)
|
||
{
|
||
pDialMeasu->StopMeasuDataInfo(false);
|
||
return;
|
||
}
|
||
else if (iRes == EN_MEASU_PROC_SUCCESS)
|
||
{
|
||
//如果成功处理该报文,则进行下一个报文的处理,此时需要将重发次数改为-1
|
||
if (EN_MEASU_BTN_MEASU_SIG == pDialMeasu->m_ucMeasuBtnStatus[pDialMeasu->m_iMeasuType])
|
||
{
|
||
pDialMeasu->StopMeasuDataInfo();
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("单点测量完成"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Test point tested"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
pDialMeasu->SetBtnStatus(pDialMeasu->m_ucMeasuBtnStatus[pDialMeasu->m_iMeasuType]);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
pDialMeasu->m_iRepeatSndCnt = -1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//如果是处理失败,则丢弃该响应报文,重发该数据
|
||
if(-1 == pDialMeasu->m_iRepeatSndCnt)
|
||
pDialMeasu->m_iRepeatSndCnt = MAX_REPEAT_SND_CNT+1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pDialMeasu->StopMeasuDataInfo(false);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strTips.Format(_T("测量数据失败,出错代码为(%d,%d)"), lOperType, lOperRes);
|
||
AfxMessageBox(strTips);
|
||
}
|
||
else
|
||
{
|
||
strTips.Format(_T("Measurement data failed, error code is (%d,%d)"), lOperType, lOperRes);
|
||
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return;
|
||
}
|
||
|
||
}
|
||
if (EN_MEASURE_GR == pDialMeasu->m_iMeasuType)
|
||
{
|
||
//如果插入信息成功,则处理下一条
|
||
if (pDialMeasu->ProcRcvGrData())
|
||
{
|
||
if (EN_MEASU_BTN_MEASU_SIG == pDialMeasu->m_ucMeasuBtnStatus[pDialMeasu->m_iMeasuType])
|
||
{
|
||
pDialMeasu->StopMeasuDataInfo();
|
||
if(LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("单点接地电阻测量完成"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Grounding Resistance point tested"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
pDialMeasu->SetBtnStatus(pDialMeasu->m_ucMeasuBtnStatus[pDialMeasu->m_iMeasuType]);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
bool bIsFinshed = false;
|
||
if (0 == pDialMeasu->m_stQueryTdInfo.iSptType)
|
||
{
|
||
if (theApp.m_ucMaxChannel == (abs(pDialMeasu->m_iRecvElecID)-1) )
|
||
bIsFinshed = true;
|
||
}
|
||
else
|
||
{
|
||
if (pDialMeasu->m_stQueryTdInfo.iEndElec > 0)
|
||
{
|
||
if (pDialMeasu->m_iRecvElecID >= pDialMeasu->m_stQueryTdInfo.iEndElec)
|
||
bIsFinshed = true;
|
||
}
|
||
else if(pDialMeasu->m_stQueryTdInfo.iEndElec == 0)
|
||
bIsFinshed= true;
|
||
}
|
||
|
||
|
||
if(bIsFinshed)
|
||
{
|
||
pDialMeasu->StopMeasuDataInfo();
|
||
if(LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("接地电阻测量完成"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Grounding Resistance tested"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
pDialMeasu->m_ucMeasuBtnStatus[pDialMeasu->m_iMeasuType] = EN_MEASU_BTN_MEASU_FIN;
|
||
pDialMeasu->SetBtnStatus(EN_MEASU_BTN_MEASU_FIN);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pDialMeasu->StopMeasuDataInfo(false);
|
||
return;
|
||
}
|
||
}
|
||
|
||
pDialMeasu->m_bIsSigMeasuring = false;
|
||
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::OnSelchangeTabChg(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
//need trans
|
||
int iCurSel;
|
||
if (EN_MEASU_BTN_MEASU_ALL == m_ucMeasuBtnStatus[m_iMeasuType] || EN_MEASU_BTN_MEASU_FROM_CUR == m_ucMeasuBtnStatus[m_iMeasuType] ||
|
||
EN_MEASU_BTN_MEASU_SIG == m_ucMeasuBtnStatus[m_iMeasuType] || EN_MEASU_BTN_COUNTINE == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
{
|
||
iCurSel = m_tabChange.GetCurSel();
|
||
if (0 == iCurSel)
|
||
iCurSel = 1;
|
||
else
|
||
iCurSel = 0;
|
||
m_tabChange.SetCurSel(iCurSel);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("请先停止测量"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Please stop measuring firstly"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
return;
|
||
}
|
||
if (m_bIsSigMeasuring)
|
||
{
|
||
iCurSel = m_tabChange.GetCurSel();
|
||
if (0 == iCurSel)
|
||
iCurSel = 1;
|
||
else
|
||
iCurSel = 0;
|
||
m_tabChange.SetCurSel(iCurSel);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("仍在测量过程中,请待测量停止后再重试"));
|
||
else
|
||
MessageBoxEx(NULL, _T("In process of testing, please wait untill finished"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
m_iMeasuType = m_tabChange.GetCurSel();
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
{
|
||
m_dialListMeasuTask.ShowWindow(SW_SHOW);
|
||
m_dialListMeasuGR.ShowWindow(SW_HIDE);
|
||
}
|
||
else
|
||
{
|
||
m_dialListMeasuTask.ShowWindow(SW_HIDE);
|
||
m_dialListMeasuGR.ShowWindow(SW_SHOW);
|
||
|
||
//已测试完成的任务,显示数据
|
||
// if (m_SelectTaskItem.byTestStatus == EN_TASK_STATE_FINISH)
|
||
// {
|
||
// InitGrList(m_dialListMeasuGR.m_listData, m_strTaskCN);
|
||
// }
|
||
//从云端下载未测试的gr数据
|
||
m_dialListMeasuGR.GetGRRequest(m_stTaskArg);
|
||
|
||
/*if ((0 == m_stQueryTdInfo.iSptType) && m_bIsDownLoadTask)
|
||
{
|
||
if (theApp.m_ucIsMultiChannel > 0)
|
||
{
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(TRUE);
|
||
}
|
||
|
||
else
|
||
{
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(TRUE);
|
||
}
|
||
*pResult = 0;
|
||
return;
|
||
}*/
|
||
|
||
|
||
}
|
||
SetBtnStatus(m_ucMeasuBtnStatus[m_iMeasuType]);
|
||
/*
|
||
//对测量中断按钮的变换
|
||
if (m_ucMeasuBtnStatus[iCurSel] == EN_MEASU_BTN_SUSPEND)
|
||
{
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("继续测量"));
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(TRUE);
|
||
}
|
||
else
|
||
{
|
||
if (m_bIsSuspenMeasu[iCurSel])
|
||
{
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("继续测量"));
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(TRUE);
|
||
}
|
||
else
|
||
{
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("暂停测量"));
|
||
if (m_ucMeasuBtnStatus[iCurSel] == EN_MEASU_BTN_COUNTINE ||
|
||
m_ucMeasuBtnStatus[iCurSel] == EN_MEASU_BTN_MEASU_ALL)
|
||
{
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(TRUE);
|
||
}
|
||
else
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
}
|
||
|
||
}
|
||
*/
|
||
|
||
|
||
*pResult = 0;
|
||
}
|
||
|
||
int CDialRealTimeMeasureData::GetNeedMeasuData(char* pData,int &iLen, int iMaxLen)
|
||
{
|
||
iLen = 0;
|
||
m_vtMeasureData.clear();
|
||
if (m_TaskdDBOper.QueryNextTdBasicData(m_vtMeasureData) < 0)
|
||
{
|
||
return -1;
|
||
}
|
||
|
||
int iNum = m_vtMeasureData.size();
|
||
if (iNum > 0)
|
||
{
|
||
if (iMaxLen < iNum * sizeof(STSigSndDataInfo))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("数据长度不对"));
|
||
else
|
||
MessageBoxEx(NULL, _T("The length of measure data is overlength"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return -1;
|
||
}
|
||
|
||
memcpy(pData, m_stQueryTdInfo.ucTaskID, sizeof(m_stQueryTdInfo.ucTaskID));
|
||
pData[sizeof(m_stQueryTdInfo.ucTaskID)] = m_vtMeasureData.size();
|
||
for (int i = 0; i < m_vtMeasureData.size(); i++)
|
||
{
|
||
STSigSndDataInfo stSigData;//转网络序
|
||
memcpy(&stSigData, &m_vtMeasureData[i], sizeof(STSigSndDataInfo));
|
||
stSigData.dwTsn = htonl(stSigData.dwTsn);
|
||
stSigData.fA = tcp_htonf(stSigData.fA);
|
||
stSigData.fB = tcp_htonf(stSigData.fB);
|
||
stSigData.fM = tcp_htonf(stSigData.fM);
|
||
stSigData.fN = tcp_htonf(stSigData.fN);
|
||
stSigData.fK = tcp_htonf(stSigData.fK);
|
||
|
||
memcpy(pData + 1 + sizeof(m_stQueryTdInfo.ucTaskID) + i*sizeof(STSigSndDataInfo), &stSigData, sizeof(STSigSndDataInfo));
|
||
}
|
||
iLen = 1 + sizeof(m_stQueryTdInfo.ucTaskID)+iNum*sizeof(STSigSndDataInfo);
|
||
}
|
||
return 1;
|
||
}
|
||
|
||
int CDialRealTimeMeasureData::GetSigNeedMeasuData(char* pData, int &iLen, int iMaxLen)
|
||
{
|
||
iLen = 0;
|
||
STSigSndDataInfo stData;
|
||
if (!m_TaskdDBOper.QueryTdSigBasicData(m_iTaskID, m_stQueryTdInfo.iSptType, m_iCurTsn, &stData))
|
||
{
|
||
// StopMeasuDataInfo(true);
|
||
return -1;
|
||
}
|
||
//pData[0] = 1;
|
||
memcpy(pData, m_stQueryTdInfo.ucTaskID, sizeof(m_stQueryTdInfo.ucTaskID));
|
||
pData[sizeof(m_stQueryTdInfo.ucTaskID)] = 1;
|
||
//网络序发送 by quxy 20180902
|
||
STSigSndDataInfo stTmpData;
|
||
memcpy(&stTmpData, &stData, sizeof(STSigSndDataInfo));
|
||
stTmpData.dwTsn = htonl(stTmpData.dwTsn);
|
||
stTmpData.fA = tcp_htonf(stTmpData.fA);
|
||
stTmpData.fB = tcp_htonf(stTmpData.fB);
|
||
stTmpData.fM = tcp_htonf(stTmpData.fM);
|
||
stTmpData.fN = tcp_htonf(stTmpData.fN);
|
||
stTmpData.fK = tcp_htonf(stTmpData.fK);
|
||
//BYTE ucStack;
|
||
memcpy(&pData[sizeof(m_stQueryTdInfo.ucTaskID)+1], &stTmpData, sizeof(STSigSndDataInfo));
|
||
iLen = 1 + sizeof(m_stQueryTdInfo.ucTaskID)+sizeof(STSigSndDataInfo);
|
||
m_vtMeasureData.clear();
|
||
m_vtMeasureData.push_back(stData);
|
||
return 1;
|
||
}
|
||
//获取下一个点的GR的测量命令,iAddtionalVal用于调节获取当前的值
|
||
int CDialRealTimeMeasureData::GetNeedMeasuGR(char* pData,int &iLen, int iMaxLen, int iAddtionalVal)
|
||
{
|
||
iLen = 0;
|
||
int iElecID = 0;
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
{
|
||
if (EN_MEASU_BTN_MEASU_SIG == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
{
|
||
iElecID = m_iRecvElecID;
|
||
}
|
||
else
|
||
{
|
||
if (m_stQueryTdInfo.iEndElec < 0)
|
||
{
|
||
iElecID = (m_iRecvElecID > m_stQueryTdInfo.iStartElec) ? m_stQueryTdInfo.iStartElec : m_iRecvElecID - 1;
|
||
if (iElecID > m_stQueryTdInfo.iEndElec)
|
||
{
|
||
return 1;
|
||
}
|
||
}
|
||
else
|
||
return 1;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
else
|
||
{
|
||
if (m_stQueryTdInfo.iEndElec > 0)
|
||
{
|
||
iElecID = (m_iRecvElecID < m_stQueryTdInfo.iStartElec) ? m_stQueryTdInfo.iStartElec : m_iRecvElecID + 1-iAddtionalVal;
|
||
}
|
||
if (iElecID > m_stQueryTdInfo.iEndElec)
|
||
{
|
||
return 1;
|
||
}
|
||
}
|
||
|
||
STMeasuGRRequest stMeasuGRReq;
|
||
stMeasuGRReq.ucStartElec = iElecID;
|
||
stMeasuGRReq.ucEndElec = iElecID;
|
||
memcpy(pData, &stMeasuGRReq, sizeof(STMeasuGRRequest));
|
||
iLen = sizeof(STMeasuGRRequest);
|
||
|
||
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::OnMeasureSuspendMeau()
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
// int iCurSel = m_tabChange.GetCurSel();
|
||
//need trans
|
||
/*if (EN_MEASU_BTN_MEASU_ALL == m_ucMeasuBtnStatus[m_iMeasuType] ||
|
||
EN_MEASU_BTN_MEASU_FROM_CUR == m_ucMeasuBtnStatus[m_iMeasuType] ||
|
||
EN_MEASU_BTN_COUNTINE == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
{
|
||
m_bIsSuspend = true;
|
||
m_ucLastBtnStatus = m_ucMeasuBtnStatus[m_iMeasuType];
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_SUSPEND;
|
||
SetBtnStatus(EN_MEASU_BTN_SUSPEND);
|
||
|
||
}*/
|
||
// else if (EN_MEASU_BTN_SUSPEND == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
// {
|
||
// m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_COUNTINE;
|
||
// SetBtnStatus(EN_MEASU_BTN_COUNTINE);
|
||
// m_bIsSuspend = false;
|
||
// }
|
||
if (EN_TASK_NO_UPLOAD == m_stTaskItem.eSynStatus)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("未上传的本地任务不支持此操作,只支持调试测试"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Unuploaded local tasks do not support this operation, only debug tests"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
//获取当前正在测量的任务,如果有,则不允许测试
|
||
if (!m_strTestingTaskID.IsEmpty() && (strcmp(m_strTaskCN, m_strTestingTaskID) != 0))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("暂时无法测量,有正常测量的任务"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Temporarily unable to measure, there are normal measurement tasks"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
if (m_stTaskItem.byTestStatus < 10 || m_stTaskItem.byTestStatus >= 20)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("非测试中任务不支持此操作"));
|
||
else
|
||
MessageBoxEx(NULL, _T("This operation is not supported for non-test tasks"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
g_eTestingMethod = EN_TASK_SUSPENDED;
|
||
char chStr[200] = { 0 };
|
||
char chSendStr[MAX_NAME_LEN + 1] = { 0 };
|
||
int iLen = 0;
|
||
|
||
theApp.m_NetWorkOper.SetSuspendForThread(true);
|
||
strncpy(chSendStr, m_stTaskItem.szTaskID, MAX_NAME_LEN * sizeof(BYTE));
|
||
PostNetRequest(EN_REQ_TASK_PAUSE, this->m_hWnd, (char*)chSendStr, MAX_NAME_LEN);
|
||
|
||
theApp.m_NetWorkOper.SetSuspendForThread(false);
|
||
SetBtnStatus(EN_MEASU_BTN_SUSPEND);
|
||
//暂停测量后更新任务状态
|
||
g_strSaveSuspendedTaskID = m_stTaskItem.szTaskID;
|
||
g_strSaveTestingTaskID.Empty();
|
||
GetParent()->SendMessage(WM_MSG_UPDATE_TASK_LIST, 0, 0);
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::ThreadJoin()
|
||
{
|
||
if (NULL == m_pThread)
|
||
{
|
||
return;
|
||
}
|
||
m_bIsRunning = false;
|
||
Sleep(200);
|
||
bool bIsShow = false;
|
||
while(!m_bIsThreadFinshed)
|
||
{
|
||
// if (!bIsShow)
|
||
// {
|
||
// AfxMessageBox(_T("线程正在关闭中,请稍候...."));
|
||
// bIsShow = true;
|
||
// }
|
||
Sleep(100);
|
||
}
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::OnClose()
|
||
{
|
||
// TODO: Add your message handler code here and/or call default
|
||
if (NULL != m_pThread)
|
||
{
|
||
int nRet = 0;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
nRet = AfxMessageBox(_T("是否确认关闭?"), MB_YESNO | MB_ICONQUESTION);
|
||
else
|
||
nRet = MessageBoxEx(NULL, _T("Close or not?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
if (IDYES != nRet)
|
||
return;
|
||
}
|
||
ThreadJoin();
|
||
//特别修改
|
||
//CNetRequestDialog::OnClose();
|
||
CNetRequestDialog::OnCancel();
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::OnCancel()
|
||
{
|
||
// TODO: Add extra cleanup here
|
||
if (m_iLoopCnt>0)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("请先等待循环测试完成"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Wait for the loop test to complete"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
CDialMeasuLoopTest dialLoop;
|
||
if (IDOK != dialLoop.DoModal())
|
||
{
|
||
return;
|
||
}
|
||
m_iLoopCnt = dialLoop.GetLoopCnt();
|
||
SetTimer(1, 1000, NULL);
|
||
|
||
// if (NULL != m_pThread)
|
||
// {
|
||
// if (IDYES != AfxMessageBox(_T("是否确认关闭?"), MB_YESNO | MB_ICONQUESTION))
|
||
// {
|
||
// return;
|
||
// }
|
||
// }
|
||
// ThreadJoin();
|
||
// CNetRequestDialog::OnCancel();
|
||
//
|
||
}
|
||
|
||
// void CDialRealTimeMeasureData::OnTCard(UINT idAction, DWORD dwActionData)
|
||
// {
|
||
// // TODO: Add your message handler code here
|
||
//
|
||
// }
|
||
|
||
void CDialRealTimeMeasureData::OnTimer(UINT nIDEvent)
|
||
{
|
||
// TODO: Add your message handler code here and/or call default
|
||
if (1 == nIDEvent)
|
||
{
|
||
if (EM_MEASU_BTN_INITI == m_ucMeasuBtnStatus[m_iMeasuType] ||
|
||
EN_MEASU_BTN_MEASU_FIN == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
{
|
||
m_iCurLoop++;
|
||
|
||
if (m_iCurLoop > m_iLoopCnt)
|
||
{
|
||
KillTimer(1);
|
||
m_iCurLoop = m_iLoopCnt = 0;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("循环测试完成"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Complete cycle test"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
CString strTxt = _T("");
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strTxt.Format(_T("测量次数:%d"), m_iCurLoop);
|
||
}
|
||
else
|
||
{
|
||
strTxt.Format(_T("Number of measurement:%d"), m_iCurLoop);
|
||
}
|
||
SetWindowText(strTxt);
|
||
OnMeasureAll();
|
||
}
|
||
//如果出错,则终止循环
|
||
else if (EN_MEASU_BTN_MEASU_TERIMI == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
{
|
||
m_iCurLoop = m_iLoopCnt = 0;
|
||
KillTimer(1);
|
||
}
|
||
}
|
||
CNetRequestDialog::OnTimer(nIDEvent);
|
||
}
|
||
|
||
void CDialRealTimeMeasureData::OnSelchangingTabChg(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
|
||
*pResult = 0;
|
||
}
|
||
void CDialRealTimeMeasureData::PreNetResponse(WPARAM wParam, LPARAM lParam)
|
||
{
|
||
LPRESPONSEPACKET pResponsePacket = (LPRESPONSEPACKET)lParam;
|
||
if (pResponsePacket == NULL)
|
||
{
|
||
return;
|
||
}
|
||
switch (pResponsePacket->clsPacketBase.ucCmd)
|
||
{
|
||
case EN_REQ_COLLOCATION:
|
||
{
|
||
if ((pResponsePacket->wDataLen < 0) || (EN_RECV_SUCCESS != pResponsePacket->pData[0]))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("任务开始测试失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Task start test to failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
m_dialListMeasuTask.m_listData.DeleteAllItems();
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_ALL);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
GetParent()->GetDlgItem(IDC_STATIC_TASK_DATA)->SetWindowTextA(_T("任务数据: 任务初始化..."));
|
||
}
|
||
else
|
||
{
|
||
GetParent()->GetDlgItem(IDC_STATIC_TASK_DATA)->SetWindowTextA(_T("Task Data: Task initialization..."));
|
||
}
|
||
|
||
GetParent()->SendMessage(WM_MSG_UPDATE_REALTIME_WND_BTN_STATUS, 0, 1);
|
||
//开始测量成功后,更新列表控件
|
||
g_strSaveTestingTaskID = m_stTaskItem.szTaskID;
|
||
g_strSaveSuspendedTaskID.Empty();
|
||
GetParent()->SendMessage(WM_MSG_UPDATE_TASK_LIST, 0, 0);
|
||
}
|
||
break;
|
||
case EN_REQ_TASK_CONTINUE:
|
||
{
|
||
if ((pResponsePacket->wDataLen < 0) || (EN_RECV_SUCCESS != pResponsePacket->pData[0]))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("任务继续测试失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Task coutinue measure to failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_SIG);
|
||
GetParent()->SendMessage(WM_MSG_UPDATE_REALTIME_WND_BTN_STATUS, 0, 1);
|
||
// //开始测量成功后,更新列表控件
|
||
g_strSaveTestingTaskID = m_stTaskItem.szTaskID;
|
||
g_strSaveSuspendedTaskID.Empty();
|
||
GetParent()->SendMessage(WM_MSG_UPDATE_TASK_LIST, 0, 0);
|
||
}
|
||
break;
|
||
case EN_REQ_TASK_PAUSE:
|
||
{
|
||
if ((pResponsePacket->wDataLen < 0) || (EN_RECV_SUCCESS != pResponsePacket->pData[0]))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("任务暂停失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Task pause to failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
bool CDialRealTimeMeasureData::InitGrList(CListCtrl &tdGrList, CString strTaskCN)
|
||
{
|
||
_RecordsetPtr pRecGrList = NULL;
|
||
CString szSql = _T("");
|
||
CString szLabel = _T("");
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
|
||
pRecGrList.CreateInstance(_uuidof(Recordset));
|
||
if ((int)VAL_ZERO != tdGrList.GetItemCount())
|
||
{
|
||
tdGrList.DeleteAllItems();
|
||
}
|
||
|
||
szSql.Format(_T("select Ecode,OMvalue,StatusCode,OM1value,StatusCode1 from gr where TDID = (select ID from td where TDCN='%s') order by Val(Ecode)"), strTaskCN);
|
||
pRecGrList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)theApp.m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
int iOMVal = -1, iOMVal1 = -1;
|
||
CString strECode, strOMVal, strOMVal1, strStatus, strStatus1;
|
||
while ((short)VAL_ZERO == pRecGrList->adoEOF)
|
||
{
|
||
strOMVal.Empty();
|
||
strStatus.Empty();
|
||
strOMVal1.Empty();
|
||
strStatus1.Empty();
|
||
strECode = pRecGrList->GetCollect(_T("Ecode"));
|
||
tdGrList.InsertItem(iIndex, strECode);
|
||
iOMVal = (int)pRecGrList->GetCollect(_T("OMvalue")).lVal;
|
||
iOMVal1 = (int)pRecGrList->GetCollect(_T("OM1value")).lVal;
|
||
if (-1 != iOMVal)
|
||
{
|
||
strOMVal.Format(_T("%d"), iOMVal);
|
||
strStatus = GetGrCodeText((int)pRecGrList->GetCollect(_T("StatusCode")).lVal);
|
||
}
|
||
if (-1 != iOMVal1)
|
||
{
|
||
strOMVal1.Format(_T("%d"), iOMVal1);
|
||
strStatus1 = GetGrCodeText((int)pRecGrList->GetCollect(_T("StatusCode1")).lVal);
|
||
}
|
||
|
||
tdGrList.SetItemText(iIndex, 0, strECode);
|
||
tdGrList.SetItemText(iIndex, 1, strOMVal);
|
||
tdGrList.SetItemText(iIndex, 2, strStatus);
|
||
tdGrList.SetItemText(iIndex, 3, strOMVal1);
|
||
tdGrList.SetItemText(iIndex, 4, strStatus1);
|
||
iIndex++;
|
||
pRecGrList->MoveNext();
|
||
}
|
||
|
||
pRecGrList->Close();
|
||
return true;
|
||
} |