a
This commit is contained in:
@@ -0,0 +1,325 @@
|
||||
// TdRecord.cpp: implementation of the CTdRecord class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "geomative.h"
|
||||
#include "TdRecord.h"
|
||||
|
||||
#include "disptdrecsplinesgrapdlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CTdRecord::CTdRecord(_ConnectionPtr& pConnection)
|
||||
{
|
||||
m_pConnection = pConnection;
|
||||
|
||||
m_fMaxAbsV = 0.0;
|
||||
}
|
||||
|
||||
CTdRecord::~CTdRecord()
|
||||
{
|
||||
this->m_saVRawData.RemoveAll();
|
||||
this->m_saIRawData.RemoveAll();
|
||||
}
|
||||
|
||||
BOOL CTdRecord::LoadCEOrgData()
|
||||
{
|
||||
float fValue = 0.0;
|
||||
CString szValue = _T("");
|
||||
|
||||
CString szVRawData = _T("");
|
||||
CString szIRawData = _T("");
|
||||
|
||||
CString szSql = _T("");
|
||||
_RecordsetPtr pRecRawData = NULL;
|
||||
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
|
||||
this->m_saVRawData.RemoveAll();
|
||||
this->m_saIRawData.RemoveAll();
|
||||
|
||||
try
|
||||
{
|
||||
pRecRawData.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
szSql.Empty();
|
||||
// szSql.Format(_T("select Vrawdata,Irawdata from td1dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_iTsn);
|
||||
szSql.Format(_T("select Vrawdata,Irawdata from td1dcon where TSN = %d and TCHID in (select id from tdchannel where tdid = %d)"), this->m_iTsn, this->m_dwChID);
|
||||
// szSql.Format(_T("select IIf(IsNull(Vrawdata),'',Vrawdata) as Vrawdata,IIf(IsNull(Irawdata),'',Irawdata) as Irawdata from td1dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_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"));
|
||||
|
||||
SplitterString(m_saVRawData, szVRawData, _T(";"));
|
||||
|
||||
iIndex = (int)VAL_ZERO;
|
||||
while (iIndex < m_saVRawData.GetSize())
|
||||
{
|
||||
szValue.Empty();
|
||||
szValue = m_saVRawData.GetAt(iIndex);
|
||||
if (4 == iIndex)
|
||||
{
|
||||
szValue.TrimLeft(szValue.Left(5));
|
||||
}
|
||||
szValue.TrimLeft();
|
||||
|
||||
if (iIndex >= 4)
|
||||
{
|
||||
fValue = 0.0;
|
||||
fValue = this->ConvertVOrgData((float)atof(szValue));
|
||||
|
||||
if (fabsf(fValue) > this->m_fMaxAbsV)
|
||||
{
|
||||
this->m_fMaxAbsV = fabsf(fValue);
|
||||
}
|
||||
|
||||
szValue.Empty();
|
||||
szValue.Format(_T("%.4f"), fValue);
|
||||
}
|
||||
|
||||
m_saVRawData.SetAt(iIndex, szValue);
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
szIRawData.Empty();
|
||||
szIRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Irawdata"));
|
||||
|
||||
SplitterString(m_saIRawData, szIRawData, _T(";"));
|
||||
iIndex = (int)VAL_ZERO;
|
||||
while (iIndex < m_saIRawData.GetSize())
|
||||
{
|
||||
szValue.Empty();
|
||||
szValue = m_saIRawData.GetAt(iIndex);
|
||||
if (4 == iIndex)
|
||||
{
|
||||
szValue.TrimLeft(szValue.Left(5));
|
||||
}
|
||||
szValue.TrimLeft();
|
||||
m_saIRawData.SetAt(iIndex, szValue);
|
||||
iIndex++;
|
||||
}
|
||||
}
|
||||
pRecRawData->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
// AfxMessageBox(e.Description());
|
||||
throw;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CTdRecord::Load2DOrgData()
|
||||
{
|
||||
float fValue = 0.0;
|
||||
CString szValue = _T("");
|
||||
|
||||
CString szVRawData = _T("");
|
||||
CString szIRawData = _T("");
|
||||
|
||||
CString szSql = _T("");
|
||||
_RecordsetPtr pRecRawData = NULL;
|
||||
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
|
||||
this->m_saVRawData.RemoveAll();
|
||||
this->m_saIRawData.RemoveAll();
|
||||
|
||||
try
|
||||
{
|
||||
pRecRawData.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
szSql.Empty();
|
||||
szSql.Format(_T("select Vrawdata,Irawdata from td2dcon where TSN = %d and TCHID in (select id from tdchannel where tdid = %d)"), this->m_iTsn, this->m_dwChID);
|
||||
// szSql.Format(_T("select IIf(IsNull(Vrawdata),'',Vrawdata) as Vrawdata,IIf(IsNull(Irawdata),'',Irawdata) as Irawdata from td2dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_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"));
|
||||
|
||||
SplitterString(m_saVRawData, szVRawData, _T(";"));
|
||||
iIndex = (int)VAL_ZERO;
|
||||
while (iIndex < m_saVRawData.GetSize())
|
||||
{
|
||||
szValue.Empty();
|
||||
szValue = m_saVRawData.GetAt(iIndex);
|
||||
if (4 == iIndex)
|
||||
{
|
||||
szValue.TrimLeft(szValue.Left(5));
|
||||
}
|
||||
szValue.TrimLeft();
|
||||
|
||||
if (iIndex >= 4)
|
||||
{
|
||||
fValue = 0.0;
|
||||
fValue = this->ConvertVOrgData((float)atof(szValue));
|
||||
|
||||
if (fabsf(fValue) > this->m_fMaxAbsV)
|
||||
{
|
||||
this->m_fMaxAbsV = fabsf(fValue);
|
||||
}
|
||||
|
||||
szValue.Empty();
|
||||
szValue.Format(_T("%.4f"), fValue);
|
||||
}
|
||||
|
||||
m_saVRawData.SetAt(iIndex, szValue);
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
szIRawData.Empty();
|
||||
szIRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Irawdata"));
|
||||
|
||||
SplitterString(m_saIRawData, szIRawData, _T(";"));
|
||||
iIndex = (int)VAL_ZERO;
|
||||
while (iIndex < m_saIRawData.GetSize())
|
||||
{
|
||||
szValue.Empty();
|
||||
szValue = m_saIRawData.GetAt(iIndex);
|
||||
if (4 == iIndex)
|
||||
{
|
||||
szValue.TrimLeft(szValue.Left(5));
|
||||
}
|
||||
szValue.TrimLeft();
|
||||
m_saIRawData.SetAt(iIndex, szValue);
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
pRecRawData->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
// AfxMessageBox(e.Description());
|
||||
throw;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
float CTdRecord::ConvertVOrgData(float fVOrgData)
|
||||
{
|
||||
return fVOrgData;
|
||||
}
|
||||
|
||||
void CTdRecord::DisplayRawDataSplines()
|
||||
{
|
||||
LoadOrgData();
|
||||
|
||||
if ((int)VAL_ZERO != this->m_saVRawData.GetSize())
|
||||
{
|
||||
CDispTdRecSplinesGrapDlg* pDispTdRecSplinesGrapDlg = new CDispTdRecSplinesGrapDlg(this->m_saVRawData, this->m_fMaxAbsV);
|
||||
pDispTdRecSplinesGrapDlg->DoModal();
|
||||
delete pDispTdRecSplinesGrapDlg;
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CTdRecord::Load3DOrgData()
|
||||
{
|
||||
float fValue = 0.0;
|
||||
CString szValue = _T("");
|
||||
|
||||
CString szVRawData = _T("");
|
||||
CString szIRawData = _T("");
|
||||
|
||||
CString szSql = _T("");
|
||||
_RecordsetPtr pRecRawData = NULL;
|
||||
|
||||
int iIndex = (int)VAL_ZERO;
|
||||
|
||||
this->m_saVRawData.RemoveAll();
|
||||
this->m_saIRawData.RemoveAll();
|
||||
|
||||
try
|
||||
{
|
||||
pRecRawData.CreateInstance(_uuidof(Recordset));
|
||||
|
||||
szSql.Empty();
|
||||
// szSql.Format(_T("select Vrawdata,Irawdata from td3dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_iTsn);
|
||||
szSql.Format(_T("select Vrawdata,Irawdata from td3dcon where TSN = %d and TCHID in (select id from tdchannel where tdid = %d)"), this->m_iTsn, this->m_dwChID);
|
||||
// szSql.Format(_T("select IIf(IsNull(Vrawdata),'',Vrawdata) as Vrawdata,IIf(IsNull(Irawdata),'',Irawdata) as Irawdata from td2dcon where TCHID = %u and TSN = %d"), this->m_dwChID, this->m_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"));
|
||||
|
||||
SplitterString(m_saVRawData, szVRawData, _T(";"));
|
||||
iIndex = (int)VAL_ZERO;
|
||||
while (iIndex < m_saVRawData.GetSize())
|
||||
{
|
||||
szValue.Empty();
|
||||
szValue = m_saVRawData.GetAt(iIndex);
|
||||
if (4 == iIndex)
|
||||
{
|
||||
szValue.TrimLeft(szValue.Left(5));
|
||||
}
|
||||
szValue.TrimLeft();
|
||||
|
||||
if (iIndex >= 4)
|
||||
{
|
||||
fValue = 0.0;
|
||||
fValue = this->ConvertVOrgData((float)atof(szValue));
|
||||
|
||||
if (fabsf(fValue) > this->m_fMaxAbsV)
|
||||
{
|
||||
this->m_fMaxAbsV = fabsf(fValue);
|
||||
}
|
||||
|
||||
szValue.Empty();
|
||||
szValue.Format(_T("%.4f"), fValue);
|
||||
}
|
||||
|
||||
m_saVRawData.SetAt(iIndex, szValue);
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
szIRawData.Empty();
|
||||
szIRawData = (LPCTSTR)(_bstr_t)pRecRawData->GetCollect(_T("Irawdata"));
|
||||
|
||||
SplitterString(m_saIRawData, szIRawData, _T(";"));
|
||||
iIndex = (int)VAL_ZERO;
|
||||
while (iIndex < m_saIRawData.GetSize())
|
||||
{
|
||||
szValue.Empty();
|
||||
szValue = m_saIRawData.GetAt(iIndex);
|
||||
if (4 == iIndex)
|
||||
{
|
||||
szValue.TrimLeft(szValue.Left(5));
|
||||
}
|
||||
szValue.TrimLeft();
|
||||
m_saIRawData.SetAt(iIndex, szValue);
|
||||
iIndex++;
|
||||
}
|
||||
|
||||
}
|
||||
pRecRawData->Close();
|
||||
}
|
||||
catch (_com_error e)
|
||||
{
|
||||
// AfxMessageBox(e.Description());
|
||||
throw;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
float CTdRecord::GetMaxAbsV()
|
||||
{
|
||||
return m_fMaxAbsV;
|
||||
}
|
||||
Reference in New Issue
Block a user