#pragma once
#include "CStepBase.h"
#include "Machine.h"

//#define FSM_TEST 1			//״̬������
#define FSM_NOT_EXECUTE 0xFFFF
#define BOND_TABLE_ID 1		//�̾�̨Id�ţ���ǰ��ֻ̨��һ���̾�̨




#ifdef FSM_TEST
typedef struct _BOND_PT_TEST
{
	UINT id;
	ATTRIBUTE att;
	bool status;
	_BOND_PT_TEST(UINT id, ATTRIBUTE att, bool status)
	{
		this->id = id;
		this->att = att;
		this->status = status;
	}
}BOND_PT_TEST;
#define MAX_TEST_PT 6
#endif

class  __declspec(dllexport) CEventBase
{
private:
	static bool m_bStopStepExecute;         //�Զ�������ijһ���۳������˳�����״̬��ִ��Step

#ifdef FSM_TEST
protected:
	std::default_random_engine e;
	void sleep_();
	void sleep_(int iTimerMin, int iTimerMax);
	virtual LONG ActionTest();

	static BOND_PT_TEST TestPt[MAX_TEST_PT];
	BOND_PT_TEST GetTestPt(UINT id);
	void SetStatus(UINT id, bool status);
	void ClearStatus(ATTRIBUTE att);
#endif

protected:
	bool m_bIsInitSuccess;
	Machine* m_pMachine;
	CStaticStepData* m_pStepPublicData; //����Step���й����е����ݲ���

	virtual LONG Action() = 0;

	//ֹͣStopʱ������,�����Զ��̾����������β�¼�CEventAutoBondDone
	virtual bool StopStepException();
	CEventBase();
public:
	//����(��ȡ)�Ƿ�ֹͣ����Stepִ�б�־
	static void SetStopStepExecute(bool b);
	static bool GetStopStepExecute();


	virtual LONG EventRun(string sStepDescribe, string m_chClass, string m_chState, string step);

};