SmartVehicle-Basis
SmartFactory
HoistCtrl.h
Go to the documentation of this file.
1 
14 #ifndef HOISTCTRL_H__
15 #define HOISTCTRL_H__
16 
17 #include "HardwareConfiguration.h"
18 #include "LogConfiguration.h"
19 
20 #include "Hoist/Hoist.h"
21 
27 class HoistCtrl {
28  //=====PUBLIC====================================================================================
29  public:
34  enum class Event { Raise,
35  Lower,
36  PosReached,
37  Error,
38  Resume,
39  Reset,
40  NoEvent
41  };
42 
47  enum class State { low,
48  raising,
49  high,
50  lowering,
51  resetState,
52  errorState
53  };
54 
60  HoistCtrl();
61 
66  void loop();
67 
73  void loop(Event currentEvent);
74 
80  const State getcurrentState();
81 
82  //=====PRIVATE====================================================================================
83  private:
87 
93  Event (HoistCtrl::*doActionFPtr)(void) = nullptr;
94 
96 
97  //=====PrivateFunctions=========================================================================
104  void process(Event e);
105  //=====StateFunctions=====
106  //=====low==========================================================
111  void entryAction_low();
112 
122 
127  void exitAction_low();
128 
129  //=====raising==========================================================
135  void entryAction_raising();
136 
146 
152  void exitAction_raising();
153 
154  //=====high==========================================================
159  void entryAction_high();
160 
170 
175  void exitAction_high();
176 
177  //=====lowering==========================================================
183  void entryAction_lowering();
184 
193 
199  void exitAction_lowering();
200 
201  //==errorState==========================================================
206  void entryAction_errorState();
207 
214 
219  void exitAction_errorState();
220 
221  //==resetState==========================================================
227  void entryAction_resetState();
228 
236 
241  void exitAction_resetState();
242 
243  //============================================================================
244  //==Aux-Function==============================================================
251  String decodeState(State state);
252 
259  String decodeEvent(Event event);
260 };
261 #endif
Ext: Start Lower.
void exitAction_errorState()
exit action of the errorState state.
Definition: HoistCtrl.cpp:206
HoistCtrl::Event doAction_resetState()
main action of the resetState
Definition: HoistCtrl.cpp:218
void process(Event e)
changes the state of the FSM based on the event
Definition: HoistCtrl.cpp:34
void entryAction_high()
executes the entry action of the high state.
Definition: HoistCtrl.cpp:151
Event currentEvent
holds the current event of the FSM
Definition: HoistCtrl.h:86
#define HOIST_SERVO_DELAY
Duration of the delay between the position updates of the Servo.
HoistCtrl::Event doAction_lowering()
executes the main action of the lowering state.
Definition: HoistCtrl.cpp:177
Contains the FSM for the Hoist.
Definition: HoistCtrl.h:27
String decodeEvent(Event event)
Decodes the Event-Enum and returns a description.
Definition: HoistCtrl.cpp:258
HoistCtrl()
Construct a new Hoist Ctrl object and initailize the currentState with low state.
Definition: HoistCtrl.cpp:16
File that contains the configuratioindetails of the different modules.
void exitAction_high()
executes the exit action of the high state.
Definition: HoistCtrl.cpp:164
Ext: Start Raise.
HoistCtrl::Event doAction_high()
executes the main action of the high state.
Definition: HoistCtrl.cpp:158
Provides the basic functions to control the Hoist.
Definition: Hoist.h:28
#define HOIST_POSITION_MIN
Minimal angle of the Servo.
#define HOIST_POISITION_MAX
Maximal angle of the Servo.
const State getcurrentState()
Get the current State.
Definition: HoistCtrl.cpp:30
void entryAction_lowering()
executes the entry action of the lowering state.
Definition: HoistCtrl.cpp:169
Ext.: Reset after Error occured.
Signal: Position reached.
void entryAction_raising()
executes the entry action of the raising state.
Definition: HoistCtrl.cpp:128
No event generated.
State currentState
holds the current state of the FSM
Definition: HoistCtrl.h:85
HoistCtrl::Event doAction_errorState()
main action of the errorState state.
Definition: HoistCtrl.cpp:200
void entryAction_errorState()
entry action of the errorState state.
Definition: HoistCtrl.cpp:192
Ext.: Resume after Error occured.
HoistCtrl::Event doAction_raising()
executes the main action of the raising state.
Definition: HoistCtrl.cpp:136
void exitAction_raising()
executes the exit action of the raising state.
Definition: HoistCtrl.cpp:145
String decodeState(State state)
Decodes the State-Enum and returns a description.
Definition: HoistCtrl.cpp:233
State lastStateBevorError
holds the last state of the FSM so it's possible to resume after error
Definition: HoistCtrl.h:84
Event
Enum holds all possible events.
Definition: HoistCtrl.h:34
void exitAction_resetState()
exit action of the resetState
Definition: HoistCtrl.cpp:227
The Class Hoist provides the basic functions for the hoist.
State
Enum holds all possible states for the Hoist.
Definition: HoistCtrl.h:47
Hoist pHoist
Hoist Object.
Definition: HoistCtrl.h:95
void loop()
Calls the do-function of the active state and hence generates Events.
Definition: HoistCtrl.cpp:19
Event(HoistCtrl::* doActionFPtr)(void)
Functionpointer to call the current states do-function.
Definition: HoistCtrl.h:93
#define HOIST_SERVO_PIN
Pin-Number for Servocontroll of the Hoist.
void exitAction_lowering()
executes the exit action of the lowering state.
Definition: HoistCtrl.cpp:186
void entryAction_low()
executes the entry action of the low state.
Definition: HoistCtrl.cpp:110
void exitAction_low()
executes the exit action of the low state.
Definition: HoistCtrl.cpp:123
HoistCtrl::Event doAction_low()
executes the main action of the low state.
Definition: HoistCtrl.cpp:117
void entryAction_resetState()
entry action of the resetState
Definition: HoistCtrl.cpp:211