SmartVehicle-Basis
SmartFactory
|
Contains the FSM for the Hoist. More...
#include <HoistCtrl.h>
Public Types | |
enum | Event { Event::Raise, Event::Lower, Event::PosReached, Event::Error, Event::Resume, Event::Reset, Event::NoEvent } |
Enum holds all possible events. More... | |
enum | State { State::low, State::raising, State::high, State::lowering, State::resetState, State::errorState } |
Enum holds all possible states for the Hoist. More... | |
Public Member Functions | |
HoistCtrl () | |
Construct a new Hoist Ctrl object and initailize the currentState with low state. More... | |
void | loop () |
Calls the do-function of the active state and hence generates Events. More... | |
void | loop (Event currentEvent) |
Procceses the current Event and calls the do-function of the active state. More... | |
const State | getcurrentState () |
Get the current State. More... | |
Private Member Functions | |
void | process (Event e) |
changes the state of the FSM based on the event More... | |
void | entryAction_low () |
executes the entry action of the low state. More... | |
HoistCtrl::Event | doAction_low () |
executes the main action of the low state. More... | |
void | exitAction_low () |
executes the exit action of the low state. More... | |
void | entryAction_raising () |
executes the entry action of the raising state. More... | |
HoistCtrl::Event | doAction_raising () |
executes the main action of the raising state. More... | |
void | exitAction_raising () |
executes the exit action of the raising state. More... | |
void | entryAction_high () |
executes the entry action of the high state. More... | |
HoistCtrl::Event | doAction_high () |
executes the main action of the high state. More... | |
void | exitAction_high () |
executes the exit action of the high state. More... | |
void | entryAction_lowering () |
executes the entry action of the lowering state. More... | |
HoistCtrl::Event | doAction_lowering () |
executes the main action of the lowering state. More... | |
void | exitAction_lowering () |
executes the exit action of the lowering state. More... | |
void | entryAction_errorState () |
entry action of the errorState state. More... | |
HoistCtrl::Event | doAction_errorState () |
main action of the errorState state. More... | |
void | exitAction_errorState () |
exit action of the errorState state. More... | |
void | entryAction_resetState () |
entry action of the resetState More... | |
HoistCtrl::Event | doAction_resetState () |
main action of the resetState More... | |
void | exitAction_resetState () |
exit action of the resetState More... | |
String | decodeState (State state) |
Decodes the State-Enum and returns a description. More... | |
String | decodeEvent (Event event) |
Decodes the Event-Enum and returns a description. More... | |
Private Attributes | |
State | lastStateBevorError |
holds the last state of the FSM so it's possible to resume after error More... | |
State | currentState |
holds the current state of the FSM More... | |
Event | currentEvent |
holds the current event of the FSM More... | |
Event(HoistCtrl::* | doActionFPtr )(void) = nullptr |
Functionpointer to call the current states do-function. More... | |
Hoist | pHoist = Hoist(HOIST_SERVO_PIN, HOIST_SERVO_DELAY, HOIST_POISITION_MAX, HOIST_POSITION_MIN) |
Hoist Object. More... | |
|
strong |
Enum holds all possible events.
Definition at line 34 of file HoistCtrl.h.
|
strong |
Enum holds all possible states for the Hoist.
Enumerator | |
---|---|
low | low State |
raising | raising State |
high | high State |
lowering | lowering State |
resetState | reset state |
errorState | error State |
Definition at line 47 of file HoistCtrl.h.
HoistCtrl::HoistCtrl | ( | ) |
Construct a new Hoist Ctrl object and initailize the currentState with low state.
Definition at line 16 of file HoistCtrl.cpp.
void HoistCtrl::loop | ( | ) |
Calls the do-function of the active state and hence generates Events.
Definition at line 19 of file HoistCtrl.cpp.
void HoistCtrl::loop | ( | Event | currentEvent | ) |
Procceses the current Event and calls the do-function of the active state.
currentEvent | - Event |
Definition at line 24 of file HoistCtrl.cpp.
const HoistCtrl::State HoistCtrl::getcurrentState | ( | ) |
|
private |
changes the state of the FSM based on the event
This Functions switchs the state based on the occuring events
e | - Event |
Definition at line 34 of file HoistCtrl.cpp.
|
private |
executes the entry action of the low state.
Definition at line 110 of file HoistCtrl.cpp.
|
private |
executes the main action of the low state.
This is an idle-state. Return NoEvent.
Definition at line 117 of file HoistCtrl.cpp.
|
private |
executes the exit action of the low state.
Definition at line 123 of file HoistCtrl.cpp.
|
private |
executes the entry action of the raising state.
Attach Servo.
Definition at line 128 of file HoistCtrl.cpp.
|
private |
executes the main action of the raising state.
Raise the Hoist till the Endposition is reached and generate an PosReached Event. Else return NoEvent.
Definition at line 136 of file HoistCtrl.cpp.
|
private |
executes the exit action of the raising state.
Detach Servo.
Definition at line 145 of file HoistCtrl.cpp.
|
private |
executes the entry action of the high state.
Definition at line 151 of file HoistCtrl.cpp.
|
private |
executes the main action of the high state.
This is an idle-state. Return NoEvent.
Definition at line 158 of file HoistCtrl.cpp.
|
private |
executes the exit action of the high state.
Definition at line 164 of file HoistCtrl.cpp.
|
private |
executes the entry action of the lowering state.
Attach Servo.
Definition at line 169 of file HoistCtrl.cpp.
|
private |
executes the main action of the lowering state.
Lower the hoist till the lowposition is reached and then generate the event PosReached. else return NoEvent.
Definition at line 177 of file HoistCtrl.cpp.
|
private |
executes the exit action of the lowering state.
Detache the Servo.
Definition at line 186 of file HoistCtrl.cpp.
|
private |
entry action of the errorState state.
Definition at line 192 of file HoistCtrl.cpp.
|
private |
main action of the errorState state.
Definition at line 200 of file HoistCtrl.cpp.
|
private |
exit action of the errorState state.
Definition at line 206 of file HoistCtrl.cpp.
|
private |
|
private |
main action of the resetState
lower the hoist and then detach the servo
Definition at line 218 of file HoistCtrl.cpp.
|
private |
exit action of the resetState
Definition at line 227 of file HoistCtrl.cpp.
|
private |
Decodes the State-Enum and returns a description.
state | - enum State |
Definition at line 233 of file HoistCtrl.cpp.
|
private |
Decodes the Event-Enum and returns a description.
event | - enum Event |
Definition at line 258 of file HoistCtrl.cpp.
|
private |
holds the last state of the FSM so it's possible to resume after error
Definition at line 84 of file HoistCtrl.h.
|
private |
holds the current state of the FSM
Definition at line 85 of file HoistCtrl.h.
|
private |
holds the current event of the FSM
Definition at line 86 of file HoistCtrl.h.
|
private |
Functionpointer to call the current states do-function.
https://stackoverflow.com/questions/1485983/calling-c-class-methods-via-a-function-pointer
Definition at line 93 of file HoistCtrl.h.
|
private |
Hoist Object.
Definition at line 95 of file HoistCtrl.h.