1086 lines
35 KiB
C++
1086 lines
35 KiB
C++
// ExecManager.cpp: implementation of the CExecManager class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "ExecManager.h"
|
|
#include "LinkList.h"
|
|
#include "opselectscondlg.h"
|
|
#include "opexeccersptestdlg.h"
|
|
#include "opexec2drsptestdlg.h"
|
|
#include "opexec2drsptestsetdlg.h"
|
|
|
|
#include "TdChannel.h"
|
|
|
|
#include "Markup.h"
|
|
|
|
#include "Rsp2DTd.h"
|
|
#include "RspCETd.h"
|
|
|
|
#include "HandleProcessor.h"
|
|
|
|
#include "Medium.h"
|
|
#include "MediumA.h"
|
|
#include "MediumB.h"
|
|
#include "MediumC.h"
|
|
#include "MediumD.h"
|
|
#include "MediumE.h"
|
|
#include "MediumK.h"
|
|
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
extern int g_iUILanguage;
|
|
extern int g_iLanguage;
|
|
extern int g_iTransMode;
|
|
extern BOOL DoEvent(HWND hWnd);
|
|
extern void TransDelay(int iTransMode, int iDS0, int iDS1, HWND hWnd = NULL);
|
|
extern BOOL GetSubStringInHeadAndTail(const CString& szSource, CString& szSub, const CString& szHead, const CString& szTail);
|
|
extern HHOOK hHook;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CExecManager::CExecManager(_ConnectionPtr& pConnection)
|
|
{
|
|
ASSERT(NULL != pConnection);
|
|
m_pConnection = pConnection;
|
|
}
|
|
|
|
CExecManager::~CExecManager()
|
|
{
|
|
|
|
}
|
|
|
|
//DEL BOOL CExecManager::Save2DRSPSetInfoToHeadFile(COpExec2DRSPTestSetDlg* pOpExec2DRSPTestSetDlg)
|
|
//DEL {
|
|
//DEL _RecordsetPtr pRecTdCha = NULL;
|
|
//DEL
|
|
//DEL CMarkup xml;
|
|
//DEL
|
|
//DEL int iSptIndex = (int)VAL_ZERO;
|
|
//DEL POSITION posSpt;
|
|
//DEL DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
//DEL DWORD dwSptID = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL CString szSql = _T("");
|
|
//DEL CString szFileName = _T("");
|
|
//DEL CString szEdCon = _T("");
|
|
//DEL
|
|
//DEL szFileName = _T("ERI20140527151254.xml");
|
|
//DEL
|
|
//DEL xml.SetDoc("<?xml version=\"1.0\" encoding=\"ansi\"?>\r\n");
|
|
//DEL xml.AddElem("measure");
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("measure_name"), pOpExec2DRSPTestSetDlg->m_szName);
|
|
//DEL xml.AddChildElem(_T("measure_location"), pOpExec2DRSPTestSetDlg->m_szLocation);
|
|
//DEL
|
|
//DEL posSpt = pOpExec2DRSPTestSetDlg->m_sptList.GetFirstSelectedItemPosition();
|
|
//DEL iSptIndex = pOpExec2DRSPTestSetDlg->m_sptList.GetNextSelectedItem(posSpt);
|
|
//DEL
|
|
//DEL dwSptHandle = pOpExec2DRSPTestSetDlg->m_sptList.GetItemData(iSptIndex);
|
|
//DEL dwSptID = this->m_handleProcessor.GetIDFromHandle(dwSptHandle);
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("measure_script_id"), pOpExec2DRSPTestSetDlg->m_sptList.GetItemText(iSptIndex, 1));
|
|
//DEL xml.AddChildElem(_T("measure_script_name"), pOpExec2DRSPTestSetDlg->m_sptList.GetItemText(iSptIndex, 2));
|
|
//DEL xml.AddChildElem(_T("measure_script_type"), 1);
|
|
//DEL xml.AddChildElem(_T("pole_count"), pOpExec2DRSPTestSetDlg->m_sptList.GetItemText(iSptIndex, 3));
|
|
//DEL xml.AddChildElem(_T("channel_count"), pOpExec2DRSPTestSetDlg->m_sptList.GetItemText(iSptIndex, 4));
|
|
//DEL xml.AddChildElem(_T("point_count"), pOpExec2DRSPTestSetDlg->m_sptList.GetItemText(iSptIndex, 5));
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("measure_type"), 0);
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("measure_mode"), pOpExec2DRSPTestSetDlg->m_cbTMode.GetCurSel());
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("medium_set"));
|
|
//DEL xml.IntoElem();
|
|
//DEL
|
|
//DEL pRecTdCha.CreateInstance(_uuidof(Recordset));
|
|
//DEL szSql.Empty();
|
|
//DEL szSql.Format(_T("select CHnumber&':'&AR as CA from channel where SCID = %d order by CHnumber"), dwSptID);
|
|
//DEL pRecTdCha->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//DEL
|
|
//DEL while (0 == pRecTdCha->adoEOF)
|
|
//DEL {
|
|
//DEL xml.AddChildElem(_T("medium"), (LPCTSTR)(_bstr_t)pRecTdCha->GetCollect(_T("CA")));
|
|
//DEL pRecTdCha->MoveNext();
|
|
//DEL }
|
|
//DEL
|
|
//DEL pRecTdCha->Close();
|
|
//DEL
|
|
//DEL xml.OutOfElem();
|
|
//DEL
|
|
//DEL pOpExec2DRSPTestSetDlg->UpdateData();
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("pole_distance"), pOpExec2DRSPTestSetDlg->m_szEDistance);
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edESpace.GetWindowText(szEdCon);
|
|
//DEL xml.AddChildElem(_T("pole_gap"), szEdCon);
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("wires_layout"), pOpExec2DRSPTestSetDlg->m_cbCLayout.GetCurSel());
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("rolling_times"), 0);
|
|
//DEL xml.AddChildElem(_T("rolling_direction"), 0);
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("iterations"), 1);
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("wave_shape"), pOpExec2DRSPTestSetDlg->m_cbTRFrequency.GetCurSel());
|
|
//DEL
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("period"), pOpExec2DRSPTestSetDlg->m_cbTRFrequency.GetCurSel());
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("industrial_frequency"), pOpExec2DRSPTestSetDlg->m_cbIFrequency.GetCurSel());
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("sample_rate"), pOpExec2DRSPTestSetDlg->m_cbSAFrequency.GetCurSel());
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edTemperature.GetWindowText(szEdCon);
|
|
//DEL xml.AddChildElem(_T("temperature"), szEdCon);
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edHeight.GetWindowText(szEdCon);
|
|
//DEL xml.AddChildElem(_T("height"), szEdCon);
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edHumidity.GetWindowText(szEdCon);
|
|
//DEL xml.AddChildElem(_T("humidity"), szEdCon);
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("weather"), pOpExec2DRSPTestSetDlg->m_cbWeather.GetCurSel());
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("wind_direction"), pOpExec2DRSPTestSetDlg->m_cbWDIR.GetCurSel());
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("create_date"), _T("20140527"));
|
|
//DEL xml.AddChildElem(_T("create_time"), _T("151254"));
|
|
//DEL xml.AddChildElem(_T("test_date"), _T("20140527"));
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("test_time"), _T("151254"));
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("PM"), pOpExec2DRSPTestSetDlg->m_szPM);
|
|
//DEL xml.AddChildElem(_T("OP"), pOpExec2DRSPTestSetDlg->m_szOP);
|
|
//DEL xml.AddChildElem(_T("QA"), pOpExec2DRSPTestSetDlg->m_szQA);
|
|
//DEL
|
|
//DEL xml.AddChildElem(_T("apparent_chargeability"));
|
|
//DEL
|
|
//DEL xml.IntoElem();
|
|
//DEL xml.AddChildElem(_T("m0"));
|
|
//DEL xml.AddChildElem(_T("m1"));
|
|
//DEL xml.AddChildElem(_T("m2"));
|
|
//DEL xml.AddChildElem(_T("m3"));
|
|
//DEL xml.AddChildElem(_T("m4"));
|
|
//DEL xml.AddChildElem(_T("m5"));
|
|
//DEL xml.AddChildElem(_T("m6"));
|
|
//DEL xml.AddChildElem(_T("m7"));
|
|
//DEL xml.AddChildElem(_T("m8"));
|
|
//DEL xml.AddChildElem(_T("m9"));
|
|
//DEL xml.OutOfElem();
|
|
//DEL
|
|
//DEL xml.Save(szFileName);
|
|
//DEL
|
|
//DEL return TRUE;
|
|
//DEL }
|
|
|
|
//DEL BOOL CExecManager::Save2DRSPSetInfo(CRsp2DTd* pRsp2DTd, COpExec2DRSPTestSetDlg* pOpExec2DRSPTestSetDlg)
|
|
//DEL {
|
|
//DEL _RecordsetPtr pRecTdChaList = NULL;
|
|
//DEL CString szSql = _T("");
|
|
//DEL CString szLbText = _T("");
|
|
//DEL
|
|
//DEL CString szPro = _T("");
|
|
//DEL CString szPrCN = _T("");
|
|
//DEL CString szTzName = _T("");
|
|
//DEL CString szTzCN = _T("");
|
|
//DEL
|
|
//DEL DWORD dwMedHandle = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL int iChNum = (int)VAL_ZERO;
|
|
//DEL int iSptIndex = (int)VAL_ZERO;
|
|
//DEL POSITION posSpt;
|
|
//DEL CTime tCT;
|
|
//DEL
|
|
//DEL CString szEdCon = _T("");
|
|
//DEL
|
|
//DEL DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
//DEL DWORD dwSptID = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL tCT = CTime::GetCurrentTime();
|
|
//DEL
|
|
//DEL pRsp2DTd->m_szTdName = pOpExec2DRSPTestSetDlg->m_szName;
|
|
//DEL pRsp2DTd->m_szTdCN = _T("ERIR")+tCT.FormatGmt(_T("%Y%m%d"))+tCT.FormatGmt(_T("%H%M%S"));
|
|
//DEL pRsp2DTd->m_szTLocation = pOpExec2DRSPTestSetDlg->m_szLocation;
|
|
//DEL
|
|
//DEL pRsp2DTd->m_bIsGr = pOpExec2DRSPTestSetDlg->m_ckIsGr.GetCheck();
|
|
//DEL
|
|
//DEL pRsp2DTd->m_dwID = (DWORD)VAL_ZERO;
|
|
//DEL pRsp2DTd->m_pDevice = (CDevice*)pOpExec2DRSPTestSetDlg->m_cbDESN.GetItemData(pOpExec2DRSPTestSetDlg->m_cbDESN.GetCurSel());
|
|
//DEL
|
|
//DEL posSpt = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetFirstSelectedItemPosition();
|
|
//DEL iSptIndex = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetNextSelectedItem(posSpt);
|
|
//DEL
|
|
//DEL dwSptHandle = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemData(iSptIndex);
|
|
//DEL dwSptID = this->m_handleProcessor.GetIDFromHandle(dwSptHandle);
|
|
//DEL
|
|
//DEL pRsp2DTd->m_dwSCID = dwSptID;
|
|
//DEL pRsp2DTd->m_szSCCN = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 0);
|
|
//DEL pRsp2DTd->m_szSName = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 1);
|
|
//DEL pRsp2DTd->m_iSType = (int)VAL_ONE;
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iTType = (int)VAL_ZERO;
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iEAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 2));
|
|
//DEL pRsp2DTd->m_iCHAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 3));
|
|
//DEL pRsp2DTd->m_iTPAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 4));
|
|
//DEL
|
|
//DEL szPro.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_cbPrName.GetLBText(pOpExec2DRSPTestSetDlg->m_cbPrName.GetCurSel(), szPro);
|
|
//DEL
|
|
//DEL szPrCN.Empty();
|
|
//DEL GetSubStringInHeadAndTail(szPro, szPrCN, _T("("), _T(")"));
|
|
//DEL pRsp2DTd->m_szPrCN = szPrCN;
|
|
//DEL
|
|
//DEL szTzName.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_cbTzName.GetLBText(pOpExec2DRSPTestSetDlg->m_cbTzName.GetCurSel(), szTzName);
|
|
//DEL pRsp2DTd->m_szTzName = szTzName;
|
|
//DEL
|
|
//DEL szTzCN.Empty();
|
|
//DEL GetSubStringInHeadAndTail(szTzName, szTzCN, _T("("), _T(")"));
|
|
//DEL pRsp2DTd->m_szTzCN = szTzCN;
|
|
//DEL
|
|
//DEL pRsp2DTd->m_dwTzID = pOpExec2DRSPTestSetDlg->m_cbTzName.GetItemData(pOpExec2DRSPTestSetDlg->m_cbTzName.GetCurSel());
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iCLayout = pOpExec2DRSPTestSetDlg->m_cbCLayout.GetCurSel();
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edESpace.GetWindowText(szEdCon);
|
|
//DEL pRsp2DTd->m_fESpace = (float)atof(szEdCon.GetBuffer(0));
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iEDistance = atoi(pOpExec2DRSPTestSetDlg->m_szEDistance.GetBuffer(0));
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iCRtime = (int)VAL_ZERO;
|
|
//DEL pRsp2DTd->m_iRDirection = (int)VAL_ZERO;
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iIFrequency = pOpExec2DRSPTestSetDlg->m_cbIFrequency.GetCurSel();
|
|
//DEL
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iSAFrequency = pOpExec2DRSPTestSetDlg->m_cbSAFrequency.GetCurSel();
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iTRFrequency = pOpExec2DRSPTestSetDlg->m_cbTRFrequency.GetCurSel();
|
|
//DEL szLbText.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_cbTRFrequency.GetLBText(pRsp2DTd->m_iTRFrequency, szLbText);
|
|
//DEL szLbText.TrimRight(_T("Hz"));
|
|
//DEL pRsp2DTd->m_fTRPeriod = 1000/(float)atof(szLbText);
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iTMode = pOpExec2DRSPTestSetDlg->m_cbTMode.GetCurSel();
|
|
//DEL pRsp2DTd->m_iTRWave = pOpExec2DRSPTestSetDlg->m_cbTRWave.GetCurSel();
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edHeight.GetWindowText(szEdCon);
|
|
//DEL pRsp2DTd->m_fHeight = (float)atof(szEdCon.GetBuffer(0));
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edHumidity.GetWindowText(szEdCon);
|
|
//DEL pRsp2DTd->m_fHumidity = (float)atof(szEdCon.GetBuffer(0));
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edTemperature.GetWindowText(szEdCon);
|
|
//DEL pRsp2DTd->m_fTemperature = (float)atof(szEdCon.GetBuffer(0));
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iWDIR = pOpExec2DRSPTestSetDlg->m_cbWDIR.GetCurSel();
|
|
//DEL pRsp2DTd->m_iWeather = pOpExec2DRSPTestSetDlg->m_cbWeather.GetCurSel();
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iN = (int)VAL_ONE;
|
|
//DEL
|
|
//DEL
|
|
//DEL pRsp2DTd->m_szCDate = tCT.FormatGmt(_T("%Y-%m-%d"));
|
|
//DEL pRsp2DTd->m_szCTime = tCT.FormatGmt(_T("%H:%M:%S"));
|
|
//DEL
|
|
//DEL pRsp2DTd->m_szTDate = tCT.FormatGmt(_T("%Y-%m-%d"));
|
|
//DEL pRsp2DTd->m_szTTime = tCT.FormatGmt(_T("%H:%M:%S"));
|
|
//DEL
|
|
//DEL pRsp2DTd->m_iRCamount = (int)VAL_ZERO;
|
|
//DEL pRsp2DTd->m_iRDirection = (int)VAL_ZERO;
|
|
//DEL pRsp2DTd->m_iCRtime = (int)VAL_ZERO;
|
|
//DEL
|
|
//DEL pRsp2DTd->m_szOP = pOpExec2DRSPTestSetDlg->m_szOP;
|
|
//DEL pRsp2DTd->m_szPM = pOpExec2DRSPTestSetDlg->m_szPM;
|
|
//DEL pRsp2DTd->m_szQA = pOpExec2DRSPTestSetDlg->m_szQA;
|
|
//DEL
|
|
//DEL pRsp2DTd->m_tdChaList.RemoveAll();
|
|
//DEL pRecTdChaList.CreateInstance(_uuidof(Recordset));
|
|
//DEL
|
|
//DEL szSql.Empty();
|
|
//DEL szSql.Format(_T("select CHnumber,AR from channel where SCID = %u order by CHnumber"), pRsp2DTd->m_dwSCID);
|
|
//DEL pRecTdChaList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//DEL
|
|
//DEL while ((short)VAL_ZERO == pRecTdChaList->adoEOF)
|
|
//DEL {
|
|
//DEL iChNum = pRecTdChaList->GetCollect(_T("CHnumber")).iVal;
|
|
//DEL CTdChannel* pTdChannel = new CTdChannel(pRsp2DTd->m_dwSCID, iChNum, m_pConnection);
|
|
//DEL dwMedHandle = m_handleProcessor.GenerateHandle(pRecTdChaList->GetCollect(_T("AR")).iVal, PZ_STYLE_MED_DEF);
|
|
//DEL pTdChannel->m_pMedium = m_medLinkList.Find(dwMedHandle);
|
|
//DEL pTdChannel->m_iEAmount = pRsp2DTd->m_iEAmount;
|
|
//DEL
|
|
//DEL pRsp2DTd->m_tdChaList.AddTail(pTdChannel);
|
|
//DEL pRecTdChaList->MoveNext();
|
|
//DEL }
|
|
//DEL
|
|
//DEL pRecTdChaList->Close();
|
|
//DEL
|
|
//DEL return TRUE;
|
|
//DEL }
|
|
|
|
//DEL BOOL CExecManager::SaveCERSPSetInfo(CRspCETd* pRspCETd, COpExec2DRSPTestSetDlg* pOpExec2DRSPTestSetDlg)
|
|
//DEL {
|
|
//DEL _RecordsetPtr pRecTdChaList = NULL;
|
|
//DEL CString szSql = _T("");
|
|
//DEL CString szLbText = _T("");
|
|
//DEL
|
|
//DEL CString szPro = _T("");
|
|
//DEL CString szPrCN = _T("");
|
|
//DEL CString szTzName = _T("");
|
|
//DEL CString szTzCN = _T("");
|
|
//DEL
|
|
//DEL DWORD dwMedHandle = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL int iChNum = (int)VAL_ZERO;
|
|
//DEL int iSptIndex = (int)VAL_ZERO;
|
|
//DEL POSITION posSpt;
|
|
//DEL CTime tCT;
|
|
//DEL
|
|
//DEL CString szEdCon = _T("");
|
|
//DEL
|
|
//DEL DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
//DEL DWORD dwSptID = (DWORD)VAL_ZERO;
|
|
//DEL
|
|
//DEL tCT = CTime::GetCurrentTime();
|
|
//DEL
|
|
//DEL pRspCETd->m_szTdName = pOpExec2DRSPTestSetDlg->m_szName;
|
|
//DEL pRspCETd->m_szTdCN = _T("ERIR")+tCT.FormatGmt(_T("%Y%m%d"))+tCT.FormatGmt(_T("%H%M%S"));
|
|
//DEL pRspCETd->m_szTLocation = pOpExec2DRSPTestSetDlg->m_szLocation;
|
|
//DEL
|
|
//DEL pRspCETd->m_dwID = (DWORD)VAL_ZERO;
|
|
//DEL pRspCETd->m_pDevice = (CDevice*)pOpExec2DRSPTestSetDlg->m_cbDESN.GetItemData(pOpExec2DRSPTestSetDlg->m_cbDESN.GetCurSel());
|
|
//DEL
|
|
//DEL posSpt = pOpExec2DRSPTestSetDlg->m_opCESptSelDlg.m_ceSptList.GetFirstSelectedItemPosition();
|
|
//DEL iSptIndex = pOpExec2DRSPTestSetDlg->m_opCESptSelDlg.m_ceSptList.GetNextSelectedItem(posSpt);
|
|
//DEL
|
|
//DEL dwSptHandle = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemData(iSptIndex);
|
|
//DEL dwSptID = this->m_handleProcessor.GetIDFromHandle(dwSptHandle);
|
|
//DEL
|
|
//DEL pRspCETd->m_dwSCID = dwSptID;
|
|
//DEL pRspCETd->m_szSCCN = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 0);
|
|
//DEL pRspCETd->m_szSName = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 1);
|
|
//DEL pRspCETd->m_iSType = (int)VAL_ONE;
|
|
//DEL
|
|
//DEL pRspCETd->m_iTType = (int)VAL_ZERO;
|
|
//DEL
|
|
//DEL pRspCETd->m_iEAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 2));
|
|
//DEL pRspCETd->m_iCHAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 3));
|
|
//DEL pRspCETd->m_iTPAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 4));
|
|
//DEL
|
|
//DEL szPro.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_cbPrName.GetLBText(pOpExec2DRSPTestSetDlg->m_cbPrName.GetCurSel(), szPro);
|
|
//DEL
|
|
//DEL szPrCN.Empty();
|
|
//DEL GetSubStringInHeadAndTail(szPro, szPrCN, _T("("), _T(")"));
|
|
//DEL pRspCETd->m_szPrCN = szPrCN;
|
|
//DEL
|
|
//DEL szTzName.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_cbTzName.GetLBText(pOpExec2DRSPTestSetDlg->m_cbTzName.GetCurSel(), szTzName);
|
|
//DEL pRspCETd->m_szTzName = szTzName;
|
|
//DEL
|
|
//DEL szTzCN.Empty();
|
|
//DEL GetSubStringInHeadAndTail(szTzName, szTzCN, _T("("), _T(")"));
|
|
//DEL pRspCETd->m_szTzCN = szTzCN;
|
|
//DEL
|
|
//DEL pRspCETd->m_dwTzID = pOpExec2DRSPTestSetDlg->m_cbTzName.GetItemData(pOpExec2DRSPTestSetDlg->m_cbTzName.GetCurSel());
|
|
//DEL
|
|
//DEL pRspCETd->m_iCLayout = pOpExec2DRSPTestSetDlg->m_cbCLayout.GetCurSel();
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edESpace.GetWindowText(szEdCon);
|
|
//DEL pRspCETd->m_fESpace = (float)atof(szEdCon.GetBuffer(0));
|
|
//DEL
|
|
//DEL pRspCETd->m_iEDistance = atoi(pOpExec2DRSPTestSetDlg->m_szEDistance.GetBuffer(0));
|
|
//DEL
|
|
//DEL pRspCETd->m_iCRtime = (int)VAL_ZERO;
|
|
//DEL pRspCETd->m_iRDirection = (int)VAL_ZERO;
|
|
//DEL
|
|
//DEL pRspCETd->m_iIFrequency = pOpExec2DRSPTestSetDlg->m_cbIFrequency.GetCurSel();
|
|
//DEL
|
|
//DEL
|
|
//DEL pRspCETd->m_iSAFrequency = pOpExec2DRSPTestSetDlg->m_cbSAFrequency.GetCurSel();
|
|
//DEL
|
|
//DEL pRspCETd->m_iTRFrequency = pOpExec2DRSPTestSetDlg->m_cbTRFrequency.GetCurSel();
|
|
//DEL szLbText.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_cbTRFrequency.GetLBText(pRspCETd->m_iTRFrequency, szLbText);
|
|
//DEL szLbText.TrimRight(_T("Hz"));
|
|
//DEL pRspCETd->m_fTRPeriod = 1000/(float)atof(szLbText);
|
|
//DEL
|
|
//DEL pRspCETd->m_iTMode = pOpExec2DRSPTestSetDlg->m_cbTMode.GetCurSel();
|
|
//DEL pRspCETd->m_iTRWave = pOpExec2DRSPTestSetDlg->m_cbTRWave.GetCurSel();
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edHeight.GetWindowText(szEdCon);
|
|
//DEL pRspCETd->m_fHeight = (float)atof(szEdCon.GetBuffer(0));
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edHumidity.GetWindowText(szEdCon);
|
|
//DEL pRspCETd->m_fHumidity = (float)atof(szEdCon.GetBuffer(0));
|
|
//DEL
|
|
//DEL szEdCon.Empty();
|
|
//DEL pOpExec2DRSPTestSetDlg->m_edTemperature.GetWindowText(szEdCon);
|
|
//DEL pRspCETd->m_fTemperature = (float)atof(szEdCon.GetBuffer(0));
|
|
//DEL
|
|
//DEL pRspCETd->m_iWDIR = pOpExec2DRSPTestSetDlg->m_cbWDIR.GetCurSel();
|
|
//DEL pRspCETd->m_iWeather = pOpExec2DRSPTestSetDlg->m_cbWeather.GetCurSel();
|
|
//DEL
|
|
//DEL pRspCETd->m_iN = (int)VAL_ONE;
|
|
//DEL
|
|
//DEL
|
|
//DEL pRspCETd->m_szCDate = tCT.FormatGmt(_T("%Y-%m-%d"));
|
|
//DEL pRspCETd->m_szCTime = tCT.FormatGmt(_T("%H:%M:%S"));
|
|
//DEL
|
|
//DEL pRspCETd->m_szTDate = tCT.FormatGmt(_T("%Y-%m-%d"));
|
|
//DEL pRspCETd->m_szTTime = tCT.FormatGmt(_T("%H:%M:%S"));
|
|
//DEL
|
|
//DEL pRspCETd->m_iRCamount = (int)VAL_ZERO;
|
|
//DEL pRspCETd->m_iRDirection = (int)VAL_ZERO;
|
|
//DEL pRspCETd->m_iCRtime = (int)VAL_ZERO;
|
|
//DEL
|
|
//DEL pRspCETd->m_szOP = pOpExec2DRSPTestSetDlg->m_szOP;
|
|
//DEL pRspCETd->m_szPM = pOpExec2DRSPTestSetDlg->m_szPM;
|
|
//DEL pRspCETd->m_szQA = pOpExec2DRSPTestSetDlg->m_szQA;
|
|
//DEL
|
|
//DEL pRspCETd->m_tdChaList.RemoveAll();
|
|
//DEL pRecTdChaList.CreateInstance(_uuidof(Recordset));
|
|
//DEL
|
|
//DEL szSql.Empty();
|
|
//DEL szSql.Format(_T("select CHnumber,AR from channel where SCID = %u order by CHnumber"), pRspCETd->m_dwSCID);
|
|
//DEL pRecTdChaList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//DEL
|
|
//DEL while ((short)VAL_ZERO == pRecTdChaList->adoEOF)
|
|
//DEL {
|
|
//DEL iChNum = pRecTdChaList->GetCollect(_T("CHnumber")).iVal;
|
|
//DEL CTdChannel* pTdChannel = new CTdChannel(pRspCETd->m_dwSCID, iChNum, m_pConnection);
|
|
//DEL dwMedHandle = m_handleProcessor.GenerateHandle(pRecTdChaList->GetCollect(_T("AR")).iVal, PZ_STYLE_MED_DEF);
|
|
//DEL pTdChannel->m_pMedium = m_medLinkList.Find(dwMedHandle);
|
|
//DEL pTdChannel->m_iEAmount = pRspCETd->m_iEAmount;
|
|
//DEL
|
|
//DEL pRspCETd->m_tdChaList.AddTail(pTdChannel);
|
|
//DEL pRecTdChaList->MoveNext();
|
|
//DEL }
|
|
//DEL
|
|
//DEL pRecTdChaList->Close();
|
|
//DEL return TRUE;
|
|
//DEL }
|
|
|
|
BOOL CExecManager::Exec2DRSPTest(COpExec2DRSPTestSetDlg* pOpExec2DRSPTestSetDlg, CLinkList<CMedium*>& m_medLinkList)
|
|
{
|
|
long lRet = VAL_ZERO;
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFileName = _T("");
|
|
CString szHostFilePath = _T("");
|
|
|
|
CRsp2DTd* pRsp2DTd = new CRsp2DTd((DWORD)VAL_ZERO, m_pConnection);
|
|
|
|
pRsp2DTd->Save2DRSPSetInfo(pOpExec2DRSPTestSetDlg, m_medLinkList);
|
|
|
|
|
|
pRsp2DTd->SaveHeadInfoToFile(szLocFilePath, szLocFileName);
|
|
|
|
szHostFilePath.Empty();
|
|
|
|
szHostFilePath.Format(_T("/SD/projects/%s/%s/"), pRsp2DTd->m_szPrCN, pRsp2DTd->m_szTzCN);
|
|
if (TRUE == pRsp2DTd->m_pDevice->SendFile(szHostFilePath, szLocFilePath, szLocFileName))
|
|
{
|
|
DeleteFile(szLocFilePath+ _T("\\")+szLocFileName);
|
|
|
|
|
|
if (TRUE == InitialMeasure(pRsp2DTd->m_pDevice, pRsp2DTd->m_szPrCN, pRsp2DTd->m_szTzCN, pRsp2DTd->m_szTdCN, pRsp2DTd->m_iEAmount))
|
|
{
|
|
try
|
|
{
|
|
COpExec2DRSPTestDlg* pOpExec2DRSPTestDlg = new COpExec2DRSPTestDlg(pRsp2DTd, (INT_PTR*)&lRet);
|
|
pOpExec2DRSPTestDlg->Create(IDD_OP_TD_S_C, AfxGetMainWnd());
|
|
|
|
pOpExec2DRSPTestDlg->ShowWindow(SW_SHOW);
|
|
pOpExec2DRSPTestDlg->RunModalLoop(MLF_SHOWONIDLE);
|
|
|
|
pOpExec2DRSPTestDlg->DestroyWindow();
|
|
|
|
delete pOpExec2DRSPTestDlg;
|
|
}
|
|
catch (...)
|
|
{
|
|
NULL;
|
|
}
|
|
}
|
|
delete pRsp2DTd;
|
|
}
|
|
else
|
|
{
|
|
DeleteFile(szLocFilePath+ _T("\\")+szLocFileName);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
CString strTips;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strTips.Format(_T("发送文件 %s 失败!"), szLocFileName);
|
|
AfxMessageBox(strTips);
|
|
}
|
|
else
|
|
{
|
|
strTips.Format(_T("Send file %s failed!"), szLocFileName);
|
|
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
delete pRsp2DTd;
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CExecManager::ExecCERSPTest(COpExec2DRSPTestSetDlg* pOpExec2DRSPTestSetDlg, CLinkList<CMedium*>& m_medLinkList)
|
|
{
|
|
long lRet = VAL_ZERO;
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFileName = _T("");
|
|
CString szHostFilePath = _T("");
|
|
|
|
CRspCETd* pRspCETd = new CRspCETd((DWORD)VAL_ZERO, m_pConnection);
|
|
|
|
pRspCETd->SaveCERSPSetInfo(pOpExec2DRSPTestSetDlg, m_medLinkList);
|
|
pRspCETd->SaveHeadInfoToFile(szLocFilePath, szLocFileName);
|
|
|
|
szHostFilePath.Empty();
|
|
|
|
szHostFilePath.Format(_T("/SD/projects/%s/%s/"), pRspCETd->m_szPrCN, pRspCETd->m_szTzCN);
|
|
if (TRUE == pRspCETd->m_pDevice->SendFile(szHostFilePath, szLocFilePath, szLocFileName))
|
|
{
|
|
DeleteFile(szLocFilePath+ _T("\\")+szLocFileName);
|
|
|
|
if (TRUE == InitialMeasure(pRspCETd->m_pDevice, pRspCETd->m_szPrCN, pRspCETd->m_szTzCN, pRspCETd->m_szTdCN, pRspCETd->m_iEAmount))
|
|
{
|
|
try
|
|
{
|
|
COpExecCERSPTestDlg* pOpExecCERSPTestDlg = new COpExecCERSPTestDlg(pRspCETd, (INT_PTR*)&lRet);
|
|
|
|
pOpExecCERSPTestDlg->Create(IDD_OP_TD_CE_C, AfxGetMainWnd());
|
|
pOpExecCERSPTestDlg->ShowWindow(SW_SHOW);
|
|
pOpExecCERSPTestDlg->RunModalLoop(MLF_SHOWONIDLE);
|
|
|
|
pOpExecCERSPTestDlg->DestroyWindow();
|
|
|
|
delete pOpExecCERSPTestDlg;
|
|
}
|
|
catch (...)
|
|
{
|
|
NULL;
|
|
}
|
|
}
|
|
delete pRspCETd;
|
|
}
|
|
else
|
|
{
|
|
DeleteFile(szLocFilePath+ _T("\\")+szLocFileName);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
CString strTips;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strTips.Format(_T("发送文件 %s 失败!"), szLocFileName);
|
|
AfxMessageBox(strTips);
|
|
}
|
|
else
|
|
{
|
|
strTips.Format(_T("Send file %s failed!"), szLocFileName);
|
|
MessageBoxEx(NULL, strTips, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
delete pRspCETd;
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
/*
|
|
void CExecManager::InitialMedLinkList()
|
|
{
|
|
CMedium* pMed = NULL;
|
|
|
|
DWORD dwHandle = (DWORD)VAL_ZERO;
|
|
int iAR = (int)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecAR = NULL;
|
|
|
|
m_medLinkList.DeleteAll();
|
|
pRecAR.CreateInstance(_uuidof(Recordset));
|
|
|
|
pRecAR->Open(_T("select MEname,AR from medium order by AR"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while ((short)VAL_ZERO == pRecAR->adoEOF)
|
|
{
|
|
iAR = pRecAR->GetCollect(_T("AR")).iVal;
|
|
switch (iAR)
|
|
{
|
|
case 1:
|
|
pMed = new CMediumA(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 2:
|
|
pMed = new CMediumB(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 3:
|
|
pMed = new CMediumC(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 4:
|
|
pMed = new CMediumD(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 5:
|
|
pMed = new CMediumE(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 6:
|
|
break;
|
|
case 7:
|
|
break;
|
|
case 8:
|
|
break;
|
|
case 9:
|
|
break;
|
|
case 10:
|
|
break;
|
|
case 11:
|
|
pMed = new CMediumK(iAR);
|
|
if (NULL != pMed)
|
|
{
|
|
dwHandle = m_handleProcessor.GenerateHandle(iAR, PZ_STYLE_MED_DEF);
|
|
m_medLinkList.Add(dwHandle, pMed);
|
|
}
|
|
break;
|
|
case 12:
|
|
break;
|
|
case 13:
|
|
break;
|
|
case 14:
|
|
break;
|
|
case 15:
|
|
break;
|
|
case 16:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
pRecAR->MoveNext();
|
|
}
|
|
pRecAR->Close();
|
|
}
|
|
*/
|
|
|
|
/*
|
|
BOOL CExecManager::InitialMeasure(CDevice* pDev, CString szPrCN, CString szTzCN, CString szTdCN, int iEAmount)
|
|
{
|
|
char aResBuff[2048] = {0};
|
|
int iResSize = (int)VAL_ZERO;
|
|
|
|
int iTime = (int)VAL_ZERO;
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szResCon = _T("");
|
|
CString szPrompt = _T("");
|
|
|
|
int iPollingTime = 0;
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
pDev->m_sComPort.SendDataDirectly("\r\n", 2);
|
|
// Sleep(30);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < MAX_POLLING_TIME))
|
|
{
|
|
while (pDev->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
if (szResBuff.Find('>') == -1)
|
|
{
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
pDev->m_sComPort.SendDataDirectly("\r\n", 2);
|
|
|
|
// TransDelay(g_iTransMode, 20, 200);
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
pDev->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);
|
|
AfxMessageBox(szPrompt, NULL, MB_ICONSTOP);
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
// this->m_szFileName.TrimRight(_T(".xml"));
|
|
TransDelay(g_iTransMode, 10, 50, NULL);
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format("meas_add(\"%s\",\"%s\",\"%s\")\r\n", szPrCN, szTzCN, szTdCN);
|
|
// AfxMessageBox(szOrder);
|
|
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 100, 200, NULL);
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < 500))
|
|
{
|
|
// Sleep(100);
|
|
while (pDev->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szResCon, _T("["), _T("]"));
|
|
|
|
if (_T("1") != szResCon)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(_T("Add measure failed!"));
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("meas_delete(\"%s\",\"%s\",\"%s\")\r\n"), szPrCN, szTzCN, szTdCN);
|
|
// MessageBox(szOrder);
|
|
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 100, 200, NULL);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = (int)VAL_ZERO;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < 500))
|
|
{
|
|
// Sleep(100);
|
|
while (pDev->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);
|
|
AfxMessageBox(szPrompt, NULL, MB_ICONSTOP);
|
|
}
|
|
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
pDev->m_sComPort.SendDataDirectly("\r\n", 2);
|
|
// TransDelay(g_iTransMode, 20, 200);
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
pDev->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);
|
|
AfxMessageBox(szPrompt, NULL, MB_ICONSTOP);
|
|
return FALSE;
|
|
}
|
|
|
|
TransDelay(g_iTransMode, 10, 50, NULL);
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
// szOrder.Format("load_measuring(\"%s\",\"%s\",\"%s\")\r\n", m_pRsp2DTd->m_szPrCN, m_pRsp2DTd->m_szTzCN, m_pRsp2DTd->m_szTdCN);
|
|
szOrder.Format("load_measuring(\"%s\",\"%s\",\"%s\")\r\n", szPrCN, szTzCN, szTdCN);
|
|
// AfxMessageBox(szOrder);
|
|
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 20, 50, NULL);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < iEAmount*10)) //依据电极数量设定轮询时长
|
|
{
|
|
Sleep(1);
|
|
while (pDev->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(szResBuff);
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szResCon, _T("["), _T("]"));
|
|
|
|
if (_T("1") != szResCon)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(_T("Load measure failed!"));
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("meas_delete(\"%s\",\"%s\",\"%s\")\r\n"), szPrCN, szTzCN, szTdCN);
|
|
// MessageBox(szOrder);
|
|
|
|
pDev->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 100, 200, NULL);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = (int)VAL_ZERO;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < 500))
|
|
{
|
|
// Sleep(100);
|
|
while (pDev->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);
|
|
AfxMessageBox(szPrompt, NULL, MB_ICONSTOP);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
*/
|
|
|
|
|
|
BOOL CExecManager::InitialMeasure(CDevice* pDev, CString szPrCN, CString szTzCN, CString szTdCN, int iEAmount)
|
|
{
|
|
char aResBuff[2048] = {0};
|
|
int iResSize = (int)VAL_ZERO;
|
|
|
|
int iTime = (int)VAL_ZERO;
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szResCon = _T("");
|
|
CString szPrompt = _T("");
|
|
|
|
int iPollingTime = 0;
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format("meas_add(\"%s\",\"%s\",\"%s\")\r\n", szPrCN, szTzCN, szTdCN);
|
|
szResBuff.Empty();
|
|
CString strShowInfo = _T("");
|
|
if (!pDev->ExecuteOrder(szOrder, ">", &szResBuff))
|
|
{
|
|
strShowInfo.Empty();
|
|
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("转发命令 %s 失败!"), szOrder.GetBuffer(0));
|
|
AfxMessageBox(strShowInfo);
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Transfer cmd %s failed!"), szOrder.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szResCon, _T("["), _T("]"));
|
|
|
|
if (_T("1") != szResCon)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("添加测量失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Add measure failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("meas_delete(\"%s\",\"%s\",\"%s\")\r\n"), szPrCN, szTzCN, szTdCN);
|
|
szResBuff.Empty();
|
|
if (!pDev->ExecuteOrder(szOrder, ">", &szResBuff))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("转发命令 %s 失败!"), szOrder.GetBuffer(0));
|
|
AfxMessageBox(strShowInfo);
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Transfer cmd %s failed!"), szOrder.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
// szOrder.Format("load_measuring(\"%s\",\"%s\",\"%s\")\r\n", m_pRsp2DTd->m_szPrCN, m_pRsp2DTd->m_szTzCN, m_pRsp2DTd->m_szTdCN);
|
|
szOrder.Format("load_measuring(\"%s\",\"%s\",\"%s\")\r\n", szPrCN, szTzCN, szTdCN);
|
|
szResBuff.Empty();
|
|
if (!pDev->ExecuteOrder(szOrder, ">", &szResBuff))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("转发命令 %s 失败!"), szOrder.GetBuffer(0));
|
|
AfxMessageBox(strShowInfo);
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Transfer cmd %s failed!"), szOrder.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
}
|
|
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
//AfxMessageBox(szResBuff);
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szResCon, _T("["), _T("]"));
|
|
|
|
if (_T("1") != szResCon)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("加载测量失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Load measure failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
|
|
pDev->m_sComPort.ClearCommReceiveBuff();
|
|
pDev->m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("meas_delete(\"%s\",\"%s\",\"%s\")\r\n"), szPrCN, szTzCN, szTdCN);
|
|
szResBuff.Empty();
|
|
if (!pDev->ExecuteOrder(szOrder, ">", &szResBuff))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("转发命令 %s 失败!"), szOrder.GetBuffer(0));
|
|
AfxMessageBox(strShowInfo);
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Transfer cmd %s failed!"), szOrder.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
} |