Keyence utility V2.0:add csv file save type.

This commit is contained in:
TAO Cheng
2013-06-07 10:03:17 +08:00
parent c4e8f629cb
commit c9d820b013
6 changed files with 106 additions and 18 deletions
@@ -1889,7 +1889,7 @@ SSI_STATUS_MOTION CSO7_Proto::Load_SevenOcean_Inifile(CString cso7IniFile)
//=========================================================================================
SSI_STATUS_MOTION CSO7_Proto::Save_So7_Config()
{
FILE* m_pOutFile;
FILE* m_pOutFile= NULL;
char *outBuff = NULL;
CString csAppPath;
GetAppPath(csAppPath);
@@ -1088,3 +1088,18 @@ Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Init:Open device succeed .
_start_machine
Exit: Exit_SO7Usb
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
@@ -12,3 +12,7 @@ Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
Construct Cso7_Proto.
Destruct Cso7_Proto.
@@ -220,7 +220,7 @@ void CKeyence_UtilDlg::OnBnClickedButtonTestKeyenceSaveLog()
CString FileName;
CString PathName;
FILE* m_pOutFile;
FileName=_T("LK_G_Data.txt");
CString szFilter=_T("TXT Files(*.txt)|*.txt|CSV Files(*.csv)|*.csv|ALL Files(*.*)|*.*||");
@@ -228,30 +228,42 @@ void CKeyence_UtilDlg::OnBnClickedButtonTestKeyenceSaveLog()
if( fdlg.DoModal()==IDOK)
{
PathName=fdlg.GetPathName();
_wfopen_s(&m_pOutFile, PathName, _T("wt"));
if (!m_pOutFile)
{
MessageBox( _T("File name Error."), _T("Message"), MB_OK);
};
switch(fdlg.m_ofn.nFilterIndex)
{
case 1:
{
const char* outBuff=NULL;
CString strOutput;
m_edMSG.GetWindowText(strOutput);
outBuff=T2A(strOutput);
fprintf(m_pOutFile,"%s", outBuff);
fclose(m_pOutFile);
FILE* m_pOutFile;
_wfopen_s(&m_pOutFile, PathName, _T("wt"));
if (!m_pOutFile)
{
MessageBox( _T("File name Error."), _T("Message"), MB_OK);
}
else
{
const char* outBuff=NULL;
CString strOutput;
m_edMSG.GetWindowText(strOutput);
outBuff=T2A(strOutput);
fprintf(m_pOutFile,"%s", outBuff);
fclose(m_pOutFile);
m_OutMessage=_T("[Saving successful] Data Stored into ")+PathName+_T(".");
OutputWithScroll(m_OutMessage,m_edMSG);
}
break;
}
case 2:
{
BOOL bSTATUS=ExportReportCSV(PathName);
if (bSTATUS)
{
m_OutMessage=_T("[Saving successful] Data Stored into ")+PathName+_T(".");
OutputWithScroll(m_OutMessage,m_edMSG);
}
else
{
MessageBox( _T("File name Error."), _T("Message"), MB_OK);
}
break;
}
}
@@ -260,6 +272,61 @@ void CKeyence_UtilDlg::OnBnClickedButtonTestKeyenceSaveLog()
GetDlgItem(IDC_EDIT_TEST_KEYENCE_SETFOCUS)->SetFocus();
}
//===========================================================
BOOL CKeyence_UtilDlg::ExportReportCSV(const CString &FilePathName)
{
FILE* m_pOutFile=NULL;
char *outBuff = NULL;
_wfopen_s(&m_pOutFile, FilePathName, _T("wt"));
if (!m_pOutFile)
{
free(outBuff);
return FALSE;
}
else
{
//Title
for (int i=0;i<8;i++)
{
if(m_LK_G_ProNOState[i])
{
fprintf(m_pOutFile,"NO.%d,NO.%d,NO.%d,", i,i,i);
}
}
fprintf(m_pOutFile, "\n");
for (int i=0;i<8;i++)
{
if(m_LK_G_ProNOState[i])
{
if (i==m_LK_G_CalibrateNO)
{
fprintf(m_pOutFile,"OUT1,OUT2,ANSWER,");
}
else
{
fprintf(m_pOutFile,"OUT1,OUT2,AVERAGE,");
}
}
}
//OUTPUT DATA
KeyenceReport TmpReport;
for(size_t i=0;i<LK_GReport.size();i++)
{
TmpReport=LK_GReport.at(i);
if (TmpReport.ProgramNo==0)
{
fprintf(m_pOutFile, "\n");
}
fprintf(m_pOutFile,"%.4f,%.4f,%.4f,", TmpReport.OUT1Value,TmpReport.OUT2Value,TmpReport.Result);
}
fprintf(m_pOutFile, "\n");
fclose(m_pOutFile);
return TRUE;
}
};
#pragma endregion
// CKeyence_UtilDlg ÏûÏ¢´¦Àí³ÌÐò
@@ -413,6 +480,7 @@ void CKeyence_UtilDlg::OnEnKillfocusEditTestLkGInterval()
}
void CKeyence_UtilDlg::OnBnClickedButtonTestKeyenceClearLog()
{
LK_GReport.clear();
m_edMSG.SetWindowText(_T(""));
UpdateData(FALSE);
GetDlgItem(IDC_EDIT_TEST_KEYENCE_SETFOCUS)->SetFocus();
@@ -41,6 +41,7 @@ public:
void Get_LK_G_DATA();
void RunCNC();
void OutputWithScroll(const CString &strNewText,CEdit &edtOutput);
BOOL ExportReportCSV(const CString &FilePathName);
afx_msg BOOL PreTranslateMessage(MSG* pMsg);
afx_msg void OnBnClickedButtonInitKeyenceLaser();
afx_msg void OnTimer(UINT_PTR nIDEvent);