2262 lines
71 KiB
C++
2262 lines
71 KiB
C++
// DialMeasureData.cpp : implementation file
|
||
//
|
||
|
||
#include "stdafx.h"
|
||
#include "GeoMative.h"
|
||
#include "DialMeasureData.h"
|
||
#include "CtrlProtocolDef.h"
|
||
#include "FileOperTools.h"
|
||
#include "DialMeasuLoopTest.h"
|
||
#include <math.h>
|
||
#include "Lock/AutoLock.h"
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CDialMeasureData dialog
|
||
#define MODULE_NAME "CDialMeasureData"
|
||
extern SYSTEMTIME g_sysCurTime;
|
||
extern int g_UIOffset;
|
||
extern int g_iUILanguage;
|
||
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 CString GetMeasuStatusByAlarm(BYTE ucAlarm);
|
||
extern CString GetGrCodeText(int iCode);
|
||
CDialMeasureData::CDialMeasureData(CWnd* pParent /*=NULL*/)
|
||
: CNetRequestDialog(CDialMeasureData::IDD, pParent)
|
||
{
|
||
//{{AFX_DATA_INIT(CDialMeasureData)
|
||
// 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_enTestTypeCmd = EN_CMD_MEASURE_NO;
|
||
InitializeCriticalSection(&m_MutexSec);
|
||
InitializeCriticalSection(&m_dbSec);
|
||
}
|
||
|
||
CDialMeasureData::~CDialMeasureData()
|
||
{
|
||
DeleteCriticalSection(&m_MutexSec);
|
||
DeleteCriticalSection(&m_dbSec);
|
||
}
|
||
|
||
void CDialMeasureData::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CNetRequestDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CDialMeasureData)
|
||
DDX_Control(pDX, IDC_TAB_CHG, m_tabChange);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CDialMeasureData, CNetRequestDialog)
|
||
//{{AFX_MSG_MAP(CDialMeasureData)
|
||
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_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()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CDialMeasureData message handlers
|
||
|
||
BOOL CDialMeasureData::OnInitDialog()
|
||
{
|
||
CNetRequestDialog::OnInitDialog();
|
||
|
||
// TODO: Add extra initialization here
|
||
if (LANG_ENUS == g_iUILanguage)
|
||
{
|
||
SetWindowText(_T("Measurement"));
|
||
//GetDlgItem(IDB_MEASURE_DOWNLOAD_MEASU_CFG)->SetWindowText("Download");
|
||
GetDlgItem(IDB_MEASURE_ALL)->SetWindowText("Start Measure");
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->SetWindowText("Continue");
|
||
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText("Pause");
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->SetWindowText("Measure current");
|
||
GetDlgItem(IDCANCEL)->SetWindowText("Loop Test");
|
||
|
||
m_tabChange.InsertItem(0, _T("DATA"));
|
||
m_tabChange.InsertItem(1, _T("GR"));
|
||
m_tabChange.SetCurSel(0);
|
||
}
|
||
else
|
||
{
|
||
m_tabChange.InsertItem(0, _T("数据"));
|
||
m_tabChange.InsertItem(1, _T("接地电阻"));
|
||
m_tabChange.SetCurSel(0);
|
||
}
|
||
|
||
// m_dialListMeasuGR.m_listData.MoveWindow(&rect);
|
||
CTaskDataOper taskOper;
|
||
|
||
// char chTType[][10]={{"RES"},{"IP"},{"SP"}};
|
||
|
||
if (taskOper.QueryTdBasicInfo(m_iTaskID, &m_stQueryTdInfo, m_strTaskCN))
|
||
{
|
||
// 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
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("查询任务信息失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Query task information failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
|
||
//由于调试测量是调试本地,所以数据库一定存在数据
|
||
if (m_iTaskID <= 0)
|
||
{
|
||
m_iTaskID = m_stQueryTdInfo.iTaskID;
|
||
}
|
||
|
||
CRect rect;
|
||
m_tabChange.GetClientRect(&rect);
|
||
m_dialListMeasuTask.SetSptType(m_stQueryTdInfo.iSptType);
|
||
m_dialListMeasuTask.SetTaskID(m_iTaskID);
|
||
m_dialListMeasuTask.Create(IDD_DIALOG_MEASURE_LIST_DATA, &m_tabChange);
|
||
rect.top = rect.top + 25;
|
||
rect.left = rect.left + 2;
|
||
rect.right = rect.right -2;
|
||
rect.bottom = rect.bottom -8;
|
||
m_dialListMeasuTask.MoveWindow(&rect);
|
||
|
||
|
||
// m_dialListMeasuGR.SetMeasureType(1);
|
||
m_dialListMeasuGR.SetSptType(m_stQueryTdInfo.iSptType);
|
||
m_dialListMeasuGR.Create(IDD_DIALOG_MEASURE_LIST_GR, &m_tabChange);
|
||
m_dialListMeasuGR.MoveWindow(&rect);
|
||
m_dialListMeasuTask.SetMeasuStatus(&m_bIsSigMeasuring);
|
||
m_dialListMeasuTask.ShowWindow(SW_SHOW);
|
||
m_dialListMeasuGR.ShowWindow(SW_HIDE);
|
||
InitGrList(m_dialListMeasuGR.m_listData, m_strTaskCN);
|
||
// m_dialListMeasuTask.SetTaskID(m_iTaskID);
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(TRUE);
|
||
m_iMeasuType = EN_MEASURE_DATA;
|
||
|
||
//theApp.m_NetWorkOper.RegeditRealMsgCall(this->m_hWnd);
|
||
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
|
||
bool CDialMeasureData::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)
|
||
{
|
||
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;
|
||
}
|
||
BOOL CDialMeasureData::DestroyWindow()
|
||
{
|
||
//theApp.m_NetWorkOper.UnRegeditRealMsgCall(this->m_hWnd);
|
||
return CNetRequestDialog::DestroyWindow();
|
||
}
|
||
|
||
bool CDialMeasureData::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 CDialMeasureData::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 CDialMeasureData::SetBtnStatus(BYTE ucBtnStatus)
|
||
{
|
||
|
||
switch (ucBtnStatus)
|
||
{
|
||
case EN_MEASU_BTN_MEASU_ALL:
|
||
case EN_MEASU_BTN_MEASU_FROM_CUR:
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(FALSE);
|
||
if ((EN_MEASURE_DATA == m_iMeasuType) || (EN_MEASURE_GR == m_iMeasuType && m_stQueryTdInfo.iSptType > 0) )
|
||
{
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(TRUE);
|
||
if (LANG_ENUS == g_iUILanguage)
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("Suspend"));
|
||
else
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("暂停测量"));
|
||
}
|
||
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
break;
|
||
case EN_MEASU_BTN_MEASU_SIG:
|
||
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(FALSE);
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
break;
|
||
case EN_MEASU_BTN_SUSPEND:
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(TRUE);
|
||
//need trans
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
//GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("继续测量"));
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
m_dialListMeasuTask.EnablePreviewBtn(true);
|
||
break;
|
||
case EN_MEASU_BTN_COUNTINE:
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(FALSE);
|
||
if (LANG_ENUS == g_iUILanguage)
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("Suspend"));
|
||
else
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("暂停测试"));
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
break;
|
||
case EN_MEASU_BTN_MEASU_FIN:
|
||
case EN_MEASU_BTN_MEASU_TERIMI:
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(TRUE);
|
||
if ((EN_MEASURE_DATA == m_iMeasuType) || (EN_MEASURE_GR == m_iMeasuType && m_stQueryTdInfo.iSptType > 0) )
|
||
{
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
if (LANG_ENUS == g_iUILanguage)
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("Suspend"));
|
||
else
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("暂停测量"));
|
||
}
|
||
else
|
||
{
|
||
if (0 == theApp.m_ucIsMultiChannel)
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(FALSE);
|
||
}
|
||
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
m_dialListMeasuTask.EnablePreviewBtn(true);
|
||
break;
|
||
case EM_MEASU_BTN_INITI:
|
||
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 CDialMeasureData::OnMeasureAll()
|
||
{
|
||
m_enTestTypeCmd = EN_CMD_MEASURE_ALL;
|
||
if (!m_bIsDownLoadTask)
|
||
{
|
||
OnMeasureDownloadMeasuCfg();
|
||
return;
|
||
}
|
||
|
||
// TODO: Add your control notification handler code here
|
||
if (m_bIsSigMeasuring)
|
||
{
|
||
if (LANG_ZHCN ==g_iUILanguage)
|
||
AfxMessageBox(_T("正在进行测量,不可重复测量..."));
|
||
else
|
||
MessageBoxEx(NULL, _T("The measurement is in progress and cannot be repeated"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
//filled current test date and time to task by quyx 20180419
|
||
_CommandPtr pCmdUpd = NULL;
|
||
CString szTDate = _T("");
|
||
CString szTTime = _T("");
|
||
CString szSql = _T("");
|
||
DWORD dwID = DWORD(m_iTaskID);
|
||
|
||
szTDate.Empty();
|
||
szTDate.Format(_T("%04d-%02d-%02d"),g_sysCurTime.wYear, g_sysCurTime.wMonth, g_sysCurTime.wDay);
|
||
szTTime.Empty();
|
||
szTTime.Format(_T("%02d:%02d:%02d"),g_sysCurTime.wHour, g_sysCurTime.wMinute, g_sysCurTime.wSecond);
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
||
try
|
||
{
|
||
if ((szTDate.GetLength() != (int)VAL_ZERO) && (szTTime.GetLength() != (int)VAL_ZERO))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("update td set Tdate = '%s',Ttime = '%s' where ID = %d"), szTDate, szTTime,dwID);
|
||
theApp.m_pConnection->BeginTrans();
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
theApp.m_pConnection->CommitTrans();
|
||
}
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
theApp.m_pConnection->RollbackTrans();
|
||
AfxMessageBox(e.Description());
|
||
return;
|
||
}
|
||
//end filled current test date and time to task by quyx 20180419
|
||
|
||
m_iRepeatSndCnt = -1;
|
||
m_iSelMeasuIndex = -1;
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
{
|
||
|
||
if (m_bIsOpenTbData)
|
||
{
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
m_TaskdDBOper.CloseTdData();
|
||
}
|
||
|
||
m_bIsOpenTbData = false;
|
||
}
|
||
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
if (!m_TaskdDBOper.OpenTdData(m_iTaskID, m_stQueryTdInfo.iSptType, 1, theApp.m_ucMaxChannel))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("打开数据表失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Failed to open database table"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
}
|
||
m_dialListMeasuTask.m_listData.DeleteAllItems();
|
||
m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_ALL;
|
||
m_bIsOpenTbData = true;
|
||
m_bIsSuspend = false;
|
||
|
||
}
|
||
else if (EN_MEASURE_GR == m_iMeasuType)
|
||
{
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
if (!m_TaskdDBOper.DeleteGrInfo(m_iTaskID, 0, EN_DEL_ALL))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("数据清除操作失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Data cleaning operation failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
}
|
||
m_iGRAttionalVal = 0;
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_ALL;
|
||
// if (0 == m_stQueryTdInfo.iSptType)
|
||
// {
|
||
// for (int i = 1;)
|
||
// {
|
||
// }
|
||
// }
|
||
m_dialListMeasuGR.m_listData.DeleteAllItems();
|
||
m_dialListMeasuGR.InitiShowGR();
|
||
m_bIsSuspend = false;
|
||
if (m_stQueryTdInfo.iSptType == 0)
|
||
{
|
||
m_iRecvElecID = 0;
|
||
}
|
||
else
|
||
m_iRecvElecID = 0;
|
||
|
||
}
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_ALL);
|
||
return;
|
||
// m_iMeasuType
|
||
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
/*
|
||
int iCurSel = m_tabChange.GetCurSel();
|
||
if ((0 == m_stQueryTdInfo.iSptType) && (1 == iCurSel))
|
||
{
|
||
AfxMessageBox(_T("该模式只能使用单点测量"));
|
||
return;
|
||
}
|
||
|
||
int iOtherSel = (0 == iCurSel) ? 1 : 0;
|
||
if (((m_ucMeasuBtnStatus[iOtherSel] >= EN_MEASU_BTN_MEASU_ALL) && (m_ucMeasuBtnStatus[iOtherSel] <= EN_MEASU_BTN_COUNTINE))||
|
||
((m_ucMeasuBtnStatus[iCurSel]>=EN_MEASU_BTN_MEASU_ALL)&&(m_ucMeasuBtnStatus[iCurSel]<=EN_MEASU_BTN_COUNTINE)))
|
||
{
|
||
AfxMessageBox(_T("正在进行信息测量操作,请等待操作完成后再试..."));
|
||
return;
|
||
}
|
||
m_iMeasuType = m_tabChange.GetCurSel()+1;
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("暂停测量"));
|
||
m_ucMeasuBtnStatus[m_iMeasuType-1] = EN_MEASU_BTN_MEASU_ALL;
|
||
m_bIsSuspenMeasu[m_iMeasuType-1] = FALSE;
|
||
CTaskDataOper dataOper;
|
||
if (1 == m_iMeasuType)
|
||
{
|
||
m_dialListMeasuTask.m_listData.DeleteAllItems();
|
||
m_ucCmd = EN_CTRL_MEASURE_DATA;
|
||
m_bIsSigMeasuring = false;
|
||
m_iMeasuMethod = EN_MEASURE_ALL;
|
||
m_iMeasureDataID = 0;
|
||
// SetTimer(1, 100, NULL);
|
||
}
|
||
if (2 == m_iMeasuType)
|
||
{
|
||
if (!dataOper.DeleteGrInfo(m_iTaskID, 0, EN_DEL_ALL))
|
||
{
|
||
AfxMessageBox(_T("数据清除操作失败"));
|
||
return;
|
||
}
|
||
m_dialListMeasuGR.m_listData.DeleteAllItems();
|
||
m_ucCmd = EN_CTRL_MEASURE_GR;
|
||
m_iMeasuMethod = EN_MEASURE_ALL;
|
||
// SetTimer(2, 100, NULL);
|
||
}
|
||
*/
|
||
|
||
|
||
}
|
||
|
||
|
||
void CDialMeasureData::OnMeasureCurPt()
|
||
{
|
||
m_enTestTypeCmd = EN_CMD_MEASURE_ONE_POINT;
|
||
if (!m_bIsDownLoadTask)
|
||
{
|
||
OnMeasureDownloadMeasuCfg();
|
||
return;
|
||
}
|
||
|
||
|
||
// TODO: Add your control notification handler code here
|
||
// if (m_bIsNetOper)
|
||
// {
|
||
// AfxMessageBox(_T("上次操作仍未完成,请稍后再试..."));
|
||
// return;
|
||
// }
|
||
|
||
if (m_bIsSigMeasuring)
|
||
{
|
||
if (LANG_ZHCN ==g_iUILanguage)
|
||
AfxMessageBox(_T("正在进行测量,不可重复测量..."));
|
||
else
|
||
MessageBoxEx(NULL, _T("In process of testing ,please wait"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
if (m_ucMeasuBtnStatus[m_iMeasuType] == 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)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("正在进行测量,请先停止测试..."));
|
||
else
|
||
MessageBoxEx(NULL, _T("The measurement is in progress, please stop the test first"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
m_iRepeatSndCnt = -1;
|
||
int iCurSel = -1;
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
{
|
||
iCurSel = m_dialListMeasuTask.m_listData.GetSelectionMark();
|
||
if(-1 == iCurSel)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("请先选择当前位置"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Please choose one task first"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
m_iSelMeasuIndex = iCurSel;
|
||
m_iCurTsn = m_dialListMeasuTask.m_listData.GetItemData(iCurSel);
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_SIG;
|
||
m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
m_bIsSuspend = false;
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_SIG);
|
||
|
||
}
|
||
else if (EN_MEASURE_GR == m_iMeasuType)
|
||
{
|
||
iCurSel = m_dialListMeasuGR.m_listData.GetSelectionMark();
|
||
if(-1 == iCurSel)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("请先选择当前位置"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Please choose one task first"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
m_iGRAttionalVal = 1;
|
||
m_iSelMeasuIndex = iCurSel;
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
{
|
||
bool bIsStartMeasu = true;
|
||
m_iRecvElecID = -1*(iCurSel+1);
|
||
if (0 == iCurSel)
|
||
{
|
||
int nRet = 0;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
nRet = AfxMessageBox(_T("请在测量前将AB线接入MN,是否开始测量?"), MB_YESNO);
|
||
}
|
||
else
|
||
{
|
||
nRet = MessageBoxEx(NULL, _T("Please connect A/B eletrodes with M/N port for checking Grounding R.\r\nDo you want to measure?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
if (IDYES != nRet)
|
||
bIsStartMeasu = false;
|
||
}
|
||
if (!bIsStartMeasu)
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
CString strID = m_dialListMeasuGR.m_listData.GetItemText(iCurSel, 0);
|
||
if (strID.IsEmpty())
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("获取接地电阻的电极ID错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Error getting electrode ID for grounding resistance"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
m_iRecvElecID = atoi(strID);
|
||
}
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_SIG;
|
||
m_bIsSuspend = false;
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_SIG);
|
||
}
|
||
}
|
||
|
||
BOOL CDialMeasureData::OnMeasureDownloadMeasuCfg()
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
if (m_bIsDownLoadTask)
|
||
{
|
||
switch (m_enTestTypeCmd)
|
||
{
|
||
case EN_CMD_MEASURE_NO:
|
||
break;
|
||
case EN_CMD_MEASURE_ALL:
|
||
OnMeasureAll();
|
||
break;
|
||
case EN_CMD_MEASURE_FROM_CUR_POINT:
|
||
OnMeasureFromCur();
|
||
break;
|
||
case EN_CMD_MEASURE_ONE_POINT:
|
||
OnMeasureCurPt();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
STMeasuTaskParam stTaskParam;
|
||
memset(&stTaskParam, 0, sizeof(STMeasuTaskParam));
|
||
stTaskParam.ucTxPeriod = m_stQueryTdInfo.iTestPeriod;
|
||
stTaskParam.ucTestType = m_stQueryTdInfo.iTestType;
|
||
stTaskParam.ucSptType = m_stQueryTdInfo.iSptType;
|
||
stTaskParam.ucCableLayout = m_stQueryTdInfo.iCableLayout;
|
||
stTaskParam.ucStacking = m_stQueryTdInfo.ucStack;
|
||
stTaskParam.iSAInterval = htonl(m_stQueryTdInfo.iSAInterval);
|
||
stTaskParam.ucArrayType = m_stQueryTdInfo.iAR;
|
||
//stTaskParam.fElecSpace = tcp_htonf(m_stQueryTdInfo.fPoleSpace);
|
||
stTaskParam.fElecSpace = tcp_htonf(m_stQueryTdInfo.fXElecDistance);
|
||
stTaskParam.ucOrgFlg = m_stQueryTdInfo.ucOrgFlg;
|
||
memcpy(stTaskParam.ucTaskID, m_stQueryTdInfo.ucTaskID, sizeof(stTaskParam.ucTaskID));
|
||
|
||
m_ucCmd = EN_CTRL_SET_TASK_PARAM;
|
||
|
||
PostNetRequest(EN_CTRL_SET_TASK_PARAM, this->m_hWnd, (char*)(&stTaskParam), sizeof(STMeasuTaskParam), 1500, WM_NET_RESPONSE, m_uiDevID, EN_DEV_GD10, 30000);
|
||
return TRUE;
|
||
}
|
||
|
||
void CDialMeasureData::OnMeasureFromCur()
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
m_enTestTypeCmd = EN_CMD_MEASURE_FROM_CUR_POINT;
|
||
if (!m_bIsDownLoadTask)
|
||
{
|
||
OnMeasureDownloadMeasuCfg();
|
||
return;
|
||
}
|
||
|
||
if (m_bIsSigMeasuring)
|
||
{
|
||
if (LANG_ZHCN ==g_iUILanguage)
|
||
AfxMessageBox(_T("正在进行测量,不可重复测量..."));
|
||
else
|
||
MessageBoxEx(NULL, _T("In process of testing ,please wait"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
if (m_ucMeasuBtnStatus[m_iMeasuType] == 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)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("正在进行测量,请先停止测试..."));
|
||
else
|
||
MessageBoxEx(NULL, _T("The measurement is in progress, please stop the test first"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
m_iRepeatSndCnt = -1;
|
||
int iCurSel = -1;
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
{
|
||
iCurSel = m_dialListMeasuTask.m_listData.GetSelectionMark();
|
||
if(-1 == iCurSel)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("请先选择当前位置"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Please choose one task first"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
m_iSelMeasuIndex = iCurSel;
|
||
int iTsn = m_dialListMeasuTask.m_listData.GetItemData(iCurSel);
|
||
if (m_bIsOpenTbData)
|
||
{
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
m_TaskdDBOper.CloseTdData();
|
||
}
|
||
m_bIsOpenTbData = false;
|
||
}
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
if (!m_TaskdDBOper.OpenTdData(m_iTaskID, m_stQueryTdInfo.iSptType, iTsn, theApp.m_ucMaxChannel))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("打开数据表失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Failed to open database table"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
}
|
||
// m_dialListMeasuTask.m_listData.DeleteAllItems();
|
||
m_dialListMeasuTask.EnablePreviewBtn(false);
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_FROM_CUR;
|
||
m_bIsOpenTbData = true;
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_FROM_CUR);
|
||
m_bIsSuspend = false;
|
||
}
|
||
else if (EN_MEASURE_GR == m_iMeasuType)
|
||
{
|
||
iCurSel = m_dialListMeasuGR.m_listData.GetSelectionMark();
|
||
if(-1 == iCurSel)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("请先选择当前位置"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Please choose one task first"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
return;
|
||
}
|
||
m_iGRAttionalVal = 1;
|
||
m_iSelMeasuIndex = iCurSel;
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
{
|
||
bool bIsStartMeasu = true;
|
||
if (1 == iCurSel)
|
||
{
|
||
int nRet = 0;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
nRet = AfxMessageBox(_T("请在测量前将AB线接入MN,是否开始测量?"), MB_YESNO);
|
||
else
|
||
nRet = MessageBoxEx(NULL, _T("Please connect A/B eletrodes with M/N port for checking Grounding R.\r\nDo you want to measure?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
if (IDYES != nRet)
|
||
bIsStartMeasu = false;
|
||
}
|
||
if (!bIsStartMeasu)
|
||
return;
|
||
|
||
}
|
||
else
|
||
{
|
||
CString strID = m_dialListMeasuGR.m_listData.GetItemText(iCurSel, 0);
|
||
if (strID.IsEmpty())
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("获取接地电阻的电极ID错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Error getting electrode ID for grounding resistance."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
m_iRecvElecID = atoi(strID);
|
||
}
|
||
// m_iMeasuMethod = EN_MEASURE_SIG;
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_FROM_CUR;
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_FROM_CUR);
|
||
m_bIsSuspend = false;
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
void CDialMeasureData::ClearRecvBuffer()
|
||
{
|
||
memset(m_ucData, 0, sizeof(m_ucData));
|
||
m_iRecvDataLen = 0;
|
||
}
|
||
|
||
bool CDialMeasureData::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 CDialMeasureData::GetMeasuDataSendInfo()*/
|
||
|
||
void CDialMeasureData::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)
|
||
{
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
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 CDialMeasureData::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);
|
||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
}
|
||
|
||
void CDialMeasureData::ProcGD10Data(const STCtrlProtoHeader& stCtrlHeader, const char* pPayload)
|
||
{
|
||
if (0 == stCtrlHeader.ucCMD && 1 == stCtrlHeader.ucDataType)
|
||
{
|
||
}
|
||
else
|
||
{
|
||
|
||
}
|
||
|
||
}
|
||
void CDialMeasureData::ProcPLCData(const STCtrlProtoHeader& stCtrlHeader, const char* pPayload)
|
||
{
|
||
|
||
}
|
||
int CDialMeasureData::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;
|
||
}
|
||
LPSTMeasuBasicDataResEx pMeasuBasicRes = NULL;
|
||
int iAttachLen = (1 == m_stQueryTdInfo.iTestType) ? sizeof(STMeasuDataResAttachIP) : 0;
|
||
//这里暂时没有对粘包或者分包做处理
|
||
if (m_iRecvDataLen != (1 + sizeof(m_stQueryTdInfo.ucTaskID) + ucPacketNum*(sizeof(STMeasuDataResBasicEx) + 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 = (LPSTMeasuBasicDataResEx)(m_ucData + 1 + sizeof(m_stQueryTdInfo.ucTaskID) + i*(sizeof(STMeasuDataResBasicEx) + 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);
|
||
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
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(STMeasuDataResBasicEx) + 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.EnsureVisible(iItemIndex, TRUE);
|
||
// 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 CDialMeasureData::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("");
|
||
INT32* pElecNum = (INT32*)(&m_ucData[MAX_NAME_LEN]);
|
||
INT32 ucElecNum = ntohl(*pElecNum);
|
||
/*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-sizeof(INT32)-MAX_NAME_LEN))
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strErr.Format(_T("接收数据长度错误,实际接收=%d, 本该接收= %d"), ucElecNum* sizeof(STMeasuSigGRResult), m_iRecvDataLen - sizeof(INT32) - MAX_NAME_LEN);
|
||
AfxMessageBox(strErr);
|
||
}
|
||
else
|
||
{
|
||
strErr.Format(_T("Received data length 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;
|
||
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
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);
|
||
pSigGr = (STMeasuSigGRResult*)(&m_ucData[MAX_NAME_LEN + sizeof(INT32) /*+ iIndex*sizeof(STMeasuSigGRResult)*/]);
|
||
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
|
||
{
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
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[MAX_NAME_LEN + sizeof(INT32) + i*sizeof(STMeasuSigGRResult)]);
|
||
//pSigGr = (STMeasuSigGRResult*)(m_ucData + 1 + i*sizeof(STMeasuSigGRResult));
|
||
m_dialListMeasuGR.m_listData.InsertItem(iItemIndex + i, _T(""));
|
||
int iColIndex = 0;
|
||
strTxt.Empty();
|
||
m_iRecvElecID = ntohl(pSigGr->ucElecID);
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
{
|
||
m_iRecvElecID = (char)ntohl(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"), m_iRecvElecID);
|
||
|
||
m_dialListMeasuGR.m_listData.SetItemText(iItemIndex + i, iColIndex++, strTxt);
|
||
if (-1 != pSigGr->iP1)
|
||
{
|
||
strTxt.Empty();
|
||
strTxt.Format(_T("%d"), ntohl(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"), ntohl(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, TRUE);
|
||
|
||
}
|
||
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 CDialMeasureData::PreNetResponse(WPARAM wParam, LPARAM lParam)
|
||
{
|
||
LPRESPONSEPACKET pResponsePacket = (LPRESPONSEPACKET)lParam;
|
||
if (pResponsePacket == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
CString strTips;
|
||
if (EN_RECV_TIMEOUT == wParam)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
strTips.Format(_T("下发配置失败"));
|
||
else
|
||
strTips.Format(_T("Failed to issue configuration"));
|
||
}
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
strTips.Format(_T("测量失败,出错代码为(%d)"), wParam);
|
||
else
|
||
strTips.Format(_T("Test failed, error ID(%d)"), wParam);
|
||
}
|
||
|
||
switch (pResponsePacket->clsPacketBase.ucCmd)
|
||
{
|
||
case EN_CTRL_SET_TASK_PARAM: //设置任务的测试参数
|
||
{
|
||
if (EN_RECV_SUCCESS == wParam)
|
||
{
|
||
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));
|
||
|
||
//GetDlgItem(IDB_MEASURE_DOWNLOAD_MEASU_CFG)->EnableWindow(FALSE);
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_CUR_PT)->EnableWindow(TRUE);
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(TRUE);
|
||
if ((0 == m_stQueryTdInfo.iSptType) && (EN_MEASURE_GR == m_iMeasuType))
|
||
{
|
||
GetDlgItem(IDB_MEASURE_FROM_CUR)->EnableWindow(FALSE);
|
||
if (0 == theApp.m_ucIsMultiChannel)
|
||
GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(FALSE);
|
||
}
|
||
|
||
if (NULL == m_pThread)
|
||
{
|
||
m_bIsRunning = true;
|
||
m_pThread = AfxBeginThread(StartMeasuData, (LPVOID)this);
|
||
if (NULL == m_pThread)
|
||
{
|
||
m_bIsRunning = false;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("创建处理数据线程失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Create process data thread failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
switch (m_enTestTypeCmd)
|
||
{
|
||
case EN_CMD_MEASURE_NO:
|
||
break;
|
||
case EN_CMD_MEASURE_ALL:
|
||
OnMeasureAll();
|
||
break;
|
||
case EN_CMD_MEASURE_FROM_CUR_POINT:
|
||
OnMeasureFromCur();
|
||
break;
|
||
case EN_CMD_MEASURE_ONE_POINT:
|
||
OnMeasureCurPt();
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("下发失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Set up failure"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
}
|
||
break;
|
||
|
||
// case EN_CTRL_MEASURE_DATA:
|
||
// {
|
||
//
|
||
// int iRes = ProcRcvMeasuData();
|
||
// break;
|
||
// }
|
||
default:
|
||
{
|
||
memcpy_s(m_ucData, MAX_RECV_MEASURE, pResponsePacket->pData, pResponsePacket->wDataLen);
|
||
m_iRecvDataLen = pResponsePacket->wDataLen;
|
||
CString strLog = _T("");
|
||
if (EN_MEASURE_DATA == m_iMeasuType)
|
||
{
|
||
//如果是超时或者是数据错误的话,则运行进行重测
|
||
if (wParam == EN_RECV_TIMEOUT || wParam == EN_RECV_DATA_ERROR || wParam == EN_RECV_DATA_DISORDER ||
|
||
wParam == EN_CLOUND_SND_FAILED)
|
||
{
|
||
if (-1 == m_iRepeatSndCnt)
|
||
{
|
||
strLog.Empty();
|
||
strLog.Format(_T("[%s][%d]Is being trigger repeat measure, tripper reason = %d"), MODULE_NAME, __LINE__, wParam);
|
||
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
||
m_iRepeatSndCnt = MAX_REPEAT_SND_CNT + 1;
|
||
}
|
||
else
|
||
{
|
||
strLog.Empty();
|
||
strLog.Format(_T("[%s][%d]measure data failed, OperRes = %d,NeedRepeatCnt = %d"),
|
||
MODULE_NAME, __LINE__, wParam, m_iRepeatSndCnt);
|
||
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
||
}
|
||
|
||
|
||
}
|
||
else if (wParam == EN_RECV_SUCCESS)
|
||
{
|
||
int iRes = ProcRcvMeasuData();
|
||
if (iRes == EN_MEASU_PROC_DB_ERR || iRes == EN_MEASU_PROC_WARINNG)
|
||
{
|
||
StopMeasuDataInfo(false);
|
||
return;
|
||
}
|
||
else if (iRes == EN_MEASU_PROC_SUCCESS)
|
||
{
|
||
//如果成功处理该报文,则进行下一个报文的处理,此时需要将重发次数改为-1
|
||
if (EN_MEASU_BTN_MEASU_SIG == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
{
|
||
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));
|
||
|
||
SetBtnStatus(m_ucMeasuBtnStatus[m_iMeasuType]);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
m_iRepeatSndCnt = -1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//如果是处理失败,则丢弃该响应报文,重发该数据
|
||
if (-1 == m_iRepeatSndCnt)
|
||
m_iRepeatSndCnt = MAX_REPEAT_SND_CNT + 1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
StopMeasuDataInfo(false);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strTips.Format(_T("测量数据失败,出错代码为(%d)"), wParam);
|
||
AfxMessageBox(strTips);
|
||
}
|
||
else
|
||
{
|
||
strTips.Format(_T("Measurement data failed, error code(%d)"), wParam);
|
||
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return;
|
||
}
|
||
|
||
}
|
||
|
||
if (EN_MEASURE_GR == m_iMeasuType)
|
||
{
|
||
//如果插入信息成功,则处理下一条
|
||
if (ProcRcvGrData())
|
||
{
|
||
if (EN_MEASU_BTN_MEASU_SIG == m_ucMeasuBtnStatus[m_iMeasuType])
|
||
{
|
||
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));
|
||
SetBtnStatus(m_ucMeasuBtnStatus[m_iMeasuType]);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
bool bIsFinshed = false;
|
||
if (0 == m_stQueryTdInfo.iSptType)
|
||
{
|
||
if (theApp.m_ucMaxChannel == (abs(m_iRecvElecID) - 1))
|
||
bIsFinshed = true;
|
||
}
|
||
else
|
||
{
|
||
if (m_stQueryTdInfo.iEndElec > 0)
|
||
{
|
||
if (m_iRecvElecID >= m_stQueryTdInfo.iEndElec)
|
||
bIsFinshed = true;
|
||
}
|
||
else if (m_stQueryTdInfo.iEndElec == 0)
|
||
bIsFinshed = true;
|
||
}
|
||
|
||
|
||
if (bIsFinshed)
|
||
{
|
||
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));
|
||
m_ucMeasuBtnStatus[m_iMeasuType] = EN_MEASU_BTN_MEASU_FIN;
|
||
SetBtnStatus(EN_MEASU_BTN_MEASU_FIN);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
StopMeasuDataInfo(false);
|
||
return;
|
||
}
|
||
}
|
||
|
||
m_bIsSigMeasuring = false;
|
||
}
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
void CDialMeasureData::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 ((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 CDialMeasureData::GetNeedMeasuData(char* pData,int &iLen, int iMaxLen)
|
||
{
|
||
iLen = 0;
|
||
m_vtMeasureData.clear();
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
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("In process of testing, please wait untill finished"), 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 CDialMeasureData::GetSigNeedMeasuData(char* pData, int &iLen, int iMaxLen)
|
||
{
|
||
iLen = 0;
|
||
STSigSndDataInfo stData;
|
||
{
|
||
CAutoLock clsLock(&m_dbSec);
|
||
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 CDialMeasureData::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;
|
||
memcpy(stMeasuGRReq.ucTaskID, m_stQueryTdInfo.ucTaskID, MAX_NAME_LEN);
|
||
stMeasuGRReq.ucStartElec = iElecID;
|
||
stMeasuGRReq.ucEndElec = iElecID;
|
||
memcpy(pData, &stMeasuGRReq, sizeof(STMeasuGRRequest));
|
||
iLen = sizeof(STMeasuGRRequest);
|
||
|
||
|
||
}
|
||
|
||
UINT CDialMeasureData::StartMeasuData(LPVOID pInfo)
|
||
{
|
||
CDialMeasureData* pMeasuData = (CDialMeasureData*)pInfo;
|
||
//这里暂时不需要用到环形队列
|
||
// if (NULL == pMeasuData->m_pReadBuf || NULL == m_pWriteBuf)
|
||
// {
|
||
// AfxMessageBox(_T("The ring buffer is empty"));
|
||
// return 0;
|
||
// }
|
||
// m_bIsRunning = true;
|
||
// char chData[512];
|
||
// STCtrlProtoHeader stCtrlProtoHeader;
|
||
// int iCtrlHeaderLen = sizeof(m_pReadBuf->GetDataBytes());
|
||
// std::vector<STSendDataInfo> vtMeasureData;
|
||
char chSndBuf[500];
|
||
pMeasuData->m_bIsThreadFinshed = false;
|
||
int iSendLen = 0;
|
||
CString strLog = _T("");
|
||
|
||
//filled current test date and time to task by quyx 20180419
|
||
_CommandPtr pCmdUpd = NULL;
|
||
CString szTDate = _T("");
|
||
CString szTTime = _T("");
|
||
CString szSql = _T("");
|
||
DWORD dwID = DWORD(pMeasuData->m_iTaskID);
|
||
|
||
szTDate.Empty();
|
||
szTDate.Format(_T("%04d-%02d-%02d"),g_sysCurTime.wYear, g_sysCurTime.wMonth, g_sysCurTime.wDay);
|
||
szTTime.Empty();
|
||
szTTime.Format(_T("%02d:%02d:%02d"),g_sysCurTime.wHour, g_sysCurTime.wMinute, g_sysCurTime.wSecond);
|
||
|
||
pCmdUpd.CreateInstance(_uuidof(Command));
|
||
pCmdUpd->ActiveConnection = theApp.m_pConnection;
|
||
try
|
||
{
|
||
if ((szTDate.GetLength() != (int)VAL_ZERO) && (szTTime.GetLength() != (int)VAL_ZERO))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("update td set Tdate = '%s',Ttime = '%s' where ID = %d"), szTDate, szTTime,dwID);
|
||
theApp.m_pConnection->BeginTrans();
|
||
pCmdUpd->CommandText = szSql.AllocSysString();
|
||
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
||
theApp.m_pConnection->CommitTrans();
|
||
}
|
||
}
|
||
catch (_com_error e)
|
||
{
|
||
theApp.m_pConnection->RollbackTrans();
|
||
AfxMessageBox(e.Description());
|
||
return -1;
|
||
}
|
||
//end filled current test date and time to task by quyx 20180419
|
||
while(pMeasuData->m_bIsRunning)
|
||
{
|
||
if (pMeasuData->m_bIsSigMeasuring || pMeasuData->m_bIsSuspend)
|
||
{
|
||
Sleep(30);
|
||
continue;
|
||
}
|
||
|
||
if (EN_MEASURE_DATA == pMeasuData->m_iMeasuType)
|
||
{
|
||
|
||
if (EN_MEASU_BTN_MEASU_ALL == pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType] ||
|
||
EN_MEASU_BTN_MEASU_FROM_CUR == pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType] ||
|
||
EN_MEASU_BTN_COUNTINE == pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType])
|
||
{
|
||
pMeasuData->m_ucCmd = EN_CTRL_MEASURE_DATA;
|
||
//如果不需要重发,则直接获取下一个点
|
||
if (pMeasuData->m_iRepeatSndCnt <= 0)
|
||
{
|
||
//如果没有打开数据表的话,则进行打开数据表
|
||
memset(chSndBuf, 0, sizeof(chSndBuf));
|
||
iSendLen = 0;
|
||
pMeasuData->m_iRepeatSndCnt = -1;//初始状态
|
||
int iRes = pMeasuData->GetNeedMeasuData(chSndBuf, iSendLen,500);
|
||
if (0 == iSendLen)
|
||
{
|
||
if (iRes > 0)
|
||
{
|
||
pMeasuData->GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType] = EN_MEASU_BTN_MEASU_FIN;
|
||
pMeasuData->StopMeasuDataInfo();
|
||
if (pMeasuData->m_iCurLoop < 1)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("测量完成"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Test finished"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
pMeasuData->SetBtnStatus(EN_MEASU_BTN_MEASU_FIN);
|
||
|
||
}
|
||
else
|
||
{
|
||
pMeasuData->StopMeasuDataInfo(false);
|
||
pMeasuData->SetBtnStatus(EN_MEASU_BTN_MEASU_TERIMI);
|
||
}
|
||
Sleep(30);
|
||
continue;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
strLog.Empty();
|
||
strLog.Format(_T("[%s][%d]Is being repeat measure, reverse repeat cnt = %d"), MODULE_NAME, __LINE__, --(pMeasuData->m_iRepeatSndCnt));
|
||
CFileOperTools::GetInstance()->WriteComLog(strLog);
|
||
}
|
||
|
||
}
|
||
else if (EN_MEASU_BTN_MEASU_SIG == pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType])
|
||
{
|
||
pMeasuData->m_ucCmd = EN_CTRL_MEASURE_DATA;
|
||
memset(chSndBuf, 0, sizeof(chSndBuf));
|
||
if (pMeasuData->m_iRepeatSndCnt <= 0)
|
||
{
|
||
pMeasuData->m_iRepeatSndCnt = -1;//初始状态
|
||
if (pMeasuData->GetSigNeedMeasuData(chSndBuf,iSendLen,500) < 1)
|
||
{
|
||
pMeasuData->StopMeasuDataInfo(false);
|
||
Sleep(30);
|
||
continue;
|
||
}
|
||
}
|
||
else
|
||
pMeasuData->m_iRepeatSndCnt--;
|
||
|
||
}
|
||
else
|
||
{
|
||
Sleep(30);
|
||
continue;
|
||
}
|
||
pMeasuData->ClearRecvBuffer();
|
||
pMeasuData->PostNetRequest(EN_CTRL_MEASURE_DATA, pMeasuData->m_hWnd, chSndBuf, iSendLen, MAX_RECV_MEASURE, WM_NET_RESPONSE, pMeasuData->m_uiDevID, EN_DEV_GD10, 60000);
|
||
/*STSendDataInfo stSendData;
|
||
stSendData.pData = chSndBuf;
|
||
stSendData.wDataLen = iSendLen;
|
||
stSendData.ucDstType = EN_DEV_GD10;
|
||
stSendData.uiDevID = pMeasuData->m_uiDevID;
|
||
|
||
pMeasuData->ClearRecvBuffer();
|
||
STRespDataInfo stRespData;
|
||
stRespData.iMaxRcvLen = MAX_RECV_MEASURE;
|
||
//test这里暂时为了测试网络稳定性以及在电阻率情况下,将超时改成3分钟
|
||
//stRespData.iTimeout = pMeasuData->m_stQueryTdInfo.ucStack * pMeasuData->m_iSigDataMeasuTimeout + 2000 + pMeasuData->m_stQueryTdInfo.iSAInterval;
|
||
stRespData.iTimeout = 60000;
|
||
stRespData.pData = (char*)pMeasuData->m_ucData;
|
||
stRespData.pRecvLen = &pMeasuData->m_iRecvDataLen;
|
||
|
||
|
||
if (false == theApp.m_NetWorkOper.TransferOper(EN_CTRL_MEASURE_DATA, &stSendData, true, &stRespData, NotifyResFunc, pMeasuData))
|
||
{
|
||
pMeasuData->StopMeasuDataInfo(false);
|
||
Sleep(30);
|
||
continue;
|
||
}*/
|
||
// m_bIsNetOper = true;
|
||
pMeasuData->m_bIsSigMeasuring = true;
|
||
}
|
||
|
||
|
||
else if (EN_MEASURE_GR == pMeasuData->m_iMeasuType)
|
||
{
|
||
|
||
Sleep(100);
|
||
if (EN_MEASU_BTN_MEASU_ALL == pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType] ||
|
||
EN_MEASU_BTN_MEASU_FROM_CUR == pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType] ||
|
||
EN_MEASU_BTN_MEASU_SIG == pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType] ||
|
||
EN_MEASU_BTN_COUNTINE == pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType])
|
||
{
|
||
pMeasuData->m_ucCmd = EN_CTRL_MEASURE_GR;
|
||
memset(chSndBuf, 0, sizeof(chSndBuf));
|
||
int iAddtionval = (pMeasuData->m_iGRAttionalVal < 1) ? 0 : pMeasuData->m_iGRAttionalVal--;
|
||
|
||
pMeasuData->GetNeedMeasuGR(chSndBuf,iSendLen, 500,iAddtionval);
|
||
if ( ((0 == iSendLen || ((STMeasuGRRequest*)chSndBuf)->ucStartElec == -1) && pMeasuData->m_stQueryTdInfo.iSptType>0) ||
|
||
( (0 == pMeasuData->m_stQueryTdInfo.iSptType) && (((STMeasuGRRequest*)chSndBuf)->ucStartElec <pMeasuData->m_stQueryTdInfo.iEndElec) ))
|
||
{
|
||
pMeasuData->StopMeasuDataInfo();
|
||
pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType] = EN_MEASU_BTN_MEASU_FIN;
|
||
pMeasuData->GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("测量完成"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Test finished"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
pMeasuData->SetBtnStatus(EN_MEASU_BTN_MEASU_FIN);
|
||
Sleep(30);
|
||
continue;
|
||
}
|
||
|
||
if (((STMeasuGRRequest*)chSndBuf)->ucStartElec == -1)
|
||
{
|
||
int nRet = 0;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
nRet = AfxMessageBox(_T("请在测量前将AB线接入MN,是否开始测量?"), MB_YESNO | MB_ICONQUESTION);
|
||
else
|
||
nRet = MessageBoxEx(NULL, _T("Please connect A/B eletrodes with M/N port for checking Grounding R.\r\nDo you want to measure?"), STRING_MESSAGEBOXEX_TITLE, MB_YESNO, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
|
||
if (IDYES != nRet)
|
||
{
|
||
pMeasuData->StopMeasuDataInfo();
|
||
pMeasuData->m_ucMeasuBtnStatus[pMeasuData->m_iMeasuType] = EN_MEASU_BTN_MEASU_TERIMI;
|
||
pMeasuData->GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->EnableWindow(FALSE);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("测量完成"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Test finished"), STRING_MESSAGEBOXEX_TITLE, MB_OK | MB_ICONQUESTION, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
pMeasuData->SetBtnStatus(EN_MEASU_BTN_MEASU_FIN);
|
||
Sleep(30);
|
||
continue;
|
||
}
|
||
|
||
}
|
||
}
|
||
else
|
||
{
|
||
Sleep(30);
|
||
continue;
|
||
}
|
||
|
||
((STMeasuGRRequest*)chSndBuf)->ucStartElec = htonl(((STMeasuGRRequest*)chSndBuf)->ucStartElec);
|
||
((STMeasuGRRequest*)chSndBuf)->ucEndElec = htonl(((STMeasuGRRequest*)chSndBuf)->ucEndElec);
|
||
pMeasuData->PostNetRequest(EN_CTRL_MEASURE_GR, pMeasuData->m_hWnd, chSndBuf, iSendLen, 5*1024, WM_NET_RESPONSE, pMeasuData->m_uiDevID, EN_DEV_GD10, 600000);
|
||
/*STSendDataInfo stSendData;
|
||
stSendData.pData = chSndBuf;
|
||
stSendData.wDataLen = iSendLen;
|
||
stSendData.ucDstType = EN_DEV_GD10;
|
||
stSendData.uiDevID = pMeasuData->m_uiDevID;
|
||
|
||
STRespDataInfo stRespData;
|
||
stRespData.iMaxRcvLen = MAX_RECV_MEASURE;
|
||
//modified by lsq 20171023
|
||
//由于台湾网络比较差,在这里直接将接地电阻的超时时间改成30S
|
||
stRespData.iTimeout = 30000;
|
||
stRespData.pData = (char*)(pMeasuData->m_ucData);
|
||
stRespData.pRecvLen = &(pMeasuData->m_iRecvDataLen);
|
||
//如果失败,则终止当前测试
|
||
if (false == theApp.m_NetWorkOper.TransferOper(EN_CTRL_MEASURE_GR, &stSendData, true, &stRespData, NotifyResFunc, pMeasuData))
|
||
{
|
||
pMeasuData->StopMeasuDataInfo(false);
|
||
AfxMessageBox(_T("传输测量接地电阻信息失败,请稍后重试..."));
|
||
Sleep(30);
|
||
continue;
|
||
}*/
|
||
// m_bIsNetOper = true;
|
||
pMeasuData->m_bIsSigMeasuring = true;
|
||
}
|
||
}
|
||
pMeasuData->m_bIsThreadFinshed = true;
|
||
return 1;
|
||
|
||
|
||
}
|
||
|
||
void CDialMeasureData::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;
|
||
// }
|
||
else
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("此种状态下不支持"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Not supported in this state"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return;
|
||
}
|
||
|
||
/*
|
||
if ((0 == m_stQueryTdInfo.iSptType) && (1 == iCurSel))
|
||
{
|
||
AfxMessageBox(_T("该模式只能使用单点测量"));
|
||
return;
|
||
}
|
||
if (m_ucMeasuBtnStatus[iOtherSel] > EM_MEASU_BTN_INITI && m_ucMeasuBtnStatus[iOtherSel] < EN_MEASU_BTN_SUSPEND )
|
||
{
|
||
AfxMessageBox(_T("请先停止另外一边的测量"));
|
||
return;
|
||
}
|
||
// if (m_ucMeasuBtnStatus[iCurSel]>= EN_MEASU_BTN_MEASU_TERIMI)
|
||
// {
|
||
// //如果之前的操作单点测试并且测试完成,则可以继续操作
|
||
// if (EN_MEASURE_SIG != m_iMeasuMethod)
|
||
// {
|
||
// AfxMessageBox(_T("此状态下不可进行暂停或继续测量操作"));
|
||
// return;
|
||
// }
|
||
// }
|
||
// else
|
||
if (EM_MEASU_BTN_INITI == m_ucMeasuBtnStatus[iCurSel] || EN_MEASU_BTN_MEASU_SIG == m_ucMeasuBtnStatus[iCurSel] ||
|
||
m_ucMeasuBtnStatus[iCurSel]== EN_MEASU_BTN_MEASU_TERIMI)
|
||
{
|
||
AfxMessageBox(_T("此状态下不可进行暂停或继续测量操作"));
|
||
return;
|
||
}
|
||
CString strTxt = _T("");
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->GetWindowText(strTxt);
|
||
m_iMeasuType = iCurSel+1;
|
||
m_iMeasuMethod = EN_MEASURE_ALL;
|
||
if (_T("暂停测量") == strTxt)
|
||
{
|
||
KillTimer(m_iMeasuType);
|
||
m_ucMeasuBtnStatus[iCurSel] = EN_MEASU_BTN_SUSPEND;
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("继续测量"));
|
||
m_bIsSuspenMeasu[m_iMeasuType-1] = TRUE;
|
||
// GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(FALSE);
|
||
}
|
||
else
|
||
{
|
||
if (2 == m_iMeasuType )
|
||
{
|
||
CString strID = m_dialListMeasuGR.m_listData.GetItemText(m_dialListMeasuGR.m_listData.GetItemCount()-1, 0);
|
||
if (strID.IsEmpty())
|
||
{
|
||
AfxMessageBox(_T("获取接地电阻的电极ID错误"));
|
||
return;
|
||
}
|
||
m_iRecvElecID = atoi(strID);
|
||
}
|
||
m_ucMeasuBtnStatus[iCurSel] = EN_MEASU_BTN_COUNTINE;
|
||
m_bIsSuspenMeasu[m_iMeasuType-1] = FALSE;
|
||
// SetTimer(m_iMeasuType, 100, NULL);
|
||
GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("暂停测量"));
|
||
// GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(TRUE);
|
||
}
|
||
// if (!m_bIsSuspend)
|
||
// {
|
||
// m_bIsSuspend = true;
|
||
// KillTimer(m_iMeasuType);
|
||
// GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("继续测量"));
|
||
// GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(FALSE);
|
||
// }
|
||
// else
|
||
// {
|
||
// m_bIsSuspend = false;
|
||
// SetTimer(m_iMeasuType, 100, NULL);
|
||
// GetDlgItem(IDB_MEASURE_SUSPEND_MEAU)->SetWindowText(_T("暂停测量"));
|
||
// GetDlgItem(IDB_MEASURE_ALL)->EnableWindow(TRUE);
|
||
//
|
||
// }
|
||
*/
|
||
}
|
||
|
||
void CDialMeasureData::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 CDialMeasureData::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;
|
||
}
|
||
//StopMeasuDataInfo(false);
|
||
ThreadJoin();
|
||
//特别修改
|
||
//CNetRequestDialog::OnClose();
|
||
CNetRequestDialog::OnCancel();
|
||
}
|
||
|
||
void CDialMeasureData::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 CDialMeasureData::OnTCard(UINT idAction, DWORD dwActionData)
|
||
// {
|
||
// // TODO: Add your message handler code here
|
||
//
|
||
// }
|
||
|
||
void CDialMeasureData::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 CDialMeasureData::OnSelchangingTabChg(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
// TODO: Add your control notification handler code here
|
||
|
||
*pResult = 0;
|
||
}
|