SmartBox-Sortic
SmartFactory
BoxLevelCtrl.h
Go to the documentation of this file.
1 
14 #ifndef BOXLEVELCTRL_H__
15 #define BOXLEVELCTRL_H__
16 
17 #include "LogConfiguration.h"
18 
19 #include "SensorArray.h"
20 #include "SensorConfiguration.h"
21 
28 class BoxLevelCtrl {
29  //=====PUBLIC====================================================================================
30  public:
35  enum class Event { PackageDetected,
38  Error,
39  Resume,
40  NoEvent
41  };
42 
47  enum class State { emptyState,
48  fullState,
49  checking,
50  errorState
51  };
52 
58  BoxLevelCtrl();
59 
64  void loop();
65 
71  void loop(Event currentEvent);
72 
78  const State getcurrentState();
79 
80  //=====PRIVATE====================================================================================
81  private:
87  void process(Event e);
88 
92 
98  Event (BoxLevelCtrl::*doActionFPtr)(void) = nullptr;
99 
101 
102  //=====StateFunctions=====
103  //=====emptyState==========================================================
110  void entryAction_emptyState();
111 
117 
122  void exitAction_emptyState();
123 
124  //=====checking==========================================================
129  void entryAction_checking();
130 
139 
144  void exitAction_checking();
145 
146  //=====fullState==========================================================
152  void entryAction_fullState();
153 
160 
165  void exitAction_fullState();
166 
167  //==errorState==========================================================
172  void entryAction_errorState();
173 
180 
185  void exitAction_errorState();
186 
187  //============================================================================
188  //==Aux-Function==============================================================
195  String decodeState(State state);
196 
203  String decodeEvent(Event event);
204 };
205 #endif
State lastStateBevorError
holds the last state of the FSM so it's possible to resume after error
Definition: BoxLevelCtrl.h:89
The BoxLevel Controll class contains the FSM for the BoxLevel.
Definition: BoxLevelCtrl.h:28
void exitAction_emptyState()
executes the exit action of the emptyState
String decodeEvent(Event event)
Decodes the Event-Enum and returns a description.
void exitAction_errorState()
exit action of the errorState
Event
Enum holds all possible events.
Definition: BoxLevelCtrl.h:35
String decodeState(State state)
Decodes the State-Enum and returns a description.
const int LB2
Pin IR sensor LightBarrier 2.
const int LOADINDICATOR_LED
PIn for Loadindicator LED.
void entryAction_fullState()
executes the entry action of the fullState
BoxLevelCtrl::Event doAction_checking()
executes the main action of the checking
BoxLevelCtrl()
Construct a new Box Level Ctrl object and initailize the currentState with emptyState.
void process(Event e)
changes the state of the FSM based on the event
BoxLevelCtrl::Event doAction_errorState()
main action of the errorState
void loop()
Calls the do-function of the active state and hence generates Events.
const int LB3
Pin IR sensor LightBarrier 3.
void entryAction_emptyState()
executes the entry action of the emptyState
void exitAction_checking()
executes the exit action of the checking
Contains Pre-Compiler directives for diffent Serialprints for Datalogin.
Ext.: Check for package.
The Class SensorArray detects the box fill level.
Definition: SensorArray.h:27
Ext.:Resume after Error occured.
State
Enum holds all possible states.
Definition: BoxLevelCtrl.h:47
BoxLevelCtrl::Event doAction_emptyState()
executes the main action of the emptyState
BoxLevelCtrl::Event doAction_fullState()
executes the main action of the fullState
void entryAction_errorState()
entry action of the errorState
const State getcurrentState()
Get the current State.
Event currentEvent
holds the current event of the FSM
Definition: BoxLevelCtrl.h:91
SensorArray pSensorArray
SensorArray Object.
Definition: BoxLevelCtrl.h:100
State currentState
holds the current state of the FSM
Definition: BoxLevelCtrl.h:90
void entryAction_checking()
executes the entry action of the checking
const int LB1
Pin IR sensor LightBarrier 1.
void exitAction_fullState()
executes the exit action of the fullState
Event(BoxLevelCtrl::* doActionFPtr)(void)
Functionpointer to call the current states do-function.
Definition: BoxLevelCtrl.h:98
The Sensor Array detects the box fill level.
File that contains the default sensor configuration.
No event generated.