| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 861 人关注过本帖
标题:有段代码,不太明白做什么用的,请指点
取消只看楼主 加入收藏
pla0007
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-10-15
结帖率:0
收藏
已结贴  问题点数:0 回复次数:0 
有段代码,不太明白做什么用的,请指点
/**************************************************************************/
/* 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);
}

搜索更多相关主题的帖子: 代码 
2009-10-15 09:52
快速回复:有段代码,不太明白做什么用的,请指点
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025010 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved