Вы находитесь на странице: 1из 3

MarioMovementSM

This service syncs mario forward movement with 60 seconds.


Currently it takes 6 seconds to reach from start to end. Idea is to move the
mario for 1 sec
and then stop it for 9 sec

First Version: Nov 27, Sunday

Data private to the module:


MyPriority

States:
PseudoState_MarioMovementSM, //PseudoState
MarioMoving,
MarioNotMoving

Intaking Events:
ES_TIMEOUT
MOVE_MARIO (from ControlSM when we have START_BUTTON_PRESSED event from
Setup to Ingame)

/****************************************************************************
Function
InitMarioMovementSM

Parameters
uint8_t : the priorty of this service

Returns
bool, false if error in initialization, true otherwise

Description
Saves away the priority, and does any
other required initialization for this service
Notes

Author
****************************************************************************/
InitMarioMovementSM

Initializes Service with recieved priority


Sets to Initial event

/****************************************************************************
Function
PostMarioMovementSM

Parameters
ES_Event_t ThisEvent ,the event to post to the queue
Returns
bool false if the Enqueue operation failed, true otherwise

Description
Posts an event to this state machine's queue
Notes

Author
****************************************************************************/
PostMarioMovementSM
Posts recieved event into service

/****************************************************************************
Function
RunMarioMovementSM

Parameters
ES_Event_t : the event from its service queue to process in this State
Machine
Types of ES_Event_t: VISUAL_BLAST_OFF, VISUAL_BLAST_ON, GLOW_RANDOM_PIPE,
ES_TIMEOUT

Returns
ES_Event_t, ES_NO_EVENT if no error ES_ERROR otherwise

Description
add your description here
Notes

Author

****************************************************************************/

RunMarioMovementSM

Reads current State (CurrentState)

if State is PseudoState_MarioMovementSM
Assigns State as MarioNotMoving

If State is MarioNotMoving:

Checks Guard conditions


If Mario is not at the end and ControlSM is at InGame
If revieved Event was ES_Timeout from MarioMovementTimer
Starts Timer for 1 second
Sets direcction of Mario H Bridge to forward
Sends value of Forward to SR_HillAndMotor_Write
Sends PWM 100% duty signal to Mario H Bridge
Sets MarioMoving as Current State

If State is Mario Moving


If revieved Event was ES_Timeout from MarioMovementTimer
Starts timer for 9 second
Stops PWM signal to Mario H Bridge
Sets MarioNotMoving as current State

Вам также может понравиться