Escolar Documentos
Profissional Documentos
Cultura Documentos
//we're isolating this even though it could be put in the overall state machine
Start Reloading State Machine (Es event)
ES_Event LocalEvent = CurrentEvent;
Current state = SettingTarget
// use LocalEvent to keep the compiler from complaining about unused var
RunRelodingStateMachine(LocalEvent);
return;
RunRelodingStateMachine(Es_event)
MakeTransition = false
return event =current event
switch case
case GettingBalls
CurrentEvent=DuringGettingBalls(ES_Event)
if event is active != No event
if ES_IR_Ball_Rising_Edge
start debounce timer
make transition
next state =checking balls
break
case CheckingBalls
CurrentEvent=DuringCheckingBalls(ES_Event)
if event != Es_no event
if event=debouncetimer expires
check if the IR is currently reading a B
all detected or not
if ball detected we are full
Es_Full_of_Balls
if ball not detected we arent full
make transition
next state=GettingBalls
if event=ES_IR_Ball_Rising_Edge
start debounce timer again
break
--------------StateTransition-----------------------------
If we are making a state transition
Execute exit function for current state
Current Event Type = ES_EXIT;
RunDrivingStateMachine(CurrentEvent);
CurrentState = NextState //Modify state variable
//Execute entry function for new state this defaults to ES_ENTRY
RunDrivingStateMachine(EntryEventKind)
return Current Event
end
DuringGettingBalls
Entry
send pulse, start ball timer
exit
not sure what is should do here if anything.
else
if ES_ball_timer
send pulse
start timer (basically we will send pulses until we get
a rising edge ball event)
return event
end
DuringCheckingBalls (here for formality)
Entry
do nothing
exit
not sure what is should do here if anything.
else
do nothing
return event
end