SmartBox-Sortic
SmartFactory
BoxLevelCtrl Class Reference

The BoxLevel Controll class contains the FSM for the BoxLevel. More...

#include <BoxLevelCtrl.h>

Collaboration diagram for BoxLevelCtrl:

Public Types

enum  Event {
  Event::PackageDetected, Event::NoPackageDetected, Event::CheckForPackage, Event::Error,
  Event::Resume, Event::NoEvent
}
 Enum holds all possible events. More...
 
enum  State { State::emptyState, State::fullState, State::checking, State::errorState }
 Enum holds all possible states. More...
 

Public Member Functions

 BoxLevelCtrl ()
 Construct a new Box Level Ctrl object and initailize the currentState with emptyState. 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_emptyState ()
 executes the entry action of the emptyState More...
 
BoxLevelCtrl::Event doAction_emptyState ()
 executes the main action of the emptyState More...
 
void exitAction_emptyState ()
 executes the exit action of the emptyState More...
 
void entryAction_checking ()
 executes the entry action of the checking More...
 
BoxLevelCtrl::Event doAction_checking ()
 executes the main action of the checking More...
 
void exitAction_checking ()
 executes the exit action of the checking More...
 
void entryAction_fullState ()
 executes the entry action of the fullState More...
 
BoxLevelCtrl::Event doAction_fullState ()
 executes the main action of the fullState More...
 
void exitAction_fullState ()
 executes the exit action of the fullState More...
 
void entryAction_errorState ()
 entry action of the errorState More...
 
BoxLevelCtrl::Event doAction_errorState ()
 main action of the errorState More...
 
void exitAction_errorState ()
 exit action of the errorState 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(BoxLevelCtrl::* doActionFPtr )(void) = nullptr
 Functionpointer to call the current states do-function. More...
 
SensorArray pSensorArray = SensorArray(LB1, LB2, LB3, LOADINDICATOR_LED)
 SensorArray Object. More...
 

Detailed Description

The BoxLevel Controll class contains the FSM for the BoxLevel.

BoxLevelCtrl.png

Definition at line 28 of file BoxLevelCtrl.h.

Member Enumeration Documentation

◆ Event

enum BoxLevelCtrl::Event
strong

Enum holds all possible events.

Enumerator
PackageDetected 

Package detected.

NoPackageDetected 

No package detected.

CheckForPackage 

Ext.: Check for package.

Error 

Error occured.

Resume 

Ext.:Resume after Error occured.

NoEvent 

No event generated.

Definition at line 35 of file BoxLevelCtrl.h.

◆ State

enum BoxLevelCtrl::State
strong

Enum holds all possible states.

Enumerator
emptyState 

Empty State.

fullState 

Full State.

checking 

check Boxlevel

errorState 

Error-state.

Definition at line 47 of file BoxLevelCtrl.h.

Constructor & Destructor Documentation

◆ BoxLevelCtrl()

BoxLevelCtrl::BoxLevelCtrl ( )

Construct a new Box Level Ctrl object and initailize the currentState with emptyState.

Definition at line 16 of file BoxLevelCtrl.cpp.

Member Function Documentation

◆ loop() [1/2]

void BoxLevelCtrl::loop ( )

Calls the do-function of the active state and hence generates Events.

Definition at line 19 of file BoxLevelCtrl.cpp.

◆ loop() [2/2]

void BoxLevelCtrl::loop ( Event  currentEvent)

procceses the current Event and calls the do-function of the active state

Parameters
currentEvent- Event

Definition at line 24 of file BoxLevelCtrl.cpp.

◆ getcurrentState()

const BoxLevelCtrl::State BoxLevelCtrl::getcurrentState ( )

Get the current State.

Returns
State - current State

Definition at line 30 of file BoxLevelCtrl.cpp.

◆ process()

void BoxLevelCtrl::process ( Event  e)
private

changes the state of the FSM based on the event

Parameters
e- Event

Definition at line 34 of file BoxLevelCtrl.cpp.

◆ entryAction_emptyState()

void BoxLevelCtrl::entryAction_emptyState ( )
private

executes the entry action of the emptyState

Turns on the Loadindicator-LED

Definition at line 90 of file BoxLevelCtrl.cpp.

◆ doAction_emptyState()

BoxLevelCtrl::Event BoxLevelCtrl::doAction_emptyState ( )
private

executes the main action of the emptyState

Definition at line 97 of file BoxLevelCtrl.cpp.

◆ exitAction_emptyState()

void BoxLevelCtrl::exitAction_emptyState ( )
private

executes the exit action of the emptyState

Definition at line 103 of file BoxLevelCtrl.cpp.

◆ entryAction_checking()

void BoxLevelCtrl::entryAction_checking ( )
private

executes the entry action of the checking

Definition at line 108 of file BoxLevelCtrl.cpp.

◆ doAction_checking()

BoxLevelCtrl::Event BoxLevelCtrl::doAction_checking ( )
private

executes the main action of the checking

checks if the sensor has a package detected and generates the appropriate event

Returns
BoxLevelCtrl::Event - generated Event

Definition at line 114 of file BoxLevelCtrl.cpp.

◆ exitAction_checking()

void BoxLevelCtrl::exitAction_checking ( )
private

executes the exit action of the checking

Definition at line 124 of file BoxLevelCtrl.cpp.

◆ entryAction_fullState()

void BoxLevelCtrl::entryAction_fullState ( )
private

executes the entry action of the fullState

Turns off the Loadindicator-LED

Definition at line 129 of file BoxLevelCtrl.cpp.

◆ doAction_fullState()

BoxLevelCtrl::Event BoxLevelCtrl::doAction_fullState ( )
private

executes the main action of the fullState

Returns
BoxLevelCtrl::Event - generated Event

Definition at line 136 of file BoxLevelCtrl.cpp.

◆ exitAction_fullState()

void BoxLevelCtrl::exitAction_fullState ( )
private

executes the exit action of the fullState

Definition at line 143 of file BoxLevelCtrl.cpp.

◆ entryAction_errorState()

void BoxLevelCtrl::entryAction_errorState ( )
private

entry action of the errorState

Definition at line 148 of file BoxLevelCtrl.cpp.

◆ doAction_errorState()

BoxLevelCtrl::Event BoxLevelCtrl::doAction_errorState ( )
private

main action of the errorState

Returns
BoxLevelCtrl::Event - generated Event

Definition at line 155 of file BoxLevelCtrl.cpp.

◆ exitAction_errorState()

void BoxLevelCtrl::exitAction_errorState ( )
private

exit action of the errorState

Definition at line 162 of file BoxLevelCtrl.cpp.

◆ decodeState()

String BoxLevelCtrl::decodeState ( State  state)
private

Decodes the State-Enum and returns a description.

Parameters
state- enum State
Returns
String - State as String

Definition at line 168 of file BoxLevelCtrl.cpp.

◆ decodeEvent()

String BoxLevelCtrl::decodeEvent ( Event  event)
private

Decodes the Event-Enum and returns a description.

Parameters
event- enum Event
Returns
String - Event as String

Definition at line 188 of file BoxLevelCtrl.cpp.

Member Data Documentation

◆ lastStateBevorError

State BoxLevelCtrl::lastStateBevorError
private

holds the last state of the FSM so it's possible to resume after error

Definition at line 89 of file BoxLevelCtrl.h.

◆ currentState

State BoxLevelCtrl::currentState
private

holds the current state of the FSM

Definition at line 90 of file BoxLevelCtrl.h.

◆ currentEvent

Event BoxLevelCtrl::currentEvent
private

holds the current event of the FSM

Definition at line 91 of file BoxLevelCtrl.h.

◆ doActionFPtr

Event(BoxLevelCtrl::* BoxLevelCtrl::doActionFPtr) (void) = nullptr
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 98 of file BoxLevelCtrl.h.

◆ pSensorArray

SensorArray BoxLevelCtrl::pSensorArray = SensorArray(LB1, LB2, LB3, LOADINDICATOR_LED)
private

SensorArray Object.

Definition at line 100 of file BoxLevelCtrl.h.


The documentation for this class was generated from the following files: