3893 lines
110 KiB
C++
3893 lines
110 KiB
C++
// Device.cpp: implementation of the CDevice class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "geomative.h"
|
|
#include "Device.h"
|
|
#include "FileTransfer.h"
|
|
#include "Zmodem.h"
|
|
|
|
#include "Markup.h"
|
|
#include "opdevpammodifydlg.h"
|
|
#include "opdevcableheadmodifydlg.h"
|
|
#include "GD10OperCmd.h"
|
|
#include "UpDateTimeWindow.h"
|
|
#include <DbgHelp.h>
|
|
#include "DetcGD10Dev.h"
|
|
#define MODULE_NAME _T("CDevice")
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
extern int g_iLanguage;
|
|
extern int g_iTransMode;
|
|
extern CString g_szMacAddress;
|
|
extern void TransDelay(int iTransMode, int iDS0, int iDS1, HWND hWnd = NULL);
|
|
extern BOOL GetSubStringInHeadAndTail(const CString& szSource, CString& szSub, const CString& szHead, const CString& szTail);
|
|
extern void SplitterString(CStringArray &szArray,const CString& szSource, const CString& szSplitter);
|
|
extern CString GetGrCodeText(int iCode);
|
|
extern SYSTEMTIME g_sysCurTime;
|
|
extern int g_iTransFileMode;
|
|
extern int g_iUILanguage;
|
|
|
|
#define ONE_SUBTASK_TEST_POINT_NUMBER (15000) //大数据任务,分割成当个子任务的每个任务最多15000个点
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
extern HHOOK hHook;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
CDevice::CDevice(DWORD dwID, _ConnectionPtr& pConnection)
|
|
{
|
|
m_dwID = dwID;
|
|
m_pConnection = pConnection;
|
|
m_uState = PZ_STATE_OFFLINE;
|
|
m_uType = PZ_STYLE_DEV;
|
|
|
|
m_szDevSN = _T("");
|
|
m_szDevName = _T("");
|
|
m_szModelNO = _T("");
|
|
m_szMDate = _T("");
|
|
m_szHWV = _T("");
|
|
m_szSWV = _T("");
|
|
m_szMBatch = _T("");
|
|
m_ucDevType = 0;
|
|
// m_pLogFile = NULL;
|
|
m_pLogFile = fopen("LOG\\device_log.txt","ab+");
|
|
if (NULL == m_pLogFile)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("打开 device_log.txt 失败!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Open device_log.txt failed!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
}
|
|
|
|
CDevice::~CDevice()
|
|
{
|
|
fclose(m_pLogFile);
|
|
m_pLogFile = NULL;
|
|
|
|
}
|
|
|
|
void CDevice::SetState(UINT uState)
|
|
{
|
|
m_uState = uState;
|
|
}
|
|
|
|
void CDevice::SetID(DWORD dwID)
|
|
{
|
|
m_dwID = dwID;
|
|
}
|
|
|
|
BOOL CDevice::Reset()
|
|
{
|
|
//用于Com/USB模式通知主机
|
|
/*CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("disconnect_gd10()\r\n"));
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
|
|
szOrder.ReleaseBuffer();
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;*/
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
bool CDevice::ShowFLDetailInfo(CListCtrl &devDetailList)
|
|
{
|
|
_RecordsetPtr pRecDev = NULL;
|
|
_RecordsetPtr pRecCm = NULL;
|
|
|
|
CString szSql;
|
|
CString szLabel;
|
|
|
|
int iRowIndex = (int)VAL_ZERO;
|
|
|
|
while (devDetailList.GetItemCount() != iRowIndex)
|
|
{
|
|
devDetailList.SetItemText(iRowIndex, 1, _T(""));
|
|
iRowIndex++;
|
|
}
|
|
|
|
pRecDev.CreateInstance(_uuidof(Recordset));
|
|
pRecCm.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select DEname,modelNO,SN,HWV,SWV,Format(Mdate,'YYYY-MM-DD') as Mdate,Mbatch from device where ID = %u"), m_dwID);
|
|
pRecDev->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecDev->GetRecordCount())
|
|
{
|
|
devDetailList.SetItemText(0, 1, pRecDev->GetCollect(_T("DEname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("DEname")));
|
|
|
|
devDetailList.SetItemText(1, 1, pRecDev->GetCollect(_T("modelNO")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("modelNO")));
|
|
devDetailList.SetItemText(2, 1, pRecDev->GetCollect(_T("SN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("SN")));
|
|
devDetailList.SetItemText(3, 1, pRecDev->GetCollect(_T("HWV")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("HWV")));
|
|
devDetailList.SetItemText(4, 1, pRecDev->GetCollect(_T("SWV")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("SWV")));
|
|
devDetailList.SetItemText(5, 1, pRecDev->GetCollect(_T("Mdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("Mdate")));
|
|
devDetailList.SetItemText(6, 1, pRecDev->GetCollect(_T("Mbatch")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("Mbatch")));
|
|
}
|
|
|
|
pRecDev->Close();
|
|
return true;
|
|
}
|
|
|
|
bool CDevice::ShowOLDetailInfo(CListCtrl& devDetailList)
|
|
{
|
|
_RecordsetPtr pRecDev = NULL;
|
|
_RecordsetPtr pRecPam = NULL;
|
|
_RecordsetPtr pRecCm = NULL;
|
|
|
|
CString szSql = _T("");
|
|
CString szLabel = _T("");
|
|
|
|
int iRowIndex = (int)VAL_ZERO;
|
|
|
|
while (devDetailList.GetItemCount() != iRowIndex)
|
|
{
|
|
devDetailList.SetItemText(iRowIndex, 1, _T(""));
|
|
iRowIndex++;
|
|
}
|
|
|
|
pRecDev.CreateInstance(_uuidof(Recordset));
|
|
pRecPam.CreateInstance(_uuidof(Recordset));
|
|
pRecCm.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select DEname,modelNO,SN,HWV,SWV,Format(Mdate,'YYYY-MM-DD') as Mdate,Mbatch from device where ID = %u"), m_dwID);
|
|
pRecDev->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecDev->GetRecordCount())
|
|
{
|
|
devDetailList.SetItemText(0, 1, pRecDev->GetCollect(_T("DEname")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("DEname")));
|
|
|
|
devDetailList.SetItemText(1, 1, pRecDev->GetCollect(_T("modelNO")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("modelNO")));
|
|
devDetailList.SetItemText(2, 1, pRecDev->GetCollect(_T("SN")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("SN")));
|
|
devDetailList.SetItemText(3, 1, pRecDev->GetCollect(_T("HWV")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("HWV")));
|
|
devDetailList.SetItemText(4, 1, pRecDev->GetCollect(_T("SWV")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("SWV")));
|
|
devDetailList.SetItemText(5, 1, pRecDev->GetCollect(_T("Mdate")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("Mdate")));
|
|
devDetailList.SetItemText(6, 1, pRecDev->GetCollect(_T("Mbatch")).vt == VT_NULL ? _T("") : (LPCTSTR)(_bstr_t)pRecDev->GetCollect(_T("Mbatch")));
|
|
}
|
|
|
|
pRecDev->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Ifrequency,numformat,Tsys,Mvoltage,Msys,maxRG,Tzone,STdelay,PSmode,PBtone,Ttone,dimmer,lang from desetting where DEID = %u"), m_dwID);
|
|
pRecPam->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecPam->GetRecordCount())
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("Ifrequency")).iVal);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
devDetailList.SetItemText(7, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'numformat' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("numformat")).iVal);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
devDetailList.SetItemText(8, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Tsys' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("Tsys")).iVal);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
devDetailList.SetItemText(9, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Mvoltage' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("Mvoltage")).iVal);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
devDetailList.SetItemText(10, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Msys' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("Msys")).iVal);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
devDetailList.SetItemText(11, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->Close();
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), (int)pRecPam->GetCollect(_T("maxRG")).iVal);
|
|
devDetailList.SetItemText(12, 1, szLabel);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Tzone' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("Tzone")).iVal);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
devDetailList.SetItemText(13, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->Close();
|
|
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'Stdelay' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("STdelay")).iVal);
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
// devDetailList.SetItemText(14, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
// pRecCm->Close();
|
|
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'Psmode' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("PSmode")).iVal);
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
// devDetailList.SetItemText(15, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
// pRecCm->Close();
|
|
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'Pbtone' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("PBtone")).iVal);
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
// devDetailList.SetItemText(16, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
// pRecCm->Close();
|
|
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'Ttone' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("Ttone")).iVal);
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
// devDetailList.SetItemText(17, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
// pRecCm->Close();
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), (int)VAL_ZERO);
|
|
devDetailList.SetItemText(14, 1, szLabel);
|
|
|
|
szLabel.Empty();
|
|
szLabel.Format(_T("%d"), (int)pRecPam->GetCollect(_T("dimmer")).iVal);
|
|
devDetailList.SetItemText(15, 1, szLabel);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Lang' and Lang = %d and Cvalue = %d order by Cvalue"), g_iLanguage, (int)pRecPam->GetCollect(_T("lang")).iVal);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
devDetailList.SetItemText(16, 1, (LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->Close();
|
|
}
|
|
pRecPam->Close();
|
|
|
|
return true;
|
|
}
|
|
|
|
bool CDevice::InitialCableHeadDlg(CListCtrl& cableHeadList)
|
|
{
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
CStringArray saRes;
|
|
|
|
CString szPos = _T("");
|
|
CString szSN = _T("");
|
|
CString szBattery = _T("");
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
int iSN = (int)VAL_ZERO;
|
|
int iLNum = (int)VAL_ZERO;
|
|
int iRNum = (int)VAL_ZERO;
|
|
|
|
cableHeadList.DeleteAllItems();
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
/*m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder = _T("\r\n");
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 10, 50);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 5))
|
|
{
|
|
Sleep(1);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
this->m_sComPort.ClearCommSendBuff();
|
|
this->m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder = _T("get_cable_count()\r\n");
|
|
// MessageBox(szOrder);
|
|
|
|
this->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 100, 200);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < 3))
|
|
{
|
|
Sleep(500);
|
|
while (this->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
// AfxMessageBox(szResBuff);
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
szRes.Empty();
|
|
if (TRUE == GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]")) && (iPollingTime < MAX_POLLING_TIME))
|
|
{
|
|
saRes.RemoveAll();
|
|
SplitterString(saRes, szRes, _T(";"));
|
|
|
|
if (saRes.GetSize() != 2) //对设备进行鉴别
|
|
{
|
|
return false;
|
|
}
|
|
|
|
iLNum = atoi(saRes.GetAt(0));
|
|
iRNum = atoi(saRes.GetAt(1));
|
|
|
|
szPos.Empty();
|
|
szPos.LoadString(IDS_LEFT);
|
|
|
|
iSN = (int)VAL_ONE;
|
|
while (iSN <= iLNum)
|
|
{
|
|
szSN.Empty();
|
|
szSN.Format(_T("%d"), iSN);
|
|
|
|
cableHeadList.InsertItem(iSN - 1, szPos);
|
|
cableHeadList.SetItemText(iSN - 1, 1, szSN);
|
|
|
|
this->m_sComPort.ClearCommSendBuff();
|
|
this->m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("get_cable_info(76,%d)\r\n"), iSN);
|
|
// MessageBox(szOrder);
|
|
|
|
this->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 100, 200);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < MAX_POLLING_TIME))
|
|
{
|
|
Sleep(1);
|
|
while (this->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
// AfxMessageBox(szResBuff);
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
szRes.Empty();
|
|
if (TRUE == GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]")) && (iPollingTime < MAX_POLLING_TIME))
|
|
{
|
|
cableHeadList.SetItemText(iSN - 1, 2, szRes);
|
|
}
|
|
|
|
iSN ++;
|
|
}
|
|
|
|
szPos.Empty();
|
|
szPos.LoadString(IDS_RIGHT);
|
|
|
|
iSN = (int)VAL_ONE;
|
|
while (iSN <= iRNum)
|
|
{
|
|
szSN.Empty();
|
|
szSN.Format(_T("%d"), iSN);
|
|
|
|
cableHeadList.InsertItem(iSN + iLNum - 1, szPos);
|
|
cableHeadList.SetItemText(iSN + iLNum - 1, 1, szSN);
|
|
|
|
this->m_sComPort.ClearCommSendBuff();
|
|
this->m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("get_cable_info(82,%d)\r\n"), iSN);
|
|
// MessageBox(szOrder);
|
|
|
|
this->m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 100, 200);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < MAX_POLLING_TIME))
|
|
{
|
|
Sleep(1);
|
|
while (this->m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
// AfxMessageBox(szResBuff);
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
szRes.Empty();
|
|
if (TRUE == GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]")) && (iPollingTime < MAX_POLLING_TIME))
|
|
{
|
|
cableHeadList.SetItemText(iSN + iLNum - 1, 2, szRes);
|
|
}
|
|
|
|
iSN ++;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}*/
|
|
|
|
return true;
|
|
}
|
|
|
|
bool CDevice::ShowGRInfo(CListCtrl& devGRList)
|
|
{
|
|
_RecordsetPtr pRecGrList = NULL;
|
|
CString szSql = _T("");
|
|
CString szLabel = _T("");
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
pRecGrList.CreateInstance(_uuidof(Recordset));
|
|
if ((int)VAL_ZERO != devGRList.GetItemCount())
|
|
{
|
|
devGRList.DeleteAllItems();
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Ecode,Format(Mdate,'YYYY-MM-DD') as Mdate,Format(Mtime,'HH:MM:SS') as Mtime,OMvalue,OM1value,")
|
|
_T(" StatusCode ,StatusCode1 from devgr where DEID = %u order by Val(Ecode)"), m_dwID);
|
|
pRecGrList->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecGrList->adoEOF)
|
|
{
|
|
devGRList.InsertItem(iIndex, (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Ecode")));
|
|
devGRList.SetItemText(iIndex, 1, (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Mdate")));
|
|
devGRList.SetItemText(iIndex, 2, (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("Mtime")));
|
|
devGRList.SetItemText(iIndex, 3, (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("OMvalue")));
|
|
|
|
devGRList.SetItemText(iIndex, 4, GetGrCodeText(pRecGrList->GetCollect(_T("StatusCode")).lVal));
|
|
devGRList.SetItemText(iIndex, 5, (LPCTSTR)(_bstr_t)pRecGrList->GetCollect(_T("OM1value")));
|
|
devGRList.SetItemText(iIndex, 6, GetGrCodeText(pRecGrList->GetCollect(_T("StatusCode1")).lVal));
|
|
|
|
iIndex++;
|
|
pRecGrList->MoveNext();
|
|
}
|
|
|
|
pRecGrList->Close();
|
|
return true;
|
|
}
|
|
|
|
bool CDevice::ShowACInfo(CListCtrl& devACList)
|
|
{
|
|
int iItemIndex = (int)VAL_ZERO;
|
|
|
|
_RecordsetPtr pRecAC = NULL;
|
|
CString szSql = _T("");
|
|
|
|
while (iItemIndex < 20)
|
|
{
|
|
devACList.SetItemText(iItemIndex, 1, _T(""));
|
|
devACList.SetItemText(iItemIndex, 2, _T(""));
|
|
iItemIndex ++;
|
|
}
|
|
|
|
szSql.Empty();
|
|
pRecAC.CreateInstance(_uuidof(Recordset));
|
|
|
|
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,"
|
|
"M10ST,M10TW,M11ST,M11TW,M12ST,M12TW,M13ST,M13TW,M14ST,M14TW,M15ST,M15TW,M16ST,M16TW,M17ST,M17TW,M18ST,M18TW,"
|
|
"M19ST,M19TW from acds where DEID = %u"), m_dwID);
|
|
pRecAC->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecAC->GetRecordCount())
|
|
{
|
|
CString strST,strTW;
|
|
for (int i = 0; i < 20; i++)
|
|
{
|
|
strST.Empty();
|
|
strTW.Empty();
|
|
strST.Format(_T("M%dST"),i);
|
|
strTW.Format(_T("M%dTW"),i);
|
|
devACList.SetItemText(i, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(strST.GetBuffer(0)));
|
|
devACList.SetItemText(i, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(strTW.GetBuffer(0)));
|
|
}
|
|
// devACList.SetItemText(0, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M0ST")));
|
|
// devACList.SetItemText(0, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M0TW")));
|
|
//
|
|
// devACList.SetItemText(1, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M1ST")));
|
|
// devACList.SetItemText(1, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M1TW")));
|
|
//
|
|
// devACList.SetItemText(2, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M2ST")));
|
|
// devACList.SetItemText(2, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M2TW")));
|
|
//
|
|
// devACList.SetItemText(3, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M3ST")));
|
|
// devACList.SetItemText(3, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M3TW")));
|
|
//
|
|
// devACList.SetItemText(4, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M4ST")));
|
|
// devACList.SetItemText(4, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M4TW")));
|
|
//
|
|
// devACList.SetItemText(5, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M5ST")));
|
|
// devACList.SetItemText(5, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M5TW")));
|
|
//
|
|
// devACList.SetItemText(6, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M6ST")));
|
|
// devACList.SetItemText(6, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M6TW")));
|
|
//
|
|
// devACList.SetItemText(7, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M7ST")));
|
|
// devACList.SetItemText(7, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M7TW")));
|
|
//
|
|
// devACList.SetItemText(8, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M8ST")));
|
|
// devACList.SetItemText(8, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M8TW")));
|
|
//
|
|
// devACList.SetItemText(9, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M9ST")));
|
|
// devACList.SetItemText(9, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M9TW")));
|
|
//
|
|
// devACList.SetItemText(10, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M10ST")));
|
|
// devACList.SetItemText(10, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M10TW")));
|
|
//
|
|
// devACList.SetItemText(11, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M11ST")));
|
|
// devACList.SetItemText(11, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M11TW")));
|
|
//
|
|
// devACList.SetItemText(12, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M12ST")));
|
|
// devACList.SetItemText(12, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M12TW")));
|
|
//
|
|
// devACList.SetItemText(13, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M13ST")));
|
|
// devACList.SetItemText(13, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M13TW")));
|
|
//
|
|
// devACList.SetItemText(14, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M14ST")));
|
|
// devACList.SetItemText(14, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M14TW")));
|
|
//
|
|
// devACList.SetItemText(15, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M15ST")));
|
|
// devACList.SetItemText(15, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M15TW")));
|
|
//
|
|
// devACList.SetItemText(16, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M16ST")));
|
|
// devACList.SetItemText(16, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M16TW")));
|
|
//
|
|
// devACList.SetItemText(17, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M17ST")));
|
|
// devACList.SetItemText(17, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M17TW")));
|
|
//
|
|
// devACList.SetItemText(18, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M18ST")));
|
|
// devACList.SetItemText(18, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M18TW")));
|
|
//
|
|
// devACList.SetItemText(19, 1, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M19ST")));
|
|
// devACList.SetItemText(19, 2, (LPCTSTR)(_bstr_t)pRecAC->GetCollect(_T("M19TW")));
|
|
|
|
}
|
|
|
|
pRecAC->Close();
|
|
|
|
return true;
|
|
}
|
|
|
|
BOOL CDevice::ShowCableHeadInfoDlg()
|
|
{
|
|
_CommandPtr pCmdUpd = NULL;
|
|
CString szSql = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CString szRes = _T("");
|
|
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
COpDevCableHeadModifyDlg *pOpDevCableHeadModifyDlg = new COpDevCableHeadModifyDlg;
|
|
|
|
pOpDevCableHeadModifyDlg->Create(IDD_OP_DEV_CABLEHEAD_M, AfxGetMainWnd());
|
|
CListCtrl &cableHeadList = pOpDevCableHeadModifyDlg->m_chList;
|
|
|
|
this->InitialCableHeadDlg(cableHeadList);
|
|
pOpDevCableHeadModifyDlg->ShowWindow(SW_SHOW);
|
|
|
|
lRet = pOpDevCableHeadModifyDlg->RunModalLoop(MLF_SHOWONIDLE);
|
|
|
|
delete pOpDevCableHeadModifyDlg;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDevice::ReceiveFile(const CString &szLocFilePath, const CString& szHostFileName,int nRetryCnt)
|
|
{
|
|
BOOL bRes = FALSE;
|
|
|
|
CProgressDlg *proDlg;
|
|
proDlg = new CProgressDlg();
|
|
|
|
if (!proDlg)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
proDlg->m_device = this;
|
|
proDlg->m_RecvOrSend = FALSE;
|
|
proDlg->m_szLocFilePath = szLocFilePath;
|
|
proDlg->m_szHostFileName = szHostFileName;
|
|
proDlg->DoModal();
|
|
bRes = proDlg->m_exCode;//获取界面中zmodem的返回值
|
|
|
|
delete proDlg;
|
|
|
|
//重新传送3次
|
|
if ((nRetryCnt > 0) && (TRUE != bRes))
|
|
{
|
|
Sleep(2000);
|
|
nRetryCnt--;
|
|
CString strShow = _T("");
|
|
CString strHost = szHostFileName;
|
|
strShow.Format(_T("retry to transfer file %s, RertyIndex = %d"),strHost.GetBuffer(0),nRetryCnt);
|
|
PrintLog(strShow);
|
|
if (EndTransfer())
|
|
{
|
|
|
|
bRes = ReceiveFile(szLocFilePath, szHostFileName,nRetryCnt);
|
|
}
|
|
else
|
|
{
|
|
strShow.Empty();
|
|
strShow.Format(_T("retry to end transfer processing failed!!!"));
|
|
PrintLog(strShow);
|
|
}
|
|
|
|
}
|
|
return bRes;
|
|
|
|
/*
|
|
int iResSize = (int)VAL_ZERO;
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
char aResBuff[1024] = {0};
|
|
|
|
CStringArray szHostFileNameArray;
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder = _T("\r\n");
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 10, 50);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < 5))
|
|
{
|
|
Sleep(1);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("sz(\"%s\")\r\n"), szHostFileName);
|
|
// AfxMessageBox(szOrder);
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 20, 50);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while (iPollingTime < 3)
|
|
{
|
|
Sleep(1);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
// AfxMessageBox(szResBuff);
|
|
|
|
if ((szResBuff.Find("...") != -1) && (szResBuff.Find(">") == -1))
|
|
{
|
|
Zmodem* zmodem = new Zmodem(&m_sComPort);
|
|
if (TRUE != zmodem->Receive(szLocFilePath))
|
|
{
|
|
delete zmodem;
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(_T("Zmodem receive file failed!"));
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
delete zmodem;
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
return TRUE;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
*/
|
|
}
|
|
|
|
BOOL CDevice::SendFile(const CString &szHostFilePath, const CString &szLocFilePath, const CString& szLocFileName)
|
|
{
|
|
BOOL bRes = FALSE;
|
|
|
|
CProgressDlg *proDlg;
|
|
proDlg = new CProgressDlg();
|
|
|
|
if (!proDlg)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
proDlg->m_device = this;
|
|
proDlg->m_RecvOrSend = TRUE;
|
|
proDlg->m_szHostFilePath = szHostFilePath;
|
|
proDlg->m_szLocFilePath = szLocFilePath;
|
|
proDlg->m_szLocFileName = szLocFileName;
|
|
proDlg->DoModal();
|
|
bRes = proDlg->m_exCode;
|
|
|
|
delete proDlg;
|
|
|
|
|
|
return bRes;
|
|
/*
|
|
//log
|
|
FILE *pFile = NULL;
|
|
pFile = fopen("LOG\\SendFile.txt", "ab");
|
|
char buffer[256];
|
|
memset(buffer, 0, 256);
|
|
int nlength = 0;
|
|
//log
|
|
|
|
|
|
//log
|
|
nlength = sprintf(buffer, "\t\t\tBEGIN\r\n");
|
|
fwrite(buffer, 1, nlength, pFile);
|
|
fflush(pFile);
|
|
//log
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
char aResBuff[1024] = {0};
|
|
char *aLocFile[] = {0};
|
|
|
|
CStringArray szHostFileNameArray;
|
|
|
|
CString szLocFile = _T("");
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder = _T("\r\n");
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
// TransDelay(g_iTransMode, 10, 50);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 5))
|
|
{
|
|
Sleep(1);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("rz(\"%s\")\r\n"), szHostFilePath);
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
|
|
//log
|
|
nlength = sprintf(buffer, "SendDataDirectly rz(\"%s\")\r\n",szHostFilePath);
|
|
fwrite(buffer, 1, nlength, pFile);
|
|
fflush(pFile);
|
|
//log
|
|
|
|
// TransDelay(g_iTransMode, 10, 50);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 3))
|
|
{
|
|
//log
|
|
nlength = sprintf(buffer, "while ((szResBuff.Find\r\n");
|
|
fwrite(buffer, 1, nlength, pFile);
|
|
fflush(pFile);
|
|
//log
|
|
|
|
Sleep(1);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
//log
|
|
nlength = sprintf(buffer, "ReceiveDataDirectly %d\r\n ", iResSize);
|
|
fwrite(buffer, 1, nlength, pFile);
|
|
fflush(pFile);
|
|
//log
|
|
|
|
//log
|
|
nlength = sprintf(buffer, "{\r\n%s\r\n}\r\n ", aResBuff);
|
|
fwrite(buffer, 1, nlength, pFile);
|
|
fflush(pFile);
|
|
//log
|
|
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
//log
|
|
nlength = sprintf(buffer, "ReceiveDataDirectly = FALSE");
|
|
fwrite(buffer, 1, nlength, pFile);
|
|
fflush(pFile);
|
|
//log
|
|
|
|
|
|
iPollingTime++;
|
|
}
|
|
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(szResBuff);
|
|
|
|
if ((szResBuff.Find("...") != -1) && (szResBuff.Find(">") == -1))
|
|
{
|
|
szLocFile = szLocFilePath + _T("\\") + szLocFileName;
|
|
Zmodem* zmodem = new Zmodem(&m_sComPort);
|
|
|
|
aLocFile[0] = szLocFile.GetBuffer(szLocFile.GetLength());
|
|
aLocFile[1] = 0;
|
|
|
|
szLocFile.ReleaseBuffer();
|
|
if (TRUE != zmodem->Send(aLocFile))
|
|
{
|
|
delete zmodem;
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(_T("Zmodem send file failed!"));
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
return FALSE;
|
|
}
|
|
else
|
|
{
|
|
szLocFile.ReleaseBuffer();
|
|
delete zmodem;
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
return TRUE;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
//log
|
|
nlength = sprintf(buffer, "\t\t\tBEGIN\r\n");
|
|
fwrite(buffer, 1, nlength, pFile);
|
|
fflush(pFile);
|
|
//log
|
|
*/
|
|
|
|
}
|
|
|
|
BOOL CDevice::GetDevInfo()
|
|
{
|
|
_CommandPtr pCmdUpd;
|
|
CString szSql = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
CStringArray saRes;
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
char aPath[1024] = {0};
|
|
CString szCurFilePath = _T("");
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFileName = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szHostFileName = _T("");
|
|
|
|
CString szHWV = _T("");
|
|
CString szSWV = _T("");
|
|
CString szMDate = _T("");
|
|
CString szMBatch = _T("");
|
|
|
|
CString szSptCN = _T("");
|
|
CString szSptFileName = _T("");
|
|
|
|
CString szIFrequency = _T("");
|
|
CString szNumFormat = _T("");
|
|
CString szTSys = _T("");
|
|
CString szMVoltage = _T("");
|
|
CString szMSys = _T("");
|
|
CString szMaxRG = _T("");
|
|
CString szTZone = _T("");
|
|
CString szSTDelay = _T("");
|
|
CString szPSMode = _T("");
|
|
CString szPBTone = _T("");
|
|
CString szTTone = _T("");
|
|
CString szBVoltage = _T("");
|
|
CString szDimmer = _T("");
|
|
CString szLang = _T("");
|
|
|
|
int iaAC[20][2] = {0};
|
|
int iIndex = (int)VAL_ZERO;
|
|
CString szACNode = _T("");
|
|
CString szACCon = _T("");
|
|
|
|
CString szPrompt = _T("");
|
|
|
|
CMarkup xmlDev;
|
|
|
|
//LOG
|
|
CString szLog = _T("");
|
|
|
|
try
|
|
{
|
|
/*szOrder.Empty();
|
|
szOrder = _T("device_ex_info()\r\n");
|
|
|
|
if (!this->ExecuteOrder(szOrder, "]", &szResBuff))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
SplitterString(saRes, szRes, _T(";"));
|
|
|
|
if (saRes.GetSize() == 4)
|
|
{
|
|
szHWV.Empty();
|
|
szHWV = saRes.GetAt(0);
|
|
|
|
szSWV.Empty();
|
|
szSWV = saRes.GetAt(1);
|
|
|
|
szMDate.Empty();
|
|
szMDate.Format(_T("%s-%s-%s"), saRes.GetAt(2).Left(4), saRes.GetAt(2).Mid(4, 2), saRes.GetAt(2).Right(2));
|
|
|
|
szMBatch.Empty();
|
|
szMBatch = saRes.GetAt(3);
|
|
}
|
|
else
|
|
return FALSE;
|
|
|
|
|
|
// //log
|
|
// szLog.Empty();
|
|
// szLog.Format("{%s} [%d] send device_ex_info, cost_ticks = %d",MODULE_NAME, __LINE__, GetTickCount() - dwBegin);
|
|
// PrintLog(szLog);
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
szCurFilePath.Empty();
|
|
szCurFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szCurFilePath.GetLength(), szCurFilePath.GetBuffer(szCurFilePath.GetLength()));
|
|
szCurFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szCurFilePath+_T("\\")+this->m_szDevSN+_T("\\equipment\\");
|
|
CreateDirectory((LPCTSTR)szLocFilePath, NULL);
|
|
|
|
szHostFileName = _T("/SD/equipment/equipment.xml");
|
|
if (TRUE != this->ReceiveFile(szLocFilePath, szHostFileName))
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("接受文件失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Receive file failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
szLog.Empty();
|
|
szLog.Format("{%s} [%d] receive file failed, LocalFilePath = %s, HostFileName = %s", MODULE_NAME,
|
|
__LINE__, szLocFilePath.GetBuffer(0), szHostFileName.GetBuffer(0));
|
|
PrintLog(szLog);
|
|
return FALSE;
|
|
}
|
|
|
|
szLocFileName = szLocFilePath+_T("equipment.xml");*/
|
|
|
|
szLocFilePath.Format(_T("%s\\sd\\equipment\\equipment.xml"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr());
|
|
|
|
if (!xmlDev.Load(szLocFilePath))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
xmlDev.FindElem(_T("equipment"));
|
|
xmlDev.FindChildElem(_T("parameter"));
|
|
xmlDev.IntoElem();
|
|
xmlDev.FindChildElem(_T("industrial_frequency"));
|
|
szIFrequency = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("number_format"));
|
|
szNumFormat = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("temperature_system"));
|
|
|
|
szTSys = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("mains_voltage"));
|
|
|
|
szMVoltage = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("metric_system"));
|
|
|
|
szMSys = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("max_rg"));
|
|
|
|
szMaxRG = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("timezone"));
|
|
|
|
szTZone = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("standby_time_delay"));
|
|
|
|
szSTDelay = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("power_save_mode"));
|
|
|
|
szPSMode = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("pushbutton_tone"));
|
|
|
|
szPBTone = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("testing_tone"));
|
|
|
|
szTTone = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("battery_voltage"));
|
|
|
|
szBVoltage = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("dimmer"));
|
|
|
|
szDimmer = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("language"));
|
|
szLang = xmlDev.GetChildData();
|
|
|
|
xmlDev.FindChildElem(_T("device_ex_info"));
|
|
szResBuff = xmlDev.GetChildData();
|
|
|
|
xmlDev.OutOfElem();
|
|
xmlDev.FindChildElem(_T("apparent_chargeability"));
|
|
xmlDev.IntoElem();
|
|
|
|
iIndex = (int)VAL_ZERO;
|
|
|
|
szACNode.Empty();
|
|
szACNode.Format(_T("m%d"), iIndex);
|
|
//在这里取前20个激电时窗
|
|
while ((xmlDev.FindChildElem(szACNode)) && iIndex<20)
|
|
{
|
|
szACCon.Empty();
|
|
szACCon = xmlDev.GetChildData();
|
|
|
|
iaAC[iIndex][0] = atoi(szACCon.Left(szACCon.Find(',', 0)));
|
|
iaAC[iIndex][1] = atoi(szACCon.Mid(szACCon.Find(',', 0) + 1));
|
|
|
|
iIndex++;
|
|
szACNode.Empty();
|
|
szACNode.Format(_T("m%d"), iIndex);
|
|
}
|
|
xmlDev.OutOfElem();
|
|
|
|
//处理数据
|
|
//GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
SplitterString(saRes, szResBuff, _T(";"));
|
|
|
|
if (saRes.GetSize() == 4)
|
|
{
|
|
szHWV.Empty();
|
|
szHWV = saRes.GetAt(0);
|
|
|
|
szSWV.Empty();
|
|
szSWV = saRes.GetAt(1);
|
|
|
|
szMDate.Empty();
|
|
szMDate.Format(_T("%s-%s-%s"), saRes.GetAt(2).Left(4), saRes.GetAt(2).Mid(4, 2), saRes.GetAt(2).Right(2));
|
|
|
|
szMBatch.Empty();
|
|
szMBatch = saRes.GetAt(3);
|
|
}
|
|
//else
|
|
// return FALSE;
|
|
|
|
m_pConnection->BeginTrans();
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = m_pConnection;
|
|
|
|
if (saRes.GetSize() == 4)
|
|
{
|
|
szSql.Empty();
|
|
szSql.Format(_T("update device set HWV='%s',SWV='%s',MDate=#%s#,MBatch='%s' where ID = %u"),
|
|
szHWV,
|
|
szSWV,
|
|
szMDate,
|
|
szMBatch,
|
|
m_dwID);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("update desetting set Ifrequency=%s,numformat=%s,Tsys=%s,Mvoltage=%s,Msys=%s,maxRG=%s,Tzone=%s,"
|
|
"STdelay=%s,PSmode=%s,PBtone=%s,Ttone=%s,Bvoltage=%s,dimmer=%s,lang=%s "
|
|
"where DEID=%u"),
|
|
szIFrequency,
|
|
szNumFormat,
|
|
szTSys,
|
|
szMVoltage,
|
|
szMSys,
|
|
szMaxRG,
|
|
szTZone,
|
|
szSTDelay,
|
|
szPSMode,
|
|
szPBTone,
|
|
szTTone,
|
|
szBVoltage,
|
|
szDimmer,
|
|
szLang,
|
|
m_dwID);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("update acds set M0ST=%d,M0TW=%d,M1ST=%d,M1TW=%d,M2ST=%d,M2TW=%d,M3ST=%d,M3TW=%d,M4ST=%d,M4TW=%d,"
|
|
"M5ST=%d,M5TW=%d,M6ST=%d,M6TW=%d,M7ST=%d,M7TW=%d,M8ST=%d,M8TW=%d,M9ST=%d,M9TW=%d,M10ST=%d,M10TW=%d,"
|
|
"M11ST=%d,M11TW=%d,M12ST=%d,M12TW=%d,M13ST=%d,M13TW=%d,M14ST=%d,M14TW=%d,M15ST=%d,M15TW=%d,M16ST=%d,M16TW=%d,"
|
|
"M17ST=%d,M17TW=%d,M18ST=%d,M18TW=%d,M19ST=%d,M19TW=%d where DEID=%u"),
|
|
iaAC[0][0],iaAC[0][1],
|
|
iaAC[1][0],iaAC[1][1],
|
|
iaAC[2][0],iaAC[2][1],
|
|
iaAC[3][0],iaAC[3][1],
|
|
iaAC[4][0],iaAC[4][1],
|
|
iaAC[5][0],iaAC[5][1],
|
|
iaAC[6][0],iaAC[6][1],
|
|
iaAC[7][0],iaAC[7][1],
|
|
iaAC[8][0],iaAC[8][1],
|
|
iaAC[9][0],iaAC[9][1],
|
|
iaAC[10][0],iaAC[10][1],
|
|
iaAC[11][0],iaAC[11][1],
|
|
iaAC[12][0],iaAC[12][1],
|
|
iaAC[13][0],iaAC[13][1],
|
|
iaAC[14][0],iaAC[14][1],
|
|
iaAC[15][0],iaAC[15][1],
|
|
iaAC[16][0],iaAC[16][1],
|
|
iaAC[17][0],iaAC[17][1],
|
|
iaAC[18][0],iaAC[18][1],
|
|
iaAC[19][0],iaAC[19][1],
|
|
m_dwID);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
szLog.Empty();
|
|
szLog.Format(_T("{CDevice} [%d] GetDevInfo:: catch an expection"),__LINE__);
|
|
PrintLog(szLog);
|
|
|
|
m_pConnection->RollbackTrans();
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(e.Description());
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDevice::GetGRInfo()
|
|
{
|
|
_CommandPtr pCmdIns = NULL;
|
|
CString szSql = _T("");
|
|
|
|
char aPath[1024] = {0};
|
|
CString szCurFilePath = _T("");
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFileName = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szHostFileName = _T("");
|
|
|
|
CString szECode = _T("");
|
|
CString szDT = _T("");
|
|
CString szMDate = _T("");
|
|
CString szMTime = _T("");
|
|
CString szTdGR = _T("");
|
|
CString szNodeName = _T("");
|
|
|
|
CStringArray saTdGR;
|
|
|
|
int iOMValue = (int)VAL_ZERO;
|
|
int iOM1Value = (int)VAL_ZERO;
|
|
int iResCode = (int)VAL_ZERO;
|
|
int iResCode1 = (int)VAL_ZERO;
|
|
|
|
int iIndex = (int)VAL_ZERO;
|
|
|
|
CString szLog = _T("");
|
|
|
|
try
|
|
{
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
/*szCurFilePath.Empty();
|
|
szCurFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szCurFilePath.GetLength(), szCurFilePath.GetBuffer(szCurFilePath.GetLength()));
|
|
szCurFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szCurFilePath+_T("\\")+this->m_szDevSN+_T("\\equipment\\resistance\\");
|
|
CreateDirectory((LPCTSTR)szLocFilePath, NULL);
|
|
|
|
szHostFileName = _T("/SD/equipment/resistance/resistance.res");
|
|
if (TRUE != this->ReceiveFile(szLocFilePath, szHostFileName))
|
|
{
|
|
szLog.Empty();
|
|
szLog.Format(_T("{%s} [%d] GetGRInfo:: receive file error, LocalFilePath = %s, szHostFileName = %s"), MODULE_NAME,
|
|
__LINE__, szLocFilePath.GetBuffer(0), szHostFileName.GetBuffer(0));
|
|
PrintLog(szLog);
|
|
|
|
return FALSE;
|
|
}
|
|
szLocFileName = szLocFilePath+_T("resistance.res");*/
|
|
|
|
szHostFileName.Format(_T("%s/SD/equipment/resistance/resistance.res"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr());
|
|
|
|
//////////////////////////////////
|
|
|
|
m_pConnection->BeginTrans();
|
|
|
|
CMarkup *pXML = new CMarkup;
|
|
pXML->Load(szHostFileName);
|
|
|
|
pXML->FindElem(_T("TD"));
|
|
|
|
pXML->FindChildElem("param");
|
|
|
|
pXML->FindChildElem("Data");
|
|
pXML->IntoElem();
|
|
|
|
iIndex = (int)VAL_ONE;
|
|
szNodeName.Empty();
|
|
szNodeName.Format(_T("D%.4d"), iIndex);
|
|
|
|
while (pXML->FindChildElem(szNodeName))
|
|
{
|
|
szTdGR = pXML->GetChildData();
|
|
SplitterString(saTdGR, szTdGR, _T(";"));
|
|
|
|
szECode.Empty();
|
|
szECode = saTdGR.GetAt(0);
|
|
szECode.TrimLeft();
|
|
szECode.TrimRight();
|
|
|
|
iOMValue = atoi(saTdGR.GetAt(1));
|
|
iResCode = atoi(saTdGR.GetAt(2));
|
|
iOM1Value = atoi(saTdGR.GetAt(3));
|
|
iResCode1 = atoi(saTdGR.GetAt(4));
|
|
|
|
szDT.Empty();
|
|
szDT = saTdGR.GetAt(5);
|
|
|
|
szDT.TrimLeft();
|
|
szDT.TrimRight();
|
|
|
|
szMDate.Empty();
|
|
szMDate.Format(_T("%s-%s-%s"), szDT.Mid(0, 4), szDT.Mid(4, 2), szDT.Mid(6, 2));
|
|
|
|
szMTime.Empty();
|
|
szMTime.Format(_T("%s:%s:%s"), szDT.Mid(8, 2), szDT.Mid(10, 2), szDT.Mid(12, 2));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into devgr(DEID,Ecode,OMvalue,Mdate,Mtime,StatusCode,OM1value,StatusCode1) values(%u,'%s',%d,#%s#,#%s#,%d,%d,%d)"),
|
|
this->m_dwID, szECode, iOMValue, szMDate, szMTime,iResCode,iOM1Value,iResCode1);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
iIndex++;
|
|
szNodeName.Empty();
|
|
if (iIndex <= 9999)
|
|
{
|
|
szNodeName.Format(_T("D%.4d"), iIndex);
|
|
}
|
|
else
|
|
{
|
|
szNodeName.Format(_T("D%d"), iIndex);
|
|
}
|
|
|
|
}
|
|
|
|
delete pXML;
|
|
|
|
m_pConnection->CommitTrans();
|
|
////////////////////////////////
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
szLog.Empty();
|
|
szLog.Format(_T("{%s} [%d] GetGRInfo:: catch an expection error!!!"), MODULE_NAME, __LINE__);
|
|
PrintLog(szLog);
|
|
|
|
m_pConnection->RollbackTrans();
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(e.Description());
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDevice::GetSynInfo()
|
|
{
|
|
char aPath[1024] = {0};
|
|
CString szCurFilePath = _T("");
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFileName = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szHostFileName = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
char aResBuff[1024] = {0};
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
int iResSize = (int)VAL_ZERO;
|
|
CString szLog = _T("");
|
|
|
|
SHFILEOPSTRUCT shFileOP = {0};
|
|
|
|
::SetCursor(::LoadCursor(NULL, IDC_WAIT));
|
|
|
|
/*szCurFilePath.Empty();
|
|
szCurFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szCurFilePath.GetLength(), szCurFilePath.GetBuffer(szCurFilePath.GetLength()));
|
|
szCurFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szCurFilePath + _T("\\") + this->m_szDevSN;
|
|
CreateDirectory((LPCTSTR)szLocFilePath, NULL);
|
|
|
|
// if (ERROR_ALREADY_EXISTS == GetLastError())
|
|
// {
|
|
// memset(aPath , 0, sizeof(aPath));
|
|
// memset(&shFileOP, 0, sizeof(SHFILEOPSTRUCT));
|
|
//
|
|
// strncpy(aPath, (LPCTSTR)szLocFilePath, sizeof(aPath));
|
|
// shFileOP.hwnd = NULL;
|
|
// shFileOP.fFlags = FOF_ALLOWUNDO | FOF_NOCONFIRMATION;
|
|
// shFileOP.pFrom = aPath;
|
|
// shFileOP.pTo = NULL;
|
|
// shFileOP.wFunc = FO_DELETE;
|
|
//
|
|
// SHFileOperation(&shFileOP);
|
|
// CreateDirectory((LPCTSTR)szLocFilePath, NULL);
|
|
// }dsada
|
|
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder = _T("cd(\"/\")\r\n");
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 10, 50);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 5))
|
|
{
|
|
Sleep(1);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
|
|
szLog.Format(_T("{%s} [%d] GetSynInfo:: recv cmd = %s"), MODULE_NAME, __LINE__, szResBuff.GetBuffer(0));
|
|
PrintLog(szLog);*/
|
|
|
|
if (TRUE != GetDevInfo())
|
|
{
|
|
::SetCursor(::LoadCursor(NULL, IDC_ARROW));
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// AfxMessageBox("Get device info failed!");
|
|
SHFileOperation(&shFileOP);
|
|
return FALSE;
|
|
}
|
|
|
|
if (TRUE != GetSptSynInfo())
|
|
{
|
|
::SetCursor(::LoadCursor(NULL, IDC_ARROW));
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("获取脚本同步信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get Script syninfo failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
SHFileOperation(&shFileOP);
|
|
return FALSE;
|
|
}
|
|
|
|
if (TRUE != GetGRInfo())
|
|
{
|
|
::SetCursor(::LoadCursor(NULL, IDC_ARROW));
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("获取设备接地电阻信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get device GR info failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
SHFileOperation(&shFileOP);
|
|
return FALSE;
|
|
}
|
|
|
|
if (TRUE != GetTdSynInfo())
|
|
{
|
|
::SetCursor(::LoadCursor(NULL, IDC_ARROW));
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("获取任务同步信息失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get Td syninfo failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
SHFileOperation(&shFileOP);
|
|
return FALSE;
|
|
}
|
|
|
|
SHFileOperation(&shFileOP);
|
|
::SetCursor(::LoadCursor(NULL, IDC_ARROW));
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDevice::GetTdSynInfo()
|
|
{
|
|
_RecordsetPtr pRecTd = NULL;
|
|
_CommandPtr pCmdIns;
|
|
CString szSql = _T("");
|
|
|
|
char aPath[1024] = {0};
|
|
CString szCurFilePath = _T("");
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFileName = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szHostFileName = _T("");
|
|
|
|
CString szPrName = _T("");
|
|
CString szPrCN = _T("");
|
|
|
|
CString szTzName = _T("");
|
|
CString szTzCN = _T("");
|
|
|
|
CString szTdCN = _T("");
|
|
CString szTdName = _T("");
|
|
int iTaskIndex = -1;
|
|
|
|
CString szCDate = _T("");
|
|
CString szCTime = _T("");
|
|
|
|
int iSType = (int)VAL_ZERO;
|
|
int iTType = (int)VAL_ZERO;
|
|
|
|
BOOL bIsSyned = FALSE;
|
|
|
|
CString szLog = _T("");
|
|
|
|
CMarkup xmlDev;
|
|
CMarkup xmlPro;
|
|
CMarkup xmlTz;
|
|
|
|
CString strMValue = _T("");
|
|
//保存大数据任务,CString保存大任务M的值,int保存Index的值,CString保存TDCN的值
|
|
map<CString, map<int, CString>> mapBigTaskList;
|
|
map<CString, map<int, CString>>::iterator iterBigTask;
|
|
map<int, CString> mapOneTask;//某一小任务
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
|
|
pRecTd.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
/*szCurFilePath.Empty();
|
|
szCurFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szCurFilePath.GetLength(), szCurFilePath.GetBuffer(szCurFilePath.GetLength()));
|
|
szCurFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szCurFilePath + _T("\\") + this->m_szDevSN;
|
|
|
|
szHostFileName = _T("/SD/users/") + g_szMacAddress + _T(".xml");*/
|
|
|
|
szHostFileName.Format(_T("%s/SD/users/%s.xml"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), g_szMacAddress);
|
|
|
|
/*szLocFilePath = szLocFilePath + _T("\\");
|
|
|
|
if (TRUE != this->ReceiveFile(szLocFilePath, szHostFileName))
|
|
{
|
|
szLog.Empty();
|
|
szLog.Format(_T("{%s} [%d] GetTdSynInfo:: receive file error, LocalFilePath = %s, szHostFileName = %s"), MODULE_NAME,
|
|
__LINE__, szLocFilePath.GetBuffer(0), szHostFileName.GetBuffer(0));
|
|
PrintLog(szLog);
|
|
|
|
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("获取用户文件失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Get user file failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
m_pConnection->RollbackTrans();
|
|
return FALSE;
|
|
}
|
|
|
|
szLocFileName = szLocFilePath + g_szMacAddress + _T(".xml");*/
|
|
|
|
|
|
|
|
|
|
xmlDev.Load(szHostFileName);
|
|
xmlDev.FindChildElem(_T("user_info"));
|
|
xmlDev.IntoElem();
|
|
xmlDev.FindChildElem(_T("path_dictionary"));
|
|
xmlDev.IntoElem();
|
|
|
|
CString strPath;
|
|
//szLocFilePath = szCurFilePath + _T("\\") + this->m_szDevSN + _T("\\projects\\");
|
|
//CreateDirectory((LPCTSTR)szLocFilePath, NULL);
|
|
while (xmlDev.FindChildElem(_T("path")))
|
|
{
|
|
strPath = xmlDev.GetChildData();
|
|
if (strPath.IsEmpty())
|
|
{
|
|
continue;
|
|
}
|
|
//szLocFilePath.Empty();
|
|
//szLocFilePath = szCurFilePath + _T("\\") + this->m_szDevSN + _T("\\projects\\") + xmlDev.GetChildData() + _T("\\");
|
|
|
|
//if (TRUE == CreateDirectory((LPCTSTR)szLocFilePath, NULL))
|
|
//if (TRUE == MakeSureDirectoryPathExists(szLocFilePath))
|
|
{
|
|
/*szHostFileName.Empty();
|
|
szHostFileName = _T("/SD/projects/");
|
|
szHostFileName = szHostFileName + xmlDev.GetChildData() + _T("/project.xml");
|
|
|
|
TransDelay(g_iTransMode, 1, 1000);
|
|
if (TRUE != this->ReceiveFile(szLocFilePath, szHostFileName))
|
|
{
|
|
// m_pConnection->RollbackTrans();
|
|
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("接受文件失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Receive file failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
// return FALSE;
|
|
continue;
|
|
}*/
|
|
|
|
szHostFileName.Empty();
|
|
//szHostFileName = _T("/SD/projects/");
|
|
szHostFileName.Format(_T("%s/SD/projects/%s/project.xml"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(),xmlDev.GetChildData());
|
|
//szHostFileName = szHostFileName + xmlDev.GetChildData() + _T("/project.xml");
|
|
|
|
//szLocFileName = szLocFilePath + "project.xml";
|
|
xmlPro.Load(szHostFileName);
|
|
|
|
xmlPro.FindChildElem(_T("project_name"));
|
|
szPrName.Empty();
|
|
szPrName = xmlPro.GetChildData();
|
|
|
|
xmlPro.FindChildElem(_T("cn"));
|
|
szPrCN.Empty();
|
|
szPrCN = xmlPro.GetChildData();
|
|
|
|
xmlPro.FindChildElem(_T("testzones"));
|
|
xmlPro.IntoElem();
|
|
|
|
while (xmlPro.FindChildElem(_T("testzone")))
|
|
{
|
|
//szLocFilePath.Empty();
|
|
//szLocFilePath = szCurFilePath + _T("\\") + this->m_szDevSN + _T("\\projects\\") + xmlDev.GetChildData() + _T("\\") + xmlPro.GetChildData() + _T("\\");
|
|
//if (TRUE == CreateDirectory((LPCTSTR)szLocFilePath, NULL))
|
|
//if (TRUE == MakeSureDirectoryPathExists(szLocFilePath))
|
|
{
|
|
szHostFileName.Empty();
|
|
//szHostFileName = _T("/SD/projects/") + xmlDev.GetChildData() + _T("/") + xmlPro.GetChildData() + _T("/") + _T("testzone.xml");
|
|
szHostFileName.Format(_T("%s/SD/projects/%s/%s/testzone.xml"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), xmlDev.GetChildData(), xmlPro.GetChildData());
|
|
/*TransDelay(g_iTransMode, 1, 1000);
|
|
if (TRUE != this->ReceiveFile(szLocFilePath, szHostFileName))
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("接受文件失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Receive file failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
// m_pConnection->RollbackTrans();
|
|
// return FALSE;
|
|
continue;
|
|
}
|
|
|
|
szLocFileName = szLocFilePath + _T("testzone.xml");*/
|
|
xmlTz.Load(szHostFileName);
|
|
|
|
xmlTz.FindChildElem(_T("cn"));
|
|
szTzCN.Empty();
|
|
szTzCN = xmlTz.GetChildData();
|
|
xmlTz.FindChildElem(_T("testzone_name"));
|
|
szTzName.Empty();
|
|
szTzName = xmlTz.GetChildData();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from tz where CN = '%s'"), szTzCN);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
bIsSyned = TRUE;
|
|
}
|
|
else
|
|
{
|
|
bIsSyned = FALSE;
|
|
}
|
|
pRecTd->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_td(DESN,PrCN,PrName,TzCN,TzName,IsSyned) values('%s','%s','%s','%s','%s',%d)"),
|
|
this->m_szDevSN, szPrCN, szPrName, szTzCN, szTzName, bIsSyned);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
xmlTz.FindChildElem(_T("vess"));
|
|
xmlTz.IntoElem();
|
|
|
|
while (xmlTz.FindChildElem(_T("ves")))
|
|
{
|
|
iSType = (int)VAL_ZERO;
|
|
|
|
szTdName.Empty();
|
|
szTdName = xmlTz.GetChildAttrib(_T("n"));
|
|
|
|
strMValue.Empty();
|
|
strMValue = xmlTz.GetChildAttrib(_T("M"));
|
|
|
|
iTaskIndex = atoi(xmlTz.GetChildAttrib(_T("index")));
|
|
|
|
szTdCN.Empty();
|
|
szTdCN = xmlTz.GetChildData();
|
|
|
|
if (!strMValue.IsEmpty() && szTdName.CompareNoCase(strMValue) != 0)
|
|
{
|
|
mapOneTask[iTaskIndex] = szTdCN;
|
|
iterBigTask = mapBigTaskList.find(strMValue);
|
|
if (iterBigTask != mapBigTaskList.end())
|
|
{
|
|
iterBigTask->second.insert(make_pair(iTaskIndex, szTdCN));
|
|
}
|
|
else
|
|
{
|
|
mapBigTaskList[strMValue] = mapOneTask;
|
|
}
|
|
mapOneTask.clear();
|
|
//如果n跟m不相同,则表示不是首任务,不用显示
|
|
continue;
|
|
}
|
|
|
|
|
|
if (szTdCN.GetLength() > 18)
|
|
{
|
|
szTdCN.TrimRight(_T("\r\n "));
|
|
}
|
|
|
|
if ("R" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 0; //电阻率
|
|
}
|
|
else if ("I" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 1; //激电
|
|
}
|
|
else if ("S" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 2; //自电
|
|
}
|
|
|
|
szCDate.Empty();
|
|
szCDate.Format(_T("%s-%s-%s"), szTdCN.Mid(4, 4), szTdCN.Mid(8, 2), szTdCN.Mid(10, 2));
|
|
|
|
szCTime.Empty();
|
|
szCTime.Format(_T("%s:%s:%s"), szTdCN.Mid(12, 2), szTdCN.Mid(14, 2), szTdCN.Mid(16, 2));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from td where TDCN = '%s' and DESN = '%s'"), szTdCN, this->m_szDevSN);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
bIsSyned = TRUE;
|
|
}
|
|
else
|
|
{
|
|
bIsSyned = FALSE;
|
|
}
|
|
pRecTd->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_td(DESN,PrCN,PrName,TzCN,TzName,TdCN,TdName,Ttype,Stype,Cdate,Ctime,IsSyned) "
|
|
"values('%s','%s','%s','%s','%s','%s','%s', %d,%d,#%s#,#%s#,%d)"),
|
|
this->m_szDevSN,
|
|
szPrCN,
|
|
szPrName,
|
|
szTzCN,
|
|
szTzName,
|
|
szTdCN,
|
|
szTdName,
|
|
iTType,
|
|
iSType,
|
|
szCDate,
|
|
szCTime,
|
|
bIsSyned
|
|
);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
}
|
|
xmlTz.OutOfElem();
|
|
|
|
xmlTz.FindChildElem(_T("eris"));
|
|
xmlTz.IntoElem();
|
|
while (xmlTz.FindChildElem(_T("eri")))
|
|
{
|
|
iSType = (int)VAL_ONE;
|
|
|
|
szTdName.Empty();
|
|
szTdName = xmlTz.GetChildAttrib(_T("n"));
|
|
|
|
strMValue.Empty();
|
|
strMValue = xmlTz.GetChildAttrib(_T("M"));
|
|
|
|
iTaskIndex = atoi(xmlTz.GetChildAttrib(_T("index")));
|
|
|
|
szTdCN.Empty();
|
|
szTdCN = xmlTz.GetChildData();
|
|
|
|
if (!strMValue.IsEmpty() && szTdName.CompareNoCase(strMValue) != 0)
|
|
{
|
|
mapOneTask[iTaskIndex] = szTdCN;
|
|
iterBigTask = mapBigTaskList.find(strMValue);
|
|
if (iterBigTask != mapBigTaskList.end())
|
|
{
|
|
iterBigTask->second.insert(make_pair(iTaskIndex, szTdCN));
|
|
}
|
|
else
|
|
{
|
|
mapBigTaskList[strMValue] = mapOneTask;
|
|
}
|
|
mapOneTask.clear();
|
|
//如果n跟m不相同,则表示不是首任务,不用显示
|
|
continue;
|
|
}
|
|
|
|
if (szTdCN.GetLength() > 18)
|
|
{
|
|
szTdCN.TrimRight(_T("\r\n "));
|
|
}
|
|
|
|
if ("R" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 0; //电阻率
|
|
}
|
|
else if ("I" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 1; //激电
|
|
}
|
|
else if ("S" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 2; //自电
|
|
}
|
|
|
|
szCDate.Empty();
|
|
szCDate.Format(_T("%s-%s-%s"), szTdCN.Mid(4, 4), szTdCN.Mid(8, 2), szTdCN.Mid(10, 2));
|
|
|
|
szCTime.Empty();
|
|
szCTime.Format(_T("%s:%s:%s"), szTdCN.Mid(12, 2), szTdCN.Mid(14, 2), szTdCN.Mid(16, 2));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from td where TDCN = '%s' and DESN = '%s'"), szTdCN, this->m_szDevSN);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
bIsSyned = TRUE;
|
|
}
|
|
else
|
|
{
|
|
bIsSyned = FALSE;
|
|
}
|
|
|
|
pRecTd->Close();
|
|
//同步到这里报错
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_td(DESN,PrCN,PrName,TzCN,TzName,TdCN,TdName,Ttype,Stype,Cdate,Ctime,IsSyned) "
|
|
"values('%s','%s','%s','%s','%s','%s','%s',%d,%d,#%s#,#%s#,%d)"),
|
|
this->m_szDevSN,
|
|
szPrCN,
|
|
szPrName,
|
|
szTzCN,
|
|
szTzName,
|
|
szTdCN,
|
|
szTdName,
|
|
iTType,
|
|
iSType,
|
|
szCDate,
|
|
szCTime,
|
|
bIsSyned
|
|
);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
xmlTz.OutOfElem();
|
|
//waston
|
|
xmlTz.FindChildElem(_T("erts"));
|
|
xmlTz.IntoElem();
|
|
while (xmlTz.FindChildElem(_T("ert")))
|
|
{
|
|
iSType = (int)VAL_TWO;
|
|
|
|
szTdName.Empty();
|
|
szTdName = xmlTz.GetChildAttrib(_T("n"));
|
|
|
|
strMValue.Empty();
|
|
strMValue = xmlTz.GetChildAttrib(_T("M"));
|
|
|
|
iTaskIndex = atoi(xmlTz.GetChildAttrib(_T("index")));
|
|
|
|
szTdCN.Empty();
|
|
szTdCN = xmlTz.GetChildData();
|
|
|
|
if (!strMValue.IsEmpty() && szTdName.CompareNoCase(strMValue) != 0)
|
|
{
|
|
mapOneTask[iTaskIndex] = szTdCN;
|
|
iterBigTask = mapBigTaskList.find(strMValue);
|
|
if (iterBigTask != mapBigTaskList.end())
|
|
{
|
|
iterBigTask->second.insert(make_pair(iTaskIndex, szTdCN));
|
|
}
|
|
else
|
|
{
|
|
mapBigTaskList[strMValue] = mapOneTask;
|
|
}
|
|
mapOneTask.clear();
|
|
//如果n跟m不相同,则表示不是首任务,不用显示
|
|
continue;
|
|
}
|
|
|
|
|
|
if (szTdCN.GetLength() > 18)
|
|
{
|
|
szTdCN.TrimRight(_T("\r\n "));
|
|
}
|
|
|
|
if ("R" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 0; //电阻率
|
|
}
|
|
else if ("I" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 1; //激电
|
|
}
|
|
else if ("S" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 2; //自电
|
|
}
|
|
|
|
szCDate.Empty();
|
|
szCDate.Format(_T("%s-%s-%s"), szTdCN.Mid(4, 4), szTdCN.Mid(8, 2), szTdCN.Mid(10, 2));
|
|
|
|
szCTime.Empty();
|
|
szCTime.Format(_T("%s:%s:%s"), szTdCN.Mid(12, 2), szTdCN.Mid(14, 2), szTdCN.Mid(16, 2));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from td where TDCN = '%s' and DESN = '%s'"), szTdCN, this->m_szDevSN);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
bIsSyned = TRUE;
|
|
}
|
|
else
|
|
{
|
|
bIsSyned = FALSE;
|
|
}
|
|
pRecTd->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_td(DESN,PrCN,PrName,TzCN,TzName,TdCN,TdName,Ttype,Stype,Cdate,Ctime,IsSyned) "
|
|
"values('%s','%s','%s','%s','%s','%s','%s',%d,%d,#%s#,#%s#,%d)"),
|
|
this->m_szDevSN,
|
|
szPrCN,
|
|
szPrName,
|
|
szTzCN,
|
|
szTzName,
|
|
szTdCN,
|
|
szTdName,
|
|
iTType,
|
|
iSType,
|
|
szCDate,
|
|
szCTime,
|
|
bIsSyned
|
|
);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
}
|
|
|
|
xmlTz.OutOfElem();
|
|
|
|
xmlTz.FindChildElem(_T("wels"));
|
|
xmlTz.IntoElem();
|
|
while (xmlTz.FindChildElem(_T("wel")))
|
|
{
|
|
iSType = (int)255;
|
|
|
|
szTdName.Empty();
|
|
szTdName = xmlTz.GetChildAttrib(_T("n"));
|
|
|
|
strMValue.Empty();
|
|
strMValue = xmlTz.GetChildAttrib(_T("M"));
|
|
|
|
iTaskIndex = atoi(xmlTz.GetChildAttrib(_T("index")));
|
|
|
|
szTdCN.Empty();
|
|
szTdCN = xmlTz.GetChildData();
|
|
|
|
if (!strMValue.IsEmpty() && szTdName.CompareNoCase(strMValue) != 0)
|
|
{
|
|
mapOneTask[iTaskIndex] = szTdCN;
|
|
iterBigTask = mapBigTaskList.find(strMValue);
|
|
if (iterBigTask != mapBigTaskList.end())
|
|
{
|
|
iterBigTask->second.insert(make_pair(iTaskIndex, szTdCN));
|
|
}
|
|
else
|
|
{
|
|
mapBigTaskList[strMValue] = mapOneTask;
|
|
}
|
|
mapOneTask.clear();
|
|
//如果n跟m不相同,则表示不是首任务,不用显示
|
|
continue;
|
|
}
|
|
|
|
|
|
if (szTdCN.GetLength() > 18)
|
|
{
|
|
szTdCN.TrimRight(_T("\r\n "));
|
|
}
|
|
|
|
if ("R" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 0; //电阻率
|
|
}
|
|
else if ("I" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 1; //激电
|
|
}
|
|
else if ("S" == szTdCN.Mid(3, 1))
|
|
{
|
|
iTType = 2; //自电
|
|
}
|
|
|
|
szCDate.Empty();
|
|
szCDate.Format(_T("%s-%s-%s"), szTdCN.Mid(4, 4), szTdCN.Mid(8, 2), szTdCN.Mid(10, 2));
|
|
|
|
szCTime.Empty();
|
|
szCTime.Format(_T("%s:%s:%s"), szTdCN.Mid(12, 2), szTdCN.Mid(14, 2), szTdCN.Mid(16, 2));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from td where TDCN = '%s' and DESN = '%s'"), szTdCN, this->m_szDevSN);
|
|
pRecTd->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecTd->GetRecordCount())
|
|
{
|
|
bIsSyned = TRUE;
|
|
}
|
|
else
|
|
{
|
|
bIsSyned = FALSE;
|
|
}
|
|
pRecTd->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_td(DESN,PrCN,PrName,TzCN,TzName,TdCN,TdName,Ttype,Stype,Cdate,Ctime,IsSyned) "
|
|
"values('%s','%s','%s','%s','%s','%s','%s',%d,%d,#%s#,#%s#,%d)"),
|
|
this->m_szDevSN,
|
|
szPrCN,
|
|
szPrName,
|
|
szTzCN,
|
|
szTzName,
|
|
szTdCN,
|
|
szTdName,
|
|
iTType,
|
|
iSType,
|
|
szCDate,
|
|
szCTime,
|
|
bIsSyned
|
|
);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
|
|
}
|
|
|
|
xmlTz.OutOfElem();
|
|
//waston
|
|
}
|
|
}
|
|
xmlPro.OutOfElem();
|
|
}
|
|
}
|
|
xmlDev.OutOfElem();
|
|
|
|
//将下位机切割的大数据任务的子任务排序后存放到数据库dev_syn_td的SubTaskCN字段
|
|
map<int, CString>::iterator iterOneTask;
|
|
CString strSubTaskCN;
|
|
int iSubTaskIndex = 0;
|
|
UINT32 uiXmlMaxTestPoint = 0;
|
|
for (iterBigTask = mapBigTaskList.begin(); iterBigTask != mapBigTaskList.end(); iterBigTask++)
|
|
{
|
|
strSubTaskCN.Empty();
|
|
iSubTaskIndex = 0;
|
|
uiXmlMaxTestPoint = 0;
|
|
for (iterOneTask = iterBigTask->second.begin(); iterOneTask != iterBigTask->second.end(); iterOneTask++)
|
|
{
|
|
if (!strSubTaskCN.IsEmpty())
|
|
{
|
|
strSubTaskCN += _T(",");
|
|
}
|
|
strSubTaskCN.AppendFormat(_T("%s"), iterOneTask->second);
|
|
|
|
//如果是最后一个子任务,读取最大点数即为整个任务的测点数,保存到dev_syn_td表中
|
|
if (iSubTaskIndex == iterBigTask->second.size() - 1)
|
|
{
|
|
uiXmlMaxTestPoint = GetXmlMaxTestPoint(iterBigTask->second.size(),szPrCN,szTzCN,iterOneTask->second);
|
|
}
|
|
iSubTaskIndex++;
|
|
}
|
|
|
|
if (strlen(strSubTaskCN) > 255)
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("子任务TDCN长度集合超过255"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Subtask TDCN has a length set of more than 255"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
continue;
|
|
}
|
|
szSql.Empty();
|
|
//根据任务名修改对应的记录
|
|
szSql.Format(_T("update dev_syn_td set SubTaskCN ='%s',TPamount=%d where TdName='%s'"), strSubTaskCN, uiXmlMaxTestPoint, iterBigTask->first);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
|
|
m_pConnection->CommitTrans();
|
|
return TRUE;
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
|
|
szLog.Empty();
|
|
szLog.Format(_T("{%s} [%d] GetTdSynInfo:: catch an expection error!!!"), MODULE_NAME, __LINE__);
|
|
PrintLog(szLog);
|
|
|
|
m_pConnection->RollbackTrans();
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(e.Description());
|
|
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
//获取子任务dat文件最大点数
|
|
UINT32 CDevice::GetXmlMaxTestPoint(int iSubIndex, CString strPrCN, CString strTzCN, CString strXmlFile)
|
|
{
|
|
UINT32 uiXmlMaxTestPoint = iSubIndex*ONE_SUBTASK_TEST_POINT_NUMBER+1;
|
|
CString szNodeName = _T("");
|
|
//log
|
|
CString strPath;
|
|
strPath.Format(_T("%sSD/projects/%s/%s/%s.dat"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr(), strPrCN, strTzCN, strXmlFile);
|
|
CMarkup *pXML = new CMarkup;
|
|
try
|
|
{
|
|
if (false == pXML->Load(strPath))
|
|
return 1;
|
|
pXML->FindElem(_T("TD"));
|
|
pXML->FindChildElem("param");
|
|
pXML->FindChildElem("Data");
|
|
pXML->IntoElem();
|
|
|
|
szNodeName.Empty();
|
|
szNodeName.Format(_T("D%.5d"), uiXmlMaxTestPoint);
|
|
CString strShowErr = _T("");
|
|
bool bIsWirteCheckLC = true;//是否需要对离叉信息进行写日志
|
|
while (pXML->FindChildElem(szNodeName))
|
|
{
|
|
uiXmlMaxTestPoint++;
|
|
szNodeName.Empty();
|
|
if (uiXmlMaxTestPoint <= 99999)
|
|
{
|
|
szNodeName.Format(_T("D%.5d"), uiXmlMaxTestPoint);
|
|
}
|
|
else
|
|
{
|
|
szNodeName.Format(_T("D%d"), uiXmlMaxTestPoint);
|
|
}
|
|
}
|
|
pXML->OutOfElem();
|
|
delete pXML;
|
|
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTHookProc, AfxGetInstanceHandle(), NULL);
|
|
AfxMessageBox(e.Description());
|
|
delete pXML;
|
|
return FALSE;
|
|
|
|
}
|
|
return uiXmlMaxTestPoint-1;
|
|
}
|
|
|
|
BOOL CDevice::DelSynInfo()
|
|
{
|
|
_CommandPtr pCmdDel = NULL;
|
|
CString szSql = _T("");
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
pCmdDel.CreateInstance(_uuidof(Command));
|
|
pCmdDel->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format("delete from dev_syn_td where DESN = '%s'", this->m_szDevSN);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
szSql.Empty();
|
|
szSql.Format("delete from dev_syn_spt where DESN = '%s'", this->m_szDevSN);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
m_pConnection->CommitTrans();
|
|
|
|
return TRUE;
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
CString strInfo =_T("");
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strInfo.Format(_T("删除同步信息异常(%s)"), e.Description());
|
|
AfxMessageBox(strInfo);
|
|
}
|
|
else
|
|
{
|
|
strInfo.Format(_T("DelSynInfo exception,msg = %s"), e.Description());
|
|
MessageBoxEx(NULL, strInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
BOOL CDevice::DelGRInfo()
|
|
{
|
|
_CommandPtr pCmdDel = NULL;
|
|
CString szSql = _T("");
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
pCmdDel.CreateInstance(_uuidof(Command));
|
|
pCmdDel->ActiveConnection = m_pConnection;
|
|
|
|
szSql.Empty();
|
|
szSql.Format("delete from devgr where DEID = %u", this->m_dwID);
|
|
pCmdDel->CommandText = szSql.AllocSysString();
|
|
pCmdDel->Execute(NULL, NULL, adCmdText);
|
|
|
|
m_pConnection->CommitTrans();
|
|
|
|
return TRUE;
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
m_pConnection->RollbackTrans();
|
|
CString strInfo = _T("");
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
strInfo.Format(_T("DelGRInfo exception, msg = %s"),e.Description());
|
|
MessageBoxEx(NULL, strInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
BOOL CDevice::GetSptSynInfo()
|
|
{
|
|
_RecordsetPtr pRecSpt = NULL;
|
|
_CommandPtr pCmdIns;
|
|
CString szSql = _T("");
|
|
|
|
char aPath[1024] = {0};
|
|
CString szCurFilePath = _T("");
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFileName = _T("");
|
|
|
|
CString szHostFilePath = _T("");
|
|
CString szHostFileName = _T("");
|
|
|
|
CString szSptCN = _T("");
|
|
CString szSptFileName = _T("");
|
|
|
|
int iSType = (int)VAL_ZERO;
|
|
CString szScName = _T(""); //脚本的名字
|
|
BOOL bIsSyned = FALSE;
|
|
|
|
CMarkup xmlSpt;
|
|
CString szLog = _T("");
|
|
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
|
|
pRecSpt.CreateInstance(_uuidof(Recordset));
|
|
|
|
pCmdIns.CreateInstance(_uuidof(Command));
|
|
pCmdIns->ActiveConnection = m_pConnection;
|
|
|
|
/*szCurFilePath.Empty();
|
|
szCurFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szCurFilePath.GetLength(), szCurFilePath.GetBuffer(szCurFilePath.GetLength()));
|
|
szCurFilePath.ReleaseBuffer();
|
|
|
|
szLocFilePath = szCurFilePath+_T("\\")+this->m_szDevSN+_T("\\scripts\\");
|
|
CreateDirectory((LPCTSTR)szLocFilePath, NULL);
|
|
|
|
szHostFileName = _T("/SD/scripts/scripts.xml");
|
|
if (TRUE != this->ReceiveFile(szLocFilePath, szHostFileName))
|
|
{
|
|
szLog.Empty();
|
|
szLog.Format(_T("{%s} [%d] GetSptSynInfo:: receive file error, LocalFilePath = %s, szHostFileName = %s"), MODULE_NAME,
|
|
__LINE__, szLocFilePath.GetBuffer(0), szHostFileName.GetBuffer(0));
|
|
PrintLog(szLog);
|
|
|
|
m_pConnection->RollbackTrans();
|
|
return FALSE;
|
|
}
|
|
|
|
szLocFileName = szLocFilePath+_T("scripts.xml");*/
|
|
|
|
szHostFileName.Format(_T("%s//SD/scripts/scripts.xml"), CDetcGD10Dev::GetInstance()->GetGD10DevAddr());
|
|
xmlSpt.Load(szHostFileName);
|
|
|
|
while (xmlSpt.FindChildElem(_T("script")))
|
|
{
|
|
iSType = atoi(xmlSpt.GetChildAttrib(_T("type")));
|
|
szScName = xmlSpt.GetChildAttrib(_T("name"));
|
|
if (szScName.IsEmpty())
|
|
szScName = "cannot get name";
|
|
szSptCN.Empty();
|
|
szSptCN = xmlSpt.GetChildData();
|
|
|
|
if ((szSptCN.Mid(3) == _T("57F59FB45D9A4D42B8370BA1BC189C76")) || (szSptCN.Mid(3) == _T("AA9E898A9D164B4595521D0D29E7D2C4"))
|
|
|| (szSptCN.Mid(3) == _T("5ED40EB7169044FF82031899409EB0EF")) || (szSptCN.Mid(3) == _T("F141EF832E2D4919BA035615D7442B6D"))
|
|
|| (szSptCN.Mid(3) == _T("B5EA526D45DD46329164E89252BAC15F"))) //对主机上的临时脚本进行过滤
|
|
{
|
|
continue;
|
|
}
|
|
CString strBakScName = szScName;
|
|
strBakScName.MakeLower();
|
|
//added by lsq 20160919 直接过虑掉临时脚本
|
|
if (-1 != strBakScName.Find(_T("temporary script")))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
szSptFileName = szSptCN + _T(".scr");
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select * from scon where CN = '%s'"), szSptCN.Mid(3));
|
|
pRecSpt->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecSpt->GetRecordCount())
|
|
{
|
|
bIsSyned = TRUE;
|
|
}
|
|
else
|
|
{
|
|
bIsSyned = FALSE;
|
|
}
|
|
|
|
pRecSpt->Close();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("insert into dev_syn_spt(DESN,SCCN,SptName,Stype,SptFileName,IsSyned) values('%s','%s','%s',%d,'%s',%d)"),
|
|
this->m_szDevSN,
|
|
szSptCN.Mid(3),
|
|
szScName,
|
|
iSType,
|
|
szSptFileName,
|
|
bIsSyned
|
|
);
|
|
pCmdIns->CommandText = szSql.AllocSysString();
|
|
pCmdIns->Execute(NULL, NULL, adCmdText);
|
|
}
|
|
xmlSpt.OutOfElem();
|
|
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
szLog.Empty();
|
|
szLog.Format(_T("{%s} [%d] GetSptSynInfo:: catch an expection error!!!"), MODULE_NAME, __LINE__);
|
|
PrintLog(szLog);
|
|
|
|
m_pConnection->RollbackTrans();
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox(e.Description());
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDevice::Register()
|
|
{
|
|
//暂时屏蔽
|
|
return TRUE;
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
|
|
CString szLocFilePath = _T("");
|
|
CString szLocFileName = _T("");
|
|
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("check_register(\"%s\")\r\n"), g_szMacAddress);
|
|
|
|
if (!ExecuteOrder(szOrder, ">", &szResBuff))
|
|
{
|
|
MessageBoxEx(NULL, _T("Excute check register cmd failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
|
|
if (_T("1") == szRes)
|
|
{
|
|
//added by lsq 20160406
|
|
//由于加入开放权限的功能,也就是可以同时开到其它人的数据,而采取的是上下微机用的统一的MAC地址进行注册
|
|
//所以在这里如果判断下微机有数据,而上微机又没有数据的情况,则直接返回,采取直接注册的流程
|
|
//所以屏蔽这段去注册的代码
|
|
/*
|
|
if (IDYES == AfxMessageBox("This device has been register!\r\n Do you want to re-registration?",MB_YESNO))
|
|
{
|
|
szOrder.Empty();
|
|
szResBuff.Empty();
|
|
szOrder.Format(_T("unregister_user(\"%s\")\r\n"),g_szMacAddress);
|
|
CString strRegisInfo = _T("");
|
|
if (!ExecuteOrder(szOrder, ">", &szResBuff))
|
|
{
|
|
strRegisInfo.Format(_T("excute cmd %s failed!"),szOrder);
|
|
AfxMessageBox(strRegisInfo);
|
|
return FALSE;
|
|
}
|
|
if (-1 == szResBuff.Find("]"))
|
|
{
|
|
AfxMessageBox(_T("Not exist unregister cmd, please check your gd-10 version!"));
|
|
return FALSE;
|
|
}
|
|
|
|
szRes.Empty();
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
if (_T("1") != szRes)
|
|
{
|
|
strRegisInfo.Format(_T("excute cmd %s error! res = %s "),szOrder, szRes);
|
|
AfxMessageBox(strRegisInfo);
|
|
return FALSE;
|
|
}
|
|
}
|
|
else
|
|
return FALSE;
|
|
*/
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
try
|
|
{
|
|
if (TRUE == this->GenerateUserFile(szLocFilePath, szLocFileName))
|
|
{
|
|
|
|
if (TRUE == this->SendFile(_T("/SD/users"), szLocFilePath, szLocFileName))
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
}
|
|
return FALSE;
|
|
}
|
|
catch (...)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBoxEx(NULL, _T("Register error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
}
|
|
|
|
int CDevice::IsExistOtherUserData()
|
|
{
|
|
CString szOrder=_T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
szOrder.Format(_T("single_owner(\"%s\")\r\n"), g_szMacAddress);
|
|
if (!ExecuteOrder(szOrder, ">", &szResBuff))
|
|
{
|
|
MessageBoxEx(NULL, _T("Get Other User Information failed!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return enGetCmdResFailed;
|
|
}
|
|
|
|
if (-1 == szResBuff.Find("]"))
|
|
{
|
|
return enNotExistCmd;
|
|
}
|
|
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
|
|
return (_T("1") == szRes) ? enNotExistOtherData: enExistOtherData;
|
|
}
|
|
|
|
BOOL CDevice::Unregister()
|
|
{
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CString szRes = _T("");
|
|
|
|
// if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
// {
|
|
if (CGD10OperCmd::GetInstance()->unregister_user(g_szMacAddress))
|
|
{
|
|
szRes = _T("1");
|
|
}
|
|
|
|
// }
|
|
// else
|
|
// {
|
|
// szOrder.Format(_T("unregister_user(\"%s\")\r\n"), g_szMacAddress);
|
|
//
|
|
// if (!ExecuteOrder(szOrder, ">", &szResBuff))
|
|
// {
|
|
// MessageBoxEx(NULL, _T("Excute unregister cmd failed!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
// return FALSE;
|
|
// }
|
|
//
|
|
// GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
// }
|
|
|
|
|
|
|
|
if (_T("1") != szRes)
|
|
{
|
|
MessageBoxEx(NULL, _T("Excute unregister cmd error!!!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
CString strLog = _T("");
|
|
strLog.Format(_T("[%d]excute unregister cmd error!,resbuf = %s"),__LINE__, szResBuff);
|
|
PrintLog(strLog);
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
/*
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("unregister_user(\"%s\")\r\n"), g_szMacAddress);
|
|
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("\r\n"));
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
Sleep(500);
|
|
|
|
szOrder.ReleaseBuffer();
|
|
szOrder.Empty();
|
|
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
|
|
|
|
// AfxMessageBox(szOrder);
|
|
Sleep(100);
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 100, 200);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 3))
|
|
{
|
|
Sleep(500);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return FALSE;
|
|
}
|
|
*/
|
|
|
|
}
|
|
|
|
BOOL CDevice::ModifyParameter()
|
|
{
|
|
_CommandPtr pCmdUpd = NULL;
|
|
CString szSql = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString strShowInfo = _T("");
|
|
CString szRes = _T("");
|
|
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
INT_PTR lRet = (long)VAL_ZERO;
|
|
|
|
COpDevPamModifyDlg *pOpDevPamModifyDlg = new COpDevPamModifyDlg;
|
|
|
|
pOpDevPamModifyDlg->Create(IDD_OP_DEV_PAM_M, AfxGetMainWnd());
|
|
pOpDevPamModifyDlg->InitUIByLanguage(g_iUILanguage);
|
|
this->InitialOpDevPamModifyDlg(pOpDevPamModifyDlg);
|
|
pOpDevPamModifyDlg->ShowWindow(SW_SHOW);
|
|
|
|
lRet = pOpDevPamModifyDlg->RunModalLoop(MLF_SHOWONIDLE);
|
|
|
|
if (RET_OK == lRet)
|
|
{
|
|
//去掉驱动,U盘模式同USB模式
|
|
//if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
//szOrder.Format(_T("industrial_frequency,%d;number_format,%d;temperature_system,%d;mains_voltage,%d;metric_system,%d;max_rg,%d"),
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("industrial_frequency,%d;number_format,%d;temperature_system,%d;mains_voltage,%d;metric_system,%d"),
|
|
pOpDevPamModifyDlg->m_cbIFrequency.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbNumFormat.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbTSys.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbMVoltage.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbMSys.GetCurSel());
|
|
if (CGD10OperCmd::GetInstance()->set_param(szOrder))
|
|
{
|
|
szRes = _T("1");
|
|
}
|
|
else
|
|
{
|
|
szRes = _T("-1");
|
|
}
|
|
|
|
}
|
|
// else
|
|
// {
|
|
// szOrder.Empty();
|
|
// szOrder.Format(_T("set_param(\"industrial_frequency,%d;number_format,%d;temperature_system,%d;mains_voltage,%d;metric_system,%d;\")\r\n"),
|
|
// pOpDevPamModifyDlg->m_cbIFrequency.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbNumFormat.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbTSys.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbMVoltage.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbMSys.GetCurSel());
|
|
// // AfxMessageBox(szOrder);
|
|
// szResBuff.Empty();
|
|
// if (!ExecuteOrder(szOrder, ">", &szResBuff))
|
|
// {
|
|
// if (LANG_ZHCN == g_iUILanguage)
|
|
// {
|
|
// strShowInfo = _T("执行设置参数命令失败!");
|
|
// AfxMessageBox(strShowInfo);
|
|
// }
|
|
// else
|
|
// {
|
|
// strShowInfo.Format(_T("Excute cmd set_param1 failed!!!"));
|
|
// MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
// }
|
|
//
|
|
// return FALSE;
|
|
// }
|
|
// szRes.Empty();
|
|
// GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
// }
|
|
|
|
|
|
if (_T("1") != szRes)
|
|
{
|
|
pOpDevPamModifyDlg->DestroyWindow();
|
|
delete pOpDevPamModifyDlg;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("执行设置参数命令错误, 返回值 = %s"), szRes.GetBuffer(0));
|
|
AfxMessageBox(strShowInfo.GetBuffer(0));
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Excute cmd set_param1 error, res = %s"), szRes.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
//去掉驱动,U盘模式同USB
|
|
//if (EN_TRANSFER_FILE_BY_USB == g_iTransFileMode)
|
|
{
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("timezone,%d;standby_time_delay,%d;power_save_mode,%d;pushbutton_tone,%d;testing_tone,%d;language,%d"),
|
|
pOpDevPamModifyDlg->m_cbTZone.GetCurSel()-12,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
pOpDevPamModifyDlg->m_cbLang.GetCurSel());
|
|
if (CGD10OperCmd::GetInstance()->set_param(szOrder))
|
|
{
|
|
szRes = _T("1");
|
|
}
|
|
else
|
|
{
|
|
szRes = _T("-1");
|
|
}
|
|
|
|
|
|
}
|
|
// else
|
|
// {
|
|
// TransDelay(g_iTransMode, 10, 50, NULL);
|
|
// szOrder.Empty();
|
|
// szOrder.Format(_T("set_param(\"timezone,%d;standby_time_delay,%d;power_save_mode,%d;pushbutton_tone,%d;testing_tone,%d;language,%d;\")\r\n"),
|
|
// pOpDevPamModifyDlg->m_cbTZone.GetCurSel()-12,
|
|
// 0,
|
|
// 0,
|
|
// 0,
|
|
// 0,
|
|
// pOpDevPamModifyDlg->m_cbLang.GetCurSel());
|
|
//
|
|
// szResBuff.Empty();
|
|
// if (!ExecuteOrder(szOrder, ">", &szResBuff))
|
|
// {
|
|
// if (LANG_ZHCN == g_iUILanguage)
|
|
// {
|
|
// strShowInfo = _T("执行设置参数2命令失败!");
|
|
// AfxMessageBox(strShowInfo.GetBuffer(0));
|
|
// }
|
|
// else
|
|
// {
|
|
// strShowInfo.Format(_T("Excute cmd set_param2 failed!!!"));
|
|
// MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
// }
|
|
// return FALSE;
|
|
// }
|
|
//
|
|
// szRes.Empty();
|
|
// GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
// }
|
|
|
|
|
|
if (_T("1") != szRes)
|
|
{
|
|
pOpDevPamModifyDlg->DestroyWindow();
|
|
delete pOpDevPamModifyDlg;
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
strShowInfo.Format(_T("执行设置参数2命令失败, 返回值 = %s"), szRes.GetBuffer(0));
|
|
AfxMessageBox(strShowInfo.GetBuffer(0));
|
|
}
|
|
else
|
|
{
|
|
strShowInfo.Format(_T("Excute cmd set_param2 error, res = %s"), szRes.GetBuffer(0));
|
|
MessageBoxEx(NULL, strShowInfo, STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = m_pConnection;
|
|
try
|
|
{
|
|
m_pConnection->BeginTrans();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("update desetting set Ifrequency=%d,numformat=%d,Tsys=%d,Mvoltage=%d,Msys=%d,Tzone=%d,STdelay=%d,PSmode=%d,"
|
|
"PBtone=%d,Ttone=%d,lang=%d where DEID = %u "),
|
|
pOpDevPamModifyDlg->m_cbIFrequency.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbNumFormat.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbTSys.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbMVoltage.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbMSys.GetCurSel(),
|
|
pOpDevPamModifyDlg->m_cbTZone.GetCurSel()-12,
|
|
0,
|
|
0,
|
|
0,
|
|
0,
|
|
pOpDevPamModifyDlg->m_cbLang.GetCurSel(),
|
|
m_dwID);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
m_pConnection->CommitTrans();
|
|
}
|
|
catch (_com_error e)
|
|
{
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
AfxMessageBox((LPCTSTR)e.Description());
|
|
m_pConnection->RollbackTrans();
|
|
pOpDevPamModifyDlg->DestroyWindow();
|
|
delete pOpDevPamModifyDlg;
|
|
return FALSE;
|
|
}
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("设置参数成功!"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Set parameters successfully!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
}
|
|
|
|
pOpDevPamModifyDlg->DestroyWindow();
|
|
|
|
delete pOpDevPamModifyDlg;
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
// BOOL CDevice::ModifyParameter()
|
|
// {
|
|
// _CommandPtr pCmdUpd = NULL;
|
|
// CString szSql = _T("");
|
|
//
|
|
// CString szOrder = _T("");
|
|
// CString szResBuff = _T("");
|
|
//
|
|
// CString szRes = _T("");
|
|
//
|
|
// char aResBuff[1024] = {0};
|
|
//
|
|
// int iResSize = (int)VAL_ZERO;
|
|
// int iPollingTime = (int)VAL_ZERO;
|
|
//
|
|
// INT_PTR lRet = (long)VAL_ZERO;
|
|
//
|
|
// COpDevPamModifyDlg *pOpDevPamModifyDlg = new COpDevPamModifyDlg;
|
|
//
|
|
// pOpDevPamModifyDlg->Create(IDD_OP_DEV_PAM_M, AfxGetMainWnd());
|
|
//
|
|
// this->InitialOpDevPamModifyDlg(pOpDevPamModifyDlg);
|
|
// pOpDevPamModifyDlg->ShowWindow(SW_SHOW);
|
|
//
|
|
// lRet = pOpDevPamModifyDlg->RunModalLoop(MLF_SHOWONIDLE);
|
|
//
|
|
// if (RET_OK == lRet)
|
|
// {
|
|
//
|
|
// m_sComPort.ClearCommReceiveBuff();
|
|
// m_sComPort.ClearCommSendBuff();
|
|
//
|
|
// szOrder.Empty();
|
|
// szOrder.Format(_T("\r\n"));
|
|
// m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
// Sleep(500);
|
|
//
|
|
// szOrder.ReleaseBuffer();
|
|
// szOrder.Empty();
|
|
//
|
|
// m_sComPort.ClearCommSendBuff();
|
|
// m_sComPort.ClearCommReceiveBuff();
|
|
//
|
|
// szOrder.Empty();
|
|
// szOrder.Format(_T("set_param(\"industrial_frequency,%d;number_format,%d;temperature_system,%d;mains_voltage,%d;metric_system,%d;max_rg,%d;\")\r\n"),
|
|
// pOpDevPamModifyDlg->m_cbIFrequency.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbNumFormat.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbTSys.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbMVoltage.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbMSys.GetCurSel(),
|
|
// 500);
|
|
// // AfxMessageBox(szOrder);
|
|
// Sleep(100);
|
|
// m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
// szOrder.ReleaseBuffer();
|
|
// // TransDelay(g_iTransMode, 100, 200);
|
|
//
|
|
// iResSize = (int)VAL_ZERO;
|
|
// memset(aResBuff, 0, sizeof(aResBuff));
|
|
// szResBuff.Empty();
|
|
// iPollingTime = 0;
|
|
// while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 3))
|
|
// {
|
|
// Sleep(500);
|
|
// while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
// {
|
|
// szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
//
|
|
// iResSize = (int)VAL_ZERO;
|
|
// memset(aResBuff, 0, sizeof(aResBuff));
|
|
// }
|
|
// iPollingTime++;
|
|
// }
|
|
// ////////////////////////////////////////////////////////
|
|
//
|
|
// if (3 == iPollingTime)
|
|
// {
|
|
// pOpDevPamModifyDlg->DestroyWindow();
|
|
// delete pOpDevPamModifyDlg;
|
|
// return FALSE;
|
|
// }
|
|
//
|
|
// GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
//
|
|
// if (_T("1") != szRes)
|
|
// {
|
|
// pOpDevPamModifyDlg->DestroyWindow();
|
|
// delete pOpDevPamModifyDlg;
|
|
// return FALSE;
|
|
// }
|
|
//
|
|
// ////////////////////////////////////////////////////////
|
|
// TransDelay(g_iTransMode, 10, 50, NULL);
|
|
//
|
|
// m_sComPort.ClearCommReceiveBuff();
|
|
// m_sComPort.ClearCommSendBuff();
|
|
//
|
|
// szOrder.Empty();
|
|
// szOrder.Format(_T("\r\n"));
|
|
// m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
// Sleep(500);
|
|
//
|
|
// szOrder.ReleaseBuffer();
|
|
// szOrder.Empty();
|
|
//
|
|
// m_sComPort.ClearCommSendBuff();
|
|
// m_sComPort.ClearCommReceiveBuff();
|
|
//
|
|
// szOrder.Empty();
|
|
// szOrder.Format(_T("set_param(\"timezone,%d;standby_time_delay,%d;power_save_mode,%d;pushbutton_tone,%d;testing_tone,%d;language,%d;\")\r\n"),
|
|
// pOpDevPamModifyDlg->m_cbTZone.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbSTDelay.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbPSMode.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbPBTone.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbTTone.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbLang.GetCurSel());
|
|
// // AfxMessageBox(szOrder);
|
|
//
|
|
// Sleep(100);
|
|
// m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
// szOrder.ReleaseBuffer();
|
|
// // TransDelay(g_iTransMode, 100, 200);
|
|
//
|
|
// iResSize = (int)VAL_ZERO;
|
|
// memset(aResBuff, 0, sizeof(aResBuff));
|
|
// szResBuff.Empty();
|
|
// iPollingTime = 0;
|
|
//
|
|
// while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 3))
|
|
// {
|
|
// Sleep(500);
|
|
// while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
// {
|
|
// szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
//
|
|
// iResSize = (int)VAL_ZERO;
|
|
// memset(aResBuff, 0, sizeof(aResBuff));
|
|
// }
|
|
// iPollingTime++;
|
|
// }
|
|
// ////////////////////////////////////////////////////////
|
|
//
|
|
// if (3 == iPollingTime)
|
|
// {
|
|
// pOpDevPamModifyDlg->DestroyWindow();
|
|
// delete pOpDevPamModifyDlg;
|
|
// return FALSE;
|
|
// }
|
|
//
|
|
// GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
//
|
|
// if (_T("1") != szRes)
|
|
// {
|
|
// pOpDevPamModifyDlg->DestroyWindow();
|
|
// delete pOpDevPamModifyDlg;
|
|
// return FALSE;
|
|
// }
|
|
//
|
|
// pCmdUpd.CreateInstance(_uuidof(Command));
|
|
// pCmdUpd->ActiveConnection = m_pConnection;
|
|
//
|
|
// m_pConnection->BeginTrans();
|
|
//
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("update desetting set Ifrequency=%d,numformat=%d,Tsys=%d,Mvoltage=%d,Msys=%d,maxRG=%d,Tzone=%d,STdelay=%d,PSmode=%d,"
|
|
// "PBtone=%d,Ttone=%d,lang=%d where DEID = %u "),
|
|
// pOpDevPamModifyDlg->m_cbIFrequency.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbNumFormat.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbTSys.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbMVoltage.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbMSys.GetCurSel(),
|
|
// 500,
|
|
// pOpDevPamModifyDlg->m_cbTZone.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbSTDelay.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbPSMode.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbPBTone.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbTTone.GetCurSel(),
|
|
// pOpDevPamModifyDlg->m_cbLang.GetCurSel(),
|
|
// m_dwID);
|
|
// pCmdUpd->CommandText = szSql.AllocSysString();
|
|
// pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
//
|
|
// m_pConnection->CommitTrans();
|
|
// }
|
|
//
|
|
// pOpDevPamModifyDlg->DestroyWindow();
|
|
//
|
|
// delete pOpDevPamModifyDlg;
|
|
// return TRUE;
|
|
// }
|
|
|
|
BOOL CDevice::TestGRForPerPole(int iSN, CStringArray& strResArray)
|
|
{
|
|
_CommandPtr pCmdUpd = NULL;
|
|
CString szSql = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CStringArray saRes;
|
|
CString szRes = _T("");
|
|
|
|
CString szRs = _T("");
|
|
CString szDT = _T("");
|
|
|
|
CString szMDate = _T("");
|
|
CString szMTime = _T("");
|
|
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
int iOMVal = (int)VAL_ZERO;
|
|
int iOM1Val = (int)VAL_ZERO;
|
|
int iResCode = (int)VAL_ZERO;
|
|
int iResCode1 = (int)VAL_ZERO;
|
|
|
|
strResArray.RemoveAll();
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("get_rg_info(%d)\r\n"), iSN);
|
|
|
|
if (!ExecuteOrder(szOrder, _T(">"), &szResBuff))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("转换TestGR命令失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Transfer TestGR command failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
if (TRUE != GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]")))
|
|
{
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
AfxMessageBox(_T("解析TestGR结果失败"));
|
|
else
|
|
MessageBoxEx(NULL, _T("Parser result of TestGR failed!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
|
return FALSE;
|
|
}
|
|
|
|
SplitterString(saRes, szRes, _T(";"));
|
|
szRs = saRes.GetAt(0);
|
|
szRs.TrimLeft();
|
|
szRs.TrimRight();
|
|
iOMVal= atoi(szRs);
|
|
strResArray.Add(szRs);
|
|
|
|
szRs.Empty();
|
|
szRs = saRes.GetAt(1);
|
|
szRs.TrimLeft();
|
|
szRs.TrimRight();
|
|
iResCode= atoi(szRs);
|
|
strResArray.Add(szRs);
|
|
|
|
szRs.Empty();
|
|
szRs = saRes.GetAt(2);
|
|
szRs.TrimLeft();
|
|
szRs.TrimRight();
|
|
iOM1Val= atoi(szRs);
|
|
strResArray.Add(szRs);
|
|
|
|
szRs.Empty();
|
|
szRs = saRes.GetAt(3);
|
|
szRs.TrimLeft();
|
|
szRs.TrimRight();
|
|
iResCode1= atoi(szRs);
|
|
strResArray.Add(szRs);
|
|
|
|
|
|
szDT = saRes.GetAt(4);
|
|
|
|
szMDate.Empty();
|
|
szMDate.Format(_T("%s-%s-%s"), szDT.Mid(0, 4), szDT.Mid(4, 2), szDT.Mid(6, 2));
|
|
|
|
szMTime.Empty();
|
|
szMTime.Format(_T("%s:%s:%s"), szDT.Mid(8, 2), szDT.Mid(10, 2), szDT.Mid(12, 2));
|
|
|
|
|
|
|
|
pCmdUpd.CreateInstance(_uuidof(Command));
|
|
pCmdUpd->ActiveConnection = m_pConnection;
|
|
|
|
m_pConnection->BeginTrans();
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("update devgr set OMvalue=%d,StatusCode=%d,OM1value=%d,StatusCode1=%d,Mdate=#%s#,Mtime=#%s# where DEID=%u and Ecode='%d'"),
|
|
iOMVal, iResCode, iOM1Val, iResCode1,szMDate, szMTime, this->m_dwID, iSN);
|
|
pCmdUpd->CommandText = szSql.AllocSysString();
|
|
pCmdUpd->Execute(NULL, NULL, adCmdText);
|
|
|
|
m_pConnection->CommitTrans();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
int CDevice::TestGRForAllPole()
|
|
{
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CString szRes = _T("");
|
|
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
TransDelay(g_iTransMode, 10, 50, NULL);
|
|
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder = _T("rg_test_all()\r\n");
|
|
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// AfxMessageBox(szOrder);
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 100, 200);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 3))
|
|
{
|
|
Sleep(500);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
// hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
// AfxMessageBox(szResBuff);
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
if (TRUE != GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]")))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
if (_T("1") != szRes)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDevice::InitialOpDevPamModifyDlg(COpDevPamModifyDlg* const pOpDevPamModifyDlg)
|
|
{
|
|
_RecordsetPtr pRecPam = NULL;
|
|
_RecordsetPtr pRecCm = NULL;
|
|
|
|
CString szSql = _T("");
|
|
|
|
pRecPam.CreateInstance(_uuidof(Recordset));
|
|
pRecCm.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Ifrequency,numformat,Tsys,Mvoltage,Msys,maxRG,Tzone,STdelay,PSmode,PBtone,Ttone,lang from desetting where DEID = %u"), this->m_dwID);
|
|
pRecPam->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
if ((long)VAL_ZERO != pRecPam->GetRecordCount())
|
|
{
|
|
pOpDevPamModifyDlg->m_cbIFrequency.ResetContent();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Ifrequency' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
{
|
|
pOpDevPamModifyDlg->m_cbIFrequency.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->MoveNext();
|
|
}
|
|
pRecCm->Close();
|
|
|
|
pOpDevPamModifyDlg->m_cbIFrequency.SetCurSel((int)pRecPam->GetCollect(_T("Ifrequency")).iVal);
|
|
|
|
pOpDevPamModifyDlg->m_cbNumFormat.ResetContent();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'numformat' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
{
|
|
pOpDevPamModifyDlg->m_cbNumFormat.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->MoveNext();
|
|
}
|
|
pRecCm->Close();
|
|
|
|
pOpDevPamModifyDlg->m_cbNumFormat.SetCurSel((int)pRecPam->GetCollect(_T("numformat")).iVal);
|
|
|
|
pOpDevPamModifyDlg->m_cbTSys.ResetContent();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Tsys' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
{
|
|
pOpDevPamModifyDlg->m_cbTSys.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->MoveNext();
|
|
}
|
|
pRecCm->Close();
|
|
|
|
pOpDevPamModifyDlg->m_cbTSys.SetCurSel((int)pRecPam->GetCollect(_T("Tsys")).iVal);
|
|
|
|
pOpDevPamModifyDlg->m_cbMVoltage.ResetContent();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Mvoltage' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
{
|
|
pOpDevPamModifyDlg->m_cbMVoltage.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->MoveNext();
|
|
}
|
|
|
|
pRecCm->Close();
|
|
|
|
pOpDevPamModifyDlg->m_cbMVoltage.SetCurSel((int)pRecPam->GetCollect(_T("Mvoltage")).iVal);
|
|
|
|
pOpDevPamModifyDlg->m_cbMSys.ResetContent();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Msys' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
{
|
|
pOpDevPamModifyDlg->m_cbMSys.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->MoveNext();
|
|
}
|
|
pRecCm->Close();
|
|
|
|
pOpDevPamModifyDlg->m_cbMSys.SetCurSel((int)pRecPam->GetCollect(_T("Msys")).iVal);
|
|
|
|
pOpDevPamModifyDlg->m_cbTZone.ResetContent();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Tzone' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
{
|
|
pOpDevPamModifyDlg->m_cbTZone.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->MoveNext();
|
|
}
|
|
pRecCm->Close();
|
|
|
|
pOpDevPamModifyDlg->m_cbTZone.SetCurSel(((int)pRecPam->GetCollect(_T("Tzone")).iVal)+12);
|
|
//由于去掉了设置参数界面的中的Standby time delay Power, save mode, Push-bottom tone, Testing tone
|
|
//所以这里需要注释掉
|
|
// pOpDevPamModifyDlg->m_cbSTDelay.ResetContent();
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'Stdelay' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//
|
|
// while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
// {
|
|
// pOpDevPamModifyDlg->m_cbSTDelay.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
// pRecCm->MoveNext();
|
|
// }
|
|
// pRecCm->Close();
|
|
//
|
|
// pOpDevPamModifyDlg->m_cbSTDelay.SetCurSel((int)pRecPam->GetCollect(_T("STdelay")).iVal);
|
|
|
|
// pOpDevPamModifyDlg->m_cbPSMode.ResetContent();
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'Psmode' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//
|
|
// while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
// {
|
|
// pOpDevPamModifyDlg->m_cbPSMode.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
// pRecCm->MoveNext();
|
|
// }
|
|
// pRecCm->Close();
|
|
//
|
|
// pOpDevPamModifyDlg->m_cbPSMode.SetCurSel((int)pRecPam->GetCollect(_T("PSmode")).iVal);
|
|
|
|
// pOpDevPamModifyDlg->m_cbPBTone.ResetContent();
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'Pbtone' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//
|
|
// while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
// {
|
|
// pOpDevPamModifyDlg->m_cbPBTone.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
// pRecCm->MoveNext();
|
|
// }
|
|
// pRecCm->Close();
|
|
//
|
|
// pOpDevPamModifyDlg->m_cbPBTone.SetCurSel((int)pRecPam->GetCollect(_T("PBtone")).iVal);
|
|
|
|
// pOpDevPamModifyDlg->m_cbTTone.ResetContent();
|
|
// szSql.Empty();
|
|
// szSql.Format(_T("select Clabel from cm where Cname = 'Ttone' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
// pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
//
|
|
// while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
// {
|
|
// pOpDevPamModifyDlg->m_cbTTone.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
// pRecCm->MoveNext();
|
|
// }
|
|
// pRecCm->Close();
|
|
//
|
|
// pOpDevPamModifyDlg->m_cbTTone.SetCurSel((int)pRecPam->GetCollect(_T("Ttone")).iVal);
|
|
|
|
pOpDevPamModifyDlg->m_cbLang.ResetContent();
|
|
szSql.Empty();
|
|
szSql.Format(_T("select Clabel from cm where Cname = 'Lang' and Lang = %d order by Cvalue"), g_iLanguage);
|
|
pRecCm->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
while ((short)VAL_ZERO == pRecCm->adoEOF)
|
|
{
|
|
pOpDevPamModifyDlg->m_cbLang.AddString((LPCTSTR)(_bstr_t)pRecCm->GetCollect(_T("Clabel")));
|
|
pRecCm->MoveNext();
|
|
}
|
|
pRecCm->Close();
|
|
|
|
pOpDevPamModifyDlg->m_cbLang.SetCurSel((int)pRecPam->GetCollect(_T("lang")).iVal);
|
|
}
|
|
pRecPam->Close();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDevice::GenerateUserFile(CString& szFilePath, CString& szFileName)
|
|
{
|
|
CString szFile = _T("");
|
|
|
|
CMarkup xml;
|
|
|
|
szFilePath.Empty();
|
|
szFilePath.GetBufferSetLength(256);
|
|
::GetCurrentDirectory(szFilePath.GetLength(), szFilePath.GetBuffer(szFilePath.GetLength()));
|
|
szFilePath.ReleaseBuffer();
|
|
|
|
szFilePath = szFilePath + _T("\\CACHE\\");//这个函数没有使用到,所以,不需要修改存储路径。20211207
|
|
szFileName.Empty();
|
|
szFileName = g_szMacAddress + _T(".xml");
|
|
|
|
szFile.Empty();
|
|
szFile = szFilePath + szFileName;
|
|
|
|
DeleteFile(szFile);
|
|
xml.SetDoc(_T("<?xml version=\"1.0\" encoding=\"ansi\"?>\r\n"));
|
|
xml.AddElem(_T("user"));
|
|
xml.IntoElem();
|
|
xml.AddElem(_T("user_info"));
|
|
xml.AddChildElem(_T("default_path"), _T(""));
|
|
xml.AddChildElem(_T("credentials"), 2);
|
|
|
|
xml.AddChildElem(_T("project_count"), 0);
|
|
xml.AddChildElem(_T("path_dictionary"), _T(""));
|
|
xml.AddChildElem(_T("cryptoguard"), 0);
|
|
xml.AddChildElem(_T("password"), _T("liyujie"));
|
|
|
|
xml.Save(szFile);
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDevice::IsTheNumofPoleChanged()
|
|
{
|
|
_RecordsetPtr pRecGrTotal = NULL;
|
|
CString szSql = _T("");
|
|
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CString szRes = _T("");
|
|
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
int iCurTotal = (int)VAL_ZERO;
|
|
int iPreTotal = (int)VAL_ZERO;
|
|
|
|
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder = _T("get_rg_count()\r\n");
|
|
// AfxMessageBox(szOrder);
|
|
|
|
TransDelay(g_iTransMode, 10, 50);
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 100, 200);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 3))
|
|
{
|
|
Sleep(500);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
if (TRUE != GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]")))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
iCurTotal = atoi(szRes);
|
|
/////////////////////////////////////////////////////////
|
|
pRecGrTotal.CreateInstance(_uuidof(Recordset));
|
|
|
|
szSql.Empty();
|
|
szSql.Format(_T("select count(*) as total from devgr where DEID = %u"), m_dwID);
|
|
pRecGrTotal->Open(szSql.AllocSysString(), _variant_t((IDispatch*)m_pConnection, true), adOpenStatic, adLockOptimistic, adCmdText);
|
|
|
|
iPreTotal = (int)pRecGrTotal->GetCollect(_T("total")).iVal;
|
|
|
|
pRecGrTotal->Close();
|
|
/////////////////////////////////////////////////////////
|
|
|
|
|
|
if (iCurTotal == iPreTotal)
|
|
{
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
int CDevice::GetPoleCount()
|
|
{
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
CString szRes = _T("");
|
|
|
|
char aResBuff[1024] = {0};
|
|
|
|
int iResSize = (int)VAL_ZERO;
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
|
|
int iCurTotal = (int)VAL_ZERO;
|
|
|
|
TransDelay(g_iTransMode, 10, 50, NULL);
|
|
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
m_sComPort.ClearCommSendBuff();
|
|
|
|
szOrder.Empty();
|
|
szOrder = _T("get_rg_count()\r\n");
|
|
// AfxMessageBox(szOrder);
|
|
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
szOrder.ReleaseBuffer();
|
|
// TransDelay(g_iTransMode, 100, 200);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
szResBuff.Empty();
|
|
iPollingTime = 0;
|
|
while ((szResBuff.Find(_T(">")) == -1) && (iPollingTime < 3))
|
|
{
|
|
Sleep(500);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
iPollingTime++;
|
|
}
|
|
|
|
if (MAX_POLLING_TIME == iPollingTime)
|
|
{
|
|
return (int)VAL_MINUS_ONE;
|
|
}
|
|
|
|
if (TRUE != GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]")))
|
|
{
|
|
return (int)VAL_MINUS_ONE;
|
|
}
|
|
|
|
iCurTotal = atoi(szRes);
|
|
|
|
return iCurTotal;
|
|
}
|
|
|
|
BOOL CDevice::LockDevice()
|
|
{
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
|
|
szOrder.Empty();
|
|
szOrder.Format(_T("connect_gd10()\r\n"));
|
|
|
|
if (!this->ExecuteOrder(szOrder, "]", &szResBuff))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
|
|
if (_T("1") == szRes)
|
|
{
|
|
return TRUE;
|
|
}
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CDevice::ModifyTimeWindow()
|
|
{
|
|
CString szSql = _T("");
|
|
|
|
DWORD dwID = (DWORD)VAL_ZERO;
|
|
|
|
CUpDateTimeWindow timeWindow;
|
|
timeWindow.m_dwID = m_dwID;
|
|
timeWindow.m_pConnection = m_pConnection;
|
|
timeWindow.m_pDev = this;
|
|
timeWindow.DoModal();
|
|
|
|
|
|
return timeWindow.m_result;
|
|
}
|
|
|
|
int CDevice::CheckGD10Password(CString strGD10Password)
|
|
{
|
|
CString szOrder=_T("");
|
|
CString szResBuff = _T("");
|
|
CString szRes = _T("");
|
|
CString strShowInfo = _T("");
|
|
szOrder.Format(_T("check_password(\"%s\")\r\n"),strGD10Password);
|
|
if (!ExecuteOrder(szOrder, "]", &szResBuff))
|
|
{
|
|
return enExecCmdError;
|
|
}
|
|
GetSubStringInHeadAndTail(szResBuff, szRes, _T("["), _T("]"));
|
|
return (_T("1") == szRes) ? enPasswordSucc : enPasswordError;
|
|
}
|
|
|
|
//执行传给设备的指令: strOrder: 传给设备的指令 strSign:收到的结果, pStrResult:希望等待到的字符串,nRepeatCnt:重发指令的次数
|
|
BOOL CDevice::ExecuteOrder(CString strOrder, CString strSign, CString *pStrResult, int nRepeatCnt, int nPollCnt)
|
|
{
|
|
CString strLog = _T("");
|
|
for (int i = 0; i < nRepeatCnt; i++)
|
|
{
|
|
if (ExecuteSignleOrder(strOrder, strSign, pStrResult, nPollCnt))
|
|
{
|
|
return TRUE;
|
|
}
|
|
strLog.Empty();
|
|
strLog.Format(_T("[%d]excute order %s failed! res_buffer = %s"), __LINE__,strOrder, *pStrResult);
|
|
PrintLog(strLog);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
//执行单次设备指令: f_szOrder: 传给设备的指令 f_szResult:收到的结果,f_szSign:希望等待到的字符串
|
|
BOOL CDevice::ExecuteSignleOrder(CString f_szOrder, CString f_szSign, CString *f_szResult, int nCmdPollCnt)
|
|
{
|
|
//log
|
|
CString szlog = _T("");
|
|
DWORD dwBegin = GetTickCount();
|
|
|
|
//log
|
|
CString szOrder = _T("");
|
|
CString szResBuff = _T("");
|
|
|
|
int iPollingTime = (int)VAL_ZERO;
|
|
int iResSize = (int)VAL_ZERO;
|
|
char aResBuff[2048] = {0};
|
|
|
|
TransDelay(g_iTransMode, 10, 50, NULL);
|
|
|
|
//清空串口缓冲区
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
|
|
//判断设备是否等待就绪
|
|
szOrder.Empty();
|
|
szResBuff.Empty();
|
|
iResSize = (int)VAL_ZERO;
|
|
iPollingTime = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
|
|
szOrder.Format(_T("\r\n"));
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
|
|
//log
|
|
szlog.Empty();
|
|
szlog.Format("[%d] send %s, cost_ticks = %d",__LINE__,szOrder.GetBuffer(0), GetTickCount() - dwBegin);
|
|
PrintLog(szlog);
|
|
//log
|
|
|
|
while ((szResBuff.Find(">") == -1) && (iPollingTime < 200))
|
|
{
|
|
Sleep(5);
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
}
|
|
|
|
iPollingTime++;
|
|
if (iPollingTime % 25 == 0)//设备没有响应,准备重发,每循环25次就重发
|
|
{
|
|
szOrder.Format(_T("\r\n"));
|
|
m_sComPort.SendDataDirectly(szOrder.GetBuffer(szOrder.GetLength()), szOrder.GetLength());
|
|
}
|
|
}
|
|
|
|
//log
|
|
szlog.Empty();
|
|
szlog.Format("[%d] recv %s, cost_ticks = %d",__LINE__,szResBuff.GetBuffer(0), GetTickCount() - dwBegin);
|
|
PrintLog(szlog);
|
|
//log
|
|
|
|
|
|
//设备没有响应
|
|
if (iPollingTime == 200 )
|
|
{
|
|
szlog.Empty();
|
|
if (szResBuff.IsEmpty())
|
|
{
|
|
szlog.Format("[%d] recv start_respose_cmd timeout",__LINE__);
|
|
PrintLog(szlog);
|
|
}
|
|
else
|
|
{
|
|
szlog.Format("[%d] recv wrong cmd_responses signal, cmd = %s",__LINE__,szResBuff.GetBuffer(0));
|
|
PrintLog(szlog);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
//设备准备局就绪,准备发送指令
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
|
|
//初始化值
|
|
szOrder.Empty();
|
|
szResBuff.Empty();
|
|
iResSize = (int)VAL_ZERO;
|
|
iPollingTime = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
|
|
//发送指令
|
|
m_sComPort.SendDataDirectly(f_szOrder.GetBuffer(f_szOrder.GetLength()), f_szOrder.GetLength());
|
|
|
|
//log
|
|
szlog.Empty();
|
|
szlog.Format("[%d] send %s, cost_ticks = %d",__LINE__,f_szOrder.GetBuffer(0), GetTickCount() - dwBegin);
|
|
PrintLog(szlog);
|
|
//log
|
|
|
|
while ((szResBuff.Find(f_szSign) == -1) && (iPollingTime < nCmdPollCnt))
|
|
{
|
|
Sleep(5);
|
|
|
|
while (m_sComPort.ReceiveDataDirectly(aResBuff, &iResSize) == TRUE)
|
|
{
|
|
|
|
szResBuff.Insert(szResBuff.GetLength(), aResBuff);
|
|
|
|
iResSize = (int)VAL_ZERO;
|
|
memset(aResBuff, 0, sizeof(aResBuff));
|
|
|
|
|
|
}
|
|
|
|
iPollingTime++;
|
|
}
|
|
|
|
if (iPollingTime == nCmdPollCnt )
|
|
{
|
|
//log
|
|
szlog.Empty();
|
|
szlog.Format("[%d] recv wrong cmd_responses_signal, cmd = %s",__LINE__,szResBuff.GetBuffer(0));
|
|
PrintLog(szlog);
|
|
//log
|
|
return FALSE;
|
|
}
|
|
f_szResult->Format("%s", szResBuff.GetBuffer(0));
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
void CDevice::PrintLog(CString& strLog)
|
|
{
|
|
if (NULL == m_pLogFile)
|
|
{
|
|
MessageBox(NULL, "can't write device_log, log File point is NULL", "LOG_ERROR", MB_OK);
|
|
return;
|
|
}
|
|
CString strOutPut = _T("");
|
|
strOutPut.Format(_T("%04d-%02d-%02d %02d:%02d:%02d.%03d %s \r\n"),g_sysCurTime.wYear, g_sysCurTime.wMonth, g_sysCurTime.wDay,
|
|
g_sysCurTime.wHour, g_sysCurTime.wMinute, g_sysCurTime.wSecond, g_sysCurTime.wMilliseconds, strLog.GetBuffer(0));
|
|
fwrite(strOutPut.GetBuffer(0), 1, strOutPut.GetLength(), m_pLogFile);
|
|
fflush(m_pLogFile);
|
|
}
|
|
|
|
BOOL CDevice::EndTransfer()
|
|
{
|
|
//首先发送终止字符,然后通过发送简单命令来判断是否手段命令响应符的方法
|
|
//来判断是否已经终止
|
|
BOOL bRes = FALSE;
|
|
int nCnt = 3;
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
Zmodem *tmpZmodem = new Zmodem(&m_sComPort);
|
|
bool bIsCancelSend = false;
|
|
while(nCnt>0)
|
|
{
|
|
nCnt--;
|
|
if (tmpZmodem->SendCancelString())
|
|
{
|
|
bIsCancelSend = true;
|
|
break;
|
|
}
|
|
}
|
|
if (bIsCancelSend)
|
|
{
|
|
CString strResult = _T("");
|
|
//如果执行成功则认为可以重传
|
|
if (ExecuteOrder("list_date()\r\n", ">", &strResult))
|
|
{
|
|
bRes = TRUE;
|
|
}
|
|
}
|
|
delete tmpZmodem;
|
|
m_sComPort.ClearCommSendBuff();
|
|
m_sComPort.ClearCommReceiveBuff();
|
|
return bRes;
|
|
} |