/***************************************************************************
**
**    $Header:   D:/EPSLDV1/SRC/LOG/SPAENTRY.H__   1.8   20 Jun 1996 09:24:44   ZJRD  $
**
**    $Log:   D:/EPSLDV1/SRC/LOG/SPAENTRY.H__  $
** 
**    Rev 1.8   20 Jun 1996 09:24:44   ZJRD
** EasyPack/SLD Version 1.20a
** 
**    Rev 1.6   10 Jun 1996 10:19:24   ZJRD
** EasyPack/SLD Version 1.20
** 
**    Rev 1.4   29 May 1996 09:28:24   ZJRD
** EasyPack/SLD Version 1.95
** 
**    Rev 1.3   16 May 1996 09:08:46   ZJRD
** EasyPack/SLD Version 1.94
** 
**    Rev 1.2   10 May 1996 09:08:16   ZJRD
** EasyPack/SLD Version 1.93
** 
**    Rev 1.1   02 May 1996 10:24:58   ZJRD
** EasyPack/SLD Version 1.92
** 
**    Rev 1.1   18 Apr 1996 13:00:42   Shirley
** No change.
** 
**    Rev 1.0   12 Apr 1996 10:37:46   Shirley
** Initial revision.
** 
****************************************************************************/

/////////////////////////////////////////////////////////////////////////////
//
//  File name: SPAENTRY.H
//
//  Description: The header file for the class: CSpaModuleEntryPage.
//
//  Author: Chen Jun
//
//  Date: 03/21/96
//
//  Modification:
//      1. 03/21/96, Initial version of the class: CSpaModuleEntryDlg.
//      2. 03/29/96, CSpaModuleEntryPage with CPropertyPage.
//
//  Copyright (C) 1996 Microtek International. All rights reserved.
//
/////////////////////////////////////////////////////////////////////////////
#ifndef _SPAENTRY_H_
#define _SPAENTRY_H_

/////////////////////////////////////////////////////////////////////////////
// CSpaModuleEntryPage dialog

class CSpaModuleEntryPage : public CPropertyPage
{
// Construction
public:
	CSpaModuleEntryPage();	// standard constructor

// Dialog Data
	//{{AFX_DATA(CSpaModuleEntryPage)
	enum { IDD = IDD_SPA_ENTRY };
	CButton	m_btnBp;
	CButton	m_btnRestart;
	CStatic	m_staticTimeBar1;
	CStatic	m_staticTimeBar2;
	CStatic	m_staticTimeBar3;
	CStatic	m_staticTimeBar4;
	CStatic	m_staticCountBar1;
	CStatic	m_staticCountBar2;
	CStatic	m_staticCountBar3;
	CStatic	m_staticCountBar4;
	CButton	m_btnEdit;
	CButton	m_btnStop;
	CButton	m_btnStart;
	CListBox	m_listEntry;
	CComboBox	m_comboRange4;
	CComboBox	m_comboRange3;
	CComboBox	m_comboRange2;
	CComboBox	m_comboRange1;
	int		m_nSelect;
	CString	m_strRange1;
	CString	m_strRange2;
	CString	m_strRange3;
	CString	m_strRange4;
	int		m_nCount0;
	DWORD	m_dwTime0;
	int		m_nCount1;
	int		m_nCount2;
	int		m_nCount3;
	int		m_nCount4;
	DWORD	m_dwTime1;
	DWORD	m_dwTime2;
	DWORD	m_dwTime3;
	DWORD	m_dwTime4;
	CEdit	m_editBp;
	CString	m_strRange0;
	//}}AFX_DATA

private:
	int		m_nCountPer1;
	int		m_nCountPer2;
	int		m_nCountPer3;
	int		m_nCountPer4;
	int		m_nTimePer1;
	int		m_nTimePer2;
	int		m_nTimePer3;
	int		m_nTimePer4;

private:
	const DWORD m_cdwMaxTime;
	const int m_cnMaxCount;

	enum { executionRange = 0, entryRange };
	enum { combo0 = 0, combo1, combo2, combo3, combo4 };
	enum { defineLen = 80, startLen = 80, endLen = 80 };
	
	enum { tmEvent = 1, tmElapse = 100 };
    UINT m_uTimerID;
    
    BOOL m_bStop;
    
    enum { stop = 0, pause, running, failure };

	enum { module0 = 0, module1, module2, module3, module4 };
    int m_nWhichModule;
    
    ::ADDR m_Addr[8];
    
    enum { btnStart = 0, btnRestart };
    int m_nWhichBtn;
    
private:
	SPABPSETINFO m_EntryInfo;

// Overrides
	// ClassWizard generate virtual function overrides
	//{{AFX_VIRTUAL(CSpaModuleEntryPage)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	virtual BOOL OnKillActive();
	virtual BOOL OnSetActive();
	//}}AFX_VIRTUAL

// Implementation
private:
	void ClearResult(void);
	void CheckInputSyntax(void);

    BOOL SetEntryData(void);
    int GetEntryData(void);

	BOOL CalcResult(void);
    BOOL CalcCount(void);
    BOOL CalcTimer(void);

	void UpdateCombo(void);
	void UpdateList(void); 

    void ReadRecord(int nWhichFile);
    void ReadRecord(int nWhichFile, int nWhichCombo);
    void ReadRecord(int nWhichFile, const CString& strDefine);

	void GetExecuteRange(void);

    void UpdateBar(void);
    void UpdateCountBar(int nWhich, BOOL bRedraw = TRUE);
    void UpdateTimerBar(int nWhich, BOOL bRedraw = TRUE);

	void StopTimerAction(void);
    void DisableControl(void);

protected:
	// Generated message map functions
	//{{AFX_MSG(CSpaModuleEntryPage)
	virtual void OnCancel();
	afx_msg void OnHelp();
	afx_msg void OnButtonSpaEdit();
	afx_msg void OnButtonSpaStart();
	afx_msg void OnButtonSpaStop();
	afx_msg void OnShowWindow(BOOL bShow, UINT nStatus);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnButtonSpaRestart();
	afx_msg void OnButtonSpaBp();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

#endif
