a
This commit is contained in:
@@ -0,0 +1,916 @@
|
||||
// opexec2drsptestdlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "geomative.h"
|
||||
#include "opexec2drsptestdlg.h"
|
||||
#include "opexec2drsptestframe.h"
|
||||
|
||||
#include "opexec2drsptestgrlistview.h"
|
||||
#include "opexec2drsptesttdlistview.h"
|
||||
#include "opexec2drsptesttdview.h"
|
||||
#include "opexec2drsptestgrview.h"
|
||||
|
||||
#include "Rsp2DTd.h"
|
||||
#include "TdChannel.h"
|
||||
#include "RSP2DTdRecord.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
extern BOOL DoEvent(HWND hWnd);
|
||||
extern int g_iTransMode;
|
||||
extern void TransDelay(int iTransMode, int iDS0, int iDS1, HWND hWnd = NULL);
|
||||
extern int StatStringCount(const CString& szSource, const CString& szMember);
|
||||
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
|
||||
extern BOOL GetSubStringInHeadAndTail(const CString& szSource, CString& szSub, const CString& szHead, const CString& szTail);
|
||||
extern int g_UIOffset;
|
||||
|
||||
extern int g_iTransMode;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COpExec2DRSPTestDlg dialog
|
||||
extern HHOOK hHook;
|
||||
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
COpExec2DRSPTestDlg::COpExec2DRSPTestDlg(CRsp2DTd* pRsp2DTd, INT_PTR* pRet, CWnd* pParent)
|
||||
: CDialog(COpExec2DRSPTestDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(COpExec2DRSPTestDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
|
||||
m_pRet = pRet;
|
||||
m_pRsp2DTd = pRsp2DTd;
|
||||
m_pOpExec2DRSPTestFrame = NULL;
|
||||
}
|
||||
|
||||
|
||||
void COpExec2DRSPTestDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(COpExec2DRSPTestDlg)
|
||||
DDX_Control(pDX, IDC_PG_TD, m_pgTd);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(COpExec2DRSPTestDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(COpExec2DRSPTestDlg)
|
||||
ON_BN_CLICKED(IDC_BT_START, OnBtStart)
|
||||
ON_BN_CLICKED(IDC_BT_PAUSE, OnBtPause)
|
||||
ON_BN_CLICKED(IDC_BT_CONTINUE, OnBtContinue)
|
||||
ON_WM_CLOSE()
|
||||
ON_BN_CLICKED(IDC_BT_STOP, OnBtStop)
|
||||
ON_WM_DESTROY()
|
||||
ON_WM_SIZE()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BEGIN_EASYSIZE_MAP(COpExec2DRSPTestDlg)
|
||||
|
||||
// EASYSIZE(IDC_BT_START, ES_BORDER, ES_BORDER, ES_BORDER,ES_BORDER,0)
|
||||
// EASYSIZE(IDC_BT_PAUSE, ES_BORDER, ES_BORDER, ES_BORDER,ES_BORDER,0)
|
||||
// EASYSIZE(IDC_BT_CONTINUE, ES_BORDER, ES_BORDER, ES_BORDER,ES_BORDER,0)
|
||||
// EASYSIZE(IDC_BT_STOP, ES_BORDER, ES_BORDER, ES_BORDER,ES_BORDER,0)
|
||||
EASYSIZE(IDOK, ES_KEEPSIZE, ES_BORDER, ES_BORDER,ES_KEEPSIZE,0)
|
||||
EASYSIZE(IDCANCEL, ES_KEEPSIZE, ES_BORDER, ES_BORDER,ES_KEEPSIZE,0)
|
||||
|
||||
EASYSIZE(IDC_STATIC_FRAME, ES_BORDER, ES_BORDER, ES_BORDER,ES_BORDER,0)
|
||||
|
||||
EASYSIZE(IDC_STATIC_PROMPT, ES_BORDER, IDC_STATIC_FRAME, ES_BORDER,ES_KEEPSIZE,0)
|
||||
EASYSIZE(IDC_PG_TD, IDC_STATIC_PROMPT, IDC_STATIC_FRAME, ES_BORDER,ES_KEEPSIZE,0)
|
||||
|
||||
END_EASYSIZE_MAP
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// COpExec2DRSPTestDlg message handlers
|
||||
|
||||
BOOL COpExec2DRSPTestDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
CTdChannel* pTdChannel = NULL;
|
||||
CRect rect;
|
||||
|
||||
CWnd *pStatic = GetDlgItem(IDC_STATIC_FRAME);
|
||||
pStatic->GetWindowRect(&rect);
|
||||
// pStatic->DestroyWindow();
|
||||
|
||||
this->ScreenToClient(&rect);
|
||||
|
||||
m_pOpExec2DRSPTestFrame = (COpExec2DRSPTestFrame*)((CRuntimeClass*)RUNTIME_CLASS(COpExec2DRSPTestFrame))->CreateObject();
|
||||
|
||||
m_pOpExec2DRSPTestFrame->Create(NULL, NULL, WS_CHILD, rect, this);
|
||||
|
||||
m_pOpExec2DRSPTestFrame->MoveWindow(&rect);
|
||||
m_pOpExec2DRSPTestFrame->ShowWindow(SW_SHOW);
|
||||
|
||||
m_bIsPause = FALSE;
|
||||
m_bIsExit = FALSE;
|
||||
|
||||
pTdChannel = (CTdChannel*)(this->m_pRsp2DTd->m_tdChaList.GetAt(m_pRsp2DTd->m_tdChaList.FindIndex(0))); //目前仅支持单通道
|
||||
m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->m_pTdChannel = pTdChannel;
|
||||
|
||||
ReSetAll();
|
||||
|
||||
INIT_EASYSIZE;
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
CString szCaption = _T("");
|
||||
|
||||
m_bIsPause = TRUE;
|
||||
m_bIsExit = TRUE;
|
||||
Sleep(20);
|
||||
|
||||
if (TRUE == this->m_pRsp2DTd->SaveData())
|
||||
{
|
||||
szCaption.Empty();
|
||||
szCaption.LoadString(IDS_OP_SUCCESS+g_UIOffset);
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
if (OFFSET_CHINESE == g_UIOffset)
|
||||
AfxMessageBox(szCaption, MB_ICONINFORMATION);
|
||||
else
|
||||
MessageBoxEx(NULL, szCaption, STRING_MESSAGEBOXEX_TITLE, MB_ICONINFORMATION, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ClearAll();
|
||||
//add by waston
|
||||
this->m_pRsp2DTd->ClearTdChaList();//清除通道信息
|
||||
//add by waston
|
||||
|
||||
szCaption.Empty();
|
||||
szCaption.LoadString(IDS_OP_FAIL+g_UIOffset);
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
if (OFFSET_CHINESE == g_UIOffset)
|
||||
AfxMessageBox(szCaption, MB_ICONINFORMATION);
|
||||
else
|
||||
MessageBoxEx(NULL, szCaption, STRING_MESSAGEBOXEX_TITLE, MB_ICONINFORMATION, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
}
|
||||
|
||||
this->EndModalLoop(RET_OK);
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnCancel()
|
||||
{
|
||||
// TODO: Add extra cleanup here
|
||||
m_bIsPause = TRUE;
|
||||
m_bIsExit = TRUE;
|
||||
Sleep(20);
|
||||
|
||||
ClearAll();
|
||||
//add by waston
|
||||
this->m_pRsp2DTd->ClearTdChaList();//清除通道信息
|
||||
//add by waston
|
||||
|
||||
this->EndModalLoop(RET_CANCEL);
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnBtStart()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
CTdChannel* pTdChannel = NULL;
|
||||
int iTdChannelIndex = (int)VAL_ZERO;
|
||||
|
||||
this->GetDlgItem(IDC_BT_START)->EnableWindow(FALSE);
|
||||
this->GetDlgItem(IDC_BT_STOP)->EnableWindow(TRUE);
|
||||
this->GetDlgItem(IDC_BT_PAUSE)->EnableWindow(TRUE);
|
||||
|
||||
CListCtrl* pTdList = &(m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdListView->GetListCtrl());
|
||||
|
||||
CString szLocFilePath = _T("");
|
||||
CString szLocFileName = _T("");
|
||||
CString szHostFilePath = _T("");
|
||||
m_bIsPause = FALSE;
|
||||
m_bIsExit = FALSE;
|
||||
|
||||
iTdChannelIndex = (int)VAL_ZERO;
|
||||
|
||||
while (iTdChannelIndex < m_pRsp2DTd->m_tdChaList.GetCount())
|
||||
{
|
||||
pTdChannel = NULL;
|
||||
pTdChannel = (CTdChannel*)m_pRsp2DTd->m_tdChaList.GetAt(m_pRsp2DTd->m_tdChaList.FindIndex(iTdChannelIndex));
|
||||
if (NULL != pTdChannel)
|
||||
{
|
||||
break;
|
||||
}
|
||||
iTdChannelIndex++;
|
||||
}
|
||||
|
||||
if (TRUE == StartDataCollection(pTdList, pTdChannel))
|
||||
{
|
||||
this->GetDlgItem(IDOK)->EnableWindow(TRUE);
|
||||
|
||||
this->GetDlgItem(IDC_BT_START)->EnableWindow(FALSE);
|
||||
this->GetDlgItem(IDC_BT_STOP)->EnableWindow(FALSE);
|
||||
this->GetDlgItem(IDC_BT_PAUSE)->EnableWindow(FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->GetDlgItem(IDC_BT_START)->EnableWindow(TRUE);
|
||||
this->GetDlgItem(IDC_BT_STOP)->EnableWindow(FALSE);
|
||||
this->GetDlgItem(IDC_BT_PAUSE)->EnableWindow(FALSE);
|
||||
this->ClearAll();
|
||||
}
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnBtPause()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
m_bIsPause = TRUE;
|
||||
this->GetDlgItem(IDC_BT_PAUSE)->EnableWindow(FALSE);
|
||||
this->GetDlgItem(IDC_BT_CONTINUE)->EnableWindow(TRUE);
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnBtContinue()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
m_bIsPause = FALSE;
|
||||
this->GetDlgItem(IDC_BT_PAUSE)->EnableWindow(TRUE);
|
||||
this->GetDlgItem(IDC_BT_CONTINUE)->EnableWindow(FALSE);
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnClose()
|
||||
{
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
m_bIsPause = TRUE;
|
||||
m_bIsExit = TRUE;
|
||||
Sleep(20);
|
||||
CDialog::OnClose();
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnBtStop()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
int iTdChannnelIndex = (int)VAL_ZERO;
|
||||
|
||||
this->GetDlgItem(IDC_BT_START)->EnableWindow(TRUE);
|
||||
this->GetDlgItem(IDC_BT_STOP)->EnableWindow(FALSE);
|
||||
this->GetDlgItem(IDC_BT_PAUSE)->EnableWindow(FALSE);
|
||||
this->GetDlgItem(IDC_BT_CONTINUE)->EnableWindow(FALSE);
|
||||
|
||||
m_bIsPause = TRUE;
|
||||
m_bIsExit = TRUE;
|
||||
Sleep(20);
|
||||
|
||||
this->ReSetAll();
|
||||
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnDestroy()
|
||||
{
|
||||
CDialog::OnDestroy();
|
||||
|
||||
// TODO: Add your message handler code here
|
||||
m_bIsPause = TRUE;
|
||||
m_bIsExit = TRUE;
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::PutScriptToList(CListCtrl* pTdList, CPtrArray& tdRecArray)
|
||||
{
|
||||
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
|
||||
int iTdRecIndex = (int)VAL_ZERO;
|
||||
CString szTdCon = _T("");
|
||||
|
||||
pTdList->DeleteAllItems();
|
||||
|
||||
while (iTdRecIndex < tdRecArray.GetSize())
|
||||
{
|
||||
pRsp2DTdRecord = (CRsp2DTdRecord*)tdRecArray.GetAt(iTdRecIndex);
|
||||
szTdCon.Empty();
|
||||
szTdCon.Format(_T("%d"), pRsp2DTdRecord->m_iTsn);
|
||||
pTdList->InsertItem(iTdRecIndex, szTdCon);
|
||||
|
||||
szTdCon.Empty();
|
||||
szTdCon.Format(_T("%d"), pRsp2DTdRecord->m_iC1);
|
||||
pTdList->SetItemText(iTdRecIndex, 1, szTdCon);
|
||||
|
||||
szTdCon.Empty();
|
||||
szTdCon.Format(_T("%d"), pRsp2DTdRecord->m_iC2);
|
||||
pTdList->SetItemText(iTdRecIndex, 2, szTdCon);
|
||||
|
||||
szTdCon.Empty();
|
||||
szTdCon.Format(_T("%d"), pRsp2DTdRecord->m_iP1);
|
||||
pTdList->SetItemText(iTdRecIndex, 3, szTdCon);
|
||||
|
||||
szTdCon.Empty();
|
||||
szTdCon.Format(_T("%d"), pRsp2DTdRecord->m_iP2);
|
||||
pTdList->SetItemText(iTdRecIndex, 4, szTdCon);
|
||||
|
||||
szTdCon.Empty();
|
||||
szTdCon.Format(_T("%d"), pRsp2DTdRecord->m_iN);
|
||||
pTdList->SetItemText(iTdRecIndex, 5, szTdCon);
|
||||
|
||||
szTdCon.Empty();
|
||||
szTdCon.Format(_T("%f"), pRsp2DTdRecord->m_fK);
|
||||
pTdList->SetItemText(iTdRecIndex, 6, szTdCon);
|
||||
|
||||
pTdList->SetItemData(iTdRecIndex, (DWORD)pRsp2DTdRecord);
|
||||
|
||||
iTdRecIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL COpExec2DRSPTestDlg::StartDataCollection(CListCtrl* pTdList, CTdChannel* pTdChannel)
|
||||
{
|
||||
char aResBuff[2048] = {0};
|
||||
int iResSize = (int)VAL_ZERO;
|
||||
|
||||
LVFINDINFO info;
|
||||
int iListIndex = (int)VAL_ZERO;
|
||||
int iTdRecIndex = (int)VAL_ZERO;
|
||||
|
||||
int iTime = (int)VAL_ZERO;
|
||||
BOOL bIsRetrans = FALSE;
|
||||
|
||||
CString szOrder = _T("");
|
||||
CString szResBuff = _T("");
|
||||
CString szResCon = _T("");
|
||||
CString szPrompt = _T("");
|
||||
|
||||
CStringArray szArrayRes;
|
||||
// CStringArray szArrayRes2;
|
||||
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
|
||||
int iPollingTime = 0;
|
||||
int iCountTime = 0;
|
||||
|
||||
m_pRsp2DTd->m_fTRPeriod = m_pRsp2DTd->m_fTRPeriod + 5;
|
||||
iTdRecIndex = (int)VAL_ZERO;
|
||||
|
||||
while ((TRUE == m_bIsExit) || (iTdRecIndex < pTdChannel->m_tdRecArray.GetSize()))
|
||||
{
|
||||
DoEvent(this->m_hWnd);
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause01\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
pRsp2DTdRecord = NULL;
|
||||
pRsp2DTdRecord = (CRsp2DTdRecord*)pTdChannel->m_tdRecArray.GetAt(iTdRecIndex);
|
||||
if (!bIsRetrans)
|
||||
{
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ClearCommReceiveBuff();
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ClearCommSendBuff();
|
||||
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.SendDataDirectly("\r\n", 2);
|
||||
// TransDelay(g_iTransMode, 20, 50);
|
||||
|
||||
iResSize = (int)VAL_ZERO;
|
||||
memset(aResBuff, 0, sizeof(aResBuff));
|
||||
szResBuff.Empty();
|
||||
iPollingTime = 0;
|
||||
|
||||
//先发送回车下去等待回应,最多发送等待2次,如果仍然没有回应,则报HOST_ERROR
|
||||
while ((szResBuff.Find(">") == -1) && (iPollingTime < MAX_POLLING_TIME))
|
||||
{
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
while (m_pRsp2DTd->m_pDevice->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
||||
{
|
||||
DoEvent(this->m_hWnd); //需要修改
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
||||
|
||||
iResSize = (int)VAL_ZERO;
|
||||
memset(aResBuff, 0, sizeof(aResBuff));
|
||||
}
|
||||
iPollingTime++;
|
||||
}
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause03\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (szResBuff.Find('>') == -1)
|
||||
{
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ClearCommReceiveBuff();
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ClearCommSendBuff();
|
||||
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.SendDataDirectly("\r\n", 2);
|
||||
// TransDelay(g_iTransMode, 20, 50);
|
||||
iResSize = (int)VAL_ZERO;
|
||||
memset(aResBuff, 0, sizeof(aResBuff));
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize);
|
||||
|
||||
szResBuff.Empty();
|
||||
szResBuff.Format(_T("%s"), aResBuff);
|
||||
if (szResBuff.Find('>') == -1)
|
||||
{
|
||||
szPrompt.Empty();
|
||||
szPrompt.LoadString(IDS_OP_HOST_ERROR);
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szPrompt, NULL, MB_ICONSTOP);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// iTime = (int)m_pRsp2DTd->m_fTRPeriod*pRsp2DTdRecord->m_iN; //发射周期与迭代次数决定延迟时间,真实环境需删除此处
|
||||
|
||||
// if (bIsRetrans) //真实环境需删除此处
|
||||
// {
|
||||
iTime = 0;
|
||||
// }
|
||||
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ClearCommReceiveBuff();
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ClearCommSendBuff();
|
||||
|
||||
//从这里开始下发需要测试的位置信息下去,之前的回车符已经得到了回应
|
||||
szOrder.Empty();
|
||||
szOrder.Format(_T("meas_point(%d,%d,%d,%d,%d,%d)\r\n"), pRsp2DTdRecord->m_iC1, pRsp2DTdRecord->m_iC2, pRsp2DTdRecord->m_iP1, pRsp2DTdRecord->m_iP2, iTime, (int)!bIsRetrans);
|
||||
|
||||
// MessageBox(szOrder);
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
||||
szOrder.ReleaseBuffer();
|
||||
// TransDelay(g_iTransMode, 100, 200);
|
||||
|
||||
bIsRetrans = FALSE;
|
||||
|
||||
DoEvent(this->m_hWnd);
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause03\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
iResSize = (int)VAL_ZERO;
|
||||
memset(aResBuff, 0, sizeof(aResBuff));
|
||||
|
||||
szResBuff.Empty();
|
||||
iPollingTime = 0;
|
||||
iCountTime = (int)m_pRsp2DTd->m_fTRPeriod*pRsp2DTdRecord->m_iN/COMM_TIMEOUT + MAX_POLLING_TIME; //依据发射周期设定轮询时长
|
||||
|
||||
while ((szResBuff.Find(">") == -1) && (iPollingTime < iCountTime))
|
||||
{
|
||||
DoEvent(this->m_hWnd);
|
||||
|
||||
Sleep(1);
|
||||
while (m_pRsp2DTd->m_pDevice->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
||||
{
|
||||
DoEvent(this->m_hWnd); //需要修改
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
||||
|
||||
iResSize = (int)VAL_ZERO;
|
||||
memset(aResBuff, 0, sizeof(aResBuff));
|
||||
}
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
iPollingTime++;
|
||||
}
|
||||
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause03\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
//如果在指定次数没有收到回应,则进行跳转到循环处进行重转
|
||||
if ((iCountTime+1) == iPollingTime)
|
||||
{
|
||||
bIsRetrans = TRUE;
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szResBuff);
|
||||
DoEvent(this->m_hWnd);
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause04\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// MessageBox(szResBuff);
|
||||
|
||||
DoEvent(this->m_hWnd);
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause03\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// MessageBox(szResBuff);
|
||||
try
|
||||
{
|
||||
if (GetSubStringInHeadAndTail(szResBuff, szResCon, _T("["), _T("]")) == TRUE)
|
||||
{
|
||||
if (StatStringCount(szResCon, _T(";")) == 4)
|
||||
{
|
||||
szArrayRes.RemoveAll();
|
||||
SplitterString(szArrayRes, szResCon, _T(";"));
|
||||
|
||||
if (szArrayRes.GetSize() == 4)
|
||||
{
|
||||
|
||||
/*szArrayRes.GetAt(0).TrimLeft();
|
||||
szArrayRes.GetAt(0).TrimRight();
|
||||
szArrayRes.GetAt(1).TrimLeft();
|
||||
szArrayRes.GetAt(1).TrimRight();
|
||||
szArrayRes.GetAt(2).TrimLeft();
|
||||
szArrayRes.GetAt(2).TrimRight();
|
||||
szArrayRes.GetAt(3).TrimLeft();
|
||||
szArrayRes.GetAt(3).TrimRight();*/
|
||||
//by quyx 20180502 为适应vs2013编译器
|
||||
CString szCstringRes0 = szArrayRes.GetAt(0);
|
||||
szCstringRes0.TrimLeft(); szCstringRes0.TrimRight();
|
||||
CString szCstringRes1 = szArrayRes.GetAt(1);
|
||||
szCstringRes1.TrimLeft(); szCstringRes1.TrimRight();
|
||||
CString szCstringRes2 = szArrayRes.GetAt(2);
|
||||
szCstringRes2.TrimLeft(); szCstringRes2.TrimRight();
|
||||
CString szCstringRes3 = szArrayRes.GetAt(3);
|
||||
szCstringRes3.TrimLeft(); szCstringRes3.TrimRight();
|
||||
|
||||
pRsp2DTdRecord->m_fI = (float)atof(szCstringRes0);// szArrayRes.GetAt(0));
|
||||
pRsp2DTdRecord->m_fV = (float)atof(szCstringRes1);//szArrayRes.GetAt(1));
|
||||
pRsp2DTdRecord->m_fR0 = (float)atof(szCstringRes2);//szArrayRes.GetAt(2));
|
||||
pRsp2DTdRecord->m_fSP = (float)atof(szCstringRes3);//szArrayRes.GetAt(3));
|
||||
|
||||
pTdChannel->SetColorToTdRec(pRsp2DTdRecord);
|
||||
|
||||
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
||||
info.lParam = (long)pRsp2DTdRecord;
|
||||
|
||||
iListIndex = pTdList->FindItem(&info);
|
||||
|
||||
if (iListIndex != (int)VAL_MINUS_ONE)
|
||||
{
|
||||
pTdList->SetItemText(iListIndex, 7, szCstringRes0);//szArrayRes.GetAt(0));
|
||||
pTdList->SetItemText(iListIndex, 8, szCstringRes1);//szArrayRes.GetAt(1));
|
||||
pTdList->SetItemText(iListIndex, 9, szCstringRes2);//szArrayRes.GetAt(2));
|
||||
pTdList->SetItemText(iListIndex, 10, szCstringRes3);//szArrayRes.GetAt(3));
|
||||
|
||||
pTdList->SetHotItem(iListIndex);
|
||||
pTdList->EnsureVisible(iListIndex, TRUE);
|
||||
pTdList->SetItemState(iListIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
||||
pTdList->SetFocus();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TransDelay(g_iTransMode, 3, 20, this->m_hWnd);
|
||||
bIsRetrans = TRUE;
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szResBuff);
|
||||
DoEvent(this->m_hWnd);
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause04\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
continue; //数据错,重测
|
||||
}
|
||||
}
|
||||
else if (_T("0") == szResCon)
|
||||
{
|
||||
pRsp2DTdRecord->m_fI = (float)0;
|
||||
pRsp2DTdRecord->m_fV = (float)0;
|
||||
pRsp2DTdRecord->m_fR0 = (float)0;
|
||||
pRsp2DTdRecord->m_fSP = (float)0;
|
||||
|
||||
pTdChannel->SetColorToTdRec(pRsp2DTdRecord);
|
||||
|
||||
info.flags = LVFI_PARTIAL | LVFI_PARAM;
|
||||
info.lParam = (long)pRsp2DTdRecord;
|
||||
|
||||
iListIndex = pTdList->FindItem(&info);
|
||||
|
||||
if (iListIndex != (int)VAL_MINUS_ONE)
|
||||
{
|
||||
pTdList->SetItemText(iListIndex, 7, _T("0"));
|
||||
pTdList->SetItemText(iListIndex, 8, _T("0"));
|
||||
pTdList->SetItemText(iListIndex, 9, _T("0"));
|
||||
pTdList->SetItemText(iListIndex, 10, _T("0"));
|
||||
|
||||
pTdList->SetHotItem(iListIndex);
|
||||
pTdList->EnsureVisible(iListIndex, TRUE);
|
||||
pTdList->SetItemState(iListIndex, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
|
||||
pTdList->SetFocus();
|
||||
}
|
||||
//
|
||||
}
|
||||
else
|
||||
{
|
||||
// TransDelay(g_iTransMode, 3, 20, this->m_hWnd); //数据错,重测
|
||||
bIsRetrans = TRUE;
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
// MessageBox(szResBuff);
|
||||
DoEvent(this->m_hWnd);
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause04\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bIsRetrans = TRUE;
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szResBuff);
|
||||
DoEvent(this->m_hWnd);
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause04\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
bIsRetrans = TRUE;
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szResBuff);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
DoEvent(this->m_hWnd);
|
||||
while (m_bIsPause)
|
||||
{
|
||||
TRACE("Pause04\n");
|
||||
Sleep(1);
|
||||
DoEvent(this->m_hWnd);
|
||||
if (m_bIsExit)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
CRect vRect;
|
||||
CRect lRect;
|
||||
int iSmWidth;
|
||||
int iSmHeight;
|
||||
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->GetClientRect(vRect);
|
||||
pTdChannel->m_pMedium->CalculateTdPtLoc(vRect, pTdChannel->m_iEAmount, pTdChannel->m_iMaxLevel, lRect, iSmWidth, iSmHeight, &pTdChannel->m_tdRecArray);
|
||||
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->m_lRect = lRect;
|
||||
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->m_iSmWidth = iSmWidth;
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->m_iSmHeight = iSmHeight;
|
||||
|
||||
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->Invalidate();
|
||||
|
||||
this->m_pgTd.StepIt();
|
||||
iTdRecIndex++; //测试下一个数据
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL COpExec2DRSPTestDlg::Create(UINT nID, CWnd* pParentWnd)
|
||||
{
|
||||
// TODO: Add your specialized code here and/or call the base class
|
||||
pParentWnd->EnableWindow(FALSE);
|
||||
return CDialog::Create(IDD, pParentWnd);
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::ReSetAll()
|
||||
{
|
||||
CTdChannel* pTdChannel = NULL;
|
||||
CRsp2DTdRecord* pRsp2DTdRecord = NULL;
|
||||
CRect vRect;
|
||||
CRect lRect;
|
||||
int iSmWidth = (int)VAL_ZERO;
|
||||
int iSmHeight = (int)VAL_ZERO;
|
||||
int iTdChannelIndex = (int)VAL_ZERO;
|
||||
int iTdRecIndex = (int)VAL_ZERO;
|
||||
CListCtrl* pTdList = &(m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdListView->GetListCtrl());
|
||||
|
||||
CClientDC dc(this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView);
|
||||
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->GetClientRect(vRect);
|
||||
dc.FillSolidRect(vRect, RGB(0xFF,0xFF,0xFF));
|
||||
|
||||
iTdChannelIndex = (int)VAL_ZERO;
|
||||
|
||||
// int q = m_pRsp2DTd->m_tdChaList.GetCount();
|
||||
while (iTdChannelIndex < m_pRsp2DTd->m_tdChaList.GetCount())
|
||||
{
|
||||
pTdChannel = NULL;
|
||||
pTdChannel = (CTdChannel*)this->m_pRsp2DTd->m_tdChaList.GetAt(this->m_pRsp2DTd->m_tdChaList.FindIndex(iTdChannelIndex));
|
||||
|
||||
if (NULL != pTdChannel)
|
||||
{
|
||||
pTdChannel->Clear2DSptRecList();
|
||||
pTdChannel->Load2DScriptFromDB();
|
||||
pTdChannel->m_pMedium->CalculateTdPtLoc(vRect, pTdChannel->m_iEAmount, pTdChannel->m_iMaxLevel, lRect, iSmWidth, iSmHeight, &pTdChannel->m_tdRecArray);
|
||||
|
||||
iTdRecIndex = (int)VAL_ZERO;
|
||||
while (iTdRecIndex < pTdChannel->m_tdRecArray.GetSize())
|
||||
{
|
||||
pRsp2DTdRecord = NULL;
|
||||
pRsp2DTdRecord = (CRsp2DTdRecord*)pTdChannel->m_tdRecArray.GetAt(iTdRecIndex);
|
||||
pRsp2DTdRecord->ClearAll();
|
||||
iTdRecIndex++;
|
||||
}
|
||||
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->m_lRect = lRect;
|
||||
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->m_iSmWidth = iSmWidth;
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->m_iSmHeight = iSmHeight;
|
||||
}
|
||||
|
||||
this->m_pRsp2DTd->m_pDevice->ShowGRInfo(m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestGrListView->GetListCtrl());
|
||||
this->PutScriptToList(pTdList, pTdChannel->m_tdRecArray);
|
||||
|
||||
this->m_pgTd.SetRange(0, pTdChannel->m_tdRecArray.GetSize());
|
||||
this->m_pgTd.SetPos(0);
|
||||
this->m_pgTd.SetStep(1);
|
||||
|
||||
iTdChannelIndex++;
|
||||
}
|
||||
|
||||
this->m_pOpExec2DRSPTestFrame->m_pOpExec2DRSPTestTdView->Invalidate();
|
||||
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::ClearAll()
|
||||
{
|
||||
CString szFilePath = _T("");
|
||||
CString szFileName = _T("");
|
||||
CString szFile = _T("");
|
||||
CString szOrder = _T("");
|
||||
CString szResBuff = _T("");
|
||||
CString szPrompt = _T("");
|
||||
|
||||
int iResSize = (int)VAL_ZERO;
|
||||
int iPollingTime = (int)VAL_ZERO;
|
||||
char aResBuff[2048] = {0};
|
||||
|
||||
szFilePath.Empty();
|
||||
szFilePath.GetBufferSetLength(2048);
|
||||
::GetCurrentDirectory(2048, szFilePath.GetBuffer(szFilePath.GetLength()));
|
||||
szFilePath.ReleaseBuffer();
|
||||
|
||||
szFileName.Empty();
|
||||
szFileName = m_pRsp2DTd->m_szTdCN + _T(".xml");
|
||||
szFile.Empty();
|
||||
szFile = szFilePath + _T("\\") + szFileName;
|
||||
|
||||
DeleteFile(szFile);
|
||||
|
||||
TransDelay(g_iTransMode, 10, 50, NULL);
|
||||
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ClearCommReceiveBuff();
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.ClearCommSendBuff();
|
||||
|
||||
szOrder.Empty();
|
||||
szOrder.Format(_T("meas_delete(\"%s\",\"%s\",\"%s\")\r\n"), m_pRsp2DTd->m_szPrCN, m_pRsp2DTd->m_szTzCN, m_pRsp2DTd->m_szTdCN);
|
||||
// MessageBox(szOrder);
|
||||
|
||||
m_pRsp2DTd->m_pDevice->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
||||
szOrder.ReleaseBuffer();
|
||||
// TransDelay(g_iTransMode, 100, 200);
|
||||
|
||||
iResSize = (int)VAL_ZERO;
|
||||
memset(aResBuff, 0, sizeof(aResBuff));
|
||||
szResBuff.Empty();
|
||||
iPollingTime = (int)VAL_ZERO;
|
||||
while ((szResBuff.Find(">") == -1) && (iPollingTime < 3))
|
||||
{
|
||||
Sleep(500);
|
||||
while (m_pRsp2DTd->m_pDevice->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
||||
{
|
||||
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
||||
|
||||
iResSize = (int)VAL_ZERO;
|
||||
memset(aResBuff, 0, sizeof(aResBuff));
|
||||
}
|
||||
iPollingTime++;
|
||||
}
|
||||
|
||||
// MessageBox(szResBuff);
|
||||
|
||||
if (szResBuff.Find('>') == -1)
|
||||
{
|
||||
szPrompt.Empty();
|
||||
szPrompt.LoadString(IDS_OP_HOST_ERROR);
|
||||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||||
MessageBox(szPrompt, NULL, MB_ICONSTOP);
|
||||
}
|
||||
|
||||
// this->m_pRsp2DTd->ClearTdChaList();
|
||||
}
|
||||
|
||||
BOOL COpExec2DRSPTestDlg::TestingPointCollection()
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL COpExec2DRSPTestDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
// TODO: Add your specialized code here and/or call the base class
|
||||
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
return CDialog::PreTranslateMessage(pMsg);
|
||||
}
|
||||
|
||||
void COpExec2DRSPTestDlg::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
CDialog::OnSize(nType, cx, cy);
|
||||
UPDATE_EASYSIZE;
|
||||
|
||||
// TODO: Add your message handler code here
|
||||
|
||||
//onsize在对话框初始化前会被调用,但此时相关对象并没有被创建起来,故需在要此进行判断
|
||||
if (m_pOpExec2DRSPTestFrame)
|
||||
{
|
||||
CRect rect;
|
||||
|
||||
CWnd *pStatic = GetDlgItem(IDC_STATIC_FRAME);
|
||||
pStatic->GetWindowRect(&rect);
|
||||
|
||||
this->ScreenToClient(&rect);
|
||||
|
||||
m_pOpExec2DRSPTestFrame->MoveWindow(&rect);
|
||||
m_pOpExec2DRSPTestFrame->ShowWindow(SW_SHOW);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user