// DialogFactCfg.cpp: 实现文件
|
//
|
|
#include "pch.h"
|
#include "MTerm1.h"
|
#include "DialogFactCfg.h"
|
#include "afxdialogex.h"
|
|
#include "MTerm1Doc.h"
|
|
// CDialogFactCfg 对话框
|
|
IMPLEMENT_DYNAMIC(CDialogFactCfg, CDialogEx)
|
|
CDialogFactCfg::CDialogFactCfg(CWnd* pParent /*=nullptr*/)
|
: CDialogEx(IDD_DIALOG_FACT_CFG, pParent)
|
{
|
InitDataItems();
|
}
|
|
CDialogFactCfg::~CDialogFactCfg()
|
{
|
}
|
|
void CDialogFactCfg::DoDataExchange(CDataExchange* pDX)
|
{
|
CDialogEx::DoDataExchange(pDX);
|
}
|
|
|
BEGIN_MESSAGE_MAP(CDialogFactCfg, CDialogEx)
|
ON_BN_CLICKED(IDC_BUTTON_CONN, &CDialogFactCfg::OnBnClickedButtonConn)
|
ON_BN_CLICKED(IDC_BUTTON_DISCONN, &CDialogFactCfg::OnBnClickedButtonDisconn)
|
ON_BN_CLICKED(IDC_BUTTON_READDATA, &CDialogFactCfg::OnBnClickedButtonReaddata)
|
ON_BN_CLICKED(IDC_BUTTON_WRITEDATA, &CDialogFactCfg::OnBnClickedButtonWritedata)
|
|
END_MESSAGE_MAP()
|
|
// CDialogFactCfg 消息处理程序
|
int CDialogFactCfg::AddDataItem(int nOffset, int nSize, int nType, CString sName)
|
{
|
FactoryDataItems[nFactoryDataItemsCount] = { nOffset,nSize,nType,sName };
|
nFactoryDataItemsCount++;
|
return 0;
|
}
|
|
int CDialogFactCfg::InitDataItems()
|
{
|
AddDataItem(0, 2, typeBIN, _T("开始标志"));
|
AddDataItem(2, 2, typeINT, _T("序号"));
|
AddDataItem(4, 2, typeHEX, _T("ModelNo"));
|
AddDataItem(6, 2, typeHEX, _T("ModelVer"));
|
AddDataItem(8, 4, typeUINT, _T("nLotNo"));
|
AddDataItem(12, 4, typeDATETIME, _T("nProductDate"));
|
AddDataItem(16, 4, typeUINT, _T("nSN1"));
|
AddDataItem(20, 4, typeHEX, _T("nProtocalVer"));
|
AddDataItem(24, 4, typeHEX, _T("nDefaultFuncr"));
|
AddDataItem(28, 16, typeString, _T("sModelStr"));
|
AddDataItem(44, 16, typeString, _T("sLot_No"));
|
AddDataItem(60, 16, typeString, _T("sSNStr"));
|
AddDataItem(76, 2, typeHEX, _T("CRC1"));
|
AddDataItem(78, 2, typeHEX, _T("EndSign"));
|
return 0;
|
}
|
|
int CDialogFactCfg::FindIdByName(CString sName)
|
{
|
for (int i = 0; i < nFactoryDataItemsCount; i++) {
|
if (FactoryDataItems[i].sName == sName) {
|
return i;
|
}
|
}
|
return -1;
|
}
|
|
int CDialogFactCfg::GetDataByOffset(void * pDataBlock, int nOffset)
|
{
|
return 0;
|
}
|
int CDialogFactCfg::GetDataByName(void * pDataBlock, CString sName)
|
{
|
return 0;
|
}
|
CString CDialogFactCfg::GetDataStrByName(void * pDataBlock, CString sName)
|
{
|
UCHAR * pBuf2 = (UCHAR *)pDataBlock;
|
CString s1;
|
UCHAR buf3[256];
|
CString s3;
|
int nIdx = FindIdByName(sName);
|
if (nIdx >= 0)
|
{
|
CTime ctime1;
|
int nType = FactoryDataItems[nIdx].nType;
|
int nSize = FactoryDataItems[nIdx].nSize;
|
int nOffset = FactoryDataItems[nIdx].nOffset;
|
int nValue;
|
UINT uValue;
|
switch (nType)
|
{
|
case typeINT:
|
if (nSize == 1) {
|
nValue = *((char *)(pBuf2 + nOffset));
|
}
|
else if (nSize == 2) {
|
nValue = *(short *)(pBuf2 + nOffset);
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
nValue = *(int *)(pBuf2 + nOffset);
|
}
|
s1.Format(_T("%d"), nValue);
|
break;
|
case typeUINT:
|
if (nSize == 1) {
|
uValue = *((UCHAR *)(pBuf2 + nOffset));
|
}
|
else if (nSize == 2) {
|
uValue = *(USHORT *)(pBuf2 + nOffset);
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
uValue = *(UINT *)(pBuf2 + nOffset);
|
}
|
s1.Format(_T("%u"), uValue);
|
break;
|
case typeHEX:
|
if (nSize == 1) {
|
uValue = *((UCHAR *)(pBuf2 + nOffset));
|
s1.Format(_T("%02X"), uValue);
|
}
|
else if (nSize == 2) {
|
uValue = *(USHORT *)(pBuf2 + nOffset);
|
s1.Format(_T("%04X"), uValue);
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
uValue = *(UINT *)(pBuf2 + nOffset);
|
s1.Format(_T("%08X"), uValue);
|
}
|
|
break;
|
case typeBIN:
|
if (nSize == 1) {
|
uValue = *((UCHAR *)(pBuf2 + nOffset));
|
s1.Format(_T("%02X"), uValue);
|
}
|
else if (nSize == 2) {
|
uValue = *(USHORT *)(pBuf2 + nOffset);
|
s1.Format(_T("%04X"), uValue);
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
uValue = *(UINT *)(pBuf2 + nOffset);
|
s1.Format(_T("%08X"), uValue);
|
}
|
|
break;
|
case typeFLOAT:
|
break;
|
case typeFIX:
|
break;
|
case typeBIT:
|
break;
|
case typeString:
|
for (int j = 0; j < nSize; j++)
|
{
|
buf3[j] = pBuf2[nOffset + j];
|
}
|
buf3[nSize] = 0;
|
s3 = buf3;
|
s1.Format(_T("%s"), s3);
|
break;
|
case typeDATETIME:
|
nValue = *(UINT *)(pBuf2 + nOffset);
|
ctime1 = nValue;
|
ctime1 = CStringToCTime(_T("2000-01-01 08:00:00"));
|
ctime1 += nValue;
|
s3 = ctime1.Format(_T("%Y-%m-%d %H:%M:%S"));
|
s1.Format(_T("%s"), s3);
|
break;
|
default:
|
break;
|
}
|
}
|
return s1;
|
}
|
int CDialogFactCfg::SetDataByName(void * pDataBlock, CString sName, UINT uValue)
|
{
|
UCHAR * pBuf2 = (UCHAR *)pDataBlock;
|
// UCHAR buf3[256];
|
int nIdx = FindIdByName(sName);
|
if (nIdx >= 0)
|
{
|
CTime ctime1;
|
CTime ctime2;
|
CTimeSpan ctime3;
|
int nType = FactoryDataItems[nIdx].nType;
|
int nSize = FactoryDataItems[nIdx].nSize;
|
int nOffset = FactoryDataItems[nIdx].nOffset;
|
int nValue;
|
switch (nType)
|
{
|
case typeINT:
|
if (nSize == 1) {
|
*((char *)(pBuf2 + nOffset)) = uValue;
|
}
|
else if (nSize == 2) {
|
*(short *)(pBuf2 + nOffset) = uValue;
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
*(int *)(pBuf2 + nOffset) = uValue;
|
}
|
break;
|
case typeUINT:
|
case typeHEX:
|
if (nSize == 1) {
|
*((UCHAR *)(pBuf2 + nOffset)) = uValue;
|
}
|
else if (nSize == 2) {
|
*(USHORT *)(pBuf2 + nOffset) = uValue;
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
*(UINT *)(pBuf2 + nOffset) = uValue;
|
}
|
break;
|
case typeBIN:
|
if (nSize == 1) {
|
*((UCHAR *)(pBuf2 + nOffset)) = uValue;
|
}
|
else if (nSize == 2) {
|
*(USHORT *)(pBuf2 + nOffset) = uValue;
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
*(UINT *)(pBuf2 + nOffset) = uValue;
|
}
|
|
break;
|
case typeFLOAT:
|
break;
|
case typeFIX:
|
break;
|
case typeBIT:
|
break;
|
case typeString:
|
break;
|
case typeDATETIME:
|
ctime1 = CStringToCTime(_T("2000-01-01 08:00:00"));
|
ctime2 = uValue;
|
ctime3 = ctime2 - ctime1;
|
nValue = (long)(ctime3.GetTotalSeconds());
|
*(UINT *)(pBuf2 + nOffset) = uValue;
|
|
break;
|
default:
|
break;
|
}
|
}
|
return 0;
|
}
|
int CDialogFactCfg::SetDataByName(void * pDataBlock, CString sName, CString sValue)
|
{
|
UCHAR * pBuf2 = (UCHAR *)pDataBlock;
|
// UCHAR buf3[256];
|
CStringA s3;
|
int nIdx = FindIdByName(sName);
|
if (nIdx >= 0)
|
{
|
CTime ctime1;
|
CTime ctime2;
|
CTimeSpan ctime3;
|
int nType = FactoryDataItems[nIdx].nType;
|
int nSize = FactoryDataItems[nIdx].nSize;
|
int nOffset = FactoryDataItems[nIdx].nOffset;
|
int nValue;
|
int len;
|
switch (nType)
|
{
|
case typeINT:
|
if (nSize == 1) {
|
*((char *)(pBuf2 + nOffset)) = _tstoi(sValue);
|
}
|
else if (nSize == 2) {
|
*(short *)(pBuf2 + nOffset) = _tstoi(sValue);
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
*(int *)(pBuf2 + nOffset) = _tstoi(sValue);
|
}
|
break;
|
case typeUINT:
|
if (nSize == 1) {
|
*((UCHAR *)(pBuf2 + nOffset)) = _tstoi(sValue);
|
}
|
else if (nSize == 2) {
|
*(USHORT *)(pBuf2 + nOffset) = _tstoi(sValue);
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
*(UINT *)(pBuf2 + nOffset) = _tstoi(sValue);
|
}
|
break;
|
case typeHEX:
|
if (nSize == 1) {
|
*((UCHAR *)(pBuf2 + nOffset)) = _tstoi(sValue);
|
|
}
|
else if (nSize == 2) {
|
*(USHORT *)(pBuf2 + nOffset) = _tstoi(sValue);
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
*(UINT *)(pBuf2 + nOffset) = _tstoi(sValue);
|
}
|
break;
|
case typeBIN:
|
if (nSize == 1) {
|
*((UCHAR *)(pBuf2 + nOffset)) = _tstoi(sValue);
|
}
|
else if (nSize == 2) {
|
*(USHORT *)(pBuf2 + nOffset) = _tstoi(sValue);
|
}
|
else if (nSize == 3) {
|
|
}
|
else if (nSize == 4) {
|
*(UINT *)(pBuf2 + nOffset) = _tstoi(sValue);
|
}
|
|
break;
|
case typeFLOAT:
|
break;
|
case typeFIX:
|
break;
|
case typeBIT:
|
break;
|
case typeString:
|
s3 = sValue;
|
len = s3.GetLength();
|
for (int j = 0; j < nSize; j++) {
|
if (j < len) {
|
pBuf2[nOffset + j] = s3[j];
|
}else {
|
pBuf2[nOffset + j] = ' ';
|
}
|
}
|
break;
|
case typeDATETIME:
|
ctime1 = CStringToCTime(_T("2000-01-01 08:00:00"));
|
ctime2 = CStringToCTime(sValue);;
|
ctime3 = ctime2 - ctime1;
|
nValue = (long)(ctime3.GetTotalSeconds());
|
*(UINT *)(pBuf2 + nOffset) = nValue;
|
|
break;
|
default:
|
break;
|
}
|
}
|
return 0;
|
}
|
|
|
|
CMTerm1Doc * CDialogFactCfg::GetDocument()
|
{
|
// TODO: 在此处添加实现代码.
|
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
CMDIChildWnd *pChild = (CMDIChildWnd *)pFrame->GetActiveFrame();
|
CView *pV = (CView*)pChild->GetActiveView();
|
CMTerm1Doc* pDoc = (CMTerm1Doc *)(pV->GetDocument());
|
return pDoc;
|
}
|
|
int CDialogFactCfg::Connect()
|
{
|
// TODO: 在此处添加实现代码.
|
CString s1;
|
CMTerm1Doc* pDoc = (CMTerm1Doc *)GetDocument();
|
|
|
int r = pDoc->Connect();
|
s1.Format(_T("Open %s = %d"), pDoc->MyKLink1.MySerPort1.m_strResult, r);
|
SysLog(s1);
|
if (r == pDoc->MyKLink1.MySerPort1.R_OK)
|
{
|
pDoc->MyKLink1.Open();
|
return false;
|
}
|
return true;
|
return 0;
|
}
|
|
|
int CDialogFactCfg::Disconnect()
|
{
|
// TODO: 在此处添加实现代码.
|
CMTerm1Doc* pDoc = (CMTerm1Doc *)GetDocument();
|
|
pDoc->DisConnect();
|
pDoc->MyKLink1.Close();
|
return 0;
|
}
|
|
int CDialogFactCfg::ReadData()
|
{
|
CMTerm1Doc* pDoc = (CMTerm1Doc *)GetDocument();
|
|
unsigned short buf1[1024];
|
unsigned short len1;
|
int res = pDoc->MyKLink1.GetInfo(1 ,&len1, buf1);
|
SysLog(pDoc->MyKLink1.m_resultStr);
|
CString s1;
|
s1.Format(_T("GetInfo = %d %d bytes"), res,len1);
|
if (res == pDoc->MyKLink1.KL_OK)
|
{
|
s1.Append(_T("\r\n"));
|
for (int i = 0; i < len1 / 2; i++)
|
{
|
s1.AppendFormat(_T("%04X "), buf1[i]);
|
}
|
}
|
SysLog(s1);
|
pKMInfoBlock pinfob = (pKMInfoBlock)buf1;
|
|
s1.Format(_T("%04X"), pinfob->nDeviceTypeVer);
|
SetDlgItemText(IDC_EDIT_DEVICE_TYPE, s1);
|
s1.Format(_T("%04X"), pinfob->nProgVer);
|
SetDlgItemText(IDC_EDIT_FIRM_VER, s1);
|
s1.Format(_T("%04X"), pinfob->nKLinkVer);
|
SetDlgItemText(IDC_EDIT_KLINK_VER, s1);
|
s1.Format(_T("%04X"), pinfob->nKBusVer);
|
SetDlgItemText(IDC_EDIT_KBUS_VER, s1);
|
s1.Format(_T("%04X"), 0);
|
s1.Empty();
|
SetDlgItemText(IDC_EDIT_KNET_VER, s1);
|
//s1.Format(_T("%04X"), 0);
|
SetDlgItemText(IDC_EDIT_KWL_VER, s1);
|
s1.Format(_T("%04X"), pinfob->nAbility);
|
SetDlgItemText(IDC_EDIT_FUNCTIONS, s1);
|
|
s1.Format(_T("%d"), pinfob->nCapacity1);
|
SetDlgItemText(IDC_EDIT_CAP_PROG, s1);
|
s1.Format(_T("%d"), pinfob->nCapacity2);
|
SetDlgItemText(IDC_EDIT_CAP_DT, s1);
|
|
SetDlgItemText(IDC_EDIT_CAP_WR, s1);
|
SetDlgItemText(IDC_EDIT_CAP_TM, s1);
|
s1.Format(_T("%d"), pinfob->nSwitchBits);
|
SetDlgItemText(IDC_EDIT_CAP_SW, s1);
|
s1.Format(_T("%d"), pinfob->nPorts);
|
SetDlgItemText(IDC_EDIT_CAP_COM, s1);
|
s1.Format(_T("%d"), pinfob->nManSize);
|
SetDlgItemText(IDC_EDIT_CAP_CFG, s1);
|
s1.Format(_T("%d"), pinfob->nLogSize);
|
SetDlgItemText(IDC_EDIT_CAP_EVENT, s1);
|
|
s1.Format(_T("%d"), pinfob->nDInput);
|
SetDlgItemText(IDC_EDIT_CAP_DIN, s1);
|
s1.Format(_T("%d"), pinfob->nDInput);
|
SetDlgItemText(IDC_EDIT_CAP_DOUT, s1);
|
s1.Format(_T("%d"), pinfob->nAInput);
|
SetDlgItemText(IDC_EDIT_CAP_AIN_I, s1);
|
s1.Format(_T("%d"), pinfob->nAOutput);
|
SetDlgItemText(IDC_EDIT_CAP_AOUT_I, s1);
|
s1.Format(_T("%d"), pinfob->nAInput);
|
SetDlgItemText(IDC_EDIT_CAP_AIN_E, s1);
|
s1.Format(_T("%d"), pinfob->nAOutput);
|
SetDlgItemText(IDC_EDIT_CAP_AOUT_E, s1);
|
s1.Format(_T("%d"), pinfob->nHInput);
|
SetDlgItemText(IDC_EDIT_CAP_HIN, s1);
|
s1.Format(_T("%d"), pinfob->nHOutput);
|
SetDlgItemText(IDC_EDIT_CAP_HOUT, s1);
|
s1.Empty();
|
SetDlgItemText(IDC_EDIT_CAP_IRQ_I, s1);
|
SetDlgItemText(IDC_EDIT_CAP_IRQ_O, s1);
|
SetDlgItemText(IDC_EDIT_CAP_EXT_I, s1);
|
SetDlgItemText(IDC_EDIT_CAP_EXT_O, s1);
|
|
CString s2;
|
CString s3;
|
unsigned char buf2[1024];
|
res = pDoc->MyKLink1.GetUID(1, &len1, (unsigned short *)buf2);
|
SysLog(pDoc->MyKLink1.m_resultStr);
|
s1.Format(_T("GetUID = %d %d bytes"), res,len1);
|
|
if (res == pDoc->MyKLink1.KL_OK)
|
{
|
s1.Append(_T("\r\n"));
|
for (int i = 0; i < 12; i++)
|
{
|
s1.AppendFormat(_T("%02X "), buf2[i]);
|
s2.AppendFormat(_T("%02X"), buf2[12-i-1]);
|
// s3.AppendFormat(_T("%c"), buf2[12 - i - 1]);
|
}
|
}
|
SysLog(s1);
|
SetDlgItemText(IDC_EDIT_DEVICE_UID, s2);
|
|
|
res = pDoc->MyKLink1.GetSN(1, &len1, (unsigned short *)buf2);
|
SysLog(pDoc->MyKLink1.m_resultStr);
|
s1.Format(_T("GetSN = %d %d bytes"), res,len1);
|
s2.Empty();
|
if (res == pDoc->MyKLink1.KL_OK)
|
{
|
s1.Append(_T("\r\n"));
|
for (int i = 0; i < 4; i++)
|
{
|
s1.AppendFormat(_T("%02X "), buf2[i]);
|
s2.AppendFormat(_T("%02X"), buf2[4-i-1]);
|
// s3.AppendFormat(_T("%c"), buf2[12 - i - 1]);
|
}
|
}
|
SysLog(s1);
|
|
res = pDoc->MyKLink1.ReadFactoryData(1, 0, 120, &len1, (unsigned short *)buf2);
|
SysLog(pDoc->MyKLink1.m_resultStr);
|
s1.Format(_T("GetFactoryData = %d %d bytes"), res, len1);
|
s2.Empty();
|
if (res == pDoc->MyKLink1.KL_OK)
|
{
|
s1.Append(_T("\r\n"));
|
for (int i = 0; i < 256 && i< len1; i++)
|
{
|
s1.AppendFormat(_T("%02X "), buf2[i]);
|
// s2.AppendFormat(_T("%02X"), buf2[4 - i - 1]);
|
// s3.AppendFormat(_T("%c"), buf2[12 - i - 1]);
|
}
|
}
|
SysLog(s1);
|
s2 = GetDataStrByName(buf2, _T("nSN1"));
|
SetDlgItemText(IDC_EDIT_ORG_FACT_SN, s2);
|
|
// unsigned char buf3[1024];
|
CTime ctime1;
|
for (int i = 0; i < nFactoryDataItemsCount; i++)
|
{
|
// int nType = FactoryDataItems[i].nType;
|
// int nSize = FactoryDataItems[i].nSize;
|
// int nOffset = FactoryDataItems[i].nOffset;
|
CString sName = FactoryDataItems[i].sName;
|
s3 = GetDataStrByName(buf2,sName);
|
s1.Format(_T("%d %s %s"), i, sName, s3);
|
SysLog(s1);
|
}
|
|
s3=GetDataStrByName(buf2, _T("sLot_No"));
|
SetDlgItemText(IDC_EDIT_ORG_LOT_NO, s3);
|
|
s3 = GetDataStrByName(buf2, _T("nProductDate"));
|
SetDlgItemText(IDC_EDIT_ORG_FAC_DATE, s3);
|
|
|
return 0;
|
}
|
|
|
|
int CDialogFactCfg::WriteData()
|
{
|
// TODO: 在此处添加实现代码.
|
|
CString s1;
|
CMTerm1Doc* pDoc = (CMTerm1Doc *)GetDocument();
|
unsigned short buf1[1024];
|
// unsigned char buf2[1024];
|
// unsigned char buf3[1024];
|
/*
|
AddDataItem(0, 2, typeBIN, _T("开始标志"));
|
AddDataItem(2, 2, typeINT, _T("序号"));
|
AddDataItem(4, 2, typeBIN, _T("ModelNo"));
|
AddDataItem(6, 2, typeBIN, _T("ModelVer"));
|
AddDataItem(8, 4, typeUINT, _T("nLotNo"));
|
AddDataItem(12, 4, typeDATETIME, _T("nProductDate"));
|
AddDataItem(16, 4, typeBIN, _T("nSN1"));
|
AddDataItem(20, 4, typeBIN, _T("nProtocalVer"));
|
AddDataItem(24, 4, typeBIN, _T("nDefaultFuncr"));
|
AddDataItem(28, 16, typeString, _T("sModelStr"));
|
AddDataItem(44, 16, typeString, _T("sLot_No"));
|
AddDataItem(60, 16, typeString, _T("sSNStr"));
|
AddDataItem(76, 2, typeBIN, _T("CRC1"));
|
AddDataItem(78, 2, typeBIN, _T("EndSign"));
|
*/
|
int res = 0;
|
unsigned short len1;
|
res = pDoc->MyKLink1.ReadFactoryData(1, 0, 120, &len1, (unsigned short *)buf1);
|
SysLog(pDoc->MyKLink1.m_resultStr);
|
s1.Format(_T("GetFactoryData = %d %d bytes"), res,len1);
|
|
GetDlgItemText(IDC_DATETIMEPICKER1, s1);
|
SysLog(s1);
|
CTime date;
|
((CDateTimeCtrl *)(GetDlgItem(IDC_DATETIMEPICKER1)))->GetTime(date);
|
|
UINT uValue;
|
|
SetDataByName(buf1, _T("开始标志"), 0x55AA);
|
SetDataByName(buf1, _T("序号"), 0x0002);
|
SetDataByName(buf1, _T("ModelNo"), 0x0008);
|
SetDataByName(buf1, _T("ModelVer"), 0x0100);
|
GetDlgItemText(IDC_EDIT_LOT_NO, s1); uValue = _tstoi(s1);
|
SetDataByName(buf1, _T("nLotNo"), uValue);
|
|
GetDlgItemText(IDC_DATETIMEPICKER1, s1);
|
s1 = date.Format(_T("%Y-%m-%d %H:%M:%S"));
|
SetDataByName(buf1, _T("nProductDate"), s1);
|
|
GetDlgItemText(IDC_EDIT_FACT_SN, s1); uValue = _tstoi(s1);
|
SetDataByName(buf1, _T("nSN1"), uValue);
|
SetDataByName(buf1, _T("nProtocalVer"), 0x01000100);
|
SetDataByName(buf1, _T("nDefaultFuncr"), 0x00000001);
|
SetDataByName(buf1, _T("sModelStr"), _T("12122121"));
|
GetDlgItemText(IDC_EDIT_LOT_NO, s1);
|
SetDataByName(buf1, _T("sLot_No"), s1);
|
SetDataByName(buf1, _T("sSNStr"), _T("56566565"));
|
SetDataByName(buf1, _T("CRC1"), 0xEFEF);
|
SetDataByName(buf1, _T("EndSign"), 0x55AA);
|
|
CString s3;
|
|
for (int i = 0; i < nFactoryDataItemsCount; i++)
|
{
|
// int nType = FactoryDataItems[i].nType;
|
// int nSize = FactoryDataItems[i].nSize;
|
// int nOffset = FactoryDataItems[i].nOffset;
|
CString sName = FactoryDataItems[i].sName;
|
s3 = GetDataStrByName(buf1, sName);
|
s1.Format(_T("%d %s %s"), i, sName, s3);
|
SysLog(s1);
|
}
|
|
res = pDoc->MyKLink1.WriteFactoryData(1, 0, 80, buf1);
|
SysLog(pDoc->MyKLink1.m_resultStr);
|
s1.Format(_T("WriteFactoryData = %d "), res);
|
SysLog(s1);
|
return 0;
|
}
|
|
void CDialogFactCfg::OnBnClickedButtonReaddata()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
ReadData();
|
}
|
|
void CDialogFactCfg::OnBnClickedButtonConn()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
Connect();
|
|
}
|
|
|
void CDialogFactCfg::OnBnClickedButtonDisconn()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
Disconnect();
|
|
}
|
|
|
|
|
void CDialogFactCfg::OnBnClickedButtonWritedata()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
WriteData();
|
|
}
|
|
CString saveInputStr=_T(""), saveInput1Str= _T("");
|
CString sDisplayStr;
|
CString sStoreStr;
|
bool bEditEndFlg = false;
|
|
/*
|
int CDialogFactCfg::CharKeyClick(CString sKey)
|
{
|
// TODO: 在此处添加实现代码.
|
if (bEditEndFlg)
|
{
|
sDisplayStr.Empty();
|
bEditEndFlg = false;
|
}
|
sDisplayStr.Append(sKey);
|
int len1 = sDisplayStr.GetLength();
|
if (len1 > 1 && sDisplayStr[0] == _T('0')) sDisplayStr = sDisplayStr.Right(sDisplayStr.GetLength() - 1);
|
|
SetDlgItemText(IDC_EDIT_VIEW, sDisplayStr);
|
return 0;
|
}
|
void CDialogFactCfg::OnBnClickedBtn1()
|
{
|
CharKeyClick(_T("1"));
|
}
|
void CDialogFactCfg::OnBnClickedBtn3()
|
{
|
CharKeyClick(_T("3"));
|
}
|
void CDialogFactCfg::OnBnClickedBtn4()
|
{
|
CharKeyClick(_T("4"));
|
}
|
void CDialogFactCfg::OnBnClickedBtn5()
|
{
|
CharKeyClick(_T("5"));
|
}
|
void CDialogFactCfg::OnBnClickedBtnClear()
|
{
|
sDisplayStr.Empty();
|
bEditEndFlg = false;
|
SetDlgItemText(IDC_EDIT_VIEW, _T("0"));
|
}
|
void CDialogFactCfg::OnBnClickedBtnAdd()
|
{
|
bEditEndFlg = true;
|
sStoreStr = sDisplayStr;
|
|
//saveInput1Str = saveInputStr;
|
//saveInputStr = "";
|
}
|
void CDialogFactCfg::OnBnClickedBtnBackSpace()
|
{
|
int len1 = sDisplayStr.GetLength();
|
if (len1 > 1)
|
{
|
sDisplayStr = sDisplayStr.Left(sDisplayStr.GetLength() - 1);
|
}
|
else if (len1 == 1)
|
{
|
sDisplayStr = "0";
|
}
|
// bEditEndFlg = false;
|
SetDlgItemText(IDC_EDIT_VIEW, sDisplayStr);
|
}
|
|
|
|
void CDialogFactCfg::OnBnClickedButton0()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
CharKeyClick(_T("0"));
|
}
|
|
|
void CDialogFactCfg::OnBnClickedButton1Dot()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
CharKeyClick(_T("."));
|
}
|
|
|
void CDialogFactCfg::OnBnClickedButtonEq()
|
{
|
// TODO: 在此添加控件通知处理程序代码
|
bEditEndFlg = true;
|
|
float a = (float)_tstof(sStoreStr);
|
float b = (float)_tstof(sDisplayStr);
|
|
float c = a + b;
|
|
sDisplayStr.Format(_T("%g"),c);
|
SetDlgItemText(IDC_EDIT_VIEW, sDisplayStr);
|
|
}
|
*/
|