Alex exoskeleton
ALEX SoftwareDocumentation
StateMachine.cpp
Go to the documentation of this file.
1 //
2 // Created by William Campbell on 2019-09-24.
3 //
4 #include "StateMachine.h"
5 
6 #include <stdio.h>
7 
8 #include <iostream>
9 
10 #include "DebugMacro.h"
11 //State machine constructors
13  currentState = NULL;
14 };
15 
17  currentState = i;
18  DEBUG_OUT("StateMachine::initialize()")
19 }
20 
22  return currentState;
23 }
24 
26  DEBUG_OUT("StateMachine::Activate")
28 }
29 
32  if (t != NULL) {
33  currentState->exit();
34  this->currentState = t->target;
36  }
38 }
State * target
Definition: Transition.h:40
StateMachine(void)
Construct a new State Machine object.
void activate(void)
Calls the entry method of the current state.
State * currentState
Pointer to the current state.
Definition: StateMachine.h:66
Transition * getActiveArc(void)
Definition: State.cpp:8
Abstract class representing a state in a StateMachine.
Definition: State.h:30
virtual void during(void)=0
Called continuously whilst in that state. Pure virtual function, must be overwritten by each state...
#define DEBUG_OUT(x)
Definition: DebugMacro.h:11
Represents possible transitions linking two State objects with an Event.
Definition: Transition.h:26
State * getCurState(void)
Returns a pointer to the current state.
virtual void entry(void)=0
Called once when the state is entered. Pure virtual function, must be overwritten by each state...
void initialize(State *i)
Sets the current state. Note: No check made.
virtual void exit(void)=0
Called once when the state exits. Pure virtual function, must be overwritten by each state...
virtual void update(void)
Processes the state machine. For each possible transition, checks if that transition should be made I...