5033 lines
173 KiB
C++
5033 lines
173 KiB
C++
// Ipsp2DTd.cpp: implementation of the CIpsp2DTd class.
|
||
//
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
#include "geomative.h"
|
||
#include "Ipsp2DTd.h"
|
||
|
||
#include "TdChannel.h"
|
||
|
||
#include "opexec2drsptestsetdlg.h"
|
||
#include "excel.h"
|
||
#include "Ipsp2DTdRecord.h"
|
||
#include "OperTxtFile.h"
|
||
#include "OperMediumPt.h"
|
||
#ifdef _DEBUG
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[]=__FILE__;
|
||
#define new DEBUG_NEW
|
||
#endif
|
||
using namespace excel9;
|
||
extern int g_iLanguage;
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Construction/Destruction
|
||
//////////////////////////////////////////////////////////////////////
|
||
extern HHOOK hHook;
|
||
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
||
extern void get_fit_equation(double x[],double y[],int n,double a[],int m,double dt[]);
|
||
extern void get_integral_area(double x1, double x2, double a[],int m,double &dRes);
|
||
extern bool get_hl_by_bisection(double dLeft, double dRight, double dCoffient[], double dAverage,double dVdata,int m, double &dRes);
|
||
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
|
||
extern CString GetGrCodeText(int iCode);
|
||
extern CString GetExcelHeaderIndex(char chIndex, int index);
|
||
extern int g_UIOffset;
|
||
extern int g_iUILanguage;
|
||
extern CGeoMativeApp theApp;
|
||
|
||
CIpsp2DTd::CIpsp2DTd(DWORD dwID, _ConnectionPtr& pConnection):CTestingData(dwID, pConnection)
|
||
{
|
||
m_dwChID = 0;
|
||
|
||
}
|
||
|
||
CIpsp2DTd::~CIpsp2DTd()
|
||
{
|
||
|
||
}
|
||
|
||
bool CIpsp2DTd::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);
|
||
|
||
iRowIndex = 0;
|
||
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TDname")));
|
||
// tdDetailList.SetItemText(1, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tlocation")));
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (pRecTd->GetCollect(_T("DESN")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("DESN")));
|
||
// tdDetailList.SetItemText(2, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("SCCN")));
|
||
tdDetailList.SetItemText(iRowIndex++, 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(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
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(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
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(5, 1, (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())
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("MEname")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
pRecCm->Close();
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Eamount")));
|
||
|
||
//tdDetailList.SetItemText(iRowIndex++, 1, _T("zm ip2d"));
|
||
szSql.Empty();
|
||
szSql.Format(_T("select count(*) as TotalPoints from td%ddcon where TCHID = %d"),
|
||
pRecTd->GetCollect(_T("Stype")).vt == VT_NULL ? 1 : pRecTd->GetCollect(_T("Stype")).iVal + 1, m_dwID);
|
||
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecCm->GetRecordCount())
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("TotalPoints")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TPamount")));
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("CHamount")));
|
||
|
||
tdDetailList.SetItemText(iRowIndex++, 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(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
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(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
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(iRowIndex++, 1, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
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(iRowIndex++, 1, pRecCm->GetCollect(_T("Clabel")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
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(13, 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(13, 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())
|
||
{
|
||
CString strNewClayout = (pRecTd->GetCollect(_T("Clayout")).vt == VT_NULL) ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Clayout"));
|
||
int iCval = atoi(strNewClayout);
|
||
if (4 == iCval || 5 == iCval)
|
||
{
|
||
strNewClayout = _T("Conventional Mode");
|
||
tdDetailList.SetItemText(iRowIndex++, 1, strNewClayout);
|
||
}
|
||
else
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
// tdDetailList.SetItemText(16, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Espace")));
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (pRecTd->GetCollect(_T("Edistance")).vt == VT_NULL) ? _T("") : (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(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
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(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
||
}
|
||
else
|
||
{
|
||
tdDetailList.SetItemText(iRowIndex++, 1, _T(""));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
CString szDefault = _T("");
|
||
|
||
//szDefault = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("temperature"));
|
||
szDefault = (pRecTd->GetCollect(_T("temperature")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("temperature"));
|
||
|
||
if (szDefault == "-9999")//若为该值则不显示东西
|
||
{
|
||
szDefault = "";
|
||
}
|
||
|
||
tdDetailList.SetItemText(iRowIndex++, 1, szDefault);
|
||
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (pRecTd->GetCollect(_T("height")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("height")));
|
||
|
||
|
||
szDefault = (pRecTd->GetCollect(_T("humidity")).vt == VT_NULL)?_T(""):(LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("humidity"));
|
||
|
||
if (szDefault == "-9999")//若为该值则不显示东西
|
||
{
|
||
szDefault = "";
|
||
}
|
||
|
||
tdDetailList.SetItemText(iRowIndex++, 1, szDefault);
|
||
|
||
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Cdate")));
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Ctime")));
|
||
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (pRecTd->GetCollect(_T("Tdate")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Tdate")));
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (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)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(25, 1, (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("PM")));
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (pRecTd->GetCollect(_T("OP")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("OP")));
|
||
tdDetailList.SetItemText(iRowIndex++, 1, (pRecTd->GetCollect(_T("QA")).vt == VT_NULL) ? _T("") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("QA")));
|
||
}
|
||
|
||
pRecTd->Close();
|
||
return true;
|
||
}
|
||
|
||
bool CIpsp2DTd::ShowConList(CListCtrl &tdConList)
|
||
{
|
||
_RecordsetPtr pRecConList = NULL;
|
||
_RecordsetPtr pRecTd = NULL;
|
||
CString szSql;
|
||
|
||
int iIndex = (int)VAL_ZERO;
|
||
double dPeriod = 0;
|
||
pRecConList.CreateInstance(_uuidof(Recordset));
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
|
||
if (VAL_ZERO != tdConList.GetItemCount())
|
||
{
|
||
tdConList.DeleteAllItems();
|
||
}
|
||
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TRfrequency 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())
|
||
{
|
||
return false;
|
||
}
|
||
int nTmp = (int)pRecTd->GetCollect(_T("TRfrequency")).iVal;
|
||
dPeriod = GetCycle(nTmp);
|
||
szSql.Empty();
|
||
szSql.Format(_T("select 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"), m_dwID);
|
||
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());
|
||
pRecTd->Close();
|
||
pRecConList->Close();
|
||
return false;
|
||
}
|
||
CString strDBVal = _T("");
|
||
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);
|
||
|
||
strDBVal.Empty();
|
||
strDBVal.Format(_T("%f"),(float)pRecConList->GetCollect(_T("V")).fltVal);
|
||
tdConList.SetItemText(iIndex, 7, strDBVal);
|
||
|
||
strDBVal.Empty();
|
||
strDBVal.Format(_T("%f"),(float)pRecConList->GetCollect(_T("R0")).fltVal);
|
||
tdConList.SetItemText(iIndex, 8, strDBVal);
|
||
|
||
strDBVal.Empty();
|
||
strDBVal.Format(_T("%f"),(float)pRecConList->GetCollect(_T("SP")).fltVal);
|
||
tdConList.SetItemText(iIndex, 9, strDBVal);
|
||
|
||
tdConList.SetItemData(iIndex, (int)pRecConList->GetCollect(_T("TSN")).lVal);
|
||
|
||
// int nHLTime = 0;
|
||
// if (dPeriod > 0)
|
||
// {
|
||
// nHLTime = GetFitEquationInfo(pRecConList->GetCollect(_T("TSN")).lVal,dPeriod);
|
||
// }
|
||
// CString strHL =_T("");
|
||
// strHL.Format("%d", nHLTime);
|
||
// tdConList.SetItemText(iIndex, 10,strHL.GetBuffer(0));
|
||
iIndex++;
|
||
}
|
||
pRecConList->MoveNext();
|
||
}
|
||
pRecTd->Close();
|
||
pRecConList->Close();
|
||
return true;
|
||
}
|
||
|
||
int CIpsp2DTd::GetFitEquationInfo(int nTSN, double nPeriod)
|
||
{
|
||
//CIpsp2DTdRecord *pIP2DTdRecord(nTSN, this->m_pConnection); = new CIpsp2DTdRecord(dwChID, this->m_pConnection);
|
||
CIpsp2DTdRecord cIP2DTdRec(m_dwID, this->m_pConnection);
|
||
cIP2DTdRec.m_iTsn = nTSN;
|
||
cIP2DTdRec.LoadOrgData();
|
||
int nDataNum = atoi(cIP2DTdRec.m_saVRawData.GetAt(3).GetString());//GetBuffer(0));
|
||
double dSplit = nPeriod/(nDataNum-1);
|
||
nDataNum = nDataNum/4;
|
||
|
||
double dXDataArray[50],dYDataArray[50], dCoefficient1[50],dCoefficient2[50],dtInfo[50];
|
||
double dVData = 0, dHalfV1Data = 0, dHalfV2Data =0;
|
||
double dX1Average = 0,d2XAverage=0;
|
||
//获取第一次放电的多项式的值
|
||
memset(dXDataArray, 0, sizeof(dXDataArray));
|
||
memset(dYDataArray, 0, sizeof(dYDataArray));
|
||
memset(dCoefficient1, 0, sizeof(dCoefficient1));
|
||
memset(dtInfo, 0, sizeof(dtInfo));
|
||
dX1Average = 0;
|
||
int nIndex= 0;
|
||
for (; nIndex < nDataNum; nIndex++)
|
||
{
|
||
dXDataArray[nIndex] = nIndex * dSplit; //以放电的第一个点的位置为基准进行多项式的计算
|
||
dX1Average += dXDataArray[nIndex];
|
||
dYDataArray[nIndex] = atof(cIP2DTdRec.m_saVRawData.GetAt(4 + nDataNum + nIndex));
|
||
}
|
||
dX1Average = dX1Average / nDataNum;
|
||
dVData = 0;
|
||
for (nIndex = 0; nIndex < 3; nIndex++)
|
||
{
|
||
dVData += atof(cIP2DTdRec.m_saVRawData.GetAt(3 + nDataNum - nIndex).GetString());//GetBuffer(0));
|
||
}
|
||
dVData = dVData/3;
|
||
get_fit_equation(dXDataArray, dYDataArray, nDataNum, dCoefficient1, nDataNum-1, dtInfo);
|
||
|
||
//获取第一次放电的半衰时
|
||
double dHL1Time = 0;
|
||
get_hl_by_bisection(1,nPeriod/4-1,dCoefficient1,dX1Average,dVData/2,nDataNum-1,dHL1Time);
|
||
//获取第而次放电的多项式的值
|
||
memset(dXDataArray, 0, sizeof(dXDataArray));
|
||
memset(dYDataArray, 0, sizeof(dYDataArray));
|
||
memset(dCoefficient2, 0, sizeof(dCoefficient1));
|
||
memset(dtInfo, 0, sizeof(dtInfo));
|
||
d2XAverage = 0;
|
||
//获取采样时窗
|
||
for (nIndex= 0; nIndex < nDataNum; nIndex++)
|
||
{
|
||
dXDataArray[nIndex] = nIndex * dSplit; //以放电的第一个点的位置为基准进行多项式的计算
|
||
d2XAverage += dXDataArray[nIndex];
|
||
dYDataArray[nIndex] = atof(cIP2DTdRec.m_saVRawData.GetAt(4 + nDataNum*3 + nIndex));
|
||
}
|
||
d2XAverage = d2XAverage/nDataNum;
|
||
dVData = 0;
|
||
for (nIndex = 0; nIndex < 3; nIndex++)
|
||
{
|
||
dVData += atof(cIP2DTdRec.m_saVRawData.GetAt(3 + 3 * nDataNum - nIndex).GetString());//GetBuffer(0));
|
||
}
|
||
dVData = dVData/3;
|
||
//计算第二段的多项式
|
||
double dHL2Time = 0;
|
||
get_fit_equation(dXDataArray, dYDataArray, nDataNum, dCoefficient2, nDataNum-1, dtInfo);
|
||
get_hl_by_bisection(1,nPeriod/(4*nDataNum)-1,dCoefficient2,d2XAverage,dVData/2,nDataNum-1,dHL2Time);
|
||
return (dHL1Time+dHL2Time)/2;
|
||
}
|
||
|
||
bool CIpsp2DTd::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, StatusCode,")
|
||
_T(" 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 CIpsp2DTd::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 CIpsp2DTd::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);
|
||
|
||
if( !pComApp->CreateDispatch(_T("Excel.Application"), NULL) )
|
||
{
|
||
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("不能创建excel应用"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Can't build excel application!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return FALSE;
|
||
}
|
||
|
||
comBooks = pComApp->GetWorkbooks();
|
||
comBook = comBooks.Add(covOptional);
|
||
|
||
comSheets = comBook.GetSheets();
|
||
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);
|
||
// comSheet03.Delete();
|
||
// 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->ReleaseDispatch();
|
||
if (pComApp != NULL)
|
||
{
|
||
delete pComApp;
|
||
pComApp = NULL;
|
||
}
|
||
// }
|
||
// else
|
||
// {
|
||
// return FALSE;
|
||
// }
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::DisplayGraph()
|
||
{
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::DisplayTPSplinesGraph(int iTSN)
|
||
{
|
||
((CTdChannel*)this->m_tdChaList.GetAt(this->m_tdChaList.FindIndex(0)))->GetTdRecord(iTSN)->DisplayRawDataSplines();
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::SaveData()
|
||
{
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::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;
|
||
|
||
if ((int)VAL_ZERO == m_tdChaList.GetCount())
|
||
{
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
pRecCh.CreateInstance(_uuidof(Recordset));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select SCID,Eamount 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())
|
||
{
|
||
dwSCID = (DWORD)pRecTd->GetCollect(_T("SCID")).ulVal;
|
||
iEAmount = (int)pRecTd->GetCollect(_T("Eamount")).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->LoadIpsp2DTdData())
|
||
{
|
||
this->m_tdChaList.AddTail((void*)pTdChannel);
|
||
}
|
||
|
||
pRecCh->MoveNext();
|
||
}
|
||
|
||
pRecCh->Close();
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::ShowTimeWindow(CListCtrl &tdConList, int iTsn)
|
||
{
|
||
tdConList.DeleteAllItems();
|
||
CreateWindowsTime();
|
||
//时窗所需参数---------------------------
|
||
int nTRwave = 0;//测试模式(发射波形)
|
||
int nTcycle = 0;//发射周期
|
||
int nSample = 0;//采样频率
|
||
int nInteration = 0;//迭代次数
|
||
int nindustrial = 0;//工业频率
|
||
CString M0;//时窗值
|
||
//--------------------
|
||
|
||
DWORD dwChID = 0;
|
||
CString szSql = _T("");
|
||
CString szMST = _T("");
|
||
CString szMTW = _T("");
|
||
CString szVrawdata = _T("");
|
||
CStringArray szOrgArray; //保存原始数据
|
||
|
||
_RecordsetPtr pRecTdTW = NULL;
|
||
_RecordsetPtr pRecRawData = NULL;
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_RecordsetPtr pRecCh = NULL;
|
||
|
||
pRecTdTW.CreateInstance(_uuidof(Recordset));
|
||
pRecRawData.CreateInstance(_uuidof(Recordset));
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
pRecCh.CreateInstance(_uuidof(Recordset));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TRwave,TRfrequency,SAfrequency,N,Ifrequency 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())
|
||
{
|
||
//时窗需要---------------
|
||
nTRwave = pRecTd->GetCollect(_T("TRwave")).iVal;
|
||
nTcycle = pRecTd->GetCollect(_T("TRfrequency")).iVal;
|
||
nSample = pRecTd->GetCollect(_T("SAfrequency")).iVal;
|
||
nInteration = pRecTd->GetCollect(_T("N")).iVal;
|
||
nindustrial = pRecTd->GetCollect(_T("Ifrequency")).iVal;
|
||
//----------------------------------
|
||
}
|
||
pRecTd->Close();
|
||
|
||
|
||
_WinTimeList _WinList;
|
||
memset(&_WinList, 0, sizeof(_WinTimeList));
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select M0ST,M0TW,M1ST,M1TW,M2ST,M2TW,M3ST,M3TW,M4ST,M4TW,M5ST,M5TW,M6ST,M6TW,M7ST,M7TW,M8ST,M8TW,M9ST,M9TW from ac where TDID = %u"), this->m_dwID);
|
||
pRecTdTW->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
int nTmpWTStart=0, nTmpWTWidth = 0;
|
||
|
||
for (int n = 0; n < 10; n++)
|
||
{
|
||
szMST.Format("M%dST", n);
|
||
szMTW.Format("M%dTW", n);
|
||
nTmpWTStart = (int)pRecTdTW->GetCollect(szMST.GetBuffer(0)).iVal;
|
||
nTmpWTWidth = (int)pRecTdTW->GetCollect(szMTW.GetBuffer(0)).iVal;
|
||
if (0 == nTmpWTWidth)
|
||
{
|
||
break;
|
||
}
|
||
|
||
_WinList.timeWinList[n].wintime_StartTime = nTmpWTStart;
|
||
_WinList.timeWinList[n].wintime_width = nTmpWTWidth;
|
||
_WinList.ListLength++;
|
||
}
|
||
pRecTdTW->Close();
|
||
m_waveCount->windowList[0] = _WinList;
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ID 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;
|
||
}
|
||
pRecCh->Close();
|
||
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select Vrawdata from td2dcon where TCHID = %u and TSN = %d"), dwChID, iTsn);
|
||
|
||
pRecRawData->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if (0 != pRecRawData->GetRecordCount())
|
||
{
|
||
szVrawdata.Empty();
|
||
szVrawdata = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Vrawdata"));
|
||
pRecRawData->Close();
|
||
}
|
||
|
||
GetORGCStringToArray(szVrawdata,&szOrgArray);
|
||
|
||
try
|
||
{
|
||
// this->CalculateTimeWindows(_WinList,&szOrgArray, nTRwave,nTcycle,nSample,nInteration,nindustrial);
|
||
this->CalculateTWInfo(&szOrgArray, nTcycle);
|
||
}
|
||
catch (...)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
CString szStart = _T("");
|
||
CString szWidth = _T("");
|
||
CString szV2 = _T("");
|
||
CString szETA = _T("");
|
||
CString szM = _T("");
|
||
CString szIndex = _T("");
|
||
//显示第一次放电的时窗信息
|
||
int iIndex = 0;
|
||
for (iIndex = 0; iIndex < this->m_waveCount->windowList[0].ListLength;iIndex++)
|
||
{
|
||
szIndex.Format("M%d", iIndex);
|
||
szStart.Format("%d", this->m_waveCount->windowList[0].timeWinList[iIndex].wintime_StartTime);
|
||
szWidth.Format("%d", this->m_waveCount->windowList[0].timeWinList[iIndex].wintime_width);
|
||
szV2.Format("%.3f", (fabs(m_waveCount->windowList[0].timeWinList[iIndex].wintime_V2)+fabs(m_waveCount->windowList[1].timeWinList[iIndex].wintime_V2))/2);
|
||
szETA.Format("%.3f",(fabs(m_waveCount->windowList[0].timeWinList[iIndex].wintime_ETA)+fabs(m_waveCount->windowList[1].timeWinList[iIndex].wintime_ETA))/2);
|
||
szM.Format("%.3f", (fabs(m_waveCount->windowList[0].timeWinList[iIndex].wintime_M)+fabs(m_waveCount->windowList[1].timeWinList[iIndex].wintime_M))/2);
|
||
|
||
tdConList.InsertItem(iIndex, szIndex);
|
||
tdConList.SetItemText(iIndex, 1, szStart);
|
||
tdConList.SetItemText(iIndex, 2, szWidth);
|
||
tdConList.SetItemText(iIndex, 3, szV2);
|
||
tdConList.SetItemText(iIndex, 4, szETA);
|
||
tdConList.SetItemText(iIndex, 5, szM);
|
||
|
||
//填充第一次放电
|
||
szV2.Empty();
|
||
szETA.Empty();
|
||
szM.Empty();
|
||
szV2.Format("%.3f", this->m_waveCount->windowList[0].timeWinList[iIndex].wintime_V2);
|
||
szETA.Format("%.3f",this->m_waveCount->windowList[0].timeWinList[iIndex].wintime_ETA);
|
||
szM.Format("%.3f", this->m_waveCount->windowList[0].timeWinList[iIndex].wintime_M);
|
||
tdConList.SetItemText(iIndex, 6, szV2);
|
||
tdConList.SetItemText(iIndex, 7, szETA);
|
||
tdConList.SetItemText(iIndex, 8, szM);
|
||
|
||
//填充第二次放电
|
||
szV2.Empty();
|
||
szETA.Empty();
|
||
szM.Empty();
|
||
szV2.Format("%.3f", this->m_waveCount->windowList[1].timeWinList[iIndex].wintime_V2);
|
||
szETA.Format("%.3f",this->m_waveCount->windowList[1].timeWinList[iIndex].wintime_ETA);
|
||
szM.Format("%.3f", this->m_waveCount->windowList[1].timeWinList[iIndex].wintime_M);
|
||
tdConList.SetItemText(iIndex, 9, szV2);
|
||
tdConList.SetItemText(iIndex, 10, szETA);
|
||
tdConList.SetItemText(iIndex, 11, szM);
|
||
|
||
|
||
}
|
||
// //显示第二次放电的时窗信息
|
||
// int nInsIndex = 0;
|
||
// for ( iIndex = 0; iIndex < this->m_waveCount->windowList[1].ListLength;iIndex++)
|
||
// {
|
||
// nInsIndex = iIndex + this->m_waveCount->windowList[0].ListLength;
|
||
// szIndex.Format("M%d", nInsIndex);
|
||
// szStart.Format("%d", this->m_waveCount->windowList[1].timeWinList[iIndex].wintime_StartTime);
|
||
// szWidth.Format("%d", this->m_waveCount->windowList[1].timeWinList[iIndex].wintime_width);
|
||
// szV2.Format("%.3f", this->m_waveCount->windowList[1].timeWinList[iIndex].wintime_V2);
|
||
// szETA.Format("%.3f",this->m_waveCount->windowList[1].timeWinList[iIndex].wintime_ETA);
|
||
// szM.Format("%.3f", this->m_waveCount->windowList[1].timeWinList[iIndex].wintime_M);
|
||
//
|
||
//
|
||
// tdConList.InsertItem(nInsIndex, szIndex);
|
||
// tdConList.SetItemText(nInsIndex, 1, szStart);
|
||
// tdConList.SetItemText(nInsIndex, 2, szWidth);
|
||
// tdConList.SetItemText(nInsIndex, 3, szV2);
|
||
// tdConList.SetItemText(nInsIndex, 4, szETA);
|
||
// tdConList.SetItemText(nInsIndex, 5, szM);
|
||
// }
|
||
|
||
this->FreeWindowsTime();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::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));
|
||
|
||
// comCols = comRange.GetEntireColumn();
|
||
// comCols.AutoFit();
|
||
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("F%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strOMVal1));
|
||
// comCols = comRange.GetEntireColumn();
|
||
// comCols.AutoFit();
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("G%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strStatus1));
|
||
// comCols = comRange.GetEntireColumn();
|
||
// comCols.AutoFit();
|
||
|
||
pRecGrList->MoveNext();
|
||
}
|
||
|
||
pRecGrList->Close();
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::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 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));
|
||
|
||
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")));
|
||
CString strNewClayout = (pRecTd->GetCollect(_T("Clayout")).vt == VT_NULL) ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Clayout"));
|
||
int iCval = atoi(strNewClayout);
|
||
if (4 == iCval || 5 == iCval)
|
||
{
|
||
strNewClayout = _T("Conventional Mode");
|
||
comRange.SetValue2(COleVariant(strNewClayout));
|
||
}
|
||
else
|
||
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((pRecTd->GetCollect(_T("Edistance")).vt == VT_NULL)?_T(""):(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"))));
|
||
|
||
comCols = comRange.GetEntireColumn();
|
||
comCols.AutoFit();
|
||
}
|
||
|
||
pRecTd->Close();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::SaveTdConToExcelFileBySort(_Worksheet *const pComSheet, int iSortMethod)
|
||
{
|
||
CString szSql = _T("");
|
||
szSql.Format(_T("select ID,AR from tdchannel where TDID = %u"),m_dwID);
|
||
_RecordsetPtr pRecTdChan = NULL;
|
||
pRecTdChan.CreateInstance(_uuidof(Recordset));
|
||
pRecTdChan->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if (pRecTdChan->GetRecordCount() < 1)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("获取AR信息失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Get AR infomation failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
pRecTdChan->Close();
|
||
return FALSE;
|
||
}
|
||
int iAR = pRecTdChan->GetCollect(_T("AR")).iVal;
|
||
int iTdChannelID = pRecTdChan->GetCollect(_T("ID")).lVal;
|
||
pRecTdChan->Close();
|
||
COperMediumPt operMedium(iAR);
|
||
if (!operMedium.InitiSortInfo(1))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
Range comRange;
|
||
excel9::Font comFont;
|
||
Range comCols;
|
||
|
||
_RecordsetPtr pRecConList = NULL;
|
||
_RecordsetPtr pRecTdAttr = NULL;
|
||
|
||
CString szRow = _T("");
|
||
|
||
int iIndex = (int)0;
|
||
CString strText = _T("");
|
||
|
||
iIndex = 1;
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("A%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("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("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("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("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));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("I%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("J%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("SP")));
|
||
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
pRecConList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdAttr.CreateInstance(_uuidof(Recordset));
|
||
bool bAddIpIndex = false;
|
||
int iTWCnt = 0;
|
||
CString strTW = _T("");
|
||
char chRDStart = 'K';
|
||
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select max(TWCNT) as MAX_TWCNT from td_spc_attr where TCHID in (select ID from tdchannel where TDID = %u order by TCHID)"),m_dwID);
|
||
pRecTdAttr->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
szSql.Empty();
|
||
if ((long)VAL_ZERO != pRecTdAttr->GetRecordCount())
|
||
{
|
||
//在Excel中先加入Thl,D,r
|
||
bAddIpIndex = true;
|
||
szRow.Empty();
|
||
szRow.Format(_T("K%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("Thl")));
|
||
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("D")));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("M%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("r")));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
char chCol = 'N';
|
||
|
||
iTWCnt = pRecTdAttr->GetCollect(_T("MAX_TWCNT")).lVal;
|
||
CString strField = _T("tb.THL as THL, tb.D as D, tb.r as r,tb.TWCNT as TWCNT");
|
||
int i = 0;
|
||
char chFlag;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入η时窗列
|
||
strTW.Empty();
|
||
szRow.Empty();
|
||
strTW.Format(_T("η%d"),i);
|
||
szRow = GetExcelHeaderIndex(chCol + i, iIndex);
|
||
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strTW));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
strTW.Empty();
|
||
strTW.Format(_T(",tb.TW%dIndex as TW%dIndex"),i, i);
|
||
strField += strTW;
|
||
}
|
||
//在这里由于M和η的列数相等
|
||
chCol = chCol + iTWCnt;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入M时窗列
|
||
strTW.Empty();
|
||
szRow.Empty();
|
||
strTW.Format(_T("M%d"),i);
|
||
chFlag = chCol + i;
|
||
szRow = GetExcelHeaderIndex(chCol + i, iIndex);
|
||
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strTW));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
}
|
||
chRDStart = chCol + i;
|
||
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.N as N, ta.K as K, ta.I as I, ta.V as V, ta.R0 as R0, ta.SP as SP, ")
|
||
_T("ta.Layer as Layer,%s,ta.R0_LC as R0_LC, ta.M0_LC as M0_LC from td2dcon ta, td_spc_attr tb where ta.TCHID = %d and ta.bUse <> 0 ")
|
||
_T("and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN order by ta.TSN"),strField, iTdChannelID);
|
||
}
|
||
else
|
||
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,R0_LC,M0_LC,Layer from td2dcon where TCHID = %d and bUse <> 0 order by TSN"), iTdChannelID);
|
||
|
||
pRecTdAttr->Close();
|
||
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());
|
||
}
|
||
//计算离差的位置信息
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
char chRDIndex = chRDStart + k;
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chRDIndex, iIndex);
|
||
|
||
CString strRD = (k != 0) ? _T("M0_RD") : _T("R0_RD");
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strRD));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
}
|
||
|
||
std::vector<StTdTaskIPDataInfo> vtStTdTaskData;
|
||
vtStTdTaskData.clear();
|
||
bool bIsErrShow = false;
|
||
int iSortIndex = 0;
|
||
while ((short)0 == pRecConList->adoEOF)
|
||
{
|
||
StTdTaskIPDataInfo 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;
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
stTdTaskData.stTdTimeData.fThl = pRecConList->GetCollect(_T("THL")).fltVal;
|
||
stTdTaskData.stTdTimeData.fD= pRecConList->GetCollect(_T("D")).fltVal;
|
||
stTdTaskData.stTdTimeData.fr = pRecConList->GetCollect(_T("r")).fltVal;
|
||
stTdTaskData.stTdTimeData.iTimeWinCnt = pRecConList->GetCollect(_T("TWCNT")).lVal;
|
||
|
||
CStringArray strIndexArr;
|
||
CString strMVal = _T("");
|
||
int iTWIndex= 0;
|
||
for (iTWIndex= 0; iTWIndex < stTdTaskData.stTdTimeData.iTimeWinCnt ; iTWIndex++)
|
||
{
|
||
//在excel中加入时窗列
|
||
strIndexArr.RemoveAll();
|
||
strText.Empty();
|
||
strMVal.Empty();
|
||
strTW.Empty();
|
||
strTW.Format(_T("TW%dIndex"),iTWIndex);
|
||
strText = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_variant_t(strTW));
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("解析时窗下标错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Parser time window index error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
stTdTaskData.stTdTimeData.fM[iTWIndex] = -1;
|
||
stTdTaskData.stTdTimeData.fEta[iTWIndex] = -1;
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
stTdTaskData.stTdTimeData.fEta[iTWIndex] = atof(strText);
|
||
stTdTaskData.stTdTimeData.fM[iTWIndex] = atof(strMVal);
|
||
|
||
}
|
||
}
|
||
}
|
||
vtStTdTaskData.push_back(stTdTaskData);
|
||
operMedium.AddSortPtInfo(stTdTaskData.iC1, stTdTaskData.iC2, stTdTaskData.iP1, stTdTaskData.iP2,
|
||
pRecConList->GetCollect(_T("Layer")).iVal, iSortIndex++);
|
||
pRecConList->MoveNext();
|
||
}
|
||
pRecConList->Close();
|
||
iSortIndex = operMedium.GetFirstSortID(iSortMethod);
|
||
BOOL bRes = TRUE;
|
||
|
||
int iDataSize = vtStTdTaskData.size();
|
||
float fPtXPos = 0;
|
||
while(iSortIndex >= 0)
|
||
{
|
||
if (iSortIndex >= iDataSize)
|
||
{
|
||
CString strErr = _T("");
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strErr.Format(_T("保存excel数据混乱,data_index = %d,total_size=%d"), iSortIndex + 1, iDataSize);
|
||
AfxMessageBox(strErr);
|
||
}
|
||
else
|
||
{
|
||
strErr.Format(_T("Data index disorder in save excel,data_index = %d,total_size=%d"), iSortIndex + 1, iDataSize);
|
||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
bRes = FALSE;
|
||
break;
|
||
}
|
||
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));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("I%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("J%d"), iIndex);
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fSP);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
szRow.Empty();
|
||
szRow.Format(_T("K%d"), iIndex);
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fThl);
|
||
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].stTdTimeData.fD);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("M%d"), iIndex);
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fr);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
char chCol = 'N';
|
||
for (int iTWIndex= 0; iTWIndex < vtStTdTaskData[iSortIndex].stTdTimeData.iTimeWinCnt; iTWIndex++)
|
||
{
|
||
//写入ETA值
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chCol+iTWIndex, iIndex);
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fEta[iTWIndex]);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
//写入M值
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chCol+vtStTdTaskData[iSortIndex].stTdTimeData.iTimeWinCnt+iTWIndex, iIndex);
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fM[iTWIndex]);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
}
|
||
}
|
||
|
||
//计算离差的位置信息
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
char chRDIndex = chRDStart + k;
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chRDIndex, iIndex);
|
||
strText.Empty();
|
||
float fVal = (k != 0) ? vtStTdTaskData[iSortIndex].fM0_LC : vtStTdTaskData[iSortIndex].fR0_LC;
|
||
strText.Format(_T("%f%%"),fVal);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
}
|
||
iSortIndex = operMedium.GetNextSortID();
|
||
}
|
||
|
||
return bRes;
|
||
}
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//在这里调用SAFEARRAY来得到数据库GetRows(-1)里面所有的数据,但是在调用释放
|
||
//SafeArrayDestroy()进行释放的时候,内存是没有被释放干净,导致多次操作之后,线程的堆栈卡住
|
||
//具体原因需要更进一步分析,但是由于时间紧急还是先使用老方式容器来获得数据库的内容,
|
||
|
||
/*const int iDivm = 2;//二维数组中Bound[0]是列,Bound[1]是行
|
||
SAFEARRAY* Saf;//安全数组
|
||
SAFEARRAYBOUND Bound[iDivm];
|
||
Bound[0].lLbound = 0;
|
||
Bound[0].cElements = pRecConList->GetFields()->Count;
|
||
Bound[1].lLbound = 0;
|
||
Bound[1].cElements = pRecConList->GetRecordCount();
|
||
Saf = SafeArrayCreate(VT_VARIANT, iDivm, Bound);
|
||
_variant_t vartemp;
|
||
vartemp.vt = VT_ARRAY|VT_UI2;
|
||
vartemp.parray = Saf;
|
||
vartemp = pRecConList->GetRows;
|
||
*/
|
||
//////////////////////////////////////////////////////////////////////////
|
||
/*
|
||
BOOL CIpsp2DTd::SaveTdConToExcelFileBySort(_Worksheet *const pComSheet, int iSortMethod)
|
||
{
|
||
CString szSql = _T("");
|
||
szSql.Format(_T("select ID,AR from tdchannel where TDID = %u order by TCHID"),m_dwID);
|
||
_RecordsetPtr pRecTdChan = NULL;
|
||
pRecTdChan.CreateInstance(_uuidof(Recordset));
|
||
pRecTdChan->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if (pRecTdChan->GetRecordCount() < 1)
|
||
{
|
||
AfxMessageBox(_T("Get Ar infomation failed"));
|
||
pRecTdChan->Close();
|
||
return FALSE;
|
||
}
|
||
int iAR = pRecTdChan->GetCollect(_T("AR")).iVal;
|
||
int iTdChannelID = pRecTdChan->GetCollect(_T("ID")).lVal;
|
||
pRecTdChan->Close();
|
||
COperMediumPt operMedium(iAR);
|
||
if (!operMedium.InitiSortInfo(1))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
Range comRange;
|
||
Font comFont;
|
||
Range comCols;
|
||
|
||
_RecordsetPtr pRecConList = NULL;
|
||
_RecordsetPtr pRecTdAttr = NULL;
|
||
|
||
CString szRow = _T("");
|
||
|
||
int iIndex = (int)0;
|
||
CString strText = _T("");
|
||
|
||
iIndex = 1;
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("A%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("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("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("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("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));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("I%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("J%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("SP")));
|
||
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
pRecConList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdAttr.CreateInstance(_uuidof(Recordset));
|
||
bool bAddIpIndex = false;
|
||
int iTWCnt = 0;
|
||
CString strTW = _T("");
|
||
char chRDStart = 'K';
|
||
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select max(TWCNT) as MAX_TWCNT from td_spc_attr where TCHID in (select ID from tdchannel where TDID = %u order by TCHID)"),m_dwID);
|
||
pRecTdAttr->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
szSql.Empty();
|
||
if ((long)VAL_ZERO != pRecTdAttr->GetRecordCount())
|
||
{
|
||
//在Excel中先加入Thl,D,r
|
||
bAddIpIndex = true;
|
||
szRow.Empty();
|
||
szRow.Format(_T("K%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("Thl")));
|
||
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("D")));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("M%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("r")));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
char chCol = 'N';
|
||
|
||
iTWCnt = pRecTdAttr->GetCollect(_T("MAX_TWCNT")).lVal;
|
||
CString strField = _T("tb.THL as THL, tb.D as D, tb.r as r,tb.TWCNT as TWCNT");
|
||
int i = 0;
|
||
char chFlag;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入η时窗列
|
||
strTW.Empty();
|
||
szRow.Empty();
|
||
strTW.Format(_T("η%d"),i);
|
||
szRow = GetExcelHeaderIndex(chCol + i, iIndex);
|
||
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strTW));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
strTW.Empty();
|
||
strTW.Format(_T(",tb.TW%dIndex as TW%dIndex"),i, i);
|
||
strField += strTW;
|
||
}
|
||
//在这里由于M和η的列数相等
|
||
chCol = chCol + iTWCnt;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入M时窗列
|
||
strTW.Empty();
|
||
szRow.Empty();
|
||
strTW.Format(_T("M%d"),i);
|
||
chFlag = chCol + i;
|
||
szRow = GetExcelHeaderIndex(chCol + i, iIndex);
|
||
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strTW));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
}
|
||
chRDStart = chCol + i;
|
||
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.N as N, ta.K as K, ta.I as I, ta.V as V, ta.R0 as R0, ta.SP as SP, ")
|
||
_T("ta.Layer as Layer,%s,ta.R0_LC as R0_LC, ta.M0_LC as M0_LC from td2dcon ta, td_spc_attr tb where ta.TCHID = %d and ta.bUse <> 0 ")
|
||
_T("and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN order by ta.TSN"),strField, iTdChannelID);
|
||
}
|
||
else
|
||
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,R0_LC,M0_LC,Layer from td2dcon where TCHID = %d and bUse <> 0 order by TSN"), iTdChannelID);
|
||
|
||
pRecTdAttr->Close();
|
||
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());
|
||
}
|
||
//计算离差的位置信息
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
char chRDIndex = chRDStart + k;
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chRDIndex, iIndex);
|
||
|
||
CString strRD = (k != 0) ? _T("M0_RD") : _T("R0_RD");
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strRD));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
}
|
||
|
||
//将数据库的内容拷贝到安全流数组中去
|
||
const int iDivm = 2;//二维数组中Bound[0]是列,Bound[1]是行
|
||
SAFEARRAY* Saf;//安全数组
|
||
SAFEARRAYBOUND Bound[iDivm];
|
||
Bound[0].lLbound = 0;
|
||
Bound[0].cElements = pRecConList->GetFields()->Count;
|
||
Bound[1].lLbound = 0;
|
||
Bound[1].cElements = pRecConList->GetRecordCount();
|
||
Saf = SafeArrayCreate(VT_VARIANT, iDivm, Bound);
|
||
_variant_t vartemp;
|
||
vartemp.vt = VT_ARRAY|VT_UI2;
|
||
vartemp.parray = Saf;
|
||
vartemp = pRecConList->GetRows(-1);
|
||
|
||
//填充排序数组
|
||
pRecConList->MoveFirst();
|
||
int iSortIndex = 0;
|
||
bool bIsErrShow = false;
|
||
while ((short)0 == pRecConList->adoEOF)
|
||
{
|
||
operMedium.AddSortPtInfo(pRecConList->GetCollect(_T("C1")).iVal, pRecConList->GetCollect(_T("C2")).iVal,
|
||
pRecConList->GetCollect(_T("P1")).iVal, pRecConList->GetCollect(_T("P2")).iVal,
|
||
pRecConList->GetCollect(_T("Layer")).iVal, iSortIndex++);
|
||
pRecConList->MoveNext();
|
||
}
|
||
|
||
int iSortIndex = operMedium.GetFirstSortID(iSortMethod);
|
||
BOOL bRes = TRUE;
|
||
long lArrIndex = {0};
|
||
_variant_t vtTest;
|
||
CStringArray strIndexArr;
|
||
CStringArray strArrMVal;
|
||
bool bIsErrShow = false;
|
||
while(iSortIndex >= 0)
|
||
{
|
||
if (iSortIndex >= Bound[1].cElements)
|
||
{
|
||
CString strErr = _T("");
|
||
strErr.Format(_T("data index disorder in save excel,data_index = %d,total_size=%d"),iSortIndex+1, Bound[1].cElements);
|
||
AfxMessageBox(strErr);
|
||
bRes = FALSE;
|
||
break;
|
||
}
|
||
char chIndex = 'A';
|
||
iIndex++;
|
||
int iUnUseCol = 0, iSigTWTCnt = 0;
|
||
for (int i = 0; i < Bound[0].cElements; i++)
|
||
{
|
||
lArrIndex[0] = i;
|
||
lArrIndex[1] = iSortIndex;
|
||
if (FAILED(SafeArrayGetElement(vartemp.parray, lArrIndex, &vtTest)))
|
||
{
|
||
AfxMessageBox(_T("SafeArrayGetElement error"));
|
||
break;
|
||
}
|
||
//C1,C2,P1,P2,N
|
||
if (i < 5)
|
||
{
|
||
szRow.Empty();
|
||
szRow.Format(_T("%c%d"),chIndex+i, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant((LPCTSTR)(_bstr_t)vtTest));
|
||
}
|
||
//从K到r,中间忽略掉Layer
|
||
else if (i < 14)
|
||
{
|
||
//如果没有时窗
|
||
if (!bAddIpIndex)
|
||
{
|
||
strText.Empty();
|
||
strText.Format(_T("%f"),vtTest.fltVal);
|
||
if (10 == i || 11 == i)
|
||
{
|
||
strText += _T("%%");
|
||
}
|
||
szRow.Empty();
|
||
szRow.Format(_T("%c%d"),chIndex+i, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
}
|
||
else
|
||
{
|
||
//在存在时窗的忽略掉Layer
|
||
if (10 == i)
|
||
{
|
||
iUnUseCol++;
|
||
continue;
|
||
}
|
||
strText.Empty();
|
||
strText.Format(_T("%f"),vtTest.fltVal);
|
||
if (10 == i || 11 == i)
|
||
{
|
||
strText += _T("%%");
|
||
}
|
||
szRow.Empty();
|
||
szRow.Format(_T("%c%d"),chIndex+i-iUnUseCol, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
}
|
||
}
|
||
//取出TWCNT字段的值,并
|
||
else if (14 == i)
|
||
{
|
||
iUnUseCol++;
|
||
iSigTWTCnt = vtTest.iVal;
|
||
}
|
||
//开始填充时窗的信息
|
||
else
|
||
{
|
||
chIndex = 'N';
|
||
CStringArray strIndexArr;
|
||
CString strMVal = _T("");
|
||
for (int iTWIndex= 0; iTWIndex < iSigTWTCnt; iTWIndex++)
|
||
{
|
||
//在excel中加入时窗列
|
||
strIndexArr.RemoveAll();
|
||
strText.Empty();
|
||
strMVal.Empty();
|
||
strTW.Empty();
|
||
strTW.Format(_T("TW%dIndex"),iTWIndex);
|
||
strText = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_variant_t(strTW));
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
AfxMessageBox(_T("parser time window index error!"));
|
||
}
|
||
strText = _T("");
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
|
||
}
|
||
//写入ETA值
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chCol+iTWIndex, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
//写入M值
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chCol+nSigTWTCnt+iTWIndex, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strMVal));
|
||
}
|
||
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
else if (i >= 16)
|
||
{
|
||
//TWCNT
|
||
if (16 == i)
|
||
{
|
||
nSigTWTCnt = vtTest.lVal;
|
||
}
|
||
else
|
||
{
|
||
//从17到17+nSigTWTCnt
|
||
if (i < 17+nSigTWTCnt)
|
||
{
|
||
strIndexArr.RemoveAll();
|
||
strText = (LPCTSTR)(_bstr_t)vtTest;
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
AfxMessageBox(_T("parser time window index error!"));
|
||
}
|
||
strText = _T("error");
|
||
strMVal = _T("error");
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
}
|
||
strArrTxt.Add(strText);
|
||
strArrMVal.Add(strText);
|
||
}
|
||
//从17+nSigTWTCnt到17+2*nSigTWTCnt
|
||
else if (i < 17+2*nSigTWTCnt)
|
||
{
|
||
strArrTxt.Add(strArrMVal.GetAt(i-17-nSigTWTCnt));
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
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));
|
||
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();
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("I%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("J%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("SP")).fltVal);
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
szRow.Empty();
|
||
szRow.Format(_T("K%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("THL")).fltVal);
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("L%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("D")).fltVal);
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("M%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("r")).fltVal);
|
||
comRange.SetValue2(COleVariant(strText));
|
||
char chCol = 'N';
|
||
CStringArray strIndexArr;
|
||
int nSigTWTCnt = pRecConList->GetCollect(_T("TWCNT")).lVal;
|
||
CString strMVal = _T("");
|
||
for (int iTWIndex= 0; iTWIndex < nSigTWTCnt; iTWIndex++)
|
||
{
|
||
//在excel中加入时窗列
|
||
strIndexArr.RemoveAll();
|
||
strText.Empty();
|
||
strMVal.Empty();
|
||
strTW.Empty();
|
||
strTW.Format(_T("TW%dIndex"),iTWIndex);
|
||
strText = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_variant_t(strTW));
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
AfxMessageBox(_T("parser time window index error!"));
|
||
}
|
||
strText = _T("");
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
|
||
}
|
||
//写入ETA值
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chCol+iTWIndex, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
//写入M值
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chCol+nSigTWTCnt+iTWIndex, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strMVal));
|
||
}
|
||
}
|
||
|
||
//计算离差的位置信息
|
||
CString strRDVal;
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
char chRDIndex = chRDStart + k;
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chRDIndex, iIndex);
|
||
CString strRDIndex = (k != 0) ? _T("M0_LC") : _T("R0_LC");
|
||
strRDVal.Empty();
|
||
strRDVal.Format(_T("%f%%"),pRecConList->GetCollect(_variant_t(strRDIndex)).fltVal);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strRDVal));
|
||
|
||
}
|
||
|
||
comCols = comRange.GetEntireColumn();
|
||
comCols.AutoFit();
|
||
}
|
||
|
||
|
||
pRecConList->MoveNext();
|
||
}
|
||
|
||
pRecConList->Close();
|
||
|
||
return bRes;
|
||
}
|
||
*/
|
||
BOOL CIpsp2DTd::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("获取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;
|
||
_RecordsetPtr pRecTdAttr = NULL;
|
||
|
||
CString szRow = _T("");
|
||
|
||
int iIndex = (int)0;
|
||
CString strText = _T("");
|
||
|
||
iIndex = 1;
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("A%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("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("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("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("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));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("I%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("J%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("SP")));
|
||
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
pRecConList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdAttr.CreateInstance(_uuidof(Recordset));
|
||
bool bAddIpIndex = false;
|
||
int iTWCnt = 0;
|
||
CString strTW = _T("");
|
||
char chRDStart = 'K';
|
||
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select max(TWCNT) as MAX_TWCNT from td_spc_attr where TCHID in (select ID from tdchannel where TDID = %u order by TCHID)"),m_dwID);
|
||
pRecTdAttr->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
szSql.Empty();
|
||
if ((long)VAL_ZERO != pRecTdAttr->GetRecordCount())
|
||
{
|
||
//在Excel中先加入Thl,D,r
|
||
bAddIpIndex = true;
|
||
szRow.Empty();
|
||
szRow.Format(_T("K%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("Thl")));
|
||
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("D")));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("M%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(_T("r")));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
char chCol = 'N';
|
||
|
||
iTWCnt = pRecTdAttr->GetCollect(_T("MAX_TWCNT")).lVal;
|
||
CString strField = _T("tb.THL as THL, tb.D as D, tb.r as r,tb.TWCNT as TWCNT");
|
||
int i = 0;
|
||
char chFlag;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入η时窗列
|
||
strTW.Empty();
|
||
szRow.Empty();
|
||
strTW.Format(_T("η%d"),i);
|
||
szRow = GetExcelHeaderIndex(chCol + i, iIndex);
|
||
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strTW));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
|
||
strTW.Empty();
|
||
strTW.Format(_T(",tb.TW%dIndex as TW%dIndex"),i, i);
|
||
strField += strTW;
|
||
}
|
||
//在这里由于M和η的列数相等
|
||
chCol = chCol + iTWCnt;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入M时窗列
|
||
strTW.Empty();
|
||
szRow.Empty();
|
||
strTW.Format(_T("M%d"),i);
|
||
chFlag = chCol + i;
|
||
szRow = GetExcelHeaderIndex(chCol + i, iIndex);
|
||
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strTW));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
}
|
||
chRDStart = chCol + i;
|
||
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.N as N, ta.K as K, ta.I as I, ta.V as V, ta.R0 as R0, ta.SP as SP, ")
|
||
_T("ta.bUse as bUse,ta.R0_LC as R0_LC, ta.M0_LC as M0_LC, %s from td2dcon ta, td_spc_attr tb where ta.TCHID in (select ID from tdchannel where TDID = %u order by ta.TCHID) ")
|
||
_T("and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN order by ta.TSN"),strField, m_dwID);
|
||
}
|
||
else
|
||
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);
|
||
|
||
pRecTdAttr->Close();
|
||
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());
|
||
}
|
||
//计算离差的位置信息
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
char chRDIndex = chRDStart + k;
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chRDIndex, iIndex);
|
||
|
||
CString strRD = (k != 0) ? _T("M0_RD") : _T("R0_RD");
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strRD));
|
||
comFont = comRange.GetFont();
|
||
comFont.SetBold(COleVariant((short)TRUE));
|
||
}
|
||
bool bIsErrShow = false;
|
||
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));
|
||
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();
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("I%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("J%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("SP")).fltVal);
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
szRow.Empty();
|
||
szRow.Format(_T("K%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("THL")).fltVal);
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("L%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("D")).fltVal);
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
szRow.Empty();
|
||
szRow.Format(_T("M%d"), iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("r")).fltVal);
|
||
comRange.SetValue2(COleVariant(strText));
|
||
char chCol = 'N';
|
||
CStringArray strIndexArr;
|
||
int nSigTWTCnt = pRecConList->GetCollect(_T("TWCNT")).lVal;
|
||
CString strMVal = _T("");
|
||
for (int iTWIndex= 0; iTWIndex < nSigTWTCnt; iTWIndex++)
|
||
{
|
||
//在excel中加入时窗列
|
||
strIndexArr.RemoveAll();
|
||
strText.Empty();
|
||
strMVal.Empty();
|
||
strTW.Empty();
|
||
strTW.Format(_T("TW%dIndex"),iTWIndex);
|
||
strText = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_variant_t(strTW));
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("解析时窗索引错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Parser time window index error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
strText = _T("");
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
|
||
}
|
||
//写入ETA值
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chCol+iTWIndex, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strText));
|
||
|
||
//写入M值
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chCol+nSigTWTCnt+iTWIndex, iIndex);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strMVal));
|
||
}
|
||
}
|
||
|
||
//计算离差的位置信息
|
||
CString strRDVal;
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
char chRDIndex = chRDStart + k;
|
||
szRow.Empty();
|
||
szRow = GetExcelHeaderIndex(chRDIndex, iIndex);
|
||
CString strRDIndex = (k != 0) ? _T("M0_LC") : _T("R0_LC");
|
||
strRDVal.Empty();
|
||
strRDVal.Format(_T("%f%%"),pRecConList->GetCollect(_variant_t(strRDIndex)).fltVal);
|
||
comRange = pComSheet->GetRange(COleVariant(szRow),COleVariant(szRow));
|
||
comRange.SetValue2(COleVariant(strRDVal));
|
||
|
||
}
|
||
|
||
comCols = comRange.GetEntireColumn();
|
||
comCols.AutoFit();
|
||
}
|
||
|
||
|
||
pRecConList->MoveNext();
|
||
}
|
||
|
||
pRecConList->Close();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
BOOL CIpsp2DTd::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();
|
||
}
|
||
|
||
pRecGrList->Close();
|
||
return TRUE;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::SaveTdHeadToCsvFile(FILE* pFile)
|
||
{
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_RecordsetPtr pRecTdHead = NULL;
|
||
_RecordsetPtr pRecDev = NULL;
|
||
_RecordsetPtr pRecPara = NULL;
|
||
_RecordsetPtr pRecCm = NULL;
|
||
|
||
CString szSql;
|
||
CString szLabel;
|
||
|
||
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;
|
||
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(','));
|
||
|
||
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())
|
||
{
|
||
CString strNewClayout = (pRecTd->GetCollect(_T("Clayout")).vt == VT_NULL) ? _T("-1") : (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Clayout"));
|
||
int iCval = atoi(strNewClayout);
|
||
if (4 == iCval || 5 == iCval)
|
||
{
|
||
strNewClayout = _T("Conventional Mode");
|
||
arrHead[i++] += strNewClayout;
|
||
}
|
||
else
|
||
arrHead[i++] += (((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel"))));
|
||
}
|
||
pRecCm->Close();
|
||
|
||
arrHead[i++] += (((pRecTd->GetCollect(_T("Edistance")).vt == VT_NULL) ? _T("") : (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"))));
|
||
}
|
||
|
||
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 CIpsp2DTd::SaveTdConToCsvFileBySort(FILE* pFile, int iSortMethod)
|
||
{
|
||
CString szSql = _T("");
|
||
szSql.Format(_T("select ID,AR from tdchannel where TDID = %u"), m_dwID);
|
||
_RecordsetPtr pRecTdChan = NULL;
|
||
pRecTdChan.CreateInstance(_uuidof(Recordset));
|
||
pRecTdChan->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if (pRecTdChan->GetRecordCount() < 1)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("获取AR信息失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Get AR infomation failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
pRecTdChan->Close();
|
||
return FALSE;
|
||
}
|
||
int iAR = pRecTdChan->GetCollect(_T("AR")).iVal;
|
||
int iTdChannelID = pRecTdChan->GetCollect(_T("ID")).lVal;
|
||
pRecTdChan->Close();
|
||
COperMediumPt operMedium(iAR);
|
||
if (!operMedium.InitiSortInfo(1))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
_RecordsetPtr pRecConList = NULL;
|
||
_RecordsetPtr pRecTdAttr = NULL;
|
||
|
||
CString szRow = _T("");
|
||
|
||
int iIndex = (int)0;
|
||
CString strText = _T("");
|
||
|
||
iIndex = 1;
|
||
|
||
szRow.Empty();
|
||
szRow += ((_T("C2"))); szRow += ',';
|
||
|
||
szRow += ((_T("C2"))); szRow += ',';
|
||
|
||
szRow += ((_T("P1"))); szRow += ',';
|
||
|
||
szRow += ((_T("P2"))); szRow += ',';
|
||
|
||
szRow += ((_T("Stacking"))); szRow += ',';
|
||
|
||
szRow += ((_T("K"))); szRow += ',';
|
||
|
||
szRow += ((_T("I(mA)"))); szRow += ',';
|
||
|
||
szRow += ((_T("V(mV)"))); szRow += ',';
|
||
|
||
szRow += ((_T("R0"))); szRow += ',';
|
||
|
||
szRow += ((_T("SP"))); szRow += ',';
|
||
|
||
pRecConList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdAttr.CreateInstance(_uuidof(Recordset));
|
||
bool bAddIpIndex = false;
|
||
int iTWCnt = 0;
|
||
CString strTW = _T("");
|
||
char chRDStart = 'K';
|
||
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select max(TWCNT) as MAX_TWCNT from td_spc_attr where TCHID in (select ID from tdchannel where TDID = %u order by TCHID)"), m_dwID);
|
||
pRecTdAttr->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
szSql.Empty();
|
||
if ((long)VAL_ZERO != pRecTdAttr->GetRecordCount())
|
||
{
|
||
|
||
//在Excel中先加入Thl,D,r
|
||
bAddIpIndex = true;
|
||
szRow += ((_T("Thl"))); szRow += ',';
|
||
szRow += ((_T("D"))); szRow += ',';
|
||
szRow += ((_T("r"))); szRow += ',';
|
||
|
||
iTWCnt = pRecTdAttr->GetCollect(_T("MAX_TWCNT")).lVal;
|
||
CString strField = _T("tb.THL as THL, tb.D as D, tb.r as r,tb.TWCNT as TWCNT");
|
||
int i = 0;
|
||
char chFlag;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入η时窗列
|
||
strTW.Empty();
|
||
strTW.Format(_T("η%d"), i);
|
||
szRow += strTW; szRow += ',';
|
||
|
||
strTW.Empty();
|
||
strTW.Format(_T(",tb.TW%dIndex as TW%dIndex"), i, i);
|
||
strField += strTW;
|
||
}
|
||
//在这里由于M和η的列数相等
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入M时窗列
|
||
strTW.Empty();
|
||
strTW.Format(_T("M%d"), i);
|
||
szRow += strTW; szRow += ',';
|
||
}
|
||
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.N as N, ta.K as K, ta.I as I, ta.V as V, ta.R0 as R0, ta.SP as SP, ")
|
||
_T("ta.Layer as Layer,%s,ta.R0_LC as R0_LC, ta.M0_LC as M0_LC from td2dcon ta, td_spc_attr tb where ta.TCHID = %d and ta.bUse <> 0 ")
|
||
_T("and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN order by ta.TSN"), strField, iTdChannelID);
|
||
}
|
||
else
|
||
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,R0_LC,M0_LC,Layer from td2dcon where TCHID = %d and bUse <> 0 order by TSN"), iTdChannelID);
|
||
|
||
pRecTdAttr->Close();
|
||
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());
|
||
}
|
||
//计算离差的位置信息
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
CString strRD = (k != 0) ? _T("M0_RD") : _T("R0_RD");
|
||
szRow += strRD; szRow += ',';
|
||
}
|
||
|
||
szRow += "\n";
|
||
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
||
|
||
std::vector<StTdTaskIPDataInfo> vtStTdTaskData;
|
||
vtStTdTaskData.clear();
|
||
bool bIsErrShow = false;
|
||
int iSortIndex = 0;
|
||
while ((short)0 == pRecConList->adoEOF)
|
||
{
|
||
StTdTaskIPDataInfo 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;
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
stTdTaskData.stTdTimeData.fThl = pRecConList->GetCollect(_T("THL")).fltVal;
|
||
stTdTaskData.stTdTimeData.fD = pRecConList->GetCollect(_T("D")).fltVal;
|
||
stTdTaskData.stTdTimeData.fr = pRecConList->GetCollect(_T("r")).fltVal;
|
||
stTdTaskData.stTdTimeData.iTimeWinCnt = pRecConList->GetCollect(_T("TWCNT")).lVal;
|
||
|
||
CStringArray strIndexArr;
|
||
CString strMVal = _T("");
|
||
int iTWIndex = 0;
|
||
for (iTWIndex = 0; iTWIndex < stTdTaskData.stTdTimeData.iTimeWinCnt; iTWIndex++)
|
||
{
|
||
//在excel中加入时窗列
|
||
strIndexArr.RemoveAll();
|
||
strText.Empty();
|
||
strMVal.Empty();
|
||
strTW.Empty();
|
||
strTW.Format(_T("TW%dIndex"), iTWIndex);
|
||
strText = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_variant_t(strTW));
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("解析时窗下标错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Parser time window index error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
stTdTaskData.stTdTimeData.fM[iTWIndex] = -1;
|
||
stTdTaskData.stTdTimeData.fEta[iTWIndex] = -1;
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
stTdTaskData.stTdTimeData.fEta[iTWIndex] = atof(strText);
|
||
stTdTaskData.stTdTimeData.fM[iTWIndex] = atof(strMVal);
|
||
|
||
}
|
||
}
|
||
}
|
||
vtStTdTaskData.push_back(stTdTaskData);
|
||
operMedium.AddSortPtInfo(stTdTaskData.iC1, stTdTaskData.iC2, stTdTaskData.iP1, stTdTaskData.iP2,
|
||
pRecConList->GetCollect(_T("Layer")).iVal, iSortIndex++);
|
||
pRecConList->MoveNext();
|
||
}
|
||
pRecConList->Close();
|
||
iSortIndex = operMedium.GetFirstSortID(iSortMethod);
|
||
BOOL bRes = TRUE;
|
||
|
||
int iDataSize = vtStTdTaskData.size();
|
||
float fPtXPos = 0;
|
||
while (iSortIndex >= 0)
|
||
{
|
||
if (iSortIndex >= iDataSize)
|
||
{
|
||
CString strErr = _T("");
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strErr.Format(_T("保存excel数据混乱,data_index = %d,total_size=%d"), iSortIndex + 1, iDataSize);
|
||
AfxMessageBox(strErr);
|
||
}
|
||
else
|
||
{
|
||
strErr.Format(_T("Data index disorder in save excel,data_index = %d,total_size=%d"), iSortIndex + 1, iDataSize);
|
||
MessageBoxEx(NULL, strErr, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
bRes = FALSE;
|
||
break;
|
||
}
|
||
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 += ',';
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fR0);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fSP);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fThl);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fD);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fr);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
char chCol = 'N';
|
||
for (int iTWIndex = 0; iTWIndex < vtStTdTaskData[iSortIndex].stTdTimeData.iTimeWinCnt; iTWIndex++)
|
||
{
|
||
//写入ETA值
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fEta[iTWIndex]);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
//写入M值
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fM[iTWIndex]);
|
||
szRow += ((strText)); szRow += ',';
|
||
}
|
||
}
|
||
|
||
//计算离差的位置信息
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
strText.Empty();
|
||
float fVal = (k != 0) ? vtStTdTaskData[iSortIndex].fM0_LC : vtStTdTaskData[iSortIndex].fR0_LC;
|
||
strText.Format(_T("%f%%"), fVal);
|
||
szRow += ((strText)); szRow += ',';
|
||
}
|
||
|
||
szRow += "\n";
|
||
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
||
|
||
iSortIndex = operMedium.GetNextSortID();
|
||
}
|
||
fflush(pFile);
|
||
|
||
return bRes;
|
||
}
|
||
|
||
BOOL CIpsp2DTd::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("获取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;
|
||
_RecordsetPtr pRecTdAttr = NULL;
|
||
|
||
CString szRow = _T("");
|
||
|
||
int iIndex = (int)0;
|
||
CString strText = _T("");
|
||
|
||
iIndex = 1;
|
||
|
||
szRow.Empty();
|
||
szRow += ((_T("C1"))); szRow += ',';
|
||
|
||
szRow += ((_T("C2"))); szRow += ',';
|
||
|
||
szRow += ((_T("P1"))); szRow += ',';
|
||
|
||
szRow += ((_T("P2"))); szRow += ',';
|
||
|
||
szRow += ((_T("Stacking"))); szRow += ',';
|
||
|
||
szRow += ((_T("K"))); szRow += ',';
|
||
|
||
szRow += ((_T("I(mA)"))); szRow += ',';
|
||
|
||
szRow += ((_T("V(mV)"))); szRow += ',';
|
||
|
||
szRow += ((_T("R0"))); szRow += ',';
|
||
|
||
szRow += ((_T("SP"))); szRow += ',';
|
||
|
||
szRow += ((_T("R0_RD"))); szRow += ',';
|
||
|
||
pRecConList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdAttr.CreateInstance(_uuidof(Recordset));
|
||
bool bAddIpIndex = false;
|
||
int iTWCnt = 0;
|
||
CString strTW = _T("");
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select max(TWCNT) as MAX_TWCNT from td_spc_attr where TCHID in (select ID from tdchannel where TDID = %u order by TCHID)"), m_dwID);
|
||
pRecTdAttr->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
szSql.Empty();
|
||
if ((long)VAL_ZERO != pRecTdAttr->GetRecordCount())
|
||
{
|
||
//在Excel中先加入Thl,D,r
|
||
bAddIpIndex = true;
|
||
szRow += ((_T("Thl"))); szRow += ',';
|
||
szRow += ((_T("D"))); szRow += ',';
|
||
szRow += ((_T("r"))); szRow += ',';
|
||
|
||
iTWCnt = pRecTdAttr->GetCollect(_T("MAX_TWCNT")).lVal;
|
||
CString strField = _T("tb.THL as THL, tb.D as D, tb.r as r,tb.TWCNT as TWCNT");
|
||
int i = 0;
|
||
char chFlag;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入η时窗列
|
||
strTW.Empty();
|
||
strTW.Format(_T("η%d"), i);
|
||
szRow += strTW; szRow += ',';
|
||
|
||
strTW.Empty();
|
||
strTW.Format(_T(",tb.TW%dIndex as TW%dIndex"), i, i);
|
||
strField += strTW;
|
||
}
|
||
//在这里由于M和η的列数相等
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入M时窗列
|
||
strTW.Empty();
|
||
strTW.Format(_T("M%d"), i);
|
||
szRow += strTW; szRow += ',';
|
||
}
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.N as N, ta.K as K, ta.I as I, ta.V as V, ta.R0 as R0, ta.SP as SP, ")
|
||
_T("ta.bUse as bUse,ta.R0_LC as R0_LC, ta.M0_LC as M0_LC, %s from td2dcon ta, td_spc_attr tb where ta.TCHID in (select ID from tdchannel where TDID = %u order by ta.TCHID) ")
|
||
_T("and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN order by ta.TSN"), strField, m_dwID);
|
||
}
|
||
else
|
||
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);
|
||
|
||
pRecTdAttr->Close();
|
||
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());
|
||
}
|
||
//计算离差的位置信息
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
CString strRD = (k != 0) ? _T("M0_RD") : _T("R0_RD");
|
||
szRow += strRD; szRow += ',';
|
||
}
|
||
|
||
szRow += "\n";
|
||
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
||
fflush(pFile);
|
||
|
||
bool bIsErrShow = false;
|
||
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 += ',';
|
||
|
||
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 += ',';
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("THL")).fltVal);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("D")).fltVal);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), pRecConList->GetCollect(_T("r")).fltVal);
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
CStringArray strIndexArr;
|
||
int nSigTWTCnt = pRecConList->GetCollect(_T("TWCNT")).lVal;
|
||
CString strMVal = _T("");
|
||
for (int iTWIndex = 0; iTWIndex < nSigTWTCnt; iTWIndex++)
|
||
{
|
||
//在excel中加入时窗列
|
||
strIndexArr.RemoveAll();
|
||
strText.Empty();
|
||
strMVal.Empty();
|
||
strTW.Empty();
|
||
strTW.Format(_T("TW%dIndex"), iTWIndex);
|
||
strText = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_variant_t(strTW));
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("解析时窗索引错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Parser time window index error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
strText = _T("");
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
|
||
}
|
||
//写入ETA值
|
||
szRow += ((strText)); szRow += ',';
|
||
|
||
//写入M值
|
||
szRow += ((strMVal)); szRow += ',';
|
||
|
||
}
|
||
}
|
||
|
||
//计算离差的位置信息
|
||
CString strRDVal;
|
||
for (int k = 0; k < 2; k++)
|
||
{
|
||
CString strRDIndex = (k != 0) ? _T("M0_LC") : _T("R0_LC");
|
||
strRDVal.Empty();
|
||
strRDVal.Format(_T("%f%%"), pRecConList->GetCollect(_variant_t(strRDIndex)).fltVal);
|
||
szRow += ((strRDVal)); szRow += ',';
|
||
}
|
||
|
||
szRow += "\n";
|
||
fwrite(szRow, 1, szRow.GetLength(), pFile);
|
||
}
|
||
|
||
pRecConList->MoveNext();
|
||
}
|
||
|
||
fflush(pFile);
|
||
|
||
pRecConList->Close();
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
bool CIpsp2DTd::ExportIP2DDataToDat(CString strFile)
|
||
{
|
||
|
||
if (strFile.IsEmpty())
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("导出文件名为空"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Export FileName is empty!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
return false;
|
||
}
|
||
int iFileType = (-1 == strFile.Find(_T("_Eta.dat"))) ? 1 : 0;
|
||
CString szSql = _T("");
|
||
CStringArray saRecord;
|
||
|
||
CString szTdName = _T("");
|
||
CString szEDistance = _T("");
|
||
CString szAr = _T("");
|
||
CString szTPAmount = _T("");
|
||
CString szTmp = _T("");
|
||
|
||
CString szA = _T("");
|
||
CString szB = _T("");
|
||
CString szM = _T("");
|
||
CString szN = _T("");
|
||
CString szR0 = _T("");
|
||
CString szFormat = _T("0");
|
||
int nFirstTW =0, nFirstTWWideth = 0;
|
||
|
||
DWORD dwChID = (DWORD)VAL_ZERO;
|
||
int nFrequence = 0;
|
||
double dPeriod = 0;
|
||
|
||
_RecordsetPtr pRecTd = NULL;
|
||
_RecordsetPtr pRecCh = NULL;
|
||
_RecordsetPtr pRecTdCon = NULL;
|
||
_RecordsetPtr pRecTdTW = NULL;
|
||
|
||
|
||
|
||
pRecTd.CreateInstance(_uuidof(Recordset));
|
||
pRecCh.CreateInstance(_uuidof(Recordset));
|
||
pRecTdCon.CreateInstance(_uuidof(Recordset));
|
||
pRecTdTW.CreateInstance(_uuidof(Recordset));
|
||
|
||
|
||
|
||
szSql.Empty();
|
||
szSql.Format(_T("select TDname,Edistance,TPamount,TRfrequency 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 = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TDname"));
|
||
szEDistance = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("Edistance"));
|
||
// szTPAmount = (LPCTSTR)(_bstr_t)pRecTd->GetCollect(_T("TPamount"));
|
||
nFrequence = (int)pRecTd->GetCollect(_T("TRfrequency")).iVal;
|
||
if (nFrequence < 0)
|
||
{
|
||
CString strInfo = _T("");
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
{
|
||
strInfo.Format(_T("获取频率信息错误 %d"), nFrequence);
|
||
AfxMessageBox(strInfo.GetBuffer(0));
|
||
}
|
||
else
|
||
{
|
||
strInfo.Format(_T("Get TRfrequency info Error, nVal = %d"), nFrequence);
|
||
MessageBoxEx(NULL, _T("Export FileName is empty!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
return false;
|
||
}
|
||
dPeriod = GetCycle(nFrequence);
|
||
}
|
||
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();
|
||
|
||
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;
|
||
}
|
||
|
||
CSaveInIP* pSaveInIP = NULL;
|
||
pSaveInIP = new CSaveInIP;
|
||
if (!pSaveInIP->CreateIPFile(strFile))
|
||
{
|
||
delete pSaveInIP;
|
||
return FALSE;
|
||
}
|
||
|
||
CIpsp2DTdRecord *pIP2DTdRecord = new CIpsp2DTdRecord(dwChID, this->m_pConnection);
|
||
szSql.Empty();
|
||
szSql.Format(_T("select M0ST,M0TW from ac where TDID = %u"), this->m_dwID);
|
||
pRecTdTW->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if ((long)VAL_ZERO != pRecTdTW->GetRecordCount())
|
||
{
|
||
nFirstTW = (int)pRecTdTW->GetCollect("M0ST").iVal;
|
||
nFirstTWWideth = (int)pRecTdTW->GetCollect("M0TW").iVal;
|
||
szTmp.Format("%d,%d", nFirstTW, nFirstTW + nFirstTWWideth);
|
||
}
|
||
|
||
pRecTdTW->Close();
|
||
//////////////////////////////////////////////////////////////////////////
|
||
//判断有没有层数信息
|
||
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)) || AR_CROSS_HOLE_GEOMATIVE == atoi(szAr) || AR_S3P_MEDIUM == atoi(szAr))
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.R0 as R0, ta.bUse as bUse,ta.TSN as TSN, tb.TW0Index as TW0Index ")
|
||
_T("from td2dcon ta, td_spc_attr tb where ta.TCHID = %u and ta.bUse <> 0 and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN ")
|
||
_T("order by ta.TSN"), dwChID);
|
||
}
|
||
//否则则按照层数和C1的逐渐增大进行排序
|
||
else
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.R0 as R0, ta.bUse as bUse,ta.TSN as TSN, tb.TW0Index as TW0Index ")
|
||
_T("from td2dcon ta, td_spc_attr tb where ta.TCHID = %u and ta.bUse <> 0 and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN ")
|
||
_T("order by ta.Layer, ta.C1"), dwChID);
|
||
}
|
||
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))
|
||
{
|
||
saRecord.Add(_T("2"));
|
||
saRecord.Add(_T("Type of measurement(0=app.resistivity,1=resistance)"));
|
||
saRecord.Add(_T("0"));
|
||
// szFormat = _T("1");
|
||
}
|
||
if (AR_EDGE_GARDIENT == atoi(szAr) || AR_DOUBLE_SIZE_3P == atoi(szAr))
|
||
{
|
||
saRecord.Add(_T("0"));
|
||
saRecord.Add(_T("Type of measurement(0=app.resistivity,1=resistance)"));
|
||
saRecord.Add(_T("0"));
|
||
}
|
||
//现在szFormat都设置成1
|
||
szFormat = _T("1");
|
||
szTPAmount.Empty();
|
||
szTPAmount.Format(_T("%d"), pRecTdCon->GetRecordCount());
|
||
saRecord.Add(szTPAmount);
|
||
saRecord.Add(szFormat);
|
||
saRecord.Add(_T("1"));
|
||
saRecord.Add(_T("Chargeabi lity"));
|
||
saRecord.Add(_T("msec"));
|
||
saRecord.Add(szTmp);
|
||
|
||
pSaveInIP->AddFileHeader(2, atoi(szAr.GetBuffer(0)), &saRecord);
|
||
//////////////////////////////////////////////////////////////////////////
|
||
CStringArray strArray;
|
||
bool bErrShow = false;
|
||
double dVData = 0, dintegralArea=0;
|
||
double dXDataArray[50],dYDataArray[50], dCoefficient[50], dtInfo[50];
|
||
while ((short)VAL_ZERO == pRecTdCon->adoEOF)
|
||
{
|
||
if (pRecTdCon->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
|
||
{
|
||
szR0.Empty();
|
||
float fR0 = (float)pRecTdCon->GetCollect(_T("R0")).fltVal;
|
||
szR0.Format(_T("%f"),fR0);
|
||
szA.Empty();
|
||
szA = (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("C1"));
|
||
szB.Empty();
|
||
szB = (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("C2"));
|
||
szM.Empty();
|
||
szM = (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("P1"));
|
||
szN.Empty();
|
||
szN = (LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("P2"));
|
||
szTmp.Empty();
|
||
szTmp = pRecTdCon->GetCollect(_T("TW0Index")).vt == VT_NULL ? _T(""):(LPCTSTR)(_bstr_t)pRecTdCon->GetCollect(_T("TW0Index"));
|
||
if (!szTmp.IsEmpty())
|
||
{
|
||
float fM0Val = 0;
|
||
strArray.RemoveAll();
|
||
SplitterString(strArray, szTmp, _T(";"));
|
||
if (strArray.GetSize() < 4)
|
||
{
|
||
if (!bErrShow)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("将数据导出到dat文件时,解析器时间窗口信息失败!"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Parser time windows information failed when export data to dat file!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
bErrShow = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//iFileType为0表示为取ETA,1表示为取M0
|
||
int iDataIndex = (0 == iFileType) ? 0 : 2;
|
||
fM0Val = atof(strArray.GetAt(iDataIndex));
|
||
}
|
||
szTmp.Empty();
|
||
szTmp.Format(_T("%.4f"), fabs(fM0Val));
|
||
}
|
||
else
|
||
{
|
||
szTmp = _T("0.0000");
|
||
}
|
||
|
||
saRecord.RemoveAll();
|
||
saRecord.Add(szA);
|
||
saRecord.Add(szB);
|
||
saRecord.Add(szM);
|
||
saRecord.Add(szN);
|
||
saRecord.Add(szR0);
|
||
saRecord.Add(szTmp);
|
||
pSaveInIP->AddDateToFile(&saRecord);
|
||
}
|
||
pRecTdCon->MoveNext();
|
||
}
|
||
|
||
pRecTdCon->Close();
|
||
pSaveInIP->CloseFile();
|
||
delete pSaveInIP;
|
||
pSaveInIP = NULL;
|
||
|
||
if (pIP2DTdRecord)
|
||
{
|
||
delete pIP2DTdRecord;
|
||
pIP2DTdRecord = NULL;
|
||
}
|
||
|
||
return TRUE;
|
||
|
||
|
||
}
|
||
|
||
BOOL CIpsp2DTd::Export2dDataToTxtBySort(CString strFileName, int iSortMethod)
|
||
{
|
||
CString szSql = _T("");
|
||
szSql.Format(_T("select ID,AR from tdchannel where TDID = %u"),m_dwID);
|
||
_RecordsetPtr pRecTdChan = NULL;
|
||
pRecTdChan.CreateInstance(_uuidof(Recordset));
|
||
pRecTdChan->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
if (pRecTdChan->GetRecordCount() < 1)
|
||
{
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("获取AR信息失败"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Get Ar infomation failed"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
pRecTdChan->Close();
|
||
return FALSE;
|
||
}
|
||
int iAR = pRecTdChan->GetCollect(_T("AR")).iVal;
|
||
int iTdChannelID = pRecTdChan->GetCollect(_T("ID")).lVal;
|
||
pRecTdChan->Close();
|
||
|
||
COperMediumPt operMedium(iAR);
|
||
if (!operMedium.InitiSortInfo(1))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
COperTxtFile operTxtFile;
|
||
if (!operTxtFile.OpenFileforWrite(strFileName))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
_RecordsetPtr pRecConList = NULL;
|
||
_RecordsetPtr pRecTdAttr = NULL;
|
||
pRecConList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdAttr.CreateInstance(_uuidof(Recordset));
|
||
|
||
bool bAddIpIndex = false;
|
||
|
||
CString strText = _T("");
|
||
CStringArray strArrTxt;
|
||
strArrTxt.RemoveAll();
|
||
|
||
int iTWCnt = 0;
|
||
CString strTW = _T("");
|
||
|
||
//添加标题
|
||
strArrTxt.Add(_T("C1"));
|
||
strArrTxt.Add(_T("C2"));
|
||
strArrTxt.Add(_T("P1"));
|
||
strArrTxt.Add(_T("P2"));
|
||
strArrTxt.Add(_T("Stacking"));
|
||
strArrTxt.Add(_T("K"));
|
||
strArrTxt.Add(_T("V(mV)"));
|
||
strArrTxt.Add(_T("I(mA)"));
|
||
strArrTxt.Add(_T("R0"));
|
||
strArrTxt.Add(_T("SP"));
|
||
strArrTxt.Add(_T("R0_RD"));
|
||
strArrTxt.Add(_T("M0_RD"));
|
||
int i = 0;
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select max(TWCNT) as MAX_TWCNT from td_spc_attr where TCHID = %d "),iTdChannelID);
|
||
pRecTdAttr->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
szSql.Empty();
|
||
if ((long)VAL_ZERO != pRecTdAttr->GetRecordCount())
|
||
{
|
||
//在Excel中先加入Thl,D,r
|
||
bAddIpIndex = true;
|
||
strArrTxt.Add(_T("Thl"));
|
||
strArrTxt.Add(_T("D"));
|
||
strArrTxt.Add(_T("r"));
|
||
|
||
iTWCnt = pRecTdAttr->GetCollect(_T("MAX_TWCNT")).lVal;
|
||
CString strField = _T("tb.THL as THL, tb.D as D, tb.r as r,tb.TWCNT as TWCNT");
|
||
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在txt中加入时窗列
|
||
strTW.Empty();
|
||
strTW.Format(_T("η%d"),i);
|
||
strArrTxt.Add(strTW);
|
||
strTW.Empty();
|
||
strTW.Format(_T(",tb.TW%dIndex as TW%dIndex"),i, i);
|
||
strField += strTW;
|
||
}
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入M时窗列
|
||
strTW.Empty();
|
||
strTW.Format(_T("M%d"),i);
|
||
strArrTxt.Add(strTW);
|
||
}
|
||
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.N as N, ta.K as K, ta.I as I, ta.V as V, ta.R0 as R0, ta.SP as SP, ")
|
||
_T("ta.R0_LC as R0_LC, ta.M0_LC as M0_LC,ta.Layer as Layer, %s from td2dcon ta, td_spc_attr tb where ta.bUse <> 0 and ta.TCHID =%d ")
|
||
_T("and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN order by ta.TSN"),strField, iTdChannelID);
|
||
}
|
||
else
|
||
szSql.Format(_T("select C1,C2,P1,P2,N,K,I,V,R0,SP,R0_LC,M0_LC,Layer from td2dcon where bUse <> 0 and TCHID = %d order by TSN"), iTdChannelID);
|
||
|
||
pRecTdAttr->Close();
|
||
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;
|
||
}
|
||
|
||
std::vector<StTdTaskIPDataInfo> vtStTdTaskData;
|
||
vtStTdTaskData.clear();
|
||
bool bIsErrShow = false;
|
||
int iSortIndex = 0;
|
||
while ((short)0 == pRecConList->adoEOF)
|
||
{
|
||
StTdTaskIPDataInfo 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;
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
stTdTaskData.stTdTimeData.fThl = pRecConList->GetCollect(_T("THL")).fltVal;
|
||
stTdTaskData.stTdTimeData.fD= pRecConList->GetCollect(_T("D")).fltVal;
|
||
stTdTaskData.stTdTimeData.fr = pRecConList->GetCollect(_T("r")).fltVal;
|
||
stTdTaskData.stTdTimeData.iTimeWinCnt = pRecConList->GetCollect(_T("TWCNT")).lVal;
|
||
|
||
CStringArray strIndexArr;
|
||
CString strMVal = _T("");
|
||
int iTWIndex= 0;
|
||
for (iTWIndex= 0; iTWIndex < stTdTaskData.stTdTimeData.iTimeWinCnt ; iTWIndex++)
|
||
{
|
||
//在excel中加入时窗列
|
||
strIndexArr.RemoveAll();
|
||
strText.Empty();
|
||
strMVal.Empty();
|
||
strTW.Empty();
|
||
strTW.Format(_T("TW%dIndex"),iTWIndex);
|
||
strText = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_variant_t(strTW));
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("解析时窗下标错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Parser time window index error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
stTdTaskData.stTdTimeData.fM[iTWIndex] = -1;
|
||
stTdTaskData.stTdTimeData.fEta[iTWIndex] = -1;
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
stTdTaskData.stTdTimeData.fEta[iTWIndex] = atof(strText);
|
||
stTdTaskData.stTdTimeData.fM[iTWIndex] = atof(strMVal);
|
||
|
||
}
|
||
}
|
||
}
|
||
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(iSortMethod);
|
||
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, _T("Parser time window index error!"), 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);
|
||
|
||
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);
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].fM0_LC);
|
||
strArrTxt.Add(strText);
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fThl);
|
||
strArrTxt.Add(strText);
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fD);
|
||
strArrTxt.Add(strText);
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fr);
|
||
strArrTxt.Add(strText);
|
||
for (int iFlag = 0; iFlag < 2; iFlag++)
|
||
{
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
if (i < vtStTdTaskData[iSortIndex].stTdTimeData.iTimeWinCnt)
|
||
{
|
||
//写入ETA值
|
||
strText.Empty();
|
||
if (iFlag < 1)
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fEta[i]);
|
||
else
|
||
strText.Format(_T("%f"), vtStTdTaskData[iSortIndex].stTdTimeData.fM[i]);
|
||
}
|
||
else
|
||
strText = " ";
|
||
strArrTxt.Add(strText);
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
if (!operTxtFile.WriteFileContent(strArrTxt))
|
||
{
|
||
operTxtFile.CloseFile();
|
||
bRes = FALSE;
|
||
break;
|
||
}
|
||
iSortIndex = operMedium.GetNextSortID();
|
||
}
|
||
pRecConList->Close();
|
||
operTxtFile.CloseFile();
|
||
return bRes;
|
||
}
|
||
|
||
|
||
BOOL CIpsp2DTd::ExportIPDataToTxt(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);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
COperTxtFile operTxtFile;
|
||
if (!operTxtFile.OpenFileforWrite(strFileName))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
_RecordsetPtr pRecConList = NULL;
|
||
_RecordsetPtr pRecTdAttr = NULL;
|
||
pRecConList.CreateInstance(_uuidof(Recordset));
|
||
pRecTdAttr.CreateInstance(_uuidof(Recordset));
|
||
|
||
bool bAddIpIndex = false;
|
||
CString strText = _T("");
|
||
CStringArray strArrTxt;
|
||
strArrTxt.RemoveAll();
|
||
|
||
int iTWCnt = 0;
|
||
CString strTW = _T("");
|
||
|
||
//添加标题
|
||
strArrTxt.Add(_T("C1"));
|
||
strArrTxt.Add(_T("C2"));
|
||
strArrTxt.Add(_T("P1"));
|
||
strArrTxt.Add(_T("P2"));
|
||
strArrTxt.Add(_T("Stacking"));
|
||
strArrTxt.Add(_T("K"));
|
||
strArrTxt.Add(_T("V(mV)"));
|
||
strArrTxt.Add(_T("I(mA)"));
|
||
strArrTxt.Add(_T("R0"));
|
||
strArrTxt.Add(_T("SP"));
|
||
strArrTxt.Add(_T("R0_RD"));
|
||
strArrTxt.Add(_T("M0_RD"));
|
||
|
||
try
|
||
{
|
||
szSql.Empty();
|
||
szSql.Format(_T("select max(TWCNT) as MAX_TWCNT from td_spc_attr where TCHID in (select ID from tdchannel where TDID = %u order by TCHID)"),m_dwID);
|
||
pRecTdAttr->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
||
szSql.Empty();
|
||
if ((long)VAL_ZERO != pRecTdAttr->GetRecordCount())
|
||
{
|
||
//在Excel中先加入Thl,D,r
|
||
bAddIpIndex = true;
|
||
strArrTxt.Add(_T("Thl"));
|
||
strArrTxt.Add(_T("D"));
|
||
strArrTxt.Add(_T("r"));
|
||
|
||
iTWCnt = pRecTdAttr->GetCollect(_T("MAX_TWCNT")).lVal;
|
||
CString strField = _T("tb.THL as THL, tb.D as D, tb.r as r,tb.TWCNT as TWCNT");
|
||
int i = 0;
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在txt中加入时窗列
|
||
strTW.Empty();
|
||
strTW.Format(_T("η%d"),i);
|
||
strArrTxt.Add(strTW);
|
||
strTW.Empty();
|
||
strTW.Format(_T(",tb.TW%dIndex as TW%dIndex"),i, i);
|
||
strField += strTW;
|
||
}
|
||
for (i = 0; i < iTWCnt; i++)
|
||
{
|
||
//在excel中加入M时窗列
|
||
strTW.Empty();
|
||
strTW.Format(_T("M%d"),i);
|
||
strArrTxt.Add(strTW);
|
||
}
|
||
|
||
szSql.Format(_T("select ta.C1 as C1, ta.C2 as C2, ta.P1 as P1, ta.P2 as P2, ta.N as N, ta.K as K, ta.I as I, ta.V as V, ta.R0 as R0, ta.SP as SP, ")
|
||
_T("ta.bUse as bUse,ta.R0_LC as R0_LC, ta.M0_LC as M0_LC, %s from td2dcon ta, td_spc_attr tb where ta.TCHID in (select ID from tdchannel where TDID = %u order by ta.TCHID) ")
|
||
_T("and ta.TCHID = tb.TCHID and ta.TSN = tb.TSN order by ta.TSN"),strField, m_dwID);
|
||
}
|
||
else
|
||
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);
|
||
|
||
pRecTdAttr->Close();
|
||
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;
|
||
}
|
||
|
||
|
||
bool bIsErrShow = false;
|
||
while ((short)0 == pRecConList->adoEOF)
|
||
{
|
||
if (pRecConList->GetCollect(_T("bUse")).boolVal != 0)//0为access数据库中的false
|
||
{
|
||
strArrTxt.RemoveAll();
|
||
strArrTxt.Add((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C1")));
|
||
strArrTxt.Add((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("C2")));
|
||
strArrTxt.Add((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P1")));
|
||
strArrTxt.Add((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("P2")));
|
||
|
||
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);
|
||
|
||
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);
|
||
|
||
strText.Empty();
|
||
strText.Format(_T("%f%%"),pRecConList->GetCollect(_T("M0_LC")).fltVal);
|
||
strArrTxt.Add(strText);
|
||
|
||
if (bAddIpIndex)
|
||
{
|
||
strArrTxt.Add((LPCTSTR)(_bstr_t)pRecConList->GetCollect(_T("THL")));
|
||
strText.Empty();
|
||
strText.Format(_T("%f"),pRecConList->GetCollect(_T("D")).fltVal);
|
||
strArrTxt.Add(strText);
|
||
strText.Empty();
|
||
strText.Format(_T("%f"),pRecConList->GetCollect(_T("r")).fltVal);
|
||
strArrTxt.Add(strText);
|
||
CStringArray strIndexArr;
|
||
CStringArray strArrMVal;
|
||
strArrMVal.RemoveAll();
|
||
int nSigTWTCnt = pRecConList->GetCollect(_T("TWCNT")).lVal;
|
||
CString strMVal = _T("");
|
||
int iTWIndex= 0;
|
||
for (iTWIndex= 0; iTWIndex < nSigTWTCnt; iTWIndex++)
|
||
{
|
||
//在excel中加入时窗列
|
||
strIndexArr.RemoveAll();
|
||
strText.Empty();
|
||
strMVal.Empty();
|
||
strTW.Empty();
|
||
strTW.Format(_T("TW%dIndex"),iTWIndex);
|
||
strText = (LPCTSTR)(_bstr_t)pRecConList->GetCollect(_variant_t(strTW));
|
||
SplitterString(strIndexArr, strText, _T(";"));
|
||
if (strIndexArr.GetSize() < 4)
|
||
{
|
||
if (!bIsErrShow)
|
||
{
|
||
bIsErrShow = true;
|
||
if (LANG_ZHCN == g_iUILanguage)
|
||
AfxMessageBox(_T("解析时窗下标错误"));
|
||
else
|
||
MessageBoxEx(NULL, _T("Parser time window index error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||
}
|
||
strText = _T("error");
|
||
strMVal = _T("error");
|
||
}
|
||
else
|
||
{
|
||
strText = strIndexArr.GetAt(0);
|
||
strMVal = strIndexArr.GetAt(2);
|
||
strText.TrimLeft();
|
||
strText.TrimRight();
|
||
strMVal.TrimLeft();
|
||
strMVal.TrimRight();
|
||
}
|
||
strArrTxt.Add(strText);
|
||
strArrMVal.Add(strMVal);
|
||
}
|
||
for (iTWIndex= 0; iTWIndex < strArrMVal.GetSize(); iTWIndex++)
|
||
{
|
||
strArrTxt.Add(strArrMVal.GetAt(iTWIndex));
|
||
}
|
||
}
|
||
|
||
|
||
if (!operTxtFile.WriteFileContent(strArrTxt))
|
||
{
|
||
operTxtFile.CloseFile();
|
||
return FALSE;
|
||
}
|
||
}
|
||
pRecConList->MoveNext();
|
||
}
|
||
pRecConList->Close();
|
||
operTxtFile.CloseFile();
|
||
return TRUE;
|
||
}
|