/**************************************************************************** Module: Robot_SM.c Description: A hierarchical state machine for the ME218B project. Module Variables: CurrentState ****************************************************************************/ /**************************************************************************** Function RunRobot_SM Takes an event to process Returns an event to return ****************************************************************************/ Depending on CurrentState: If robot is off... ... and game starts, turn robot on. If robot is on... ... and Game Timer expires, turn robot off. If we are making a state transition Execute exit function for current state Execute entry function for new state return ReturnEvent End of function /**************************************************************************** Function StartRobot_SM Takes an event CurrentEvent Returns nothing Does any required initialization for this state machine ***************************************************************************/ Set Current State to Off State Call RunRobotSM with CurrentEvent End of function /**************************************************************************** Function QueryRobot_SM Takes nothing Returns the current state of the Robot state machine ****************************************************************************/ Return the value of CurrentState End of function /*************************************************************************** 'During' functions: ***************************************************************************/ DuringOffState Entry functions: none Exit functions: none During functions: none End of function DuringOnState Entry functions: Start Driving SM with current event Start Hopping SM with current event Exit functions: Run Drivng SM with current event Run Hopping SM with current event Stop the hopper motor Stop the drive motors During functions: Run Drivng SM with current event Run Hopping SM with current event Return any new events End of function