|
#include "sme.h"
#include "Player.h"
#include "SingleState.h"
#include "EventId.h"
#include <stdio.h>
#include "sme_cross_platform.h"
#include "sme_debug.h"
/*******************************************************************************
The followings could be defined in another file.
*/
/* Define composite state PowerUp */
#ifdef SME_CURR_DEFAULT_PARENT
#undef SME_CURR_DEFAULT_PARENT
#endif
#define SME_CURR_DEFAULT_PARENT PowerUp
SME_HANDLER_CLASS_DEF(CPlayer)
SME_BEGIN_COMP_STATE_DEF(SME_CURR_DEFAULT_PARENT, Player, PowerUpEntry, PowerUpExit)
SME_ON_INIT_STATE(OnPowerUpInitChild, Playing)
SME_ON_STATE_TIMEOUT_INTERNAL_TRAN(3000, PowerUpTimeOut)
SME_END_STATE_DEF
SME_BEGIN_LEAF_STATE_DEF_P(Playing, PlayingEntry, PlayingExit)
SME_ON_EVENT(EXT_EVENT_ID_PAUSE_RESUME,OnPlayingEXT_EVENT_ID_PAUSE_RESUME,Pause)
SME_ON_INTERNAL_TRAN_WITH_GUARD(SME_EVENT_TIMER,GuardTimer2_func,OnTimer2Proc) /* Regular timer event */
SME_ON_STATE_TIMEOUT(9000, PlayingTimeOut, Pause) /* Go to Pause state if 9 sec is timeout. */
SME_END_STATE_DEF
SME_BEGIN_LEAF_STATE_DEF_P(Pause, PauseEntry, PauseExit)
SME_ON_EVENT(EXT_EVENT_ID_PAUSE_RESUME,OnPauseEXT_EVENT_ID_PAUSE_RESUME,Playing)
SME_END_STATE_DEF
SME_END_COMP_STATE_DEF(PowerUp)
/****************************************************************
Player1&2, SingleState1&2, Timer1&2 run at threadcontext1
Player3&4, SingleState3&4, Timer3&4 run at threadcontext2
*/
extern CPlayer Player1;
extern CSingleState SingleState1;
extern CPlayer Player2;
extern CSingleState SingleState2;
unsigned int m_Timer1=0;
unsigned int m_Timer2=0;
unsigned int m_Timer3=0;
unsigned int m_Timer4=0;
int CPlayer::OnPowerUpInitChild(SME_OBJ_T *pDestObj, SME_EVENT_T *pEvent)
{
printf("OnPowerUpInitChild-Playing\n");
return 0;
}
int CPlayer::PlayingTimeOut(SME_OBJ_T *pDestObj, SME_EVENT_T *pEvent)
{
printf("Playing State timeout SeqNum=%d\n", pEvent->nSequenceNum);
return 0;
}
int CPlayer::PowerUpTimeOut(SME_OBJ_T *pDestObj, SME_EVENT_T *pEvent)
{
printf("PowerUp State timeout SeqNum=%d\n", pEvent->nSequenceNum);
return 0;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.