5011 lines
170 KiB
C++
5011 lines
170 KiB
C++
// Rsp2DTd.cpp: implementation of the CRsp2DTd class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "TdChannel.h"
|
|
#include "Rsp2DTd.h"
|
|
#include "Markup.h"
|
|
|
|
#include "optgddlg.h"
|
|
|
|
#include "SaveInRes.h"
|
|
|
|
#include "opexec2drsptestsetdlg.h"
|
|
#include "RSP2DTdRecord.h"
|
|
|
|
#include "excel.h"
|
|
#include "Disp2DRSPGrapDlg.h"
|
|
#include "disptdrecsplinesgrapdlg.h"
|
|
#include "OperTxtFile.h"
|
|
#include "OperMediumPt.h"
|
|
#include "GetProcessInfo.h"
|
|
#include "OperUrfFile.h"
|
|
#include <shlwapi.h>
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
using namespace excel9;
|
|
extern int g_iLanguage;
|
|
extern BOOL GetSubStringInHeadAndTail(const CString& szSource, CString& szSub, const CString& szHead, const CString& szTail);
|
|
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
|
|
extern CString GetGrCodeText(int iCode);
|
|
extern int g_iUILanguage;
|
|
extern int g_UIOffset;
|
|
extern CGeoMativeApp theApp;
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
extern HHOOK hHook;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
|
|
typedef struct ST_ELECTRODE_COORDINATES
|
|
{
|
|
UINT32 uiElecID;
|
|
float fX;
|
|
float fY;
|
|
float fZ;
|
|
ST_ELECTRODE_COORDINATES()
|
|
{
|
|
memset(this, 0, sizeof(ST_ELECTRODE_COORDINATES));
|
|
}
|
|
}STElectrodeCoordinates;
|
|
|
|
CRsp2DTd::CRsp2DTd(DWORD dwID, _ConnectionPtr& pConnection):CTestingData(dwID, pConnection)
|
|
{
|
|
m_iStartPole = 1;
|
|
m_iEndPole = 1;
|
|
|
|
}
|
|
|
|
CRsp2DTd::~CRsp2DTd()
|
|
{
|
|
ClearTdChaList();
|
|
}
|
|
/*
|
|
bool CRsp2DTd::ShowDetailInfo(CListCtrl &tdDetailList)
|
|
{
|
|
_RecordsetPtr pRecTd = NULL;
|
|
_RecordsetPtr pRecTdHead = NULL;
|
|
_RecordsetPtr pRecDev = NULL;
|
|
_RecordsetPtr pRecPara = NULL;
|
|
_RecordsetPtr pRecCm = NULL;
|
|
|
|
CString szSql;
|
|
CString szLabel;
|
|
|
|
int iRowIndex = (int)VAL_ZERO;
|
|
|
|
while (tdDetailList.GetItemCount() != iRowIndex)
|
|
{
|
|
tdDetailList.SetItemText(iRowIndex, 1, _T(""));
|
|
iRowIndex++;
|
|
}
|
|
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
pRecTdHead.CreateInstance(_uuidof(Recordset));
|
|
pRecDev.CreateInstance(_uuidof(Recordset));
|
|
pRecPara.CreateInstance(_uuidof(Recordset));
|
|
pRecCm.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,TDname,Tlocation,DESN,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,SAfrequency,Clayout,Espace,Edistance,weather,WDIR,"
|
|
"temperature,height,humidity,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,Format(Tdate,'YYYY-MM-DD') as Tdate,Format(Ttime,'HH:MM:SS') as Ttime,"
|
|
"Rdirection,CRtime,IIf(IsNull(PM),'',PM) as PM,IIf(IsNull(OP),'',OP) as OP,IIf(IsNull(QA),'',QA) as QA from td where ID = %u"), m_dwID);
|
|
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(0, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TDname")));
|
|
// tdDetailList.SetItemText(1, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tlocation")));
|
|
tdDetailList.SetItemText(1, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")));
|
|
// tdDetailList.SetItemText(2, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SCCN")));
|
|
tdDetailList.SetItemText(2, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Sname")));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Stype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Stype")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(3, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Ttype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttype")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(4, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Tmode' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Tmode")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tmode")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
// tdDetailList.SetItemText(6, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
tdDetailList.SetItemText(5, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Eamount")));
|
|
tdDetailList.SetItemText(6, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TPamount")));
|
|
tdDetailList.SetItemText(7, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("CHamount")));
|
|
|
|
tdDetailList.SetItemText(8, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("N")));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'TRwave' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("TRwave")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TRwave")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(9, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
if ((0 == pRecTd->GetCollect(_T("Ttype")).iVal) || (1 == pRecTd->GetCollect(_T("Ttype")).iVal))
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequency' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Trfrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(10, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
}
|
|
else if (2 == pRecTd->GetCollect(_T("Ttype")).iVal)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequencyself' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Trfrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(10, 1, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Ifrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ifrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(11, 1, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
if (0 == pRecTd->GetCollect(_T("Ifrequency")).iVal)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency50' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SAfrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(12, 1, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
}
|
|
else if (1 == pRecTd->GetCollect(_T("Ifrequency")).iVal)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency60' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SAfrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(12, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Clayout' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Clayout")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Clayout")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(13, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
// tdDetailList.SetItemText(16, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Espace")));
|
|
tdDetailList.SetItemText(14, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Edistance")));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'weather' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("weather")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("weather")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(15, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'WDIR' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("WDIR")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("WDIR")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
tdDetailList.SetItemText(16, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
CString szDefault = _T("");
|
|
|
|
szDefault = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("temperature"));
|
|
|
|
if (szDefault == "-9999")//若为该值则不显示东西
|
|
{
|
|
szDefault = "";
|
|
}
|
|
|
|
tdDetailList.SetItemText(17, 1, szDefault);
|
|
|
|
tdDetailList.SetItemText(18, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("height")));
|
|
|
|
szDefault = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("humidity"));
|
|
|
|
if (szDefault == "-9999")//若为该值则不显示东西
|
|
{
|
|
szDefault = "";
|
|
}
|
|
|
|
tdDetailList.SetItemText(19, 1, szDefault);
|
|
|
|
tdDetailList.SetItemText(20, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Cdate")));
|
|
tdDetailList.SetItemText(21, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ctime")));
|
|
|
|
tdDetailList.SetItemText(22, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tdate")));
|
|
tdDetailList.SetItemText(23, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttime")));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Rdirection' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Rdirection")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Rdirection")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
// tdDetailList.SetItemText(27, 1, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
// tdDetailList.SetItemText(28, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("CRtime")));
|
|
|
|
tdDetailList.SetItemText(24, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("PM")));
|
|
tdDetailList.SetItemText(25, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("OP")));
|
|
tdDetailList.SetItemText(26, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("QA")));
|
|
}
|
|
|
|
pRecTd->Close();
|
|
return true;
|
|
}
|
|
*/
|
|
bool CRsp2DTd::ShowConList(CListCtrl &tdConList)
|
|
{
|
|
_RecordsetPtr pRecConList = NULL;
|
|
CString szSql;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
pRecConList.CreateInstance(_uuidof(Recordset));
|
|
if (VAL_ZERO != tdConList.GetItemCount())
|
|
{
|
|
tdConList.DeleteAllItems();
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select top %d TSN,C1,C2,P1,P2,N,K,I,V,R0,SP,bUse from td2dcon where TCHID in (select ID from tdchannel where TDID = %u order by TCHID) order by TSN"), ONE_PAGE_DATA_NUMBER, m_dwID);
|
|
try
|
|
{
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
}
|
|
|
|
try
|
|
{
|
|
CString strDBVal = _T("");
|
|
float fV = 0, fI = 0, fR = 0;
|
|
while ((short)VAL_ZERO == pRecConList->adoEOF)
|
|
{
|
|
if (pRecConList->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
|
|
{
|
|
tdConList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C1")));
|
|
tdConList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C2")));
|
|
tdConList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P1")));
|
|
tdConList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P2")));
|
|
tdConList.SetItemText(iIndex, 4, (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("N")));
|
|
|
|
strDBVal.Empty();
|
|
strDBVal.Format(_T("%f"),(float)pRecConList->GetCollect(_T("K")).fltVal);
|
|
tdConList.SetItemText(iIndex, 5, strDBVal);
|
|
|
|
strDBVal.Empty();
|
|
strDBVal.Format(_T("%f"),(float)pRecConList->GetCollect(_T("I")).fltVal);
|
|
tdConList.SetItemText(iIndex, 6, strDBVal);
|
|
fI = (float)pRecConList->GetCollect(_T("I")).fltVal;
|
|
|
|
|
|
strDBVal.Empty();
|
|
strDBVal.Format(_T("%f"),(float)pRecConList->GetCollect(_T("V")).fltVal);
|
|
tdConList.SetItemText(iIndex, 7, strDBVal);
|
|
|
|
fV = (float)pRecConList->GetCollect(_T("V")).fltVal;
|
|
|
|
//添加R
|
|
fR = (0 == fI) ? 0 : fV/fI;
|
|
strDBVal.Empty();
|
|
strDBVal.Format(_T("%f"),fR);
|
|
tdConList.SetItemText(iIndex, 8, strDBVal);
|
|
|
|
strDBVal.Empty();
|
|
strDBVal.Format(_T("%f"),(float)pRecConList->GetCollect(_T("R0")).fltVal);
|
|
tdConList.SetItemText(iIndex, 9, strDBVal);
|
|
|
|
strDBVal.Empty();
|
|
strDBVal.Format(_T("%f"),(float)pRecConList->GetCollect(_T("SP")).fltVal);
|
|
tdConList.SetItemText(iIndex, 10, strDBVal);
|
|
|
|
tdConList.SetItemData(iIndex, (int)pRecConList->GetCollect(_T("TSN")).lVal);
|
|
iIndex++;
|
|
}
|
|
pRecConList->MoveNext();
|
|
}
|
|
}
|
|
catch(_com_error e)
|
|
{
|
|
AfxMessageBox(e.Description());
|
|
}
|
|
pRecConList->Close();
|
|
return true;
|
|
}
|
|
|
|
bool CRsp2DTd::ShowGrList(CListCtrl &tdGrList)
|
|
{
|
|
_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.Empty();
|
|
szSql.Format(_T("select Ecode,Format(Mdate,'YYYY-MM-DD') as Mdate,Format(Mtime,'HH:MM:SS') as Mtime,OMvalue,OM1value,")
|
|
_T(" StatusCode, StatusCode1 from gr where TDID = %u order by Val(Ecode)"), m_dwID);
|
|
pRecGrList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
int iOMVal = -1, iOMVal1 = -1;
|
|
CString strOMVal, strOMVal1;
|
|
CString strMdate, strMtime;
|
|
CString strStatus, strStatus1;
|
|
while ((short)VAL_ZERO == pRecGrList->adoEOF)
|
|
{
|
|
tdGrList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Ecode")));
|
|
strOMVal.Empty();
|
|
strOMVal1.Empty();
|
|
strMdate.Empty();
|
|
strMtime.Empty();
|
|
strStatus.Empty();
|
|
strStatus1.Empty();
|
|
iOMVal = (int)pRecGrList->GetCollect(_T("OMvalue")).lVal;
|
|
iOMVal1 = (int)pRecGrList->GetCollect(_T("OM1value")).lVal;
|
|
if (-1 != iOMVal)
|
|
{
|
|
strOMVal.Format(_T("%d"),iOMVal);
|
|
strMdate = (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Mdate"));
|
|
strMtime = (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Mtime"));
|
|
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, 1, strOMVal);
|
|
tdGrList.SetItemText(iIndex, 2, strStatus);
|
|
tdGrList.SetItemText(iIndex, 3, strOMVal1);
|
|
tdGrList.SetItemText(iIndex, 4, strStatus1);
|
|
tdGrList.SetItemText(iIndex, 5, strMdate);
|
|
tdGrList.SetItemText(iIndex, 6, strMtime);
|
|
|
|
iIndex++;
|
|
pRecGrList->MoveNext();
|
|
}
|
|
|
|
pRecGrList->Close();
|
|
return true;
|
|
}
|
|
|
|
BOOL CRsp2DTd::Save2DRSPSetInfo(COpExec2DRSPTestSetDlg* const pOpExec2DRSPTestSetDlg, CLinkList<CMedium*>& m_medLinkList)
|
|
{
|
|
_RecordsetPtr pRecTdChaList = NULL;
|
|
CString szSql = _T("");
|
|
CString szLbText = _T("");
|
|
|
|
CString szPro = _T("");
|
|
CString szPrCN = _T("");
|
|
CString szTzName = _T("");
|
|
CString szTzCN = _T("");
|
|
|
|
DWORD dwMedHandle = (DWORD)VAL_ZERO;
|
|
|
|
int iChNum = (int)VAL_ZERO;
|
|
int iSptIndex = (int)VAL_ZERO;
|
|
POSITION posSpt;
|
|
CTime tCT;
|
|
|
|
CString szEdCon = _T("");
|
|
|
|
DWORD dwSptHandle = (DWORD)VAL_ZERO;
|
|
DWORD dwSptID = (DWORD)VAL_ZERO;
|
|
|
|
tCT = CTime::GetCurrentTime();
|
|
|
|
this->m_szTdName = pOpExec2DRSPTestSetDlg->m_szName;
|
|
this->m_szTdCN = _T("ERIR")+tCT.FormatGmt(_T("%Y%m%d"))+tCT.FormatGmt(_T("%H%M%S"));
|
|
this->m_szTLocation = pOpExec2DRSPTestSetDlg->m_szLocation;
|
|
|
|
// this->m_bIsGr = pOpExec2DRSPTestSetDlg->m_ckIsGr.GetCheck();
|
|
|
|
this->m_dwID = (DWORD)VAL_ZERO;
|
|
this->m_pDevice = (CDevice*)pOpExec2DRSPTestSetDlg->m_cbDESN.GetItemData(pOpExec2DRSPTestSetDlg->m_cbDESN.GetCurSel());
|
|
|
|
posSpt = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetFirstSelectedItemPosition();
|
|
iSptIndex = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetNextSelectedItem(posSpt);
|
|
|
|
dwSptHandle = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemData(iSptIndex);
|
|
dwSptID = this->m_handleProcessor.GetIDFromHandle(dwSptHandle);
|
|
|
|
this->m_dwSCID = dwSptID;
|
|
this->m_szSCCN = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 0);
|
|
this->m_szSName = pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 1);
|
|
this->m_iSType = (int)VAL_ONE;
|
|
|
|
this->m_iTType = (int)VAL_ZERO;
|
|
|
|
this->m_iEAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 2));
|
|
this->m_iCHAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 3));
|
|
this->m_iTPAmount = atoi(pOpExec2DRSPTestSetDlg->m_op2DSptSelDlg.m_sptList.GetItemText(iSptIndex, 4));
|
|
|
|
szPro.Empty();
|
|
pOpExec2DRSPTestSetDlg->m_cbPrName.GetLBText(pOpExec2DRSPTestSetDlg->m_cbPrName.GetCurSel(), szPro);
|
|
|
|
szPrCN.Empty();
|
|
GetSubStringInHeadAndTail(szPro, szPrCN, _T("("), _T(")"));
|
|
this->m_szPrCN = szPrCN;
|
|
|
|
szTzName.Empty();
|
|
pOpExec2DRSPTestSetDlg->m_cbTzName.GetLBText(pOpExec2DRSPTestSetDlg->m_cbTzName.GetCurSel(), szTzName);
|
|
this->m_szTzName = szTzName;
|
|
|
|
szTzCN.Empty();
|
|
GetSubStringInHeadAndTail(szTzName, szTzCN, _T("("), _T(")"));
|
|
this->m_szTzCN = szTzCN;
|
|
|
|
this->m_dwTzID = pOpExec2DRSPTestSetDlg->m_cbTzName.GetItemData(pOpExec2DRSPTestSetDlg->m_cbTzName.GetCurSel());
|
|
|
|
this->m_iCLayout = pOpExec2DRSPTestSetDlg->m_cbCLayout.GetCurSel();
|
|
|
|
szEdCon.Empty();
|
|
pOpExec2DRSPTestSetDlg->m_edESpace.GetWindowText(szEdCon);
|
|
this->m_fESpace = (float)atof(szEdCon.GetBuffer(0));
|
|
|
|
this->m_szEDistance = pOpExec2DRSPTestSetDlg->m_szEDistance;
|
|
|
|
this->m_iCRtime = (int)VAL_ZERO;
|
|
this->m_iRDirection = (int)VAL_ZERO;
|
|
|
|
this->m_iIFrequency = pOpExec2DRSPTestSetDlg->m_iIFrequency;
|
|
|
|
this->m_iSAFrequency = pOpExec2DRSPTestSetDlg->m_iSAFrequency;
|
|
|
|
this->m_iTRFrequency = pOpExec2DRSPTestSetDlg->m_iTRFrenquency;
|
|
this->m_fTRPeriod = pOpExec2DRSPTestSetDlg->m_fTRPeriod;
|
|
|
|
this->m_iTMode = pOpExec2DRSPTestSetDlg->m_iTestMode;
|
|
|
|
//在这里默认为0,因为暂时只实现了这一种的方式0+0-的方式
|
|
this->m_iTRWave = m_iTRWave;
|
|
//pOpExec2DRSPTestSetDlg->m_cbTRWave.GetCurSel();
|
|
|
|
szEdCon.Empty();
|
|
pOpExec2DRSPTestSetDlg->m_edHeight.GetWindowText(szEdCon);
|
|
this->m_fHeight = (float)atof(szEdCon.GetBuffer(0));
|
|
|
|
szEdCon.Empty();
|
|
pOpExec2DRSPTestSetDlg->m_edHumidity.GetWindowText(szEdCon);
|
|
this->m_fHumidity = (float)atof(szEdCon.GetBuffer(0));
|
|
|
|
szEdCon.Empty();
|
|
pOpExec2DRSPTestSetDlg->m_edTemperature.GetWindowText(szEdCon);
|
|
this->m_fTemperature = (float)atof(szEdCon.GetBuffer(0));
|
|
|
|
this->m_iWDIR = pOpExec2DRSPTestSetDlg->m_cbWDIR.GetCurSel();
|
|
this->m_iWeather = pOpExec2DRSPTestSetDlg->m_cbWeather.GetCurSel();
|
|
|
|
this->m_iN = (int)VAL_ONE;
|
|
|
|
|
|
this->m_szCDate = tCT.FormatGmt(_T("%Y-%m-%d"));
|
|
this->m_szCTime = tCT.FormatGmt(_T("%H:%M:%S"));
|
|
|
|
this->m_szTDate = tCT.FormatGmt(_T("%Y-%m-%d"));
|
|
this->m_szTTime = tCT.FormatGmt(_T("%H:%M:%S"));
|
|
|
|
this->m_iRCamount = (int)VAL_ZERO;
|
|
this->m_iRDirection = (int)VAL_ZERO;
|
|
this->m_iCRtime = (int)VAL_ZERO;
|
|
|
|
this->m_szOP = pOpExec2DRSPTestSetDlg->m_szOP;
|
|
this->m_szPM = pOpExec2DRSPTestSetDlg->m_szPM;
|
|
this->m_szQA = pOpExec2DRSPTestSetDlg->m_szQA;
|
|
|
|
this->m_tdChaList.RemoveAll();
|
|
pRecTdChaList.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select CHnumber,AR from channel where SCID = %u order by CHnumber"), this->m_dwSCID);
|
|
pRecTdChaList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecTdChaList->adoEOF)
|
|
{
|
|
iChNum = pRecTdChaList->GetCollect(_T("CHnumber")).iVal;
|
|
CTdChannel* pTdChannel = new CTdChannel(this->m_dwSCID, iChNum, m_pConnection);
|
|
dwMedHandle = m_handleProcessor.GenerateHandle(pRecTdChaList->GetCollect(_T("AR")).iVal, PZ_STYLE_MED_DEF);
|
|
pTdChannel->m_pMedium = m_medLinkList.Find(dwMedHandle);
|
|
pTdChannel->m_iEAmount = this->m_iEAmount;
|
|
|
|
this->m_tdChaList.AddTail((void*)pTdChannel);
|
|
pRecTdChaList->MoveNext();
|
|
}
|
|
|
|
pRecTdChaList->Close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
BOOL CRsp2DTd::SaveHeadInfoToFile(CString& szFilePath, CString& szFileName)
|
|
{
|
|
CMarkup xml;
|
|
CTdChannel* pTdChannel = NULL;
|
|
|
|
POSITION pos;
|
|
|
|
CString szCon = _T("");
|
|
CString szFile = _T("");
|
|
|
|
xml.SetDoc("<?xml version=\"1.0\" encoding=\"ansi\"?>\n");
|
|
xml.AddElem("measure");
|
|
|
|
xml.AddChildElem(_T("measure_name"), this->m_szTdName);
|
|
xml.AddChildElem(_T("measure_location"), this->m_szTLocation);
|
|
|
|
xml.AddChildElem(_T("measure_script_id"), this->m_szSCCN);
|
|
xml.AddChildElem(_T("measure_script_name"), this->m_szSName);
|
|
xml.AddChildElem(_T("measure_script_type"), 1);
|
|
|
|
xml.AddChildElem(_T("measure_type"), 0);
|
|
xml.AddChildElem(_T("measure_mode"), this->m_iTMode);
|
|
|
|
xml.AddChildElem(_T("medium_set"));
|
|
xml.IntoElem();
|
|
|
|
pos = this->m_tdChaList.GetHeadPosition();
|
|
while (pos != NULL)
|
|
{
|
|
pTdChannel = (CTdChannel*)m_tdChaList.GetNext(pos);
|
|
if(pTdChannel != NULL)
|
|
{
|
|
szCon.Empty();
|
|
szCon.Format(_T("%d:%d"), pTdChannel->m_iChNum, pTdChannel->m_pMedium->m_iAR);
|
|
xml.AddChildElem(_T("medium"), szCon);
|
|
}
|
|
}
|
|
xml.OutOfElem();
|
|
|
|
xml.AddChildElem(_T("pole_count"), this->m_iEAmount);
|
|
xml.AddChildElem(_T("pole_distance"), this->m_szEDistance);
|
|
|
|
szCon.Empty();
|
|
szCon.Format(_T("%.2f"), this->m_fESpace);
|
|
xml.AddChildElem(_T("pole_gap"), szCon);
|
|
|
|
xml.AddChildElem(_T("rect"), _T(""));
|
|
xml.AddChildElem(_T("rect_loc"), _T(""));
|
|
|
|
xml.AddChildElem(_T("wires_layout"), this->m_iCLayout);
|
|
xml.AddChildElem(_T("point_count"), this->m_iTPAmount);
|
|
|
|
xml.AddChildElem(_T("rolling_times"), 0);
|
|
xml.AddChildElem(_T("rolling_direction"), 0);
|
|
|
|
xml.AddChildElem(_T("rolling_step"), _T(""));
|
|
|
|
xml.AddChildElem(_T("channel_count"), this->m_iCHAmount);
|
|
|
|
xml.AddChildElem(_T("iterations"), 1);
|
|
|
|
xml.AddChildElem(_T("emit_source"), _T(""));
|
|
|
|
xml.AddChildElem(_T("wave_shape"), this->m_iTRWave);
|
|
xml.AddChildElem(_T("period"), this->m_iTRFrequency);
|
|
|
|
xml.AddChildElem(_T("industrial_frequency"), this->m_iIFrequency);
|
|
|
|
xml.AddChildElem(_T("sample_rate"), this->m_iSAFrequency);
|
|
|
|
xml.AddChildElem(_T("sample_interval"), _T(""));
|
|
xml.AddChildElem(_T("v_gain"), _T(""));
|
|
xml.AddChildElem(_T("i_gain"), _T(""));
|
|
|
|
szCon.Empty();
|
|
szCon.Format(_T("%.2f"), this->m_fTemperature);
|
|
xml.AddChildElem(_T("temperature"), szCon);
|
|
|
|
szCon.Empty();
|
|
szCon.Format(_T("%.2f"), this->m_fHeight);
|
|
xml.AddChildElem(_T("height"), szCon);
|
|
|
|
szCon.Empty();
|
|
szCon.Format(_T("%.2f"), this->m_fHumidity);
|
|
xml.AddChildElem(_T("humidity"), szCon);
|
|
|
|
xml.AddChildElem(_T("weather"), this->m_iWeather);
|
|
|
|
xml.AddChildElem(_T("wind_direction"), this->m_iWDIR);
|
|
|
|
xml.AddChildElem(_T("create_date"), this->m_szCDate);
|
|
xml.AddChildElem(_T("create_time"), this->m_szCTime);
|
|
|
|
xml.AddChildElem(_T("test_date"), this->m_szTDate);
|
|
xml.AddChildElem(_T("test_time"), this->m_szTTime);
|
|
|
|
xml.AddChildElem(_T("PM"), this->m_szPM);
|
|
xml.AddChildElem(_T("OP"), this->m_szOP);
|
|
xml.AddChildElem(_T("QA"), this->m_szQA);
|
|
|
|
xml.AddChildElem(_T("apparent_chargeability"));
|
|
|
|
//m0
|
|
xml.IntoElem();
|
|
xml.AddChildElem(_T("m0"));
|
|
xml.AddChildElem(_T("m1"));
|
|
xml.AddChildElem(_T("m2"));
|
|
xml.AddChildElem(_T("m3"));
|
|
xml.AddChildElem(_T("m4"));
|
|
xml.AddChildElem(_T("m5"));
|
|
xml.AddChildElem(_T("m6"));
|
|
xml.AddChildElem(_T("m7"));
|
|
xml.AddChildElem(_T("m8"));
|
|
xml.AddChildElem(_T("m9"));
|
|
xml.OutOfElem();
|
|
//m9
|
|
|
|
szFilePath.Empty();
|
|
szFilePath.GetBufferSetLength(2048);
|
|
::GetCurrentDirectory(2048, szFilePath.GetBuffer(szFilePath.GetLength()));
|
|
szFilePath.ReleaseBuffer();
|
|
szFilePath = szFilePath + "\\CACHE\\projects\\";
|
|
szFilePath += this->m_szPrCN + "\\" + this->m_szTzCN + "\\";
|
|
|
|
szFileName.Empty();
|
|
szFileName = this->m_szTdCN + _T(".xml");
|
|
|
|
szFile.Empty();
|
|
szFile = szFilePath + szFileName;
|
|
|
|
DeleteFile(szFile);
|
|
|
|
xml.Save(szFile);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveTdHeadToExcelFile(_Worksheet* const pComSheet)
|
|
{
|
|
Range comRange;
|
|
excel9::Font comFont;
|
|
Range comCols;
|
|
|
|
_RecordsetPtr pRecTd = NULL;
|
|
_RecordsetPtr pRecTdHead = NULL;
|
|
_RecordsetPtr pRecDev = NULL;
|
|
_RecordsetPtr pRecPara = NULL;
|
|
_RecordsetPtr pRecCm = NULL;
|
|
|
|
CString szSql;
|
|
CString szLabel;
|
|
int iAR = 0;
|
|
int iRowIndex = (int)0;
|
|
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
pRecTdHead.CreateInstance(_uuidof(Recordset));
|
|
pRecDev.CreateInstance(_uuidof(Recordset));
|
|
pRecPara.CreateInstance(_uuidof(Recordset));
|
|
pRecCm.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,TDname,Tlocation,DESN,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,SAfrequency,Clayout,Espace,Edistance,weather,WDIR,"
|
|
"temperature,height,humidity,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,Format(Tdate,'YYYY-MM-DD') as Tdate,Format(Ttime,'HH:MM:SS') as Ttime,"
|
|
"Rdirection,CRtime,IIf(IsNull(PM),'',PM) as PM,IIf(IsNull(OP),'',OP) as OP,IIf(IsNull(QA),'',QA) as QA from td where ID = %u"), m_dwID);
|
|
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
CString strRowTitle;
|
|
if ((long)0 != pRecTd->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A1")), COleVariant(_T("A1")));
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
comRange.SetValue2(COleVariant(_T("测试任务名称")));
|
|
else
|
|
comRange.SetValue2(COleVariant(_T("Test data name")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("A2")),COleVariant(_T("A2")));
|
|
// comRange.SetValue2(COleVariant(_T("Zone location")));
|
|
|
|
// comFont = comRange.GetFont();
|
|
// comFont.SetBold(COleVariant((short)TRUE));
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_DESN + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A2")), COleVariant(_T("A2")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("A4")),COleVariant(_T("A4")));
|
|
// comRange.SetValue2(COleVariant(_T("Script ID")));
|
|
|
|
// comFont = comRange.GetFont();
|
|
// comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_SNAME + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A3")), COleVariant(_T("A3")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_STYPE + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A4")), COleVariant(_T("A4")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TTYPE + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A5")), COleVariant(_T("A5")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_ARRAY_TYPE + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A6")), COleVariant(_T("A6")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("A8")),COleVariant(_T("A8")));
|
|
// comRange.SetValue2(COleVariant(_T("Test mode")));
|
|
//
|
|
// comFont = comRange.GetFont();
|
|
// comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_EAMOUNT + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A7")), COleVariant(_T("A7")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TPAMOUNT + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A8")), COleVariant(_T("A8")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_CHAMOUNT + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A9")), COleVariant(_T("A9")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_N + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A10")), COleVariant(_T("A10")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TRWAVE + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A11")), COleVariant(_T("A11")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TRFREQUENCY + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A12")), COleVariant(_T("A12")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_IFREQUENCY + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A13")), COleVariant(_T("A13")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("A14")),COleVariant(_T("A14")));
|
|
// comRange.SetValue2(COleVariant(_T("Sample rate")));
|
|
//
|
|
// comFont = comRange.GetFont();
|
|
// comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_CLAYOUT + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A14")), COleVariant(_T("A14")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("A18")),COleVariant(_T("A18")));
|
|
// comRange.SetValue2(COleVariant(_T("Electrode step")));
|
|
//
|
|
// comFont = comRange.GetFont();
|
|
// comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_EDISTANCE + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A15")), COleVariant(_T("A15")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_WEATHER + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A16")), COleVariant(_T("A16")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_WDIR + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A17")), COleVariant(_T("A17")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TEMPERATURE + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A18")), COleVariant(_T("A18")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_HEIGHT + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A19")), COleVariant(_T("A19")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_HUMIDITY + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A20")), COleVariant(_T("A20")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_CDATE + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A21")), COleVariant(_T("A21")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_CTIME + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A22")), COleVariant(_T("A22")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TDATE + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A23")), COleVariant(_T("A23")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TTIME + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A24")), COleVariant(_T("A24")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("A29")),COleVariant(_T("A29")));
|
|
// comRange.SetValue2(COleVariant(_T("Rolling direction")));
|
|
//
|
|
// comFont = comRange.GetFont();
|
|
// comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("A30")),COleVariant(_T("A30")));
|
|
// comRange.SetValue2(COleVariant(_T("Rolling times")));
|
|
//
|
|
// comFont = comRange.GetFont();
|
|
// comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("A26")),COleVariant(_T("A26")));
|
|
// comRange.SetValue2(COleVariant(_T("Project manager")));
|
|
|
|
// comFont = comRange.GetFont();
|
|
// comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_OP + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A25")), COleVariant(_T("A25")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_QA + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A26")), COleVariant(_T("A26")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
CString strTmpSql = _T("");
|
|
strTmpSql.Format(_T("select AR from tdchannel where TDID = %d"), m_dwID);
|
|
pRecTdHead->Open(strTmpSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if (pRecTdHead->GetRecordCount() < 1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("获取装置失败,查询TdChannel失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get Medium AR failed. query TdChannel failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
else
|
|
{
|
|
iAR = pRecTdHead->GetCollect(_T("AR")).iVal;
|
|
if (AR_CROSS_HOLE_TYPE == iAR)
|
|
{
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_INITI_DEPETH + g_UIOffset);
|
|
comRange = pComSheet->GetRange(COleVariant(_T("A27")), COleVariant(_T("A27")));
|
|
comRange.SetValue2(COleVariant(strRowTitle));
|
|
}
|
|
}
|
|
pRecTdHead->Close();
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B1")), COleVariant(_T("B1")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TDname"))));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B2")),COleVariant(_T("B2")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tlocation"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B2")), COleVariant(_T("B2")));
|
|
comRange.SetValue2(COleVariant((pRecTd->GetCollect(_T("DESN")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN"))));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B4")),COleVariant(_T("B4")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SCCN"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B3")), COleVariant(_T("B3")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Sname"))));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Stype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Stype")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B4")), COleVariant(_T("B4")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Ttype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttype")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B5")), COleVariant(_T("B5")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Tmode' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Tmode")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tmode")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B8")),COleVariant(_T("B8")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
///////////////////////////////////加入装置类型////////////////////////////
|
|
szSql.Empty();
|
|
szSql.Format(_T("select MEname from medium where LANG = %d and AR in (select AR from tdchannel where TDID = %d)"),
|
|
g_iLanguage, m_dwID);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B6")), COleVariant(_T("B6")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("MEname"))));
|
|
}
|
|
pRecCm->Close();
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B7")), COleVariant(_T("B7")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Eamount"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B8")), COleVariant(_T("B8")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TPamount"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B9")), COleVariant(_T("B9")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("CHamount"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B10")), COleVariant(_T("B10")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("N"))));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'TRwave' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("TRwave")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TRwave")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B11")), COleVariant(_T("B11")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
if ((0 == pRecTd->GetCollect(_T("Ttype")).iVal) || (1 == pRecTd->GetCollect(_T("Ttype")).iVal))
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequency' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Trfrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B12")), COleVariant(_T("B12")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
}
|
|
else if (2 == pRecTd->GetCollect(_T("Ttype")).iVal)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequencyself' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Trfrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B12")), COleVariant(_T("B12")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Ifrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ifrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B13")), COleVariant(_T("B13")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
// if (0 == pRecTd->GetCollect(_T("Ifrequency")).iVal)
|
|
// {
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency50' and Lang = %d and Cvalue = %s"),
|
|
// g_iLanguage, pRecTd->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SAfrequency")));
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
// if ((long)0 != pRecCm->GetRecordCount())
|
|
// {
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B14")),COleVariant(_T("B14")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
// }
|
|
// pRecCm->Close();
|
|
// }
|
|
// else if (1 == pRecTd->GetCollect(_T("Ifrequency")).iVal)
|
|
// {
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'SAfrequency60' and Lang = %d and Cvalue = %s"),
|
|
// g_iLanguage, pRecTd->GetCollect(_T("SAfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SAfrequency")));
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
// if ((long)0 != pRecCm->GetRecordCount())
|
|
// {
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B14")),COleVariant(_T("B14")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
// }
|
|
// pRecCm->Close();
|
|
// }
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Clayout' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Clayout")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Clayout")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B14")), COleVariant(_T("B14")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B18")),COleVariant(_T("B18")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Espace"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B15")), COleVariant(_T("B15")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Edistance"))));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'weather' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("weather")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("weather")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B16")), COleVariant(_T("B16")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'WDIR' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("WDIR")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("WDIR")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B17")), COleVariant(_T("B17")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
CString strTmp = _T("");
|
|
float fTmp = (pRecTd->GetCollect(_T("temperature")).vt == VT_NULL) ? -9999 : (float)pRecTd->GetCollect(_T("temperature")).fltVal;
|
|
if (fTmp > -9000)
|
|
{
|
|
strTmp.Format(_T("%f"), fTmp);
|
|
}
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B18")), COleVariant(_T("B18")));
|
|
comRange.SetValue2(COleVariant(strTmp));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B19")), COleVariant(_T("B19")));
|
|
comRange.SetValue2(COleVariant((pRecTd->GetCollect(_T("height")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("height"))));
|
|
|
|
|
|
strTmp.Empty();
|
|
fTmp = (pRecTd->GetCollect(_T("humidity")).vt == VT_NULL) ? -9999 : (float)pRecTd->GetCollect(_T("humidity")).fltVal;
|
|
if (fTmp > -9000)
|
|
{
|
|
strTmp.Format(_T("%f"), fTmp);
|
|
}
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B20")), COleVariant(_T("B20")));
|
|
comRange.SetValue2(COleVariant(strTmp));
|
|
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B21")), COleVariant(_T("B21")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Cdate"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B22")), COleVariant(_T("B22")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ctime"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B23")), COleVariant(_T("B23")));
|
|
comRange.SetValue2(COleVariant((pRecTd->GetCollect(_T("Tdate")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tdate"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B24")), COleVariant(_T("B24")));
|
|
comRange.SetValue2(COleVariant((pRecTd->GetCollect(_T("Ttime")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttime"))));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Rdirection' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Rdirection")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Rdirection")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B29")),COleVariant(_T("B29")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B30")),COleVariant(_T("B30")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("CRtime"))));
|
|
|
|
// comRange = pComSheet->GetRange(COleVariant(_T("B26")),COleVariant(_T("B26")));
|
|
// comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("PM"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B25")), COleVariant(_T("B25")));
|
|
comRange.SetValue2(COleVariant((pRecTd->GetCollect(_T("OP")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("OP"))));
|
|
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B26")), COleVariant(_T("B26")));
|
|
comRange.SetValue2(COleVariant((pRecTd->GetCollect(_T("QA")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("QA"))));
|
|
if (AR_CROSS_HOLE_TYPE == iAR)
|
|
{
|
|
comRange = pComSheet->GetRange(COleVariant(_T("B27")), COleVariant(_T("B27")));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Espace"))));
|
|
}
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
}
|
|
|
|
pRecTd->Close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveTdConToExcelFile(_Worksheet* const pComSheet)
|
|
{
|
|
CString szSql = _T("");
|
|
if (EXP_2D_DATA_BY_DEPTH == theApp.Get2dDataExpStyle())
|
|
{
|
|
_RecordsetPtr pRecAR = NULL;
|
|
pRecAR.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Format(_T("select AR from tdchannel where TDID = %u"), m_dwID);
|
|
pRecAR->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if (pRecAR->GetRecordCount() < 1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("在excel保存中获取AR信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get AR information failed in save excel"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecAR->Close();
|
|
return FALSE;
|
|
}
|
|
int iAR = pRecAR->GetCollect(_T("AR")).iVal;
|
|
if (AR_CROSS_HOLE_TYPE != iAR && AR_BIPOLE_HOLE_SPT != iAR)
|
|
{
|
|
pRecAR->Close();
|
|
return SaveTdConToExcelFileBySort(pComSheet, 1);
|
|
}
|
|
}
|
|
|
|
Range comRange;
|
|
excel9::Font comFont;
|
|
Range comCols;
|
|
|
|
_RecordsetPtr pRecConList = NULL;
|
|
CString szRow = _T("");
|
|
|
|
int iIndex = (int)0;
|
|
|
|
iIndex = 1;
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("A%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("A(C1)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("B%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("B(C2)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("C%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("M(P1)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("D%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("N(P2)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("E%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("Stacking")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("F%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("K")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("G%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("I(mA)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("H%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("V(mV)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
//新增加R
|
|
szRow.Empty();
|
|
szRow.Format(_T("I%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("R(Ohm)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("J%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("R0")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("K%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("SP")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("L%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("R0_RD")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
|
|
pRecConList.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,bUse,R0_LC,M0_LC from td2dcon where TCHID in (select ID from tdchannel where TDID = %u order by TCHID) order by TSN"), m_dwID);
|
|
try
|
|
{
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
}
|
|
float fV = 0, fI = 0, fR = 0;
|
|
CString strText = _T("");
|
|
while ((short)0 == pRecConList->adoEOF)
|
|
{
|
|
if (pRecConList->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
|
|
{
|
|
iIndex++;
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("A%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C1"))));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("B%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C2"))));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("C%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P1"))));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("D%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P2"))));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("E%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("N"))));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("F%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), pRecConList->GetCollect(_T("K")).fltVal);
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("G%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
// fI = (float)pRecConList->GetCollect(_T("I")).fltVal;
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), pRecConList->GetCollect(_T("I")).fltVal);
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("H%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), pRecConList->GetCollect(_T("V")).fltVal);
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
//添加R
|
|
fV = (float)pRecConList->GetCollect(_T("V")).fltVal;
|
|
fI = (float)pRecConList->GetCollect(_T("I")).fltVal;
|
|
fR = (0 == fI) ? 0 : fV / fI;
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), fR);
|
|
szRow.Empty();
|
|
szRow.Format(_T("I%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
|
|
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("J%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), pRecConList->GetCollect(_T("R0")).fltVal);
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
//
|
|
szRow.Empty();
|
|
szRow.Format(_T("K%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), pRecConList->GetCollect(_T("SP")).fltVal);
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("L%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%f%%"), pRecConList->GetCollect(_T("R0_LC")).fltVal);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
}
|
|
pRecConList->MoveNext();
|
|
}
|
|
|
|
pRecConList->Close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
BOOL CRsp2DTd::SaveTdConToExcelFileBySort(_Worksheet* const pComSheet, int iMethod)
|
|
{
|
|
Range comRange;
|
|
excel9::Font comFont;
|
|
Range comCols;
|
|
|
|
_RecordsetPtr pRecConList = NULL;
|
|
CString szSql = _T("");
|
|
CString szRow = _T("");
|
|
|
|
int iIndex = (int)0;
|
|
|
|
iIndex = 1;
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("A%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("A(C1)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("B%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("B(C2)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("C%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("M(P1)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("D%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("N(P2)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("E%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("Stacking")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("F%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("K")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("G%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("I(mA)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("H%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("V(mV)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
//新增加R
|
|
szRow.Empty();
|
|
szRow.Format(_T("I%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("R(Ohm)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("J%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("R0")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("K%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("SP")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("L%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("R0_RD")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
|
|
pRecConList.CreateInstance(_uuidof(Recordset));
|
|
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,R0_LC,M0_LC,Layer,AR from td2dcon a, tdchannel b where a.bUse <> 0 and a.TCHID = b.ID and b.TDID = %u order by a.TSN"), m_dwID);
|
|
try
|
|
{
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
}
|
|
if (pRecConList->GetRecordCount() < 1)
|
|
{
|
|
pRecConList->Close();
|
|
return TRUE;
|
|
}
|
|
int iAR = pRecConList->GetCollect(_T("AR")).iVal;
|
|
COperMediumPt operMedium(iAR);
|
|
if (!operMedium.InitiSortInfo(iMethod))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("初始排序信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Initial sort information failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecConList->Close();
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
std::vector<StTdTaskComDataInfo> vtStTdTaskData;
|
|
vtStTdTaskData.clear();
|
|
int iSortIndex = 0;
|
|
while ((short)0 == pRecConList->adoEOF)
|
|
{
|
|
StTdTaskComDataInfo stTdTaskData;
|
|
stTdTaskData.iC1 = pRecConList->GetCollect(_T("C1")).iVal;
|
|
stTdTaskData.iC2 = pRecConList->GetCollect(_T("C2")).iVal;
|
|
stTdTaskData.iP1 = pRecConList->GetCollect(_T("P1")).iVal;
|
|
stTdTaskData.iP2 = pRecConList->GetCollect(_T("P2")).iVal;
|
|
stTdTaskData.iN = pRecConList->GetCollect(_T("N")).iVal;
|
|
stTdTaskData.fK = pRecConList->GetCollect(_T("K")).fltVal;
|
|
stTdTaskData.fV = pRecConList->GetCollect(_T("V")).fltVal;
|
|
stTdTaskData.fI = pRecConList->GetCollect(_T("I")).fltVal;
|
|
stTdTaskData.fR0 = pRecConList->GetCollect(_T("R0")).fltVal;
|
|
stTdTaskData.fSP = pRecConList->GetCollect(_T("SP")).fltVal;
|
|
stTdTaskData.fR0_LC = pRecConList->GetCollect(_T("R0_LC")).fltVal;
|
|
stTdTaskData.fM0_LC = pRecConList->GetCollect(_T("M0_LC")).fltVal;
|
|
|
|
vtStTdTaskData.push_back(stTdTaskData);
|
|
operMedium.AddSortPtInfo(stTdTaskData.iC1, stTdTaskData.iC2, stTdTaskData.iP1, stTdTaskData.iP2,
|
|
pRecConList->GetCollect(_T("Layer")).iVal, iSortIndex++);
|
|
pRecConList->MoveNext();
|
|
}
|
|
|
|
float fR = 0;
|
|
CString strText = _T("");
|
|
iSortIndex = operMedium.GetFirstSortID(iMethod);
|
|
BOOL bRes = TRUE;
|
|
CString strErr = _T("");
|
|
float fPtXPos = 0;
|
|
while (iSortIndex >= 0)
|
|
{
|
|
if (iSortIndex >= vtStTdTaskData.size())
|
|
{
|
|
strErr.Empty();
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErr.Format(_T("导出excel中的数据索引混乱,data_index =%d,total_size=%d"), iSortIndex + 1, vtStTdTaskData.size());
|
|
AfxMessageBox(strErr);
|
|
}
|
|
else
|
|
{
|
|
strErr.Format(_T("Data index disorder in export excel,data_index = %d,total_size=%d"), iSortIndex + 1, vtStTdTaskData.size());
|
|
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
bRes = FALSE;
|
|
break;
|
|
}
|
|
|
|
CString strIndex = _T("");
|
|
|
|
iIndex++;
|
|
if ((fPtXPos > EPSINON) && (operMedium.GetCurPtXPos() - fPtXPos > EPSINON))
|
|
{
|
|
//这里由于需要明确区分一次排序后的的点,以空一行来表示分开
|
|
iIndex++;
|
|
}
|
|
fPtXPos = operMedium.GetCurPtXPos();
|
|
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("A%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iC1);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("B%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iC2);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("C%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iP1);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("D%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iP2);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("E%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iN);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("F%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fK);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("G%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fI);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("H%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fV);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
fR = (fabsf(vtStTdTaskData[iSortIndex].fI) <= EPSINON) ? 0 : vtStTdTaskData[iSortIndex].fV / vtStTdTaskData[iSortIndex].fI;
|
|
szRow.Empty();
|
|
szRow.Format(_T("I%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), fR);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("J%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fR0);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("K%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fSP);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("L%d"), iIndex);
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fR0_LC);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strText));
|
|
|
|
iSortIndex = operMedium.GetNextSortID();
|
|
}
|
|
|
|
pRecConList->Close();
|
|
return bRes;
|
|
}
|
|
|
|
|
|
BOOL CRsp2DTd::SaveTdHeadToCsvFile(FILE* pFile)
|
|
{
|
|
|
|
_RecordsetPtr pRecTd = NULL;
|
|
_RecordsetPtr pRecTdHead = NULL;
|
|
_RecordsetPtr pRecDev = NULL;
|
|
_RecordsetPtr pRecPara = NULL;
|
|
_RecordsetPtr pRecCm = NULL;
|
|
|
|
CString szSql;
|
|
CString szLabel;
|
|
int iAR = 0;
|
|
int iRowIndex = (int)0;
|
|
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
pRecTdHead.CreateInstance(_uuidof(Recordset));
|
|
pRecDev.CreateInstance(_uuidof(Recordset));
|
|
pRecPara.CreateInstance(_uuidof(Recordset));
|
|
pRecCm.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,TDname,Tlocation,DESN,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,SAfrequency,Clayout,Espace,Edistance,weather,WDIR,"
|
|
"temperature,height,humidity,Format(Cdate,'YYYY-MM-DD') as Cdate,Format(Ctime,'HH:MM:SS') as Ctime,Format(Tdate,'YYYY-MM-DD') as Tdate,Format(Ttime,'HH:MM:SS') as Ttime,"
|
|
"Rdirection,CRtime,IIf(IsNull(PM),'',PM) as PM,IIf(IsNull(OP),'',OP) as OP,IIf(IsNull(QA),'',QA) as QA from td where ID = %u"), m_dwID);
|
|
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
CString strRowTitle = _T("");
|
|
CStringArray arrHead;
|
|
if ((long)0 != pRecTd->GetRecordCount())
|
|
{
|
|
strRowTitle.Empty();
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
strRowTitle = _T("测试任务名称");
|
|
else
|
|
strRowTitle = _T("Test data name");
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_DESN+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_SNAME+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_STYPE+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TTYPE+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_ARRAY_TYPE+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_EAMOUNT+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TPAMOUNT+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_CHAMOUNT+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_N+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TRWAVE+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TRFREQUENCY+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_IFREQUENCY+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_CLAYOUT+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_EDISTANCE+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_WEATHER+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_WDIR+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TEMPERATURE+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_HEIGHT+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_HUMIDITY+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_CDATE+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_CTIME+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TDATE+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_TTIME+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_OP+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_QA+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
|
|
|
|
CString strTmpSql = _T("");
|
|
strTmpSql.Format(_T("select AR from tdchannel where TDID = %d"),m_dwID);
|
|
pRecTdHead->Open(strTmpSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if (pRecTdHead->GetRecordCount() < 1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("获取装置失败,查询TdChannel失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get Medium AR failed. query TdChannel failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
else
|
|
{
|
|
iAR = pRecTdHead->GetCollect(_T("AR")).iVal;
|
|
if (AR_CROSS_HOLE_TYPE == iAR)
|
|
{
|
|
strRowTitle.Empty();
|
|
strRowTitle.LoadString(IDS_DB_TD_INITI_DEPETH+g_UIOffset);
|
|
arrHead.Add(strRowTitle + _T(','));
|
|
}
|
|
}
|
|
pRecTdHead->Close();
|
|
/////////////////////////////////////////////////////
|
|
int i = 0;
|
|
arrHead[i++] += ((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TDname")));
|
|
arrHead[i++] += (pRecTd->GetCollect(_T("DESN")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN"));
|
|
arrHead[i++] += ((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Sname")));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Stype' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Stype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Stype")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Ttype' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Ttype")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttype")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Tmode' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Tmode")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tmode")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
|
|
}
|
|
pRecCm->Close();
|
|
|
|
///////////////////////////////////加入装置类型////////////////////////////
|
|
szSql.Empty();
|
|
szSql.Format(_T("select MEname from medium where LANG = %d and AR in (select AR from tdchannel where TDID = %d)"),
|
|
g_iLanguage, m_dwID);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("MEname"))));
|
|
}
|
|
pRecCm->Close();
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Eamount"))));
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TPamount"))));
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("CHamount"))));
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("N"))));
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'TRwave' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("TRwave")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TRwave")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
if ((0 == pRecTd->GetCollect(_T("Ttype")).iVal) || (1 == pRecTd->GetCollect(_T("Ttype")).iVal))
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequency' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Trfrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
}
|
|
else if (2 == pRecTd->GetCollect(_T("Ttype")).iVal)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Trfrequencyself' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Trfrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Trfrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Ifrequency")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ifrequency")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Clayout' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Clayout")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Clayout")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Edistance"))));
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'weather' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("weather")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("weather")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'WDIR' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("WDIR")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("WDIR")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
|
}
|
|
pRecCm->Close();
|
|
|
|
CString strTmp = _T("");
|
|
float fTmp =(pRecTd->GetCollect(_T("temperature")).vt == VT_NULL) ? -9999:(float)pRecTd->GetCollect(_T("temperature")).fltVal;
|
|
if (fTmp > -9000)
|
|
{
|
|
strTmp.Format(_T("%f"),fTmp);
|
|
}
|
|
arrHead[i++] += ((strTmp));
|
|
arrHead[i++] += (((pRecTd->GetCollect(_T("height")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("height"))));
|
|
|
|
strTmp.Empty();
|
|
fTmp = (pRecTd->GetCollect(_T("humidity")).vt == VT_NULL) ? -9999:(float)pRecTd->GetCollect(_T("humidity")).fltVal;
|
|
if (fTmp > -9000)
|
|
{
|
|
strTmp.Format(_T("%f"),fTmp);
|
|
}
|
|
|
|
arrHead[i++] += ((strTmp));
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Cdate"))));
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ctime"))));
|
|
arrHead[i++] += (((pRecTd->GetCollect(_T("Tdate")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tdate"))));
|
|
arrHead[i++] += (((pRecTd->GetCollect(_T("Ttime")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttime"))));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Rdirection' and Lang = %d and Cvalue = %s"),
|
|
g_iLanguage, pRecTd->GetCollect(_T("Rdirection")).vt == VT_NULL ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Rdirection")));
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)0 != pRecCm->GetRecordCount())
|
|
{
|
|
|
|
}
|
|
pRecCm->Close();
|
|
|
|
arrHead[i++] += (((pRecTd->GetCollect(_T("OP")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("OP"))));
|
|
arrHead[i++] += (((pRecTd->GetCollect(_T("QA")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("QA"))));
|
|
if (AR_CROSS_HOLE_TYPE == iAR)
|
|
{
|
|
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Espace"))));
|
|
}
|
|
}
|
|
|
|
pRecTd->Close();
|
|
|
|
for (int j = 0; j < arrHead.GetCount(); j++)
|
|
{
|
|
arrHead[j] += "\n";
|
|
fwrite(arrHead[j], 1, arrHead[j].GetLength(), pFile);
|
|
}
|
|
fflush(pFile);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveTdConToCsvFile(FILE* pFile)
|
|
{
|
|
CString szSql = _T("");
|
|
if (EXP_2D_DATA_BY_DEPTH == theApp.Get2dDataExpStyle())
|
|
{
|
|
_RecordsetPtr pRecAR = NULL;
|
|
pRecAR.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Format(_T("select AR from tdchannel where TDID = %u"), m_dwID);
|
|
pRecAR->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if (pRecAR->GetRecordCount() < 1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("在excel保存中获取AR信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get AR information failed in save excel"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecAR->Close();
|
|
return FALSE;
|
|
}
|
|
int iAR = pRecAR->GetCollect(_T("AR")).iVal;
|
|
if (AR_CROSS_HOLE_TYPE != iAR && AR_BIPOLE_HOLE_SPT != iAR)
|
|
{
|
|
pRecAR->Close();
|
|
return SaveTdConToCsvFileBySort(pFile,1);
|
|
}
|
|
}
|
|
|
|
_RecordsetPtr pRecConList = NULL;
|
|
CString szRow = _T("");
|
|
|
|
//A(C1) B(C2) M(P1) N(P2) Stacking K I(mA) V(mV) R(Ohm) R0 SP R0_RD
|
|
int iIndex = (int)0;
|
|
iIndex = 1;
|
|
|
|
szRow.Empty();
|
|
szRow += ((_T("A(C1)"))); szRow += ',';
|
|
|
|
szRow += ((_T("B(C2)"))); szRow += ',';
|
|
|
|
szRow += ((_T("M(P1)"))); szRow += ',';
|
|
|
|
szRow += ((_T("N(P2)"))); szRow += ',';
|
|
|
|
szRow += ((_T("Stacking"))); szRow += ',';
|
|
|
|
szRow += ((_T("K"))); szRow += ',';
|
|
|
|
szRow += ((_T("I(mA)"))); szRow += ',';
|
|
|
|
szRow += ((_T("V(mV)"))); szRow += ',';
|
|
|
|
szRow += ((_T("R(Ohm)"))); szRow += ',';
|
|
|
|
szRow += ((_T("R0"))); szRow += ',';
|
|
|
|
szRow += ((_T("SP"))); szRow += ',';
|
|
|
|
szRow += ((_T("R0_RD")));
|
|
szRow += "\n";
|
|
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
|
fflush(pFile);
|
|
|
|
pRecConList.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,bUse,R0_LC,M0_LC from td2dcon where TCHID in (select ID from tdchannel where TDID = %u order by TCHID) order by TSN"), m_dwID);
|
|
try
|
|
{
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
}
|
|
float fV = 0, fI = 0, fR = 0;
|
|
CString strText = _T("");
|
|
while ((short)0 == pRecConList->adoEOF)
|
|
{
|
|
if (pRecConList->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
|
|
{
|
|
iIndex++;
|
|
|
|
szRow.Empty();
|
|
szRow += (((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C1")))); szRow += ',';
|
|
|
|
szRow += (((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C2")))); szRow += ',';
|
|
|
|
szRow += (((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P1")))); szRow += ',';
|
|
|
|
szRow += (((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P2")))); szRow += ',';
|
|
|
|
szRow += (((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("N")))); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("K")).fltVal);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("I")).fltVal);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("V")).fltVal);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
//添加R
|
|
fV = (float)pRecConList->GetCollect(_T("V")).fltVal;
|
|
fI = (float)pRecConList->GetCollect(_T("I")).fltVal;
|
|
fR = (0 == fI) ? 0 : fV/fI;
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),fR);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("R0")).fltVal);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("SP")).fltVal);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f%%"), pRecConList->GetCollect(_T("R0_LC")).fltVal);
|
|
szRow += ((strText));
|
|
szRow += "\n";
|
|
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
|
}
|
|
|
|
pRecConList->MoveNext();
|
|
}
|
|
|
|
|
|
fflush(pFile);
|
|
|
|
pRecConList->Close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveTdConToCsvFileBySort(FILE* pFile, int iMethod)
|
|
{
|
|
_RecordsetPtr pRecConList = NULL;
|
|
CString szSql = _T("");
|
|
CString szRow = _T("");
|
|
|
|
int iIndex = (int)0;
|
|
|
|
iIndex = 1;
|
|
|
|
szRow.Empty();
|
|
szRow += ((_T("A(C1)"))); szRow += ',';
|
|
|
|
szRow += ((_T("B(C2)"))); szRow += ',';
|
|
|
|
szRow += ((_T("M(P1)"))); szRow += ',';
|
|
|
|
szRow += ((_T("N(P2)"))); szRow += ',';
|
|
|
|
szRow += ((_T("Stacking"))); szRow += ',';
|
|
|
|
szRow += ((_T("K"))); szRow += ',';
|
|
|
|
szRow += ((_T("I(mA)"))); szRow += ',';
|
|
|
|
szRow += ((_T("V(mV)"))); szRow += ',';
|
|
|
|
szRow += ((_T("R(Ohm)"))); szRow += ',';
|
|
|
|
szRow += ((_T("R0"))); szRow += ',';
|
|
|
|
szRow += ((_T("SP"))); szRow += ',';
|
|
|
|
szRow += ((_T("R0_RD")));
|
|
szRow += "\n";
|
|
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
|
|
|
pRecConList.CreateInstance(_uuidof(Recordset));
|
|
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,R0_LC,M0_LC,Layer,AR from td2dcon a, tdchannel b where a.bUse <> 0 and a.TCHID = b.ID and b.TDID = %u order by a.TSN"), m_dwID);
|
|
try
|
|
{
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
}
|
|
if (pRecConList->GetRecordCount() < 1)
|
|
{
|
|
pRecConList->Close();
|
|
return TRUE;
|
|
}
|
|
int iAR = pRecConList->GetCollect(_T("AR")).iVal;
|
|
COperMediumPt operMedium(iAR);
|
|
if (!operMedium.InitiSortInfo(iMethod))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("初始排序信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Initial sort information failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecConList->Close();
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
std::vector<StTdTaskComDataInfo> vtStTdTaskData;
|
|
vtStTdTaskData.clear();
|
|
int iSortIndex = 0;
|
|
while ((short)0 == pRecConList->adoEOF)
|
|
{
|
|
StTdTaskComDataInfo stTdTaskData;
|
|
stTdTaskData.iC1 = pRecConList->GetCollect(_T("C1")).iVal;
|
|
stTdTaskData.iC2 = pRecConList->GetCollect(_T("C2")).iVal;
|
|
stTdTaskData.iP1 = pRecConList->GetCollect(_T("P1")).iVal;
|
|
stTdTaskData.iP2 = pRecConList->GetCollect(_T("P2")).iVal;
|
|
stTdTaskData.iN = pRecConList->GetCollect(_T("N")).iVal;
|
|
stTdTaskData.fK = pRecConList->GetCollect(_T("K")).fltVal;
|
|
stTdTaskData.fV = pRecConList->GetCollect(_T("V")).fltVal;
|
|
stTdTaskData.fI = pRecConList->GetCollect(_T("I")).fltVal;
|
|
stTdTaskData.fR0 = pRecConList->GetCollect(_T("R0")).fltVal;
|
|
stTdTaskData.fSP = pRecConList->GetCollect(_T("SP")).fltVal;
|
|
stTdTaskData.fR0_LC = pRecConList->GetCollect(_T("R0_LC")).fltVal;
|
|
stTdTaskData.fM0_LC = pRecConList->GetCollect(_T("M0_LC")).fltVal;
|
|
|
|
vtStTdTaskData.push_back(stTdTaskData);
|
|
operMedium.AddSortPtInfo(stTdTaskData.iC1, stTdTaskData.iC2, stTdTaskData.iP1, stTdTaskData.iP2,
|
|
pRecConList->GetCollect(_T("Layer")).iVal, iSortIndex++);
|
|
pRecConList->MoveNext();
|
|
}
|
|
|
|
float fR = 0;
|
|
CString strText = _T("");
|
|
iSortIndex = operMedium.GetFirstSortID(iMethod);
|
|
BOOL bRes = TRUE;
|
|
CString strErr = _T("");
|
|
float fPtXPos = 0;
|
|
while(iSortIndex>=0)
|
|
{
|
|
if (iSortIndex >= vtStTdTaskData.size())
|
|
{
|
|
strErr.Empty();
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErr.Format(_T("导出excel中的数据索引混乱,data_index =%d,total_size=%d"), iSortIndex + 1, vtStTdTaskData.size());
|
|
AfxMessageBox(strErr);
|
|
}
|
|
else
|
|
{
|
|
strErr.Format(_T("Data index disorder in export excel,data_index = %d,total_size=%d"), iSortIndex + 1, vtStTdTaskData.size());
|
|
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
bRes = FALSE;
|
|
break;
|
|
}
|
|
|
|
CString strIndex = _T("");
|
|
|
|
iIndex++;
|
|
if ((fPtXPos > EPSINON) && (operMedium.GetCurPtXPos() - fPtXPos > EPSINON))
|
|
{
|
|
//这里由于需要明确区分一次排序后的的点,以空一行来表示分开
|
|
iIndex++;
|
|
}
|
|
fPtXPos = operMedium.GetCurPtXPos();
|
|
|
|
|
|
szRow.Empty();
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iC1);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iC2);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iP1);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iP2);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iN);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fK);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fI);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fV);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
fR = (fabsf(vtStTdTaskData[iSortIndex].fI) <= EPSINON) ? 0 : vtStTdTaskData[iSortIndex].fV/vtStTdTaskData[iSortIndex].fI;
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), fR);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fR0);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fSP);
|
|
szRow += ((strText)); szRow += ',';
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fR0_LC);
|
|
szRow += ((strText));
|
|
szRow += "\n";
|
|
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
|
|
|
iSortIndex = operMedium.GetNextSortID();
|
|
}
|
|
|
|
fflush(pFile);
|
|
|
|
pRecConList->Close();
|
|
return bRes;
|
|
}
|
|
|
|
BOOL CRsp2DTd::ExportResDataToTxt(CString strFileName)
|
|
{
|
|
CString szSql = _T("");
|
|
if (EXP_2D_DATA_BY_DEPTH == theApp.Get2dDataExpStyle())
|
|
{
|
|
_RecordsetPtr pRecAR = NULL;
|
|
pRecAR.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Format(_T("select AR from tdchannel where TDID = %u"), m_dwID);
|
|
pRecAR->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if (pRecAR->GetRecordCount() < 1)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("获取AR信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get AR information failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
pRecAR->Close();
|
|
return FALSE;
|
|
}
|
|
int iAR = pRecAR->GetCollect(_T("AR")).iVal;
|
|
if (AR_CROSS_HOLE_TYPE != iAR && AR_BIPOLE_HOLE_SPT != iAR)
|
|
{
|
|
pRecAR->Close();
|
|
return Export2dDataToTxtBySort(strFileName,1);
|
|
}
|
|
}
|
|
|
|
_RecordsetPtr pRecTd = NULL;
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
szSql = _T("");
|
|
szSql.Format(_T("select Eamount, AR from td a, tdchannel b where a.ID = %u and a.ID = b.TDID and b.CHnumber=1"), this->m_dwID);
|
|
|
|
try
|
|
{
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
}
|
|
catch(_com_error e)
|
|
{
|
|
AfxMessageBox(e.Description());
|
|
return FALSE;
|
|
}
|
|
if (pRecTd->GetRecordCount()< 1)
|
|
{
|
|
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));
|
|
pRecTd->Close();
|
|
return FALSE;
|
|
}
|
|
int iAR= pRecTd->GetCollect(_T("AR")).iVal;
|
|
int iEamount = (pRecTd->GetCollect(_T("Eamount")).vt == VT_NULL) ? 0 : pRecTd->GetCollect(_T("Eamount")).iVal;
|
|
int iMidEAmout = iEamount/2;
|
|
pRecTd->Close();
|
|
int iLeftHole = 0, iRightHole = 0;
|
|
if ((AR_CUSTOM_2D_TYPE == iAR) && m_bIsCustomToCrossHole)
|
|
{
|
|
CString strName = PathFindFileName(strFileName);
|
|
// strFileName.TrimLeft();
|
|
// CString strKey = strName.Left(3);
|
|
CStringArray strArrKey;
|
|
strArrKey.RemoveAll();
|
|
SplitterString(strArrKey, strName, "_");
|
|
if (strArrKey.GetSize() < 2)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("解析文件名中的漏洞信息失败。"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Parser the hole information in the file name failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
iLeftHole = atoi(strArrKey.GetAt(0));
|
|
iRightHole = atoi(strArrKey.GetAt(1));
|
|
CString strKey = "";
|
|
strKey.Format(_T("%d_%d"),iLeftHole, iRightHole);
|
|
std::map<CString, STCorssHoleCfgInfo>::iterator iter = theApp.m_mapCrossHole.find(strKey);
|
|
if (iter == theApp.m_mapCrossHole.end())
|
|
{
|
|
CString strErr = "";
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErr.Format(_T("导出到txt时找不到跨孔密钥信息(%s)"), strKey);
|
|
AfxMessageBox(strErr);
|
|
}
|
|
else
|
|
{
|
|
strErr.Format(_T("Can not found cross_hole key info(%s) when expot to txt"), strKey);
|
|
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
}
|
|
|
|
COperTxtFile operTxtFile;
|
|
if (!operTxtFile.OpenFileforWrite(strFileName))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
_RecordsetPtr pRecConList = NULL;
|
|
pRecConList.CreateInstance(_uuidof(Recordset));
|
|
CStringArray strArrTxt;
|
|
strArrTxt.RemoveAll();
|
|
strArrTxt.Add(_T("A(C1)"));
|
|
strArrTxt.Add(_T("B(C2)"));
|
|
strArrTxt.Add(_T("M(P1)"));
|
|
strArrTxt.Add(_T("N(P2)"));
|
|
|
|
strArrTxt.Add(_T("Stacking"));
|
|
strArrTxt.Add(_T("K"));
|
|
strArrTxt.Add(_T("V(mV)"));
|
|
strArrTxt.Add(_T("I(mA)"));
|
|
strArrTxt.Add(_T("R(Ohm)"));
|
|
strArrTxt.Add(_T("R0"));
|
|
strArrTxt.Add(_T("SP"));
|
|
strArrTxt.Add(_T("R0_RD"));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,bUse,R0_LC,M0_LC from td2dcon where TCHID in (select ID from tdchannel where TDID = %u order by TCHID) order by TSN"), m_dwID);
|
|
try
|
|
{
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
operTxtFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
if (!operTxtFile.WriteFileContent(strArrTxt))
|
|
{
|
|
operTxtFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
CString strText = _T("");
|
|
float fV = 0, fI = 0, fR = 0;
|
|
CString strC1, strC2, strP1, strP2;
|
|
while ((short)0 == pRecConList->adoEOF)
|
|
{
|
|
if (pRecConList->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
|
|
{
|
|
strArrTxt.RemoveAll();
|
|
strC1 = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C1"));
|
|
strC2 = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C2"));
|
|
strP1 = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P1"));
|
|
strP2 = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P2"));
|
|
if ((iAR == AR_CUSTOM_2D_TYPE) && m_bIsCustomToCrossHole)
|
|
{
|
|
int iLFlag, iRFlag;
|
|
if (iLeftHole <= iRightHole)
|
|
{
|
|
iLFlag = 0;
|
|
iRFlag = 1;
|
|
}
|
|
else
|
|
{
|
|
iLFlag = 1;
|
|
iRFlag = 0;
|
|
}
|
|
strC1.Format(_T("%d"), CalcuCrossHolePoleID(atoi(strC1), iLeftHole, iLFlag, iMidEAmout));
|
|
strC2.Format(_T("%d"), CalcuCrossHolePoleID(atoi(strC2), iRightHole, iRFlag,iMidEAmout));
|
|
strP1.Format(_T("%d"), CalcuCrossHolePoleID(atoi(strP1), iLeftHole, iLFlag, iMidEAmout));
|
|
strP2.Format(_T("%d"), CalcuCrossHolePoleID(atoi(strP2), iRightHole, iRFlag, iMidEAmout));
|
|
}
|
|
strArrTxt.Add(strC1);
|
|
strArrTxt.Add(strC2);
|
|
strArrTxt.Add(strP1);
|
|
strArrTxt.Add(strP2);
|
|
|
|
strArrTxt.Add((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("N")));
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("K")).fltVal);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("V")).fltVal);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("I")).fltVal);
|
|
strArrTxt.Add(strText);
|
|
|
|
//添加R
|
|
fV = (float)pRecConList->GetCollect(_T("V")).fltVal;
|
|
fI = (float)pRecConList->GetCollect(_T("I")).fltVal;
|
|
fR = (0 == fI) ? 0 : fV/fI;
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),fR);
|
|
strArrTxt.Add(strText);
|
|
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("R0")).fltVal);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"),pRecConList->GetCollect(_T("SP")).fltVal);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f%%"),pRecConList->GetCollect(_T("R0_LC")).fltVal);
|
|
strArrTxt.Add(strText);
|
|
|
|
|
|
if (!operTxtFile.WriteFileContent(strArrTxt))
|
|
{
|
|
operTxtFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
|
|
}
|
|
pRecConList->MoveNext();
|
|
}
|
|
|
|
pRecConList->Close();
|
|
operTxtFile.CloseFile();
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveTdGRToExcelFile(_Worksheet* const pComSheet)
|
|
{
|
|
Range comRange;
|
|
excel9::Font comFont;
|
|
Range comCols;
|
|
|
|
_RecordsetPtr pRecGrList = NULL;
|
|
CString szSql = _T("");
|
|
CString szRow = _T("");
|
|
|
|
int iIndex = (int)0;
|
|
|
|
iIndex = 1;
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("A%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("Electrode ID")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("B%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("Test date")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("C%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("Test time")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("D%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("P1 Rg(Ω)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("E%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("Status")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("F%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("P2 Rg(Ω)")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("G%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(_T("Status")));
|
|
|
|
comFont = comRange.GetFont();
|
|
comFont.SetBold(COleVariant((short)TRUE));
|
|
|
|
comCols = comRange.GetEntireColumn();
|
|
comCols.AutoFit();
|
|
|
|
pRecGrList.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Ecode,Format(Mdate,'YYYY-MM-DD') as Mdate,Format(Mtime,'HH:MM:SS') as Mtime,OMvalue, OM1value,")
|
|
_T(" StatusCode, StatusCode1 from gr where TDID = %u order by Val(Ecode)"), m_dwID);
|
|
pRecGrList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
int iOMVal = -1, iOMVal1 = -1;
|
|
CString strOMVal, strOMVal1;
|
|
CString strMdate, strMtime;
|
|
CString strStatus, strStatus1;
|
|
while ((short)0 == pRecGrList->adoEOF)
|
|
{
|
|
|
|
iIndex++;
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("A%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Ecode"))));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
strOMVal.Empty();
|
|
strOMVal1.Empty();
|
|
strMdate.Empty();
|
|
strMtime.Empty();
|
|
strStatus.Empty();
|
|
strStatus1.Empty();
|
|
iOMVal = (int)pRecGrList->GetCollect(_T("OMvalue")).lVal;
|
|
iOMVal1 = (int)pRecGrList->GetCollect(_T("OM1value")).lVal;
|
|
|
|
if (-1 != iOMVal)
|
|
{
|
|
strOMVal.Format(_T("%d"), iOMVal);
|
|
strMdate = (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Mdate"));
|
|
strMtime = (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Mtime"));
|
|
strStatus = GetGrCodeText((int)pRecGrList->GetCollect(_T("StatusCode")).lVal);
|
|
}
|
|
if (-1 != iOMVal1)
|
|
{
|
|
strOMVal1.Format(_T("%d"), iOMVal1);
|
|
strStatus1 = GetGrCodeText((int)pRecGrList->GetCollect(_T("StatusCode1")).lVal);
|
|
}
|
|
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("B%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strMdate));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("C%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strMtime));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("D%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strOMVal));
|
|
|
|
// comCols = comRange.GetEntireColumn();
|
|
// comCols.AutoFit();
|
|
szRow.Empty();
|
|
szRow.Format(_T("E%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strStatus));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("F%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strOMVal1));
|
|
|
|
szRow.Empty();
|
|
szRow.Format(_T("G%d"), iIndex);
|
|
comRange = pComSheet->GetRange(COleVariant(szRow), COleVariant(szRow));
|
|
comRange.SetValue2(COleVariant(strStatus1));
|
|
|
|
pRecGrList->MoveNext();
|
|
}
|
|
|
|
pRecGrList->Close();
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveTdGRToCsvFile(FILE* pFile)
|
|
{
|
|
_RecordsetPtr pRecGrList = NULL;
|
|
CString szSql = _T("");
|
|
CString szRow = _T("");
|
|
|
|
int iIndex = (int)0;
|
|
|
|
iIndex = 1;
|
|
szRow.Empty();
|
|
szRow += ((_T("Electrode ID"))); szRow += ',';
|
|
|
|
szRow += ((_T("Test date"))); szRow += ',';
|
|
|
|
szRow += ((_T("Test time"))); szRow += ',';
|
|
|
|
szRow += ((_T("P1 Rg(Ω)"))); szRow += ',';
|
|
|
|
szRow += ((_T("Status"))); szRow += ',';
|
|
|
|
szRow += ((_T("P2 Rg(Ω)"))); szRow += ',';
|
|
|
|
szRow += ((_T("Status")));
|
|
szRow += "\n";
|
|
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
|
fflush(pFile);
|
|
|
|
pRecGrList.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Ecode,Format(Mdate,'YYYY-MM-DD') as Mdate,Format(Mtime,'HH:MM:SS') as Mtime,OMvalue, OM1value,")
|
|
_T(" StatusCode, StatusCode1 from gr where TDID = %u order by Val(Ecode)"), m_dwID);
|
|
pRecGrList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
int iOMVal = -1, iOMVal1 = -1;
|
|
CString strOMVal, strOMVal1;
|
|
CString strMdate, strMtime;
|
|
CString strStatus, strStatus1;
|
|
while ((short)0 == pRecGrList->adoEOF)
|
|
{
|
|
|
|
iIndex++;
|
|
|
|
szRow.Empty();
|
|
szRow += (((LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Ecode")))); szRow += ',';
|
|
|
|
strOMVal.Empty();
|
|
strOMVal1.Empty();
|
|
strMdate.Empty();
|
|
strMtime.Empty();
|
|
strStatus.Empty();
|
|
strStatus1.Empty();
|
|
iOMVal = (int)pRecGrList->GetCollect(_T("OMvalue")).lVal;
|
|
iOMVal1 = (int)pRecGrList->GetCollect(_T("OM1value")).lVal;
|
|
|
|
if (-1 != iOMVal)
|
|
{
|
|
strOMVal.Format(_T("%d"),iOMVal);
|
|
strMdate = (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Mdate"));
|
|
strMtime = (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Mtime"));
|
|
strStatus = GetGrCodeText((int)pRecGrList->GetCollect(_T("StatusCode")).lVal);
|
|
}
|
|
if (-1 != iOMVal1)
|
|
{
|
|
strOMVal1.Format(_T("%d"),iOMVal1);
|
|
strStatus1 = GetGrCodeText((int)pRecGrList->GetCollect(_T("StatusCode1")).lVal);
|
|
}
|
|
|
|
|
|
szRow += ((strMdate)); szRow += ',';
|
|
|
|
szRow += ((strMtime)); szRow += ',';
|
|
|
|
szRow += ((strOMVal)); szRow += ',';
|
|
|
|
szRow += ((strStatus)); szRow += ',';
|
|
|
|
szRow += ((strOMVal1)); szRow += ',';
|
|
|
|
szRow += ((strStatus1));
|
|
szRow += "\n";
|
|
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
|
|
|
pRecGrList->MoveNext();
|
|
}
|
|
|
|
fflush(pFile);
|
|
|
|
pRecGrList->Close();
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::ExportDataToUrf(CString strFileName)
|
|
{
|
|
strFileName.TrimLeft();
|
|
|
|
COperUrfFile operUrfFile;
|
|
if (!operUrfFile.OpenUrfFileForWrite(strFileName))
|
|
{
|
|
return FALSE;
|
|
}
|
|
operUrfFile.WriteUrfHeadInfo();
|
|
_RecordsetPtr pRecConList = NULL;
|
|
_RecordsetPtr pRecTd = NULL;
|
|
pRecConList.CreateInstance(_uuidof(Recordset));
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
|
|
CString szSql = _T("");
|
|
try
|
|
{
|
|
szSql.Format(_T("select StartElec,EndElec,Eamount,Edistance,AR,SCCN,TDCN from td a, tdchannel b where a.ID = %u and a.ID = b.TDID and b.CHnumber=1"), this->m_dwID);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if (pRecTd->GetRecordCount() < 1)
|
|
{
|
|
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));
|
|
operUrfFile.CloseFile();
|
|
pRecTd->Close();
|
|
return FALSE;
|
|
}
|
|
int iTaskAR = (pRecTd->GetCollect(_T("AR")).vt == VT_NULL) ? 0 : pRecTd->GetCollect(_T("AR")).iVal;
|
|
int iStartElec = (pRecTd->GetCollect(_T("StartElec")).vt == VT_NULL) ? 0 : pRecTd->GetCollect(_T("StartElec")).lVal;
|
|
int iEndElec = (pRecTd->GetCollect(_T("EndElec")).vt == VT_NULL) ? 0 : pRecTd->GetCollect(_T("EndElec")).lVal;
|
|
CString strSCCN = (pRecTd->GetCollect(_T("SCCN")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SCCN"));
|
|
CString strTDCN = (pRecTd->GetCollect(_T("TDCN")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TDCN"));
|
|
STCorssHoleCfgInfo stCroHoleInfo;
|
|
int iLeftHole = 0, iRightHole = 0;
|
|
int iExpType = 39;//任务导出类型,默认按照温-斯装置导
|
|
if ((AR_CUSTOM_2D_TYPE == iTaskAR) && m_bIsCustomToCrossHole)
|
|
{
|
|
CString strName = PathFindFileName(strFileName);
|
|
CStringArray strArrKey;
|
|
strArrKey.RemoveAll();
|
|
SplitterString(strArrKey, strName, "_");
|
|
if (strArrKey.GetSize() < 2)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("解析文件名中的孔信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Parser the hole information in the file name failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
iLeftHole = atoi(strArrKey.GetAt(0));
|
|
iRightHole = atoi(strArrKey.GetAt(1));
|
|
CString strKey = "";
|
|
strKey.Format(_T("%d_%d"),iLeftHole, iRightHole);
|
|
std::map<CString, STCorssHoleCfgInfo>::iterator iter = theApp.m_mapCrossHole.find(strKey);
|
|
if (iter == theApp.m_mapCrossHole.end())
|
|
{
|
|
CString strErr = "";
|
|
strErr.Format(_T("can not found key(%s) when export customer task to urf."),strKey);
|
|
pRecTd->Close();
|
|
operUrfFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
stCroHoleInfo = iter->second;
|
|
iExpType = AR_CUSTOM_2D_TYPE;
|
|
operUrfFile.SetExtParam(stCroHoleInfo.fFirstPoleDep);
|
|
|
|
}
|
|
CString strTxt = (pRecTd->GetCollect(_T("Edistance")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Edistance"));
|
|
int iEamount = (pRecTd->GetCollect(_T("Eamount")).vt == VT_NULL) ? 0 : pRecTd->GetCollect(_T("Eamount")).iVal;
|
|
pRecTd->Close();
|
|
if (AR_CROSS_HOLE_GEOMATIVE != iTaskAR && AR_CROSS_HOLE_GEOMATIVE_AM != iTaskAR)
|
|
{
|
|
if (strTxt.IsEmpty() || iEamount == 0)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("查询Eamount或Edistance错误"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Query Eamount or Edistance error"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
operUrfFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
float fParamVal = (AR_CUSTOM_2D_TYPE == iTaskAR) ? stCroHoleInfo.fHoleSpace : 0;
|
|
if (AR_CROSS_HOLE_TYPE == iTaskAR)//quyx 20181010
|
|
{
|
|
iExpType = 40;
|
|
CStringArray strArrKey;
|
|
strArrKey.RemoveAll();
|
|
SplitterString(strArrKey, strTxt, ",");
|
|
if (strArrKey.GetSize() >= 2)
|
|
{
|
|
fParamVal = atof(strArrKey.GetAt(1));
|
|
}
|
|
}
|
|
|
|
switch (iTaskAR)
|
|
{
|
|
case AR_POLE_DIPOLE_AMN:
|
|
iExpType = 37;//任务导出类型,默认按照温-斯装置导
|
|
break;
|
|
case AR_DIPOLE_POLE_MNB:
|
|
iExpType = 38;//任务导出类型,默认按照温-斯装置导
|
|
break;
|
|
case AR_POLE_POLE_AM:
|
|
iExpType = 36;//任务导出类型,默认按照温-斯装置导
|
|
break;
|
|
case AR_CROSS_HOLE_GEOMATIVE:
|
|
case AR_CROSS_HOLE_GEOMATIVE_AM:
|
|
iExpType = AR_CROSS_HOLE_GEOMATIVE;//Cross-Hole(Geomative)按自己的方式导出
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//兼容之前的数据库td没有写入起始电极,默认从1开始。
|
|
if (0 == iStartElec)
|
|
iStartElec = 1;
|
|
|
|
if (iExpType != AR_CROSS_HOLE_GEOMATIVE)
|
|
{
|
|
if (!operUrfFile.WriteUrfPoleInfo(iExpType, iEamount, atof(strTxt), fParamVal, iStartElec, iEndElec))
|
|
{
|
|
operUrfFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//跨孔的直接传脚本的CN
|
|
//三维的任务暂时用二维的导出方式
|
|
if (strSCCN.IsEmpty())
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Eamount,Edistance,SCCN,TDCN from td where TDCN='%s'"),strTDCN);
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while ((short)0 == pRecConList->adoEOF)
|
|
{
|
|
strSCCN = (pRecConList->GetCollect(_T("SCCN")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("SCCN"));
|
|
if (!strSCCN.IsEmpty())
|
|
{
|
|
break;
|
|
}
|
|
pRecConList->MoveNext();
|
|
}
|
|
pRecConList->Close();
|
|
}
|
|
|
|
if (strSCCN.IsEmpty() && strTDCN.IsEmpty())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("没有找到脚本信息和任务ID"));
|
|
else
|
|
MessageBoxEx(NULL, _T("No script and taskid information was found"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
if (!operUrfFile.WriteUrfPoleInfo(iExpType, iEamount, atof(strTxt), fParamVal, iStartElec, iEndElec, strSCCN, strTDCN))
|
|
{
|
|
operUrfFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
if (AR_CROSS_HOLE_TYPE == iTaskAR) { iExpType = 39; }//quyx 20181010
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,bUse from td2dcon where TCHID in (select ID from tdchannel where TDID = %u order by TCHID) order by TSN"), m_dwID);
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
float fV = 0, fI = 0, fR = 0;
|
|
int iC1 = 0, iC2 = 0, iP1 = 0, iP2 = 0;
|
|
int iMidEAmount = iEamount/2;
|
|
while ((short)0 == pRecConList->adoEOF)
|
|
{
|
|
if (pRecConList->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
|
|
{
|
|
iC1 = pRecConList->GetCollect(_T("C1")).iVal;
|
|
iC2 = pRecConList->GetCollect(_T("C2")).iVal;
|
|
iP1 = pRecConList->GetCollect(_T("P1")).iVal;
|
|
iP2 = pRecConList->GetCollect(_T("P2")).iVal;
|
|
if ((AR_CUSTOM_2D_TYPE == iTaskAR) && m_bIsCustomToCrossHole)
|
|
{
|
|
int iLFlag, iRFlag;
|
|
if (iLeftHole <= iRightHole)
|
|
{
|
|
iLFlag = 0;
|
|
iRFlag = 1;
|
|
}
|
|
else
|
|
{
|
|
iLFlag = 1;
|
|
iRFlag = 0;
|
|
}
|
|
iC1 = CalcuCrossHolePoleID(iC1, iLeftHole, iLFlag, iMidEAmount);
|
|
iC2 = CalcuCrossHolePoleID(iC2, iRightHole, iRFlag, iMidEAmount);
|
|
iP1 = CalcuCrossHolePoleID(iP1, iLeftHole, iLFlag, iMidEAmount);
|
|
iP2 = CalcuCrossHolePoleID(iP2, iRightHole, iRFlag, iMidEAmount);
|
|
}
|
|
fV = (float)pRecConList->GetCollect(_T("V")).fltVal;
|
|
fI = (float)pRecConList->GetCollect(_T("I")).fltVal;
|
|
fR = (0 == fI) ? 0 : fV/fI;
|
|
strTxt.Empty();
|
|
switch (iTaskAR)
|
|
{
|
|
case AR_DIPOLE_POLE_MNB:
|
|
strTxt.Format(_T("%d,%d,%d,%d,%.6f,%.6f\n"), 1, iC2 + 1, iP1 + 1, iP2 + 1, fR, fI);
|
|
break;
|
|
case AR_POLE_DIPOLE_AMN:
|
|
strTxt.Format(_T("%d,%d,%d,%d,%.6f,%.6f\n"), iC1, iEamount + 1, iP1, iP2, fR, fI);
|
|
break;
|
|
case AR_POLE_POLE_AM:
|
|
strTxt.Format(_T("%d,%d,%d,%d,%.6f,%.6f\n"), iC1+1, 1, iP1+1, iEamount + 2, fR, fI);
|
|
break;
|
|
default:
|
|
strTxt.Format(_T("%d,%d,%d,%d,%.6f,%.6f\n"), iC1, iC2, iP1, iP2, fR, fI);
|
|
break;
|
|
}
|
|
|
|
if (!operUrfFile.WriteUrfDataInfo(strTxt))
|
|
{
|
|
pRecConList->Close();
|
|
operUrfFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
|
|
}
|
|
pRecConList->MoveNext();
|
|
}
|
|
return TRUE;
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
operUrfFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveTdToCsvFile(CString f_szFileName)
|
|
{
|
|
if (PathFileExists(f_szFileName))
|
|
{
|
|
if (0 == DeleteFile(f_szFileName))
|
|
return FALSE;
|
|
}
|
|
|
|
FILE* pCsvFile;
|
|
pCsvFile = fopen(f_szFileName, "w+");
|
|
if (NULL == pCsvFile)
|
|
{
|
|
CString str = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
str.Format(_T("无法构建csv应用程序!错误码 %d"), GetLastError());
|
|
AfxMessageBox(str);
|
|
}
|
|
else
|
|
{
|
|
str.Format(_T("Can't build csv application!,err = %d"), GetLastError());
|
|
MessageBoxEx(NULL, str, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
this->SaveTdHeadToCsvFile(pCsvFile);
|
|
|
|
this->SaveTdConToCsvFile(pCsvFile);
|
|
|
|
this->SaveTdGRToCsvFile(pCsvFile);
|
|
|
|
fclose(pCsvFile);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
|
|
BOOL CRsp2DTd::SaveTdToExcelFile(CString f_szFileName)
|
|
{
|
|
if (PathFileExists(f_szFileName))
|
|
{
|
|
if (0 == DeleteFile(f_szFileName))
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
_Application* pComApp = new _Application;
|
|
Workbooks comBooks;
|
|
_Workbook comBook;
|
|
Sheets comSheets;
|
|
_Worksheet comSheet01;
|
|
_Worksheet comSheet02;
|
|
_Worksheet comSheet03;
|
|
|
|
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND, VT_ERROR);
|
|
|
|
// CString szCurFilePath = _T("");
|
|
// CString szCurFile = _T("");
|
|
//
|
|
// CFileDialog dlgSaveFile(FALSE, "xlsx", "", OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_NOCHANGEDIR, "Excel file(*.xlsx)|*.xlsx||", NULL);
|
|
//
|
|
// szCurFilePath.Empty();
|
|
// szCurFilePath.GetBufferSetLength(256);
|
|
// ::GetCurrentDirectory(szCurFilePath.GetLength(), szCurFilePath.GetBuffer(szCurFilePath.GetLength()));
|
|
// szCurFilePath.ReleaseBuffer();
|
|
//
|
|
// dlgSaveFile.m_ofn.lpstrTitle = _T("Save");
|
|
// dlgSaveFile.m_ofn.lpstrInitialDir = szCurFilePath;
|
|
//
|
|
// if (dlgSaveFile.DoModal() == IDOK)
|
|
// {
|
|
// szCurFile.Empty();
|
|
// szCurFile = dlgSaveFile.GetPathName();
|
|
// DeleteFile(szCurFile);
|
|
COleException oleExp;
|
|
if (!pComApp->CreateDispatch(_T("Excel.Application"), &oleExp))
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
|
oleExp.ReportError(MB_OK);
|
|
CString str = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
str.Format(_T("无法构建excel应用程序!错误码 %d"), GetLastError());
|
|
AfxMessageBox(str);
|
|
}
|
|
else
|
|
{
|
|
str.Format(_T("Can't build excel application!,err = %d"), GetLastError());
|
|
MessageBoxEx(NULL, str, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
comBooks = pComApp->GetWorkbooks();
|
|
comBook = comBooks.Add(covOptional);
|
|
comSheets = comBook.GetSheets();
|
|
|
|
//HWND hWndXL = ::FindWindow("XLMAIN", pComApp->GetCaption());
|
|
//::ShowWindow(hWndXL, SW_HIDE);
|
|
pComApp->SetVisible(FALSE);
|
|
|
|
int iSheetCnt = comSheets.GetCount();
|
|
int iNeedCreateCnt = 3 - iSheetCnt;
|
|
if (iNeedCreateCnt > 0)
|
|
{
|
|
/////////////////////VC插入sheet页到指定位置////////////////////////////////////////////////
|
|
/*
|
|
插入sheet的函数用 sheets.Add(Before, After,Count,Type)
|
|
Before Variant 类型,可选。指定工作表对象,新建的工作表将置于此工作表之前。
|
|
After Variant 类型,可选。指定工作表对象,新建的工作表将置于此工作表之后。
|
|
Count Variant 类型,可选。要创建的工作表的数目。默认值为一。
|
|
Type Variant 类型,可选。工作表类型。
|
|
如果我们默认参数都为vtMissing,则 插入sheet的位置时在当前激活sheet页之前,而且时只插入一个sheet页
|
|
sheets.Add(vtMissing, vtMissing,vtMissing,vtMissing)
|
|
假如我们要求插入到第二个sheet之后,第三个sheet之前,我们应该按照下面的方法写
|
|
sheets.Add(-variant_t(sheets.GetItem(COleVariant((short)2))), -variant_t(sheets.GetItem(COleVariant((short)3))),-variant_t((long)1),vtMissing)
|
|
*/
|
|
//在这里covOptional可以等同于vtMissing
|
|
comSheets.Add(covOptional, _variant_t(comSheets.GetItem(COleVariant((short)iSheetCnt))), _variant_t((long)iNeedCreateCnt), covOptional);
|
|
}
|
|
|
|
comSheet01 = comSheets.GetItem(COleVariant((short)1));
|
|
comSheet01.SetName(_T("Head"));
|
|
|
|
this->SaveTdHeadToExcelFile(&comSheet01);
|
|
|
|
comSheet02 = comSheets.GetItem(COleVariant((short)2));
|
|
comSheet02.SetName(_T("DAT"));
|
|
this->SaveTdConToExcelFile(&comSheet02);
|
|
|
|
comSheet03 = comSheets.GetItem(COleVariant((short)3));
|
|
comSheet03.SetName(_T("GR"));
|
|
this->SaveTdGRToExcelFile(&comSheet03);
|
|
|
|
// comApp.SetVisible(TRUE);
|
|
// comApp.SetUserControl(TRUE);
|
|
|
|
|
|
comBook.SaveAs(COleVariant(f_szFileName), covOptional, covOptional, covOptional, covOptional, covOptional, 0, covOptional, covOptional, covOptional, covOptional, covOptional);
|
|
comSheet01.ReleaseDispatch();
|
|
comSheet02.ReleaseDispatch();
|
|
comSheet03.ReleaseDispatch();
|
|
comSheets.ReleaseDispatch();
|
|
comBook.Close(covOptional, COleVariant(""), covOptional);
|
|
comBook.ReleaseDispatch();
|
|
comBooks.Close();
|
|
comBooks.ReleaseDispatch();
|
|
|
|
|
|
|
|
pComApp->Quit();
|
|
|
|
// pComApp->DetachDispatch();
|
|
pComApp->ReleaseDispatch();
|
|
if (pComApp != NULL)
|
|
{
|
|
delete pComApp;
|
|
pComApp = NULL;
|
|
}
|
|
// DWORD dwExcelID = CGetProcessInfo::CreateInstance()->GetSpcialProcessIdFromName(_T("EXCEL.EXE"), 1000);
|
|
// if (0 == dwExcelID)
|
|
// {
|
|
// CString strInfo = _T("");
|
|
// strInfo.Format(_T("found excel id failed,parentID = %d"),::GetCurrentProcessId());
|
|
// AfxMessageBox(strInfo);
|
|
// }
|
|
// else
|
|
// {
|
|
// HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS,FALSE,dwExcelID); //通过pid获得进程句柄,
|
|
// TerminateProcess(hProcess,1); //调用该函数终结进程,第二个参数为进程退出码
|
|
// }
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// return FALSE;
|
|
// }
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveTdToRes2DFile(CString f_szFileName)
|
|
{
|
|
long lRet = VAL_ZERO;
|
|
int iListIndex = (int)VAL_ZERO;
|
|
|
|
CString szSql = _T("");
|
|
CString szCaption = _T("");
|
|
|
|
UINT uExecCode = (UINT)APP_SUCCESS;
|
|
CSaveInRes* pSaveInRes = NULL;
|
|
|
|
CString szFilePath = _T("");
|
|
CString szFileName = _T("");
|
|
CString szFile = _T("");
|
|
|
|
CStringArray saRecord;
|
|
|
|
CString szTdName = _T("");
|
|
CString szTdCN = _T("");
|
|
CString strSCCN = _T("");
|
|
// CString szDESN = _T("");
|
|
CString szEDistance = _T("");
|
|
CString szAr = _T("");
|
|
CString szTPAmount = _T("");
|
|
CString strESpace = _T("");
|
|
CString strFormat = _T("0");
|
|
|
|
CString szTType = _T("");
|
|
|
|
CString szA = _T("");
|
|
CString szB = _T("");
|
|
CString szM = _T("");
|
|
CString szN = _T("");
|
|
CString szR0 = _T("");
|
|
CString szV = _T("");
|
|
CString szI = _T("");
|
|
|
|
CString szDistance = _T("");
|
|
CString szElevation = _T("");
|
|
CString strEamount = _T("");
|
|
|
|
DWORD dwChID = (DWORD)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecTd = NULL;
|
|
_RecordsetPtr pRecCh = NULL;
|
|
_RecordsetPtr pRecTdCon = NULL;
|
|
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
pRecCh.CreateInstance(_uuidof(Recordset));
|
|
pRecTdCon.CreateInstance(_uuidof(Recordset));
|
|
|
|
map<UINT32, STElectrodeCoordinates> mapElecCoordinates;//存放所有电极对应的坐标,便于写入dat文件时查找
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select TDname,TdCN,DESN,Ttype,Edistance,TPamount,Espace,Eamount,SCCN from td where ID = %u"), this->m_dwID);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
szTdName = (pRecTd->GetCollect(_T("TDname")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TDname"));
|
|
szTdCN = (pRecTd->GetCollect(_T("TdCN")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TdCN"));
|
|
strSCCN = (pRecTd->GetCollect(_T("SCCN")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SCCN"));
|
|
// szDESN = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN"));
|
|
szTType = (pRecTd->GetCollect(_T("Ttype")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ttype"));
|
|
szEDistance = (pRecTd->GetCollect(_T("Edistance")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Edistance"));
|
|
strEamount = (pRecTd->GetCollect(_T("Eamount")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Eamount"));
|
|
strESpace = (pRecTd->GetCollect(_T("Espace")).vt == VT_NULL)?_T("0"):(LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Espace"));
|
|
// strESpace = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Espace"));
|
|
// nTPAmount = (int)pRecTd->GetCollect(_T("TPamount")).iVal;
|
|
// szTPAmount = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TPamount"));
|
|
}
|
|
pRecTd->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,AR from tdchannel where TDID = %u and CHnumber = 1"), this->m_dwID);
|
|
pRecCh->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecCh->GetRecordCount())
|
|
{
|
|
dwChID = pRecCh->GetCollect(_T("ID")).ulVal;
|
|
szAr = (LPCTSTR)(_bstr_t)pRecCh->GetCollect(_T("AR"));
|
|
}
|
|
pRecCh->Close();
|
|
STCorssHoleCfgInfo stCrossHole;
|
|
bool bIsRealCustToCroHole = false;
|
|
int iLeftHole = 0, iRightHole = 0;
|
|
if ((AR_CUSTOM_2D_TYPE == atoi(szAr)) && m_bIsCustomToCrossHole)
|
|
{
|
|
CString strName = PathFindFileName(f_szFileName);
|
|
// f_szFileName.TrimLeft();
|
|
CStringArray strArrKey;
|
|
strArrKey.RemoveAll();
|
|
SplitterString(strArrKey, strName, "_");
|
|
if (strArrKey.GetSize() < 2)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("解析孔信息失败."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Parser the hole information in the file name failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
iLeftHole = atoi(strArrKey.GetAt(0));
|
|
iRightHole = atoi(strArrKey.GetAt(1));
|
|
CString strKey = "";
|
|
strKey.Format(_T("%d_%d"),iLeftHole, iRightHole);
|
|
std::map<CString, STCorssHoleCfgInfo>::iterator iter = theApp.m_mapCrossHole.find(strKey);
|
|
if (iter == theApp.m_mapCrossHole.end())
|
|
{
|
|
CString strErr = "";
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErr.Format(_T("在导出到dat时找不到交叉孔密钥信息(%s)"), strKey);
|
|
AfxMessageBox(strErr);
|
|
}
|
|
else
|
|
{
|
|
strErr.Format(_T("Can not found cross_hole key info(%s) when expot to dat"), strKey);
|
|
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
stCrossHole = iter->second;
|
|
//在这里改变装置类型,使得最后可以按照跨孔装置来导出
|
|
szAr = "16";
|
|
CString strTmp = szEDistance;
|
|
szEDistance.Format(_T("%s,%f"),strTmp,stCrossHole.fHoleSpace);
|
|
bIsRealCustToCroHole = true;
|
|
|
|
strESpace.Empty();
|
|
strESpace.Format(_T("%f"), stCrossHole.fFirstPoleDep);
|
|
}
|
|
if(AR_BIPOLE_HOLE_SPT == atoi(szAr))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("不支持将该装置装置数据导出dat"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Not support export data to dat file"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
pSaveInRes = new CSaveInRes;
|
|
szFilePath.Empty();
|
|
szFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szFilePath.GetLength(), szFilePath.GetBuffer(szFilePath.GetLength()));
|
|
szFilePath.ReleaseBuffer();
|
|
|
|
szFilePath = szFilePath + _T("\\DAT\\");
|
|
|
|
szFileName = szTdName + _T(".dat");
|
|
szFile = szFilePath + szFileName;
|
|
|
|
pSaveInRes->CreateResFile(f_szFileName);
|
|
|
|
//如果是跨井装置类型,则需要同时获取电极间距以及AB之间的距离间隔系数n
|
|
if (AR_CROSS_HOLE_TYPE == atoi(szAr))
|
|
{
|
|
CString strError = _T("");
|
|
float fCrossHole = 1, fEDistance = 1;
|
|
CStringArray strEDisArray;
|
|
strEDisArray.RemoveAll();
|
|
SplitterString(strEDisArray, szEDistance,_T(","));
|
|
if (2 != strEDisArray.GetSize())
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strError.Format(_T("在cross_hole_medium中解析器Edistance错误,msg = %s,tdid = %d"), szEDistance, this->m_dwID);
|
|
AfxMessageBox(strError);
|
|
}
|
|
else
|
|
{
|
|
strError.Format(_T("Parser Edistance error in cross_hole_medium, msg = %s,tdid = %d"), szEDistance, this->m_dwID);
|
|
MessageBoxEx(NULL, strError, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
fEDistance = atof(strEDisArray.GetAt(0));
|
|
fCrossHole = atof(strEDisArray.GetAt(1));
|
|
}
|
|
szEDistance.Empty();
|
|
szEDistance.Format(_T("%.2f"),fEDistance);
|
|
pSaveInRes->SetCorssHoleParam(fCrossHole,atof(strESpace));
|
|
strFormat = _T("2");
|
|
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
//判断有没有层数信息
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1 from td2dcon where TCHID = %u and bUse <> 0 and Layer is null"),dwChID);
|
|
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//如果存在着层数为空的数据,那么则认为是以前版本的数据,此时按照老规则直接取出数据进行生成DAT文件
|
|
//对于跨孔和自定义装置,则不需要进行排序操作
|
|
if (((long)VAL_ZERO != pRecTdCon->GetRecordCount()) || (AR_CUSTOM_2D_TYPE == atoi(szAr)) || (AR_CROSS_HOLE_TYPE == atoi(szAr)))
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,R0,bUse,V,I from td2dcon where TCHID = %u and bUse <> 0 order by TSN"), dwChID);
|
|
}
|
|
//否则则按照层数和C1的逐渐增大进行排序
|
|
else
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,R0,bUse,V,I from td2dcon where TCHID = %u and bUse <> 0 order by TSN,Layer, C1"), dwChID);
|
|
}
|
|
pRecTdCon->Close();
|
|
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
szTPAmount.Empty();
|
|
szTPAmount.Format(_T("%d"), pRecTdCon->GetRecordCount());
|
|
pRecTdCon->Close();
|
|
//pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
//添加文件包头,由于真实的测点个数需要查询数据表中才能知道,所以添加文件头的信息放在执行数据查询之后
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(szTdName);
|
|
saRecord.Add(szEDistance);
|
|
saRecord.Add(szAr);
|
|
if (AR_CUSTOM_2D_TYPE == atoi(szAr) ||
|
|
AR_DOUBLE_SIZE_3P == atoi(szAr)||
|
|
AR_S3P_MEDIUM == atoi(szAr))
|
|
{
|
|
saRecord.Add(_T("0"));
|
|
saRecord.Add(_T("Type of measurement(0=app.resistivity,1=resistance)"));
|
|
saRecord.Add(_T("0"));
|
|
strFormat = _T("1");
|
|
}
|
|
//三极装置置为0
|
|
else if (AR_POLE_DIPOLE_AMN == atoi(szAr)
|
|
|| AR_DIPOLE_POLE_MNB == atoi(szAr))
|
|
{
|
|
strFormat = _T("0");
|
|
}
|
|
//赛盈跨孔
|
|
else if (AR_CROSS_HOLE_GEOMATIVE == atoi(szAr) || AR_CROSS_HOLE_GEOMATIVE_AM == atoi(szAr))
|
|
{
|
|
STElectrodeCoordinates stElecCoordinates;//电极坐标详情
|
|
//szTPAmount.Empty();
|
|
//szTPAmount.Format(_T("%d"), pRecTdCon->GetRecordCount());
|
|
saRecord.Add(szTPAmount);
|
|
strFormat = _T("2");
|
|
saRecord.Add(strFormat);
|
|
saRecord.Add(szTType);
|
|
pSaveInRes->AddFileHeader(Res, atoi(szAr.GetBuffer(0)), &saRecord);
|
|
pSaveInRes->Init2DFileHeader(&saRecord);
|
|
|
|
//pRecTdCon->Close();
|
|
int iWellCount = 0;
|
|
int iWellIndex = 1;
|
|
float fX = 0.0,fTemp=0.0,fWellDistance=0.0;
|
|
float fXStartPoint = 0.0; //地表测线X最小值起点
|
|
BOOL bFlag = FALSE; //标志是否已经赋值
|
|
BOOL bFirstWell = TRUE; //标志是否为最左边的井
|
|
BOOL bCalcWellDistance = FALSE; //标志是否井X坐标叠加孔间距,当最左井X小于2时
|
|
const int CONST_SURFACE_MIN_ELECTRODE_NUMBER = 7;
|
|
CString strSql, strWellCoor, strX, strY;
|
|
|
|
/*********************************在线获取电极坐标信息 begin****************************************/
|
|
//判断二维跨孔是否只有两口井,计算出孔间距
|
|
strSql.Empty();
|
|
strSql.Format(_T("select X from TTaskBindElecInfo where taskID='%s' and Z <> 0 group by X order by X"), szTdCN);
|
|
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
iWellCount = pRecTd->GetRecordCount();
|
|
if (iWellCount > 2)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("跨孔装置不支持两口井以上的dat格式导出."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get task information failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
|
{
|
|
fTemp = pRecTd->GetCollect(_T("X")).fltVal;
|
|
if (!bFlag)
|
|
{
|
|
fXStartPoint = fTemp;
|
|
bFlag = TRUE;
|
|
}
|
|
fWellDistance = abs(fWellDistance - fTemp);
|
|
pRecTd->MoveNext();
|
|
}
|
|
pRecTd->Close();
|
|
|
|
//判断是否有地表测线
|
|
strSql.Empty();
|
|
strSql.Format(_T("select ElectrodeID,X,Z from TTaskBindElecInfo where taskID='%s' and Z=0"), szTdCN);
|
|
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
int iElecCount = pRecTd->GetRecordCount();
|
|
if (iElecCount > 0)
|
|
{
|
|
//井地井类型 ,跟刘博确定,不存在地表电极个数小于孔间距/电极间距的情况,且两口井不会位于地表测线的两端,因此不需要考虑地表电极数小于7的情况和井位于布线两端的情况,直接从数据库读取电极坐标信息即可。
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(_T("Surface Electrodes"));
|
|
strSql.Format(_T("%d"), iElecCount);
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
|
|
//获取数据库地表电极
|
|
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
|
{
|
|
memset(&stElecCoordinates, 0, sizeof(stElecCoordinates));
|
|
|
|
stElecCoordinates.uiElecID = pRecTd->GetCollect(_T("ElectrodeID")).uintVal;
|
|
|
|
strX.Empty();
|
|
stElecCoordinates.fX = (float)pRecTd->GetCollect(_T("X")).fltVal;
|
|
strX.Format(_T("%.2f"), stElecCoordinates.fX);
|
|
|
|
strY.Empty();
|
|
stElecCoordinates.fZ = (float)pRecTd->GetCollect(_T("Z")).fltVal;
|
|
strY.Format(_T("%.2f"), stElecCoordinates.fZ);
|
|
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(strX);
|
|
saRecord.Add(strY);
|
|
pSaveInRes->AddElectrodeCoordinatesInfo(&saRecord);
|
|
|
|
mapElecCoordinates[stElecCoordinates.uiElecID] = stElecCoordinates;
|
|
|
|
pRecTd->MoveNext();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//有井下测线的前提下,跨孔没有地表测线,添加虚拟电极
|
|
if (iWellCount > 0)
|
|
{
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(_T("Surface Electrodes"));
|
|
int iWellElecCount = fWellDistance / atof(szEDistance);
|
|
int iAddElecCount = 0;
|
|
if (fXStartPoint < 2.00)
|
|
{
|
|
fXStartPoint = 2.00;
|
|
}
|
|
//如果2倍电极间距的电极数仍然小于7个电极数,那么直接用七个电极数生成
|
|
if (2 * iWellElecCount < CONST_SURFACE_MIN_ELECTRODE_NUMBER)
|
|
{
|
|
fXStartPoint = fXStartPoint - (CONST_SURFACE_MIN_ELECTRODE_NUMBER - iElecCount) / 2;
|
|
iAddElecCount = (CONST_SURFACE_MIN_ELECTRODE_NUMBER - iElecCount) / 2;
|
|
}
|
|
else
|
|
{
|
|
fXStartPoint = fXStartPoint - fWellDistance / 2;
|
|
iAddElecCount = iWellElecCount / 2;
|
|
}
|
|
strSql.Format(_T("%d"), iWellElecCount + 2 * iAddElecCount + 1);//两倍电极间距
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
|
|
strY.Format(_T("0.00"));
|
|
for (int i = 0; i <= iWellElecCount + 2 * iAddElecCount; i++)
|
|
{
|
|
strX.Empty();
|
|
strX.Format(_T("%.2f"), fXStartPoint + i*atof(szEDistance));
|
|
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(strX);
|
|
saRecord.Add(strY);
|
|
pSaveInRes->AddElectrodeCoordinatesInfo(&saRecord);
|
|
}
|
|
}
|
|
}
|
|
pRecTd->Close();
|
|
|
|
//根据X分辨几口井
|
|
strSql.Empty();
|
|
strSql.Format(_T("select X from TTaskBindElecInfo where taskID='%s' and Z <> 0 group by X order by X"), szTdCN);
|
|
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
UINT32 uiWellNumber = pRecTd->GetRecordCount();
|
|
if (uiWellNumber > 0)
|
|
{
|
|
saRecord.RemoveAll();
|
|
strSql.Empty();
|
|
strSql.Format(_T("Number of boreholes"));
|
|
saRecord.Add(strSql);
|
|
|
|
strSql.Empty();
|
|
strSql.Format(_T("%d"), uiWellNumber);
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
}
|
|
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
|
{
|
|
fX = pRecTd->GetCollect(_T("X")).fltVal;
|
|
strSql.Empty();
|
|
strSql.Format(_T("select ElectrodeID,X,Z from TTaskBindElecInfo where taskID='%s' and Z <> 0 and X = %f"), szTdCN, fX);
|
|
pRecTdCon->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
iElecCount = pRecTdCon->GetRecordCount();
|
|
if (iElecCount > 0)
|
|
{
|
|
saRecord.RemoveAll();
|
|
strSql.Empty();
|
|
strSql.Format(_T("Borehole %d Electrodes"), iWellIndex);
|
|
saRecord.Add(strSql);
|
|
|
|
strSql.Empty();
|
|
strSql.Format(_T("%d"), iElecCount);
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
}
|
|
if (bCalcWellDistance)
|
|
{
|
|
fX = 2.00 + fWellDistance;//2.00第一口井坐标,fWellDistance孔间距
|
|
}
|
|
|
|
if (fX < 2.0 && bFirstWell)
|
|
{
|
|
bFirstWell = FALSE;
|
|
bCalcWellDistance = TRUE;
|
|
fX = 2.00;
|
|
}
|
|
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
|
|
{
|
|
memset(&stElecCoordinates, 0, sizeof(STElectrodeCoordinates));
|
|
|
|
stElecCoordinates.uiElecID = pRecTdCon->GetCollect(_T("ElectrodeID")).uintVal;
|
|
|
|
strX.Empty();
|
|
//fTemp = (float)pRecTdCon->GetCollect(_T("X")).fltVal;
|
|
stElecCoordinates.fX = fX;
|
|
strX.Format(_T("%.2f"), fX);
|
|
|
|
strY.Empty();
|
|
stElecCoordinates.fZ = abs((float)pRecTdCon->GetCollect(_T("Z")).fltVal);
|
|
strY.Format(_T("%.2f"), stElecCoordinates.fZ);
|
|
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(strX);
|
|
saRecord.Add(strY);
|
|
|
|
//pSaveInRes->AddDateToFile(&saRecord);
|
|
pSaveInRes->AddElectrodeCoordinatesInfo(&saRecord);
|
|
mapElecCoordinates[stElecCoordinates.uiElecID] = stElecCoordinates;
|
|
|
|
pRecTdCon->MoveNext();
|
|
}
|
|
pRecTdCon->Close();
|
|
iWellIndex++;
|
|
pRecTd->MoveNext();
|
|
}
|
|
pRecTd->Close();
|
|
|
|
//写数据标题
|
|
/*saRecord.RemoveAll();
|
|
strSql.Empty();
|
|
strSql.Format(_T("Measured data"));
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
*/
|
|
/*********************************在线获取电极坐标信息 end****************************************/
|
|
|
|
|
|
/*********************************非在线(由主机新建的任务)获取电极坐标信息 begin****************************************/
|
|
if (mapElecCoordinates.size() <= 0)
|
|
{
|
|
iWellIndex = 1;
|
|
fX = 0.0, fTemp = 0.0, fWellDistance = 0.0;
|
|
fXStartPoint = 0.0; //地表测线X最小值起点
|
|
bFlag = FALSE; //标志是否已经赋值
|
|
bFirstWell = TRUE; //标志是否为最左边的井
|
|
bCalcWellDistance = FALSE; //标志是否井X坐标叠加孔间距,当最左井X小于2时
|
|
//const int CONST_SURFACE_MIN_ELECTRODE_NUMBER = 7;
|
|
//strSql, strWellCoor, strX, strY;
|
|
//判断二维跨孔是否只有两口井,计算出孔间距
|
|
strSql.Empty();
|
|
strSql.Format(_T("select X from TCoordinatesInfo where ScriptCN='%s' and Z <> 0 group by X order by X"), strSCCN);
|
|
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
iWellCount = pRecTd->GetRecordCount();
|
|
if (iWellCount > 2)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("跨孔装置不支持两口井以上的dat格式导出."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get task information failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
|
{
|
|
fTemp = pRecTd->GetCollect(_T("X")).fltVal;
|
|
if (!bFlag)
|
|
{
|
|
fXStartPoint = fTemp;
|
|
bFlag = TRUE;
|
|
}
|
|
fWellDistance = abs(fWellDistance - fTemp);
|
|
pRecTd->MoveNext();
|
|
}
|
|
pRecTd->Close();
|
|
|
|
//判断是否有地表测线
|
|
strSql.Empty();
|
|
strSql.Format(_T("select ElectrodeID,X,Z from TCoordinatesInfo where ScriptCN='%s' and Z=0"), strSCCN);
|
|
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
int iElecCount = pRecTd->GetRecordCount();
|
|
if (iElecCount > 0)
|
|
{
|
|
//井地井类型 ,跟刘博确定,不存在地表电极个数小于孔间距/电极间距的情况,且两口井不会位于地表测线的两端,因此不需要考虑地表电极数小于7的情况和井位于布线两端的情况,直接从数据库读取电极坐标信息即可。
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(_T("Surface Electrodes"));
|
|
strSql.Format(_T("%d"), iElecCount);
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
|
|
//获取数据库地表电极
|
|
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
|
{
|
|
memset(&stElecCoordinates, 0, sizeof(stElecCoordinates));
|
|
|
|
stElecCoordinates.uiElecID = pRecTd->GetCollect(_T("ElectrodeID")).uintVal;
|
|
|
|
strX.Empty();
|
|
stElecCoordinates.fX = (float)pRecTd->GetCollect(_T("X")).fltVal;
|
|
strX.Format(_T("%.2f"), stElecCoordinates.fX);
|
|
|
|
strY.Empty();
|
|
stElecCoordinates.fZ = (float)pRecTd->GetCollect(_T("Z")).fltVal;
|
|
strY.Format(_T("%.2f"), stElecCoordinates.fZ);
|
|
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(strX);
|
|
saRecord.Add(strY);
|
|
pSaveInRes->AddElectrodeCoordinatesInfo(&saRecord);
|
|
|
|
mapElecCoordinates[stElecCoordinates.uiElecID] = stElecCoordinates;
|
|
|
|
pRecTd->MoveNext();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (iWellCount > 0)
|
|
{
|
|
//跨孔没有地表测线,添加虚拟电极
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(_T("Surface Electrodes"));
|
|
int iWellElecCount = fWellDistance / atof(szEDistance);
|
|
int iAddElecCount = 0;
|
|
if (fXStartPoint < 2.00)
|
|
{
|
|
fXStartPoint = 2.00;
|
|
}
|
|
//如果2倍电极间距的电极数仍然小于7个电极数,那么直接用七个电极数生成
|
|
if (2 * iWellElecCount < CONST_SURFACE_MIN_ELECTRODE_NUMBER)
|
|
{
|
|
fXStartPoint = fXStartPoint - (CONST_SURFACE_MIN_ELECTRODE_NUMBER - iElecCount) / 2;
|
|
iAddElecCount = (CONST_SURFACE_MIN_ELECTRODE_NUMBER - iElecCount) / 2;
|
|
}
|
|
else
|
|
{
|
|
fXStartPoint = fXStartPoint - fWellDistance / 2;
|
|
iAddElecCount = iWellElecCount / 2;
|
|
}
|
|
strSql.Format(_T("%d"), iWellElecCount + 2 * iAddElecCount + 1);//两倍电极间距
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
|
|
strY.Format(_T("0.00"));
|
|
for (int i = 0; i <= iWellElecCount + 2 * iAddElecCount; i++)
|
|
{
|
|
strX.Empty();
|
|
strX.Format(_T("%.2f"), fXStartPoint + i*atof(szEDistance));
|
|
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(strX);
|
|
saRecord.Add(strY);
|
|
pSaveInRes->AddElectrodeCoordinatesInfo(&saRecord);
|
|
}
|
|
}
|
|
}
|
|
pRecTd->Close();
|
|
|
|
//根据X分辨几口井
|
|
strSql.Empty();
|
|
strSql.Format(_T("select X from TCoordinatesInfo where ScriptCN='%s' and Z <> 0 group by X order by X"), strSCCN);
|
|
pRecTd->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
UINT32 uiWellNumber = pRecTd->GetRecordCount();
|
|
if (uiWellNumber > 0)
|
|
{
|
|
saRecord.RemoveAll();
|
|
strSql.Empty();
|
|
strSql.Format(_T("Number of boreholes"));
|
|
saRecord.Add(strSql);
|
|
|
|
strSql.Empty();
|
|
strSql.Format(_T("%d"), uiWellNumber);
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
}
|
|
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
|
{
|
|
fX = pRecTd->GetCollect(_T("X")).fltVal;
|
|
strSql.Empty();
|
|
strSql.Format(_T("select ElectrodeID,X,Z from TCoordinatesInfo where ScriptCN='%s' and Z <> 0 and X = %f"), strSCCN, fX);
|
|
pRecTdCon->Open(strSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
iElecCount = pRecTdCon->GetRecordCount();
|
|
if (iElecCount > 0)
|
|
{
|
|
saRecord.RemoveAll();
|
|
strSql.Empty();
|
|
strSql.Format(_T("Borehole %d Electrodes"), iWellIndex);
|
|
saRecord.Add(strSql);
|
|
|
|
strSql.Empty();
|
|
strSql.Format(_T("%d"), iElecCount);
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
}
|
|
if (bCalcWellDistance)
|
|
{
|
|
fX = 2.00 + fWellDistance;//2.00第一口井坐标,fWellDistance孔间距
|
|
}
|
|
|
|
if (fX < 2.0 && bFirstWell)
|
|
{
|
|
bFirstWell = FALSE;
|
|
bCalcWellDistance = TRUE;
|
|
fX = 2.00;
|
|
}
|
|
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
|
|
{
|
|
memset(&stElecCoordinates, 0, sizeof(STElectrodeCoordinates));
|
|
|
|
stElecCoordinates.uiElecID = pRecTdCon->GetCollect(_T("ElectrodeID")).uintVal;
|
|
|
|
strX.Empty();
|
|
//fTemp = (float)pRecTdCon->GetCollect(_T("X")).fltVal;
|
|
stElecCoordinates.fX = fX;
|
|
strX.Format(_T("%.2f"), fX);
|
|
|
|
strY.Empty();
|
|
stElecCoordinates.fZ = abs((float)pRecTdCon->GetCollect(_T("Z")).fltVal);
|
|
strY.Format(_T("%.2f"), stElecCoordinates.fZ);
|
|
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(strX);
|
|
saRecord.Add(strY);
|
|
|
|
//pSaveInRes->AddDateToFile(&saRecord);
|
|
pSaveInRes->AddElectrodeCoordinatesInfo(&saRecord);
|
|
mapElecCoordinates[stElecCoordinates.uiElecID] = stElecCoordinates;
|
|
|
|
pRecTdCon->MoveNext();
|
|
}
|
|
pRecTdCon->Close();
|
|
iWellIndex++;
|
|
pRecTd->MoveNext();
|
|
}
|
|
pRecTd->Close();
|
|
}
|
|
/*********************************非在线(由主机新建的任务)获取电极坐标信息 end****************************************/
|
|
|
|
//写数据标题
|
|
saRecord.RemoveAll();
|
|
strSql.Empty();
|
|
strSql.Format(_T("Measured data"));
|
|
saRecord.Add(strSql);
|
|
pSaveInRes->AddElectrodeTitle(&saRecord);
|
|
}
|
|
|
|
//跨孔装置的strFormat仍然不改变,设置为2,其它的装置都为1
|
|
else if (AR_CROSS_HOLE_TYPE != atoi(szAr))
|
|
{
|
|
strFormat = _T("1");
|
|
}
|
|
|
|
if (AR_EDGE_GARDIENT == atoi(szAr)
|
|
|| AR_STRONG_GRADIENT == atoi(szAr)
|
|
/*|| AR_CROSS_HOLE_GEOMATIVE == atoi(szAr)
|
|
|| AR_CROSS_HOLE_GEOMATIVE_AM == atoi(szAr)*/)
|
|
{
|
|
saRecord.Add(_T("0"));
|
|
saRecord.Add(_T("Type of measurement(0=app.resistivity,1=resistance)"));
|
|
saRecord.Add(_T("0"));
|
|
}
|
|
|
|
if (!(AR_CROSS_HOLE_GEOMATIVE == atoi(szAr) || AR_CROSS_HOLE_GEOMATIVE_AM == atoi(szAr)))
|
|
{
|
|
saRecord.Add(szTPAmount);
|
|
saRecord.Add(strFormat);
|
|
saRecord.Add(szTType);
|
|
pSaveInRes->AddFileHeader(Res, atoi(szAr.GetBuffer(0)), &saRecord);
|
|
pSaveInRes->Init2DFileHeader(&saRecord);
|
|
}
|
|
|
|
|
|
if (AR_CROSS_HOLE_TYPE == atof(szAr))
|
|
{
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(_T("1"));
|
|
saRecord.Add(strEamount);
|
|
pSaveInRes->AddDateToFile(&saRecord);
|
|
}
|
|
int iC1,iC2,iP1,iP2;
|
|
int iMidEAmout = (atoi(strEamount))/2;
|
|
float fR0;
|
|
pRecTdCon->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
|
|
{
|
|
if (pRecTdCon->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
|
|
{
|
|
szR0.Empty();
|
|
fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
|
|
//szR0.Format(_T("%f"), abs(fR0));
|
|
szR0.Format(_T("%f"), fR0);
|
|
szA.Empty();
|
|
szA = (pRecTdCon->GetCollect(_T("C1")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("C1"));
|
|
szB.Empty();
|
|
szB = (pRecTdCon->GetCollect(_T("C2")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("C2"));
|
|
szM.Empty();
|
|
szM = (pRecTdCon->GetCollect(_T("P1")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("P1"));
|
|
szN.Empty();
|
|
szN = (pRecTdCon->GetCollect(_T("P2")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("P2"));
|
|
szV.Empty();
|
|
szV = (pRecTdCon->GetCollect(_T("V")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("V"));
|
|
szI.Empty();
|
|
szI = (pRecTdCon->GetCollect(_T("I")).vt == VT_NULL) ? _T("0") : (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("I"));
|
|
|
|
//非跨孔装置
|
|
if (!(AR_CROSS_HOLE_GEOMATIVE == atoi(szAr) || AR_CROSS_HOLE_GEOMATIVE_AM == atoi(szAr)))
|
|
{
|
|
if (AR_STRONG_GRADIENT == atoi(szAr))
|
|
{
|
|
szR0.Format(_T("%f"), abs(atof(szV) / atof(szI)));
|
|
}
|
|
if (bIsRealCustToCroHole)
|
|
{
|
|
// iC1 = CalcuCrossHolePoleID(atoi(szA), iLeftHole, 0);
|
|
// iC2 = CalcuCrossHolePoleID(atoi(szB), iRightHole, 1);
|
|
// iP1 = CalcuCrossHolePoleID(atoi(szM), iLeftHole, 0);
|
|
// iP2 = CalcuCrossHolePoleID(atoi(szN), iRightHole, 1);
|
|
int iLFlag, iRFlag;
|
|
if (iLeftHole <= iRightHole)
|
|
{
|
|
iLFlag = 0;
|
|
iRFlag = 1;
|
|
}
|
|
else
|
|
{
|
|
iLFlag = 1;
|
|
iRFlag = 0;
|
|
}
|
|
szA.Format(_T("%d"), CalcuCrossHolePoleID(atoi(szA), iLeftHole, iLFlag, iMidEAmout));
|
|
szB.Format(_T("%d"), CalcuCrossHolePoleID(atoi(szB), iRightHole, iRFlag, iMidEAmout));
|
|
szM.Format(_T("%d"), CalcuCrossHolePoleID(atoi(szM), iLeftHole, iLFlag, iMidEAmout));
|
|
szN.Format(_T("%d"), CalcuCrossHolePoleID(atoi(szN), iRightHole, iRFlag, iMidEAmout));
|
|
}
|
|
}
|
|
//跨孔装置
|
|
else
|
|
{
|
|
if (mapElecCoordinates.size() <= 0)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("导出dat文件没有电极坐标信息,请先从服务端下载数据"));
|
|
else
|
|
MessageBoxEx(NULL, _T("There is no electrode coordinate information in the exported dat file. Please download the data from the server first."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
//A坐标
|
|
map<UINT32, STElectrodeCoordinates>::iterator iterFind = mapElecCoordinates.find(atoi(szA));
|
|
if (iterFind != mapElecCoordinates.end())
|
|
{
|
|
szA.Empty();
|
|
szA.AppendFormat(_T("%.2f %.2f"), iterFind->second.fX,iterFind->second.fZ);
|
|
}
|
|
|
|
//B坐标
|
|
iterFind = mapElecCoordinates.find(atoi(szB));
|
|
if (iterFind != mapElecCoordinates.end())
|
|
{
|
|
szB.Empty();
|
|
szB.AppendFormat(_T("%.2f %.2f"), iterFind->second.fX, iterFind->second.fZ);
|
|
}
|
|
|
|
//M坐标
|
|
iterFind = mapElecCoordinates.find(atoi(szM));
|
|
if (iterFind != mapElecCoordinates.end())
|
|
{
|
|
szM.Empty();
|
|
szM.AppendFormat(_T("%.2f %.2f"), iterFind->second.fX, iterFind->second.fZ);
|
|
}
|
|
|
|
//N坐标
|
|
iterFind = mapElecCoordinates.find(atoi(szN));
|
|
if (iterFind != mapElecCoordinates.end())
|
|
{
|
|
szN.Empty();
|
|
szN.AppendFormat(_T("%.2f %.2f"), iterFind->second.fX, iterFind->second.fZ);
|
|
}
|
|
}
|
|
|
|
saRecord.RemoveAll();
|
|
saRecord.Add(szA);
|
|
saRecord.Add(szB);
|
|
saRecord.Add(szM);
|
|
saRecord.Add(szN);
|
|
saRecord.Add(szR0);
|
|
saRecord.Add(szV);
|
|
saRecord.Add(szI);
|
|
pSaveInRes->AddDateToFile(&saRecord);
|
|
}
|
|
pRecTdCon->MoveNext();
|
|
}
|
|
|
|
pRecTdCon->Close();
|
|
|
|
|
|
|
|
//////////////////////////deleted by lsq 20160713////////////////////////////////////////////
|
|
|
|
//地形文件的添加放到了工具栏中,所以这里就无需再加了
|
|
/*
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_CAPTION_0009);
|
|
if (szAr != "3") //微分类型无需添加地型文件
|
|
{
|
|
if (AfxMessageBox( szCaption, MB_YESNO) == IDYES )
|
|
{
|
|
COpTGDDlg* pOpTGDDlg = new COpTGDDlg();
|
|
|
|
pOpTGDDlg->Create(IDD_OP_TGD_C, AfxGetMainWnd());
|
|
|
|
this->InitialTGDDlg(pOpTGDDlg);
|
|
|
|
pOpTGDDlg->ShowWindow(SW_SHOW);
|
|
lRet = pOpTGDDlg->RunModalLoop(MLF_SHOWONIDLE);
|
|
|
|
if (RET_OK == lRet)
|
|
{
|
|
int nDisType = (int)pOpTGDDlg->m_cbDisType.GetItemData(pOpTGDDlg->m_cbDisType.GetCurSel());
|
|
|
|
int nStart = pOpTGDDlg->m_cbTGDSN.GetCurSel() + 1;
|
|
|
|
this->UpdataTopography(nDisType,nStart,pOpTGDDlg->m_tgdList);
|
|
|
|
pSaveInRes->m_nLandSign = nDisType;
|
|
pSaveInRes->m_nFirstPole = nStart;
|
|
|
|
iListIndex = (int)VAL_ZERO;
|
|
saRecord.RemoveAll();
|
|
|
|
while (iListIndex < pOpTGDDlg->m_tgdList.GetItemCount())
|
|
{
|
|
szDistance.Empty();
|
|
szDistance = pOpTGDDlg->m_tgdList.GetItemText(iListIndex, 1);
|
|
|
|
szElevation.Empty();
|
|
szElevation = pOpTGDDlg->m_tgdList.GetItemText(iListIndex, 2);
|
|
|
|
saRecord.Add(szDistance + _T(" ") + szElevation);
|
|
iListIndex ++;
|
|
}
|
|
pSaveInRes->WriteLandInform(&saRecord);
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
pSaveInRes->CloseFile();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CRsp2DTd::InitialTGDDlg(COpTGDDlg* pOpTGDDlg)
|
|
{
|
|
_RecordsetPtr pRecCM = NULL;
|
|
CString szSql = _T("");
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
pRecCM.CreateInstance(_uuidof(Recordset));
|
|
|
|
pOpTGDDlg->m_cbDisType.ResetContent();
|
|
|
|
iIndex = (int)VAL_ZERO;
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel,Cvalue from cm where Cname = 'Distance type' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
|
|
pRecCM->Open(szSql.AllocSysString(),_variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCM->adoEOF)
|
|
{
|
|
iIndex = pOpTGDDlg->m_cbDisType.AddString((LPCTSTR)(_bstr_t)pRecCM->GetCollect(_T("Clabel")));
|
|
pOpTGDDlg->m_cbDisType.SetItemData(iIndex, (DWORD)pRecCM->GetCollect(_T("Cvalue")).iVal);
|
|
pRecCM->MoveNext();
|
|
}
|
|
|
|
pRecCM->Close();
|
|
|
|
int nStart = 0;
|
|
int nDisType = 0;
|
|
CString szTmp = _T("");
|
|
|
|
if (this->GetTopography(&nDisType, &nStart, pOpTGDDlg->m_tgdList))
|
|
{
|
|
for (int n = 1; n < pOpTGDDlg->m_tgdList.GetItemCount() + 1; n++)
|
|
{
|
|
szTmp.Format("%d", n);
|
|
pOpTGDDlg->m_cbTGDSN.AddString(szTmp);
|
|
}
|
|
pOpTGDDlg->m_cbTGDSN.SetCurSel(nStart - 1);
|
|
pOpTGDDlg->m_cbDisType.SetCurSel(nDisType - 1);
|
|
}
|
|
}
|
|
|
|
void CRsp2DTd::ClearTdChaList()
|
|
{
|
|
CTdChannel* pTdChannel = NULL;
|
|
int iTdChannelIndex = (int)VAL_ZERO;
|
|
iTdChannelIndex = (int)VAL_ZERO;
|
|
|
|
while (iTdChannelIndex < this->m_tdChaList.GetCount())
|
|
{
|
|
pTdChannel = NULL;
|
|
pTdChannel = (CTdChannel *)this->m_tdChaList.GetAt(this->m_tdChaList.FindIndex(iTdChannelIndex));
|
|
pTdChannel->Clear2DSptRecList();
|
|
delete pTdChannel;
|
|
iTdChannelIndex++;
|
|
}
|
|
|
|
this->m_tdChaList.RemoveAll();
|
|
}
|
|
|
|
BOOL CRsp2DTd::SaveData()
|
|
{
|
|
CTdChannel* pTdChannel = NULL;
|
|
_RecordsetPtr pRecTd;
|
|
_CommandPtr pCmdIns;
|
|
CString szSql = _T("");
|
|
int iChIndex = (int)VAL_ZERO;
|
|
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
//int nPoleStep = atoi(this->m_szEDistance.GetBuffer(0));
|
|
float fPoleDistance = (float)atof(this->m_szEDistance.GetBuffer(0));
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into td(TDname,TDCN,Tlocation,DEID,DESN,TZID,SCID,SCCN,Sname,Stype,Ttype,Tmode,Eamount,TPamount,CHamount,N,TRwave,TRfrequency,Ifrequency,"
|
|
"SAfrequency,Clayout,Espace,Edistance,weather,WDIR,temperature,height,humidity,Cdate,Ctime,Tdate,Ttime,Rdirection,CRtime,PM,OP,QA) "
|
|
"values('%s','%s','%s',%u,'%s',%u,%u,'%s','%s',%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%.2f,%.2f,%d,%d,%.2f,%.2f,%.2f,#%s#,#%s#,#%s#,#%s#,%d,%d,'%s','%s','%s')"),
|
|
this->m_szTdName,
|
|
this->m_szTdCN,
|
|
this->m_szTLocation,
|
|
this->m_pDevice->m_dwID,
|
|
this->m_pDevice->m_szDevSN,
|
|
this->m_dwTzID,
|
|
this->m_dwSCID,
|
|
this->m_szSCCN,
|
|
this->m_szSName,
|
|
this->m_iSType,
|
|
this->m_iTType,
|
|
this->m_iTMode,
|
|
this->m_iEAmount,
|
|
this->m_iTPAmount,
|
|
this->m_iCHAmount,
|
|
this->m_iN,
|
|
this->m_iTRWave,
|
|
this->m_iTRFrequency,
|
|
this->m_iIFrequency,
|
|
this->m_iSAFrequency,
|
|
this->m_iCLayout,
|
|
this->m_fESpace,
|
|
fPoleDistance,
|
|
// this->m_szEDistance,
|
|
this->m_iWeather,
|
|
this->m_iWDIR,
|
|
this->m_fTemperature,
|
|
this->m_fHeight,
|
|
this->m_fHumidity,
|
|
this->m_szCDate,
|
|
this->m_szCTime,
|
|
this->m_szTDate,
|
|
this->m_szTTime,
|
|
this->m_iRDirection,
|
|
this->m_iCRtime,
|
|
this->m_szPM,
|
|
this->m_szOP,
|
|
this->m_szQA);
|
|
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
pRecTd->Open(_T("select max(ID) as ID from td"), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
this->m_dwID = (int)pRecTd->GetCollect(_T("ID")).ulVal;
|
|
}
|
|
pRecTd->Close();
|
|
|
|
iChIndex = (int)VAL_ZERO;
|
|
while (iChIndex < m_tdChaList.GetCount())
|
|
{
|
|
pTdChannel = NULL;
|
|
pTdChannel = (CTdChannel*)m_tdChaList.GetAt(m_tdChaList.FindIndex(iChIndex));
|
|
|
|
pTdChannel->SaveRsp2DTdData(m_dwID);
|
|
|
|
iChIndex++;
|
|
}
|
|
|
|
this->SaveGRDataToDB(m_dwID);
|
|
this->SaveOrgDataToDB(m_dwID);
|
|
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
catch(_com_error e)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(e.Description());
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
BOOL CRsp2DTd::LoadData(CLinkList<CMedium*>& m_medLinkList)
|
|
{
|
|
CTdChannel* pTdChannel = NULL;
|
|
DWORD dwSCID = (DWORD)VAL_ZERO;
|
|
DWORD dwMedHandle = (DWORD)VAL_ZERO;
|
|
|
|
int iEAmount = (int)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecTd;
|
|
_RecordsetPtr pRecCh;
|
|
_RecordsetPtr pRecTdCon;
|
|
|
|
CString szSql = _T("");
|
|
int iChIndex = (int)VAL_ZERO;
|
|
try
|
|
{
|
|
if ((int)VAL_ZERO == m_tdChaList.GetCount())
|
|
{
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
pRecCh.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select SCID,Eamount,InitiEamount, rect from td where ID = %u"), this->m_dwID);
|
|
// szSql.Format(_T("select SCID,Eamount, rect from td where ID = %u"), this->m_dwID);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
int iStartPole = 1, iEndPole = 1;
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
dwSCID = (DWORD)pRecTd->GetCollect(_T("SCID")).ulVal;
|
|
iEAmount = (int)pRecTd->GetCollect(_T("Eamount")).iVal;
|
|
CString strValidPole = (pRecTd->GetCollect(_T("rect")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("rect"));
|
|
CStringArray strArray;
|
|
strArray.RemoveAll();
|
|
if (!strValidPole.IsEmpty())
|
|
{
|
|
SplitterString(strArray, strValidPole, _T(","));
|
|
if (2 == strArray.GetSize())
|
|
{
|
|
iStartPole = atoi(strArray.GetAt(0));
|
|
iEndPole = atoi(strArray.GetAt(1));
|
|
if (iStartPole < 1 || iEndPole <= iStartPole)
|
|
{
|
|
CString strErr = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErr.Format(_T("解析孔信息错误.start_pole = %d, end_pole = %d"), iStartPole, iEndPole);
|
|
AfxMessageBox(strErr);
|
|
}
|
|
else
|
|
{
|
|
strErr.Format(_T("Parser pole inforamtion error.start_pole = %d, end_pole = %d"), iStartPole, iEndPole);
|
|
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_iStartPole = iStartPole;
|
|
m_iEndPole = iEndPole;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("解析器有效电极信息错误"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Parser valid pole inforamtion error."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
m_iStartPole = 1;
|
|
m_iEndPole = iEAmount;
|
|
}
|
|
//如果InitiEamount为空或者为零,则按照原来的电极个数进行获取
|
|
if (pRecTd->GetCollect(_T("InitiEamount")).vt != VT_NULL)
|
|
{
|
|
if (0 != pRecTd->GetCollect(_T("InitiEamount")).lVal)
|
|
{
|
|
iEAmount = (int)pRecTd->GetCollect(_T("InitiEamount")).iVal;
|
|
}
|
|
}
|
|
|
|
}
|
|
pRecTd->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select ID,ChNumber,AR from tdchannel where TDID = %u"), this->m_dwID);
|
|
pRecCh->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCh->adoEOF)
|
|
{
|
|
pTdChannel = new CTdChannel(dwSCID, (int)pRecCh->GetCollect(_T("ChNumber")).iVal, this->m_pConnection);
|
|
pTdChannel->m_dwID = (DWORD)pRecCh->GetCollect(_T("ID")).ulVal;
|
|
pTdChannel->m_iEAmount = iEAmount;
|
|
|
|
dwMedHandle = m_handleProcessor.GenerateHandle((int)pRecCh->GetCollect(_T("AR")).iVal, PZ_STYLE_MED_DEF);
|
|
pTdChannel->m_pMedium = m_medLinkList.Find(dwMedHandle);
|
|
|
|
if (TRUE == pTdChannel->LoadRsp2DTdData())
|
|
{
|
|
this->m_tdChaList.AddTail((void*)pTdChannel);
|
|
}
|
|
pRecCh->MoveNext();
|
|
}
|
|
pRecCh->Close();
|
|
}
|
|
}
|
|
catch(_com_error e)
|
|
{
|
|
CString strLog = _T("");
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strLog.Format(_T("加载数据错误. desc_msg = %s,error_msg = %s"), e.Description(), e.ErrorMessage());
|
|
AfxMessageBox(strLog);
|
|
}
|
|
else
|
|
{
|
|
strLog.Format(_T("Load data error. desc_msg = %s,error_msg = %s"), e.Description(), e.ErrorMessage());
|
|
MessageBoxEx(NULL, strLog , STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::DisplayGraph()
|
|
{
|
|
CString szSql = _T("");
|
|
_RecordsetPtr pRecTd = NULL;
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
szSql.Format(_T("select CRtime from td where ID = %u"), m_dwID);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
if ((long)VAL_ZERO == pRecTd->GetRecordCount())
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("获取任务信息失败."));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get task information failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
if (VT_NULL == pRecTd->GetCollect(_T("CRtime")).vt)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("让任务滚动时间失败。"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get rolling times of task failed."), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
int iRTime = pRecTd->GetCollect(_T("CRtime")).lVal;
|
|
// if (iRTime > 0)
|
|
// {
|
|
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// AfxMessageBox(_T("Don't support the graph of task with rolling along."));
|
|
// return FALSE;
|
|
// }
|
|
CDisp2DRSPGrapDlg* pDisp2DRSPGrapDlg = new CDisp2DRSPGrapDlg(this);
|
|
pDisp2DRSPGrapDlg->DoModal();
|
|
delete pDisp2DRSPGrapDlg;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::DisplayTPSplinesGraph(int iTSN)
|
|
{
|
|
((CTdChannel*)this->m_tdChaList.GetAt(this->m_tdChaList.FindIndex(0)))->GetTdRecord(iTSN)->DisplayRawDataSplines();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CRsp2DTd::GetTopography(int *f_disType ,int *f_start,CListCtrl &f_list)
|
|
{
|
|
_RecordsetPtr pRecTd = NULL;
|
|
|
|
CString szSql = _T("");
|
|
CString szTmp = _T("");
|
|
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select DType,StartNum,Distance,Elevation from t2dtg where TDID = %u"), this->m_dwID);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO == pRecTd->GetRecordCount())
|
|
return FALSE;
|
|
|
|
*f_disType = pRecTd->GetCollect(_T("DType")).iVal;
|
|
*f_start = pRecTd->GetCollect(_T("StartNum")).iVal;
|
|
|
|
int nId = 0;
|
|
while ((short)VAL_ZERO == pRecTd->adoEOF)
|
|
{
|
|
szTmp.Format("%d" , nId + 1);
|
|
f_list.InsertItem(nId,szTmp);
|
|
f_list.SetItemText(nId,1,(LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Distance")));
|
|
f_list.SetItemText(nId,2,(LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Elevation")));
|
|
|
|
nId++;
|
|
pRecTd->MoveNext();
|
|
}
|
|
|
|
pRecTd->Close();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
//DEL void CRsp2DTd::GetCrossHoleSurfaceElectrode(float fPoleDis, float fCrosshole, int nHoleElectrodeNum,CStringArray* strArray)
|
|
//DEL {
|
|
//DEL strArray->RemoveAll();
|
|
//DEL int nElectordeCnt = 7;
|
|
//DEL float fXPos = 0;
|
|
//DEL CString strInfo = _T("");
|
|
//DEL CString strText = _T("Surface electrode");
|
|
//DEL strArray->Add(strText);
|
|
//DEL float fElecPos[2];
|
|
//DEL
|
|
//DEL strInfo.Format(_T("%d"),nElectordeCnt);
|
|
//DEL strArray->Add(strInfo);
|
|
//DEL int nFirstRealElectIndex = nElectordeCnt/2;
|
|
//DEL int i = 0;
|
|
//DEL for (; i < nFirstRealElectIndex; i++)
|
|
//DEL {
|
|
//DEL fXPos = i*fPoleDis;
|
|
//DEL strInfo.Empty();
|
|
//DEL strInfo.Format(_T("%.1f, 0.0"),fXPos);
|
|
//DEL strArray->Add(strInfo);
|
|
//DEL }
|
|
//DEL fElecPos[0] = fXPos;
|
|
//DEL //添加两孔中间的虚拟电极
|
|
//DEL fXPos += fCrosshole*fPoleDis/2;
|
|
//DEL strInfo.Empty();
|
|
//DEL strInfo.Format(_T("%.1f, 0.0"),fXPos);
|
|
//DEL strArray->Add(strInfo);
|
|
//DEL
|
|
//DEL //第二个实际电极的位置
|
|
//DEL i = 0;
|
|
//DEL fXPos = nFirstRealElectIndex * fPoleDis + fCrosshole * fPoleDis;
|
|
//DEL fElecPos[1] = fXPos;
|
|
//DEL int nRemain = nElectordeCnt - nFirstRealElectIndex - 1;
|
|
//DEL for (; i < nRemain; i++)
|
|
//DEL {
|
|
//DEL fXPos += i*fPoleDis;
|
|
//DEL strInfo.Empty();
|
|
//DEL strInfo.Format(_T("%.1f, 0.0"),fXPos);
|
|
//DEL strArray->Add(strInfo);
|
|
//DEL }
|
|
//DEL
|
|
//DEL
|
|
//DEL int nHoleElecNumMid = nHoleElectrodeNum / 2;
|
|
//DEL i = 0;
|
|
//DEL float fZPos = 0;
|
|
//DEL for (; i < 2; i++)
|
|
//DEL {
|
|
//DEL //添加钻孔1的电极信息
|
|
//DEL strText.Empty();
|
|
//DEL strText.Format(_T("Drill hole %d"),i+1);
|
|
//DEL strArray->Add(strText);
|
|
//DEL for (int j = 0; j < nHoleElecNumMid; j++)
|
|
//DEL {
|
|
//DEL strInfo.Empty();
|
|
//DEL strInfo.Format(_T("%.1f, %.1f"), fElecPos[i], j*fPoleDis);
|
|
//DEL strArray->Add(strInfo);
|
|
//DEL }
|
|
//DEL }
|
|
//DEL }
|
|
|
|
void CRsp2DTd::UpdataTopography(int f_disType ,int f_start,CListCtrl &f_list)
|
|
{
|
|
_CommandPtr pRecTd = NULL;
|
|
_RecordsetPtr pRecSelect = NULL;
|
|
_CommandPtr pCmdIns = NULL;
|
|
|
|
CString szSql = _T("");
|
|
CString szTmp = _T("");
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
pRecTd.CreateInstance(_uuidof(Command));
|
|
pRecTd->ActiveConnection = m_pConnection;
|
|
|
|
pRecSelect.CreateInstance(_uuidof(Recordset));
|
|
|
|
|
|
szSql.Empty();
|
|
szSql.Format("select * from t2dtg where TDID = %u", this->m_dwID);
|
|
|
|
pRecSelect->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSelect->GetRecordCount())
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format("delete from t2dtg where TDID = %u", this->m_dwID);
|
|
|
|
//把旧数据都删掉
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
|
|
pRecSelect->Close();
|
|
|
|
CString szDistance = _T("");
|
|
CString szElevation = _T("");
|
|
|
|
for (int i = 0; i < f_list.GetItemCount(); i++)
|
|
{
|
|
szDistance = f_list.GetItemText(i,1);
|
|
szElevation = f_list.GetItemText(i, 2);
|
|
|
|
szSql.Empty();
|
|
szSql.Format("insert into t2dtg(TDID,DType,StartNum,Distance,Elevation) values(%u, %d, %d, %d, %d)",
|
|
this->m_dwID,
|
|
f_disType,
|
|
f_start,
|
|
atoi(szDistance.GetBuffer(0)),
|
|
atoi(szElevation.GetBuffer(0))
|
|
);
|
|
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
}
|
|
|
|
BOOL CRsp2DTd::Export2dDataToTxtBySort(CString strFileName, int iSortMethod)
|
|
{
|
|
COperTxtFile operTxtFile;
|
|
if (!operTxtFile.OpenFileforWrite(strFileName))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
_RecordsetPtr pRecConList = NULL;
|
|
|
|
|
|
pRecConList.CreateInstance(_uuidof(Recordset));
|
|
CString szSql = _T("");
|
|
CStringArray strArrTxt;
|
|
strArrTxt.RemoveAll();
|
|
strArrTxt.Add(_T("A(C1)"));
|
|
strArrTxt.Add(_T("B(C2)"));
|
|
strArrTxt.Add(_T("M(P1)"));
|
|
strArrTxt.Add(_T("N(P2)"));
|
|
|
|
strArrTxt.Add(_T("Stacking"));
|
|
strArrTxt.Add(_T("K"));
|
|
strArrTxt.Add(_T("V(mV)"));
|
|
strArrTxt.Add(_T("I(mA)"));
|
|
|
|
strArrTxt.Add(_T("R(Ohm)"));
|
|
strArrTxt.Add(_T("R0"));
|
|
strArrTxt.Add(_T("SP"));
|
|
strArrTxt.Add(_T("R0_RD"));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select C1,C2,P1,P2,N,K,V,I,R0,SP,R0_LC,M0_LC,Layer,AR from td2dcon a, tdchannel b where a.TCHID = b.ID and b.TDID = %u and a.bUse <> 0 order by a.TSN"), m_dwID);
|
|
try
|
|
{
|
|
pRecConList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
operTxtFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
if (!operTxtFile.WriteFileContent(strArrTxt))
|
|
{
|
|
operTxtFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
if (pRecConList->GetRecordCount() <= 0)
|
|
{
|
|
operTxtFile.CloseFile();
|
|
return TRUE;
|
|
}
|
|
|
|
CString strText = _T("");
|
|
float fR = 0;
|
|
int iDataIndex = 0;
|
|
int iAR = pRecConList->GetCollect(_T("AR")).iVal;
|
|
|
|
COperMediumPt operMedium(iAR);
|
|
if (!operMedium.InitiSortInfo(1))
|
|
{
|
|
operTxtFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
|
|
std::vector<StTdTaskComDataInfo> vtStTdTaskData;
|
|
vtStTdTaskData.clear();
|
|
int iSortIndex = 0;
|
|
while ((short)0 == pRecConList->adoEOF)
|
|
{
|
|
StTdTaskComDataInfo stTdTaskData;
|
|
stTdTaskData.iC1 = pRecConList->GetCollect(_T("C1")).iVal;
|
|
stTdTaskData.iC2 = pRecConList->GetCollect(_T("C2")).iVal;
|
|
stTdTaskData.iP1 = pRecConList->GetCollect(_T("P1")).iVal;
|
|
stTdTaskData.iP2 = pRecConList->GetCollect(_T("P2")).iVal;
|
|
stTdTaskData.iN = pRecConList->GetCollect(_T("N")).iVal;
|
|
stTdTaskData.fK = pRecConList->GetCollect(_T("K")).fltVal;
|
|
stTdTaskData.fV = pRecConList->GetCollect(_T("V")).fltVal;
|
|
stTdTaskData.fI = pRecConList->GetCollect(_T("I")).fltVal;
|
|
stTdTaskData.fR0 = pRecConList->GetCollect(_T("R0")).fltVal;
|
|
stTdTaskData.fSP = pRecConList->GetCollect(_T("SP")).fltVal;
|
|
stTdTaskData.fR0_LC = pRecConList->GetCollect(_T("R0_LC")).fltVal;
|
|
stTdTaskData.fM0_LC = pRecConList->GetCollect(_T("M0_LC")).fltVal;
|
|
|
|
vtStTdTaskData.push_back(stTdTaskData);
|
|
operMedium.AddSortPtInfo(stTdTaskData.iC1, stTdTaskData.iC2, stTdTaskData.iP1, stTdTaskData.iP2,
|
|
pRecConList->GetCollect(_T("Layer")).iVal, iSortIndex++);
|
|
pRecConList->MoveNext();
|
|
}
|
|
|
|
iSortIndex = operMedium.GetFirstSortID(1);
|
|
BOOL bRes = TRUE;
|
|
float fPtXPos = 0;
|
|
while(iSortIndex >= 0)
|
|
{
|
|
if (iSortIndex >= vtStTdTaskData.size())
|
|
{
|
|
CString strErr = _T("");
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strErr.Format(_T("数据索引混乱,data_index =%d,total_size=%d"), iSortIndex + 1, vtStTdTaskData.size());
|
|
AfxMessageBox(strErr);
|
|
}
|
|
else
|
|
{
|
|
strErr.Format(_T("Data index disorder,data_index = %d,total_size=%d"), iSortIndex + 1, vtStTdTaskData.size());
|
|
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
bRes = FALSE;
|
|
break;
|
|
}
|
|
|
|
if ((fPtXPos > EPSINON) && (operMedium.GetCurPtXPos() - fPtXPos > EPSINON))
|
|
{
|
|
//这里由于需要明确区分一次排序后的的点,以空一行来表示分开
|
|
operTxtFile.WriteEmptyRow();
|
|
}
|
|
fPtXPos = operMedium.GetCurPtXPos();
|
|
|
|
strArrTxt.RemoveAll();
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iC1);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iC2);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iP1);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iP2);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%d"), vtStTdTaskData[iSortIndex].iN);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fK);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fV);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fI);
|
|
strArrTxt.Add(strText);
|
|
|
|
fR = (fabsf(vtStTdTaskData[iSortIndex].fI) <= EPSINON) ? 0 : vtStTdTaskData[iSortIndex].fV/vtStTdTaskData[iSortIndex].fI;
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), fR);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fR0);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fSP);
|
|
strArrTxt.Add(strText);
|
|
|
|
strText.Empty();
|
|
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fR0_LC);
|
|
strArrTxt.Add(strText);
|
|
|
|
if (!operTxtFile.WriteFileContent(strArrTxt))
|
|
{
|
|
operTxtFile.CloseFile();
|
|
return FALSE;
|
|
}
|
|
iSortIndex = operMedium.GetNextSortID();
|
|
|
|
}
|
|
|
|
pRecConList->Close();
|
|
operTxtFile.CloseFile();
|
|
return bRes;
|
|
|
|
}
|