📄 emc_menustate.c
字号:
};
#define BCSTimeoutActionNumber (sizeof(maBCSTimeoutAction)/sizeof(Dvb_MenuAction_t))
const Dvb_MenuAction_t maPasswordInputAction[] =
{
{cmd_Num0, 0, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num1, 1, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num2, 2, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num3, 3, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num4, 4, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num5, 5, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num6, 6, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num7, 7, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num8, 8, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Num9, 9, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_ArrowLeft, -1, NOCHANGE, (void(*)(int))msm_InputPassword },
{cmd_Select, 0, NOCHANGE, (void(*)(int))msm_ConfirmPasswordInput},
{cmd_Exit, cmd_Exit, DVB_MAINMENU, (void(*)(int))msm_HidePasswordInputWindow },
{cmd_PasswordCorrect, cmd_PasswordCorrect, DVB_MAINMENU, (void(*)(int))msm_HidePasswordInputWindow },
};
#define PasswordInputActionNumber (sizeof(maPasswordInputAction)/sizeof(Dvb_MenuAction_t))
/*stone added for timezone 2006-3-18*/
const Dvb_MenuAction_t maTIMEZONEAction[] =
{
{cmd_ArrowUp, 1, NOCHANGE, (void(*)(int))msm_TIMEZONEItemUp},
{cmd_ArrowDown, 1, NOCHANGE, (void(*)(int))msm_TIMEZONEItemDown},
{cmd_Select, 2, DVB_DISPLAY, (void(*)(int))msm_TIMEZONEConfirm},
{cmd_Exit, 2, DVB_DISPLAY, (void(*)(int))msm_TIMEZONEConfirm},/*problem*/
};
#define TIMEZONEActionNumber (sizeof(maTIMEZONEAction)/sizeof(Dvb_MenuAction_t))
/*end of stone timezone*/
/* Functions--------------------------------------------------------------------- */
void msm_ChangeToState(dvb_state_e newState)
{
//PROG_INFO_STRUCT *pstProgInfoTemp;
switch(newState)
{
case NOCHANGE:
/*State is NO Change!Just return!*/
return;
case DVB_DISPLAY:
break;
case DVB_MAINMENU:
bNoSignalLogoShow = FALSE;
break;
case DVB_CH_LIST:
case DVB_CH_MANAGE:
case DVB_EPG:
case DVB_PRE_AUTO_SEARCH:
case DVB_AUTO_SEARCH:
case DVB_MANUAL:
case DVB_PASSWORD:
case DVB_SUBTITLE:
case DVB_MENU_TIMEOUT:
case DVB_INFO_TIMEOUT:
case DVB_PRONUM_TIMEOUT:
case DVB_VOL_TIMEOUT:
case DVB_BCS_TIMEOUT:
bLockMenuItem = TRUE;
bNoSignalLogoShow = FALSE;
break;
case DVB_TIMEZONE:/*stone added for timezone 2006-3-18*/
break;
}
currMenuState = newState;
}
BOOL inSearchProgramState(void)
{
if(currMenuState== DVB_AUTO_SEARCH || currMenuState == DVB_MANUAL || currMenuState == DVB_PRE_AUTO_SEARCH)
return TRUE;
else
return FALSE;
}
/* Interface procedures/functions --------------------------------------------------*/
/********************************************************************************
Function name : MenuStateMachineInit
Description : initialize Menu State machine
Input param : none
Output param : None
Return : None
Auther: Allen Wu(12/17/2005)
********************************************************************************/
static void MenuStateMachineInit(void)
{
MenuStateProcess[DVB_MAINMENU].cValidLinkNumber = MainMenuActionNumber;
MenuStateProcess[DVB_MAINMENU].pstAction = (Dvb_MenuAction_t *)&maMainMenuAction;
MenuStateProcess[DVB_DISPLAY].cValidLinkNumber = DisplayActionNumber;
MenuStateProcess[DVB_DISPLAY].pstAction = (Dvb_MenuAction_t *)&maDisplayAction;
MenuStateProcess[DVB_AUTO_SEARCH].cValidLinkNumber = AutoSearchActionNumber;
MenuStateProcess[DVB_AUTO_SEARCH].pstAction = (Dvb_MenuAction_t *)&maAutoSearchAction;
MenuStateProcess[DVB_PRE_AUTO_SEARCH].cValidLinkNumber = PreAutoSearchActionNumber;
MenuStateProcess[DVB_PRE_AUTO_SEARCH].pstAction = (Dvb_MenuAction_t *)&maPreAutoSearchAction;
MenuStateProcess[DVB_CH_LIST].cValidLinkNumber = ChannelListActionNumber;
MenuStateProcess[DVB_CH_LIST].pstAction = (Dvb_MenuAction_t *)&maChannelListAction;
MenuStateProcess[DVB_CH_MANAGE].cValidLinkNumber = ChannelManageActionNumber;
MenuStateProcess[DVB_CH_MANAGE].pstAction = (Dvb_MenuAction_t *)&maChannelManageAction;
MenuStateProcess[DVB_CONFIRM_DEL].cValidLinkNumber = ConfirmDeleteActionNumber;
MenuStateProcess[DVB_CONFIRM_DEL].pstAction = (Dvb_MenuAction_t *)&maConfirmDeleteAction;
MenuStateProcess[DVB_MANUAL].cValidLinkNumber = ManualSearchActionNumber;
MenuStateProcess[DVB_MANUAL].pstAction = (Dvb_MenuAction_t *)&maManualSearchAction;
MenuStateProcess[DVB_INFO_TIMEOUT].cValidLinkNumber = InfoTimeoutActionNumber;
MenuStateProcess[DVB_INFO_TIMEOUT].pstAction = (Dvb_MenuAction_t *)&maInfoTimeoutAction;
MenuStateProcess[DVB_PRONUM_TIMEOUT].cValidLinkNumber = ProNumTimeoutActionNumber;
MenuStateProcess[DVB_PRONUM_TIMEOUT].pstAction = (Dvb_MenuAction_t *)&maProNumTimeoutAction;
MenuStateProcess[DVB_EPG].cValidLinkNumber = EPGActionNumber;
MenuStateProcess[DVB_EPG].pstAction = (Dvb_MenuAction_t *)&maEPGAction;
MenuStateProcess[DVB_VOL_TIMEOUT].cValidLinkNumber = VolTimeoutActionNumber;
MenuStateProcess[DVB_VOL_TIMEOUT].pstAction = (Dvb_MenuAction_t *)&maVolTimeoutAction;
MenuStateProcess[DVB_BCS_TIMEOUT].cValidLinkNumber = BCSTimeoutActionNumber;
MenuStateProcess[DVB_BCS_TIMEOUT].pstAction = (Dvb_MenuAction_t *)&maBCSTimeoutAction;
MenuStateProcess[DVB_PASSWORD].cValidLinkNumber = PasswordInputActionNumber;
MenuStateProcess[DVB_PASSWORD].pstAction = (Dvb_MenuAction_t *)&maPasswordInputAction;
/*stone added for timezone 2006-3-17*/
MenuStateProcess[DVB_TIMEZONE].cValidLinkNumber = TIMEZONEActionNumber;
MenuStateProcess[DVB_TIMEZONE].pstAction = (Dvb_MenuAction_t *)&maTIMEZONEAction;
/*end of stone added*/
}
/********************************************************************************
Function name: MenuStateMachineExecute
Description: Execute the menu state machine,implemented by an infinite loop.
Read Msgs from the message queue,then drive the state machine running.
Input param: None
Output param: None
Return: None
Auther: Allen Wu(12/17/2005)
********************************************************************************/
static void MenuStateMachineExecute(void *pvParam)
{
char cLoop,cFound;
clock_t timeout;
msm_cmd_t *msg_p;
dvb_MenuCmd_e eLinkId;
/*Config main menu*/
MainMenuConfigInitialize();
/*Initialize the menu state machine*/
MenuStateMachineInit();
/*Start the MSM*/
while(TRUE)
{
//timeout = 1;
//timeout = TIMEOUT_IMMEDIATE ;
//sttbx_Print(".");
msg_p = (msm_cmd_t *)message_receive_timeout(pstMenuStateMsgQueue,TIMEOUT_IMMEDIATE /*&timeout*/);
if(msg_p != NULL)
{
cFound = cLoop = 0;
eLinkId = msg_p->cmdType;
//sttbx_Print("\n----Receive Cmd[%d]\n",eLinkId);
//sttbx_Print("----Current Menu State = %d\n",currMenuState);
do
{
// printf("\n#####################test of MSM##################33 \n"/*,((MenuStateProcess[currMenuState].pstAction)+cLoop)->eLinkId*/);
/*search for the event in the state description */
/*while all key of the state have been checked or command is executed*/
if ((MenuStateProcess[currMenuState].pstAction+cLoop)->eLinkId == eLinkId)
{ /*valid Link found! -> process */
if(((MenuStateProcess[currMenuState].pstAction)+cLoop)->pfKeyProcess!=NULL)
{
((MenuStateProcess[currMenuState].pstAction)+cLoop)->pfKeyProcess(
((MenuStateProcess[currMenuState].pstAction)+cLoop)->Param);
//sttbx_Print("\n----Execute the pfAction successful\n");
}
msm_ChangeToState(((MenuStateProcess[currMenuState].pstAction)+cLoop)->nextState);
printf("\n----((MenuStateProcess[currMenuState].pstAction)+cLoop)->eLinkId==== \n"/*,((MenuStateProcess[currMenuState].pstAction)+cLoop)->eLinkId*/);
cFound = 1; /*indicate that the loop is over*/
}
cLoop++;
//sttbx_Print("\n----cLoop = %d,cFound = %d\n",cLoop,cFound);
}
while ((cLoop < MenuStateProcess[currMenuState].cValidLinkNumber)&&(cFound == 0));
/* free the message received*/
message_release(pstMenuStateMsgQueue, (void *)msg_p);
//sttbx_Print("\n---message_release(pstMenuStateMsgQueue, (void *)msg_p)\n");
}
/*12-26 Start*/
if(currMenuState == DVB_AUTO_SEARCH)
{
//sttbx_Print("\n*********************AutoSearchPerform();\n");
AutoSearchPerform();
}
else if(currMenuState != DVB_MANUAL)
{
//NoSignalCheck(); stone
}
if(currMenuState == DVB_INFO_TIMEOUT || currMenuState== DVB_VOL_TIMEOUT ||currMenuState == DVB_BCS_TIMEOUT)
{
InfoPanelTimeoutPerform();
}
else if(currMenuState == DVB_PRONUM_TIMEOUT)
{
ProNumPanelTimeoutPerform();
}
//sttbx_Print("\n----CurrMenuState = %d\n",currMenuState);
/*12-26 End*/
task_delay (ST_GetClocksPerSecondLow() / 100); /* FF03 change 100 to 10 , just save cpu time, nothing else*/
}
}
void msm_FeedbackMsg(dvb_MenuCmd_e message)
{
msm_cmd_t *msg_p;
if ( ( msg_p = ( msm_cmd_t *) message_claim ( pstMenuStateMsgQueue ) ) != NULL )
{
msg_p->cmdType = message;
message_send ( pstMenuStateMsgQueue, msg_p );
//sttbx_Print("\n----Sending Cmd[%d]\n",message);
}
else
{
sttbx_Print("\n----Error in msm_FeedbackMsg()\n");
}
}
BOOL MenuStateMachineProcessSetup(void)
{
BOOL bError = FALSE;
if ( symbol_enquire_value ( "msm_queue", ( void ** ) &pstMenuStateMsgQueue ) )
{
sttbx_Print( "\n\n----Can't find MenuStateMachine message queue\n" );
bError = TRUE;
}
if ( ( pMsmTask=task_create( MenuStateMachineExecute,
NULL,
MSM_PROCESS_WORKSPACE,
MSM_PROCESS_PRIORITY,
"MenuStateMachineTask",
0 ) ) == NULL )
{
sttbx_Print( "\n\n----Failed to start MenuStateMachine process\n" );
bError = TRUE;
}
if(!bError)
sttbx_Print("\n----Success Setup MSM Process!\n");
return bError;
}
/*------------------------------------EOF---------------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -