有段代码,不太明白做什么用的,请指点
/**************************************************************************//* File Name: RunHoldStop.cpp */
/* Purpose: Test Control window with the Run/Hold/Stop buttons */
/**************************************************************************/
//***** pseudo program include files *****
#include "stdafx.h"
#include "Pseudo2.h"
#include "RunHoldStop.h"
#include "RampCmd.h"
#include "externals.h"
#include "ft_externals.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//***** external functions *****
extern void ExitPseudo(void);
/////////////////////////////////////////////////////////////////////////////
// RunHoldStop dialog
/*-----------------------------------------*/
RunHoldStop::RunHoldStop(CWnd* pParent /*=NULL*/)
: CDialog(RunHoldStop::IDD, pParent)
{
//{{AFX_DATA_INIT(RunHoldStop)
m_Status = _T("");
//}}AFX_DATA_INIT
}
/*-----------------------------------------*/
void RunHoldStop::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(RunHoldStop)
DDX_Text(pDX, IDC_STATUS, m_Status);
DDV_MaxChars(pDX, m_Status, 200);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(RunHoldStop, CDialog)
//{{AFX_MSG_MAP(RunHoldStop)
ON_BN_CLICKED(IDC_RUN, OnRun)
ON_BN_CLICKED(IDC_HOLD, OnHold)
ON_BN_CLICKED(IDC_STOP, OnStop)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// RunHoldStop message handlers
/*-----------------------------------------*/
BOOL RunHoldStop::OnInitDialog()
{
CDialog::OnInitDialog();
SetStatus("Press RUN to start the test");
return FALSE;
}
/*-----------------------------------------*/
void RunHoldStop::OnRun()
{
if(Simulation)
{
if(execStatus == testHolding || execStatus == testInterrupted || execStatus == testNotStarted)
{
SetStatus("Running...");
execStatus = testRunning; //set execution status to running
}
}
else
runTest();
}
/*-----------------------------------------*/
void RunHoldStop::OnHold()
{
if(Simulation)
{
if(execStatus == testRunning)
{
SetStatus("Holding...");
execStatus = testHolding; //set execution status to holding
}
}
else
holdTest();
}
/*-----------------------------------------*/
void RunHoldStop::OnStop()
{
if(Simulation)
{
if (execStatus == testRunning || execStatus == testHolding) //stop pressed for 1st time
{
SetStatus("Test Interrupted! STOP to exit or RUN to resume.");
execStatus = testInterrupted; //set execution status to interrupted
}
else if (execStatus == testInterrupted || execStatus == testCompleted)
{
SetStatus("Closing Pseudodynamic Test Program.");
ExitPseudo();
}
else if(execStatus == testNotStarted) //stop pressed before test even started
{
SetStatus("Test Interrupted! STOP to exit or RUN to resume.");
execStatus = testInterrupted; //set execution status to interrupted
}
}
else
stopTest();
}
/*-----------------------------------------*/
boolean RunHoldStop::rampDone(void)
{
endOfRamp = TRUE;
return TRUE;
}
/*-----------------------------------------*/
boolean RunHoldStop::interlock(void)
{
testInterlock();
return TRUE;
}
/*-----------------------------------------*/
void RunHoldStop::SetStatus(const char *msg)
{
m_Status.Format("%s", msg);
SetDlgItemText(IDC_STATUS, m_Status);
}
/*-----------------------------------------*/
void RunHoldStop::enableRunHold(BOOL State)
{
GetDlgItem(IDC_STOP)->SetFocus();
GetDlgItem(IDC_RUN)->EnableWindow(State);
GetDlgItem(IDC_HOLD)->EnableWindow(State);
}
/*-----------------------------------------*/
void RunHoldStop::enableStop(BOOL State)
{
GetDlgItem(IDC_STOP)->EnableWindow(State);
}
/*-----------------------------------------*/
BOOL RunHoldStop::OnCommand(WPARAM wParam, LPARAM lParam)
{
if(LOWORD(wParam) == 0x02) //escape key pressed, ignore it
return TRUE;
return CDialog::OnCommand(wParam, lParam);
}