SmartVehicle-Sortic
SmartFactory
NavigationCtrl.h
Go to the documentation of this file.
1 
14 #ifndef NAVIGATIONCTRL_H__
15 #define NAVIGATIONCTRL_H__
16 
17 #include "LogConfiguration.h"
18 
19 #include "DriveCtrl.h"
20 
28  //=====PUBLIC====================================================================================
29  public:
34  enum class Event { MoveToTargetPosition,
37  PosReached,
38  Error,
39  Resume,
40  Reset,
41  NoEvent
42  };
43 
48  enum class State { endPoint,
49  toGateway,
50  gateway,
51  crossTransit,
52  toEndPoint,
53  resetState,
54  errorState
55  };
56 
61  enum class Sector {
69  Parking,
75  error
76  };
77 
84 
89  void loop();
90 
96  void loop(Event currentEvent);
97 
103  const State getcurrentState();
104 
110  const Sector getcurrentSector();
111 
117  const int getcurrentLine();
118 
125  void setTargetPosition(Sector sector, const int line);
126 
133  void setActualPosition(Sector sector, const int line);
134 
139  void giveToken();
140 
147  String decodeSector(Sector sector);
148 
155  NavigationCtrl::Sector decodeSector(String sector);
156 
157  //=====PRIVATE====================================================================================
158  private:
165 
170  struct ActualPos {
174  int line = 1;
175  bool token = false;
176  } pActual;
177 
182  struct TargetPos {
184  int line;
185  } pTarget;
186 
187  bool tranistonce = true;
188  DriveCtrl::Event pLastGatewayTurn;
189 
196  Event (NavigationCtrl::*doActionFPtr)(void) = nullptr;
197 
198  DriveCtrl pDriveCtrl;
199 
200  //=====PrivateFunctions=========================================================================
206  void process(Event e);
207  //=====StateFunctions=====
208  //=====endPoint==========================================================
214  void entryAction_endPoint();
215 
222 
227  void exitAction_endPoint();
228 
229  //=====toGateway==========================================================
234  void entryAction_toGateway();
235 
248 
252  void exitAction_toGateway();
253 
254  //=====gateway==========================================================
259  void entryAction_gateway();
260 
280 
285  void exitAction_gateway();
286 
287  //=====crossTransit==========================================================
293 
302 
307 
308  //=====toEndPoint==========================================================
313  void entryAction_toEndPoint();
314 
322 
326  void exitAction_toEndPoint();
327 
328  //==errorState==========================================================
333  void entryAction_errorState();
334 
341 
346  void exitAction_errorState();
347 
348  //==resetState==========================================================
353  void entryAction_resetState();
354 
361 
366  void exitAction_resetState();
367  //============================================================================
368  //==Aux-Function==============================================================
375  String decodeState(State state);
376 
383  String decodeEvent(Event event);
384 };
385 #endif
void entryAction_endPoint()
executes the entry action of the endPoint state.
const Sector getcurrentSector()
Get the current Sector.
Sector startSector
Startpoint from current path.
NavigationCtrl::Event doAction_toEndPoint()
executes the main action of the toEndPoint state.
int pCurrentSubState
Counter for the Current Substate.
void exitAction_resetState()
exit action of the resetState
void exitAction_endPoint()
executes the exit action of the endPoint state.
void entryAction_errorState()
entry action of the errorState state.
NavigationCtrl::Event doAction_toGateway()
executes the main action of the toGateway state.
Ext.: Reset after Error occured.
NavigationCtrl::Event doAction_errorState()
main action of the errorState state.
DriveCtrl pDriveCtrl
Navigation Object.
void giveToken()
give Token to access the Gateway
State lastStateBevorError
holds the last state of the FSM so it's possible to resume after error
int pLastSubStateBevorError
Holds the last Substate befor an Error occured.
NavigationCtrl()
Construct a new Navigation Ctrl object and initailize the currentState with endPoint state.
Ext: Resume after Error occured.
void entryAction_resetState()
entry action of the resetState
Ext: Start MoveToTargetPosition.
String decodeEvent(Event event)
Decodes the Event-Enum and returns a description.
NavigationCtrl::Event doAction_gateway()
executes the main action of the gateway state.
void exitAction_gateway()
executes the exit action of the gateway state.
State currentState
holds the current state of the FSM
Holds the information about the vehicle target.
void setTargetPosition(Sector sector, const int line)
Set the Target Position object.
Sector sector
actual sector
Transit - Wait for Gateway Transfer.
void exitAction_toGateway()
executes the exit action of the toGateway state.
Event(NavigationCtrl::* doActionFPtr)(void)
Functionpointer to call the current states do-function.
Sector lastSector
last sector
NavigationCtrl::Event doAction_endPoint()
executes the main action of the endPoint state. This is an Idel-state ->NoEvent generated
void loop()
Calls the do-function of the active state and hence generates Events.
bool token
token for gateway accees
NavigationCtrl::Event doAction_resetState()
main action of the resetState
struct NavigationCtrl::ActualPos pActual
NavigationCtrl::Event doAction_crossTransit()
executes the main action of the crossTransit state.
const State getcurrentState()
Get the current State.
void entryAction_gateway()
executes the entry action of the gateway state.
void process(Event e)
changes the state of the FSM based on the event
Contains the FSM for the Navigation.
String decodeState(State state)
Decodes the State-Enum and returns a description.
Event
Enum holds all possible events.
Parking (not used atm)
Contains Pre-Compiler directives for diffent Serialprints for Datalogin.
State
Enum holds all possible states for the Navigation.
Signal: Position reached.
void exitAction_crossTransit()
executes the exit action of the crossTransit state.
Event currentEvent
holds the current event of the FSM
void exitAction_errorState()
exit action of the errorState state.
Holds the actual information about the vehicleposition.
String decodeSector(Sector sector)
Decodes the Sector-Enum and returns a description.
void entryAction_toGateway()
executes the entry action of the toGateway state.
Transit - Wait for Gateway Sortic.
error for unknown sector
const int getcurrentLine()
Get the current Line.
int pSubStateLoopInc
Counter so you can call the same substatefunction multiple times.
struct NavigationCtrl::TargetPos pTarget
void setActualPosition(Sector sector, const int line)
Set the actual Position object.
void entryAction_toEndPoint()
executes the entry action of the toEndPoint state.
void exitAction_toEndPoint()
executes the exit action of the toEndPoint state.
DriveCtrl::Event pLastGatewayTurn
Variable which holds the last made turn in gateway.
void entryAction_crossTransit()
executes the entry action of the crossTransit state.
bool tranistonce
prevents an loop between transit and gateway
Sector sector
TargetSector.
Sector
Enum holds all possible sectors.