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.
86 lines
2.1 KiB
C++
86 lines
2.1 KiB
C++
#include "StdAfx.h"
|
|
#include "TimingProgressMgr.h"
|
|
#include "DlgTimingProgress.h"
|
|
#include "AllThreadMgr.h"
|
|
#include "GlobalFunction.h"
|
|
|
|
UINT TimingProgressThread(LPVOID pParam)
|
|
{
|
|
CTimingProgressMgr *p = (CTimingProgressMgr *)pParam;
|
|
p->StartTimingProgressExt();
|
|
return 0;
|
|
}
|
|
CTimingProgressMgr gTimingProgressMgr;
|
|
CTimingProgressMgr::CTimingProgressMgr(void)
|
|
{
|
|
m_StopExecute = true;
|
|
m_bExecuting = false;//是否正在执行
|
|
m_bCloseApp = false;//是否正在执行关闭软件操作
|
|
m_CurExecuteTime = 0;//当前的执行时间ms
|
|
}
|
|
CTimingProgressMgr::~CTimingProgressMgr(void)
|
|
{
|
|
}
|
|
|
|
//设置进度条显示内容
|
|
void CTimingProgressMgr::SetShowInfo(CString str)
|
|
{
|
|
m_ShowInfo = str;
|
|
}
|
|
//设置进度时间
|
|
void CTimingProgressMgr::SetTimingProgressTime(double ExecuteTime)
|
|
{
|
|
//进度正在执行的时候不要修改时间
|
|
if(m_bExecuting)
|
|
return;
|
|
m_ExecuteTime = ExecuteTime;//执行时间ms
|
|
}
|
|
//停止进度条
|
|
void CTimingProgressMgr::StopExecute()
|
|
{
|
|
m_StopExecute = true;
|
|
m_ShowInfo = "";
|
|
m_CurExecuteTime = 0;//当前的执行时间ms
|
|
}
|
|
//启动进度条
|
|
void CTimingProgressMgr::StartTimingProgress()
|
|
{
|
|
//进度正在执行的时候不要重复启动
|
|
if(m_bExecuting)
|
|
return;
|
|
m_StopExecute = false;
|
|
m_CurExecuteTime = 0;//当前的执行时间ms
|
|
|
|
//在新的线程中启动进度条对话框
|
|
//激光预热界面不要弹出对话框
|
|
{
|
|
CWinThread* pThread = AfxBeginThread(TimingProgressThread,this);
|
|
if(m_bCloseApp)
|
|
{
|
|
WaitForThreadExit(pThread);//等待线程结束
|
|
}
|
|
}
|
|
}
|
|
//检查时间是否超过CheckTime
|
|
bool CTimingProgressMgr::CheckCurExecuteTime(double CheckTime)
|
|
{
|
|
if(CheckTime>0)
|
|
return (m_CurExecuteTime>CheckTime);
|
|
//CheckTime <0 的时候检查是否达到设定的总时间
|
|
return (m_CurExecuteTime>m_ExecuteTime);
|
|
}
|
|
//获取进度条使用的比例值(0~99)
|
|
double CTimingProgressMgr::GetProgressVal()
|
|
{
|
|
double val = 100;
|
|
if(m_CurExecuteTime>0)
|
|
{
|
|
val = (m_CurExecuteTime/m_ExecuteTime)*100;
|
|
}
|
|
return val;
|
|
}
|
|
void CTimingProgressMgr::StartTimingProgressExt()
|
|
{
|
|
CDlgTimingProgress dlg;
|
|
dlg.DoModal();
|
|
} |