You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

147 lines
4.3 KiB
C++

#include "stdafx.h"
#include "LaiPuLaser.h"
#include "afxdialogex.h"
#include "DlgChildEventLog.h"
#include "WorkRecord.h"
#include "GlobalFunction.h"
#include "LogMgr.h"
#include "FileMgr.h"
IMPLEMENT_DYNAMIC(CDlgChildEventLog, CMyDlgView)
BEGIN_MESSAGE_MAP(CDlgChildEventLog, CMyDlgView)
ON_BN_CLICKED(IDC_CLEAR_LIST_BTN, &CDlgChildEventLog::OnBnClickedClearListBtn)
ON_BN_CLICKED(IDC_OPEN_LOG_DIR_BTN, &CDlgChildEventLog::OnBnClickedOpenLogDirBtn)
ON_CBN_SELCHANGE(IDC_LOG_TYPE_COMBO, &CDlgChildEventLog::OnCbnSelchangeLogTypeCombo)
ON_BN_CLICKED(IDC_STOP_REV_LOG_BTN, &CDlgChildEventLog::OnBnClickedStopRevLogBtn)
END_MESSAGE_MAP()
#define MAX_LOG_LIST_ROWS 1000//最大log 行数
CDlgChildEventLog::CDlgChildEventLog(CWnd* pParent /*=NULL*/)
: CMyDlgView(CDlgChildEventLog::IDD, pParent)
{
m_bStopRevLog = false;//暂停接受新的log (不影响log 保存到文件)
}
CDlgChildEventLog::~CDlgChildEventLog()
{
}
void CDlgChildEventLog::DoDataExchange(CDataExchange* pDX)
{
CMyDlgView::DoDataExchange(pDX);
DDX_Control(pDX, NEW_REV_LOG_LIST, m_LaipuLaserLogList);
DDX_Control(pDX, NEW_LAIPU_DRAWING_LOG_LIST, m_LaipuDrawingLogList);
DDX_Control(pDX, IDC_LOG_TYPE_COMBO, m_SelLogTypeComb);
}
BOOL CDlgChildEventLog::OnInitDialog()
{
CMyDlgView::OnInitDialog();
InitLogList(m_LaipuLaserLogList);
InitLogList(m_LaipuDrawingLogList);
//初始化SelLogTypeComb
m_SelLogTypeComb.InsertString(0,"LaipuLaser");
m_SelLogTypeComb.InsertString(1,"LaipuDrawing");
m_SelLogTypeComb.SetCurSel(0);
m_CurLogListType = _LogListType_LaipuLaser;
UpdateData(FALSE);
return TRUE;
}
//响应view 打开的时候
void CDlgChildEventLog::OnViewOpen()
{
}
//初始化日志列表
void CDlgChildEventLog::InitLogList(CListCtrl &List)
{
//设置风格
List.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
//设置列
int idx = 0;
List.InsertColumn(idx,"LOG",LVCFMT_LEFT,2000,-1);
idx++;
}
CListCtrl &CDlgChildEventLog::GetLogList(eLogListType LogListType)
{
if(LogListType==_LogListType_LaipuLaser)
return m_LaipuLaserLogList;
return m_LaipuDrawingLogList;
}
void CDlgChildEventLog::InsertLogToList(CString &LogStr,eLogListType LogListType)
{
if(!m_bStopRevLog)
{
InsertLogToListExt(LogStr,GetLogList(LogListType));
}
}
//插入一条log
void CDlgChildEventLog::InsertLogToListExt(CString &LogStr,CListCtrl &List)
{
int CurItemCount = List.GetItemCount();//当前的行数
if(CurItemCount>=MAX_LOG_LIST_ROWS)//数量超出则删除第一行
{
List.DeleteItem(0);
CurItemCount--;
}
//新插入一行
int idx = CurItemCount;
List.InsertItem(idx," ");//插入一行
List.SetItemText(idx,0,LogStr);
//显示最后一行
List.EnsureVisible(idx,FALSE);
}
void CDlgChildEventLog::OnBnClickedClearListBtn()
{
CListCtrl &List = GetLogList(m_CurLogListType);
List.DeleteAllItems();
gLogMgr->WriteDebugLog("Func---->OnBnClickedClearListBtn");
}
void CDlgChildEventLog::OnBnClickedOpenLogDirBtn()
{
gLogMgr->WriteDebugLog("Func---->OnBnClickedOpenLogDirBtn");
CString DirPath;
if(m_CurLogListType==_LogListType_LaipuLaser)
DirPath = gProgramLaserTuiHuo->GetLaipuLaserDataDir("\\LogFile\\");
else
DirPath = gProgramLaserTuiHuo->GetLaipuLaserDataDir("\\LogFile_DataMgr\\");
CFileMgr FileMgr;
FileMgr.OpenDir(DirPath);
}
void CDlgChildEventLog::OnCbnSelchangeLogTypeCombo()
{
gLogMgr->WriteDebugLog("Func---->OnCbnSelchangeLogTypeCombo");
int idx = m_SelLogTypeComb.GetCurSel();
if(idx==1)
{
GetDlgItem(NEW_REV_LOG_LIST)->ShowWindow(SW_HIDE);
GetDlgItem(NEW_LAIPU_DRAWING_LOG_LIST)->ShowWindow(SW_SHOW);
m_CurLogListType = _LogListType_LaipuDrawing;
}
else
{
GetDlgItem(NEW_REV_LOG_LIST)->ShowWindow(SW_SHOW);
GetDlgItem(NEW_LAIPU_DRAWING_LOG_LIST)->ShowWindow(SW_HIDE);
m_CurLogListType = _LogListType_LaipuLaser;
}
}
void CDlgChildEventLog::OnBnClickedStopRevLogBtn()
{
gLogMgr->WriteDebugLog("Func---->OnBnClickedStopRevLogBtn");
m_bStopRevLog = !m_bStopRevLog;
if(m_bStopRevLog)
GetDlgItem(IDC_STOP_REV_LOG_BTN)->SetWindowText("开始接收");
else
GetDlgItem(IDC_STOP_REV_LOG_BTN)->SetWindowText("暂停接收");
}