#include <rlstatemachine.h>
Public Member Functions | |
rlStatemachine (int numStates, int numProcessVariables, rlPlcState *state=NULL) | |
virtual | ~rlStatemachine () |
int | setPlcStateInt (int index, int val) |
float | setPlcStateFloat (int index, float val) |
double | setPlcStateDouble (int index, double val) |
virtual void | doState () |
virtual void | enterState (int newState, int whichEntry=0) |
virtual void | exitState (int whichExit=0) |
int | getPlcStateInt (int index) |
float | getPlcStateFloat (int index) |
double | getPlcStateDouble (int index) |
int | getState () |
rlPlcState * | getVar () |
Protected Attributes | |
int | num_states |
int | num_process_variables |
int | state |
int | haveto_free_state |
rlPlcState * | var |
class for a statemachine principle:
the user declares and implements his statemachine class Machine1 :public rlStatemachine { public: enum MyStates // declare your states { state1 = 0, state2, state3, numberOfStates };
enum MyIndexes // declare indexes for your process variables { temperature = 0, speed, voltage, numberOfProcessVariables };
Machine1(int numProcessVariables=numberOfProcessVariables); virtual ~Machine1(); virtual void doState(); virtual void enterState(int newState, int whichEntry=0); virtual void exitState(int whichExit=0); };
the statemachines are all executed forever Machine1 stm1; // declare some statemachines Machine2 stm2; // all Machines are derived from rlStatemachine Machine3 stm3; // user has to implement these Machines
while(1) // forever do the statemachines { // for example within your SoftPLC or within slotNullEvent rlsleep(cycletime); readProcessImageFromField(); // here the setPlcStateInt/Float/Double methods are called the inputs are read from the field stm1.doState(); // now we do the state transitions stm2.doState(); stm3.doState(); writeProcessImageToField(); // here the getPlcStateInt/Float/Double methods are called in case of SoftPLC write to field in case of slotNullEvent update GUI }
Definition at line 63 of file rlstatemachine.h.
rlStatemachine::rlStatemachine | ( | int | numStates, |
int | numProcessVariables, | ||
rlPlcState * | state = NULL |
||
) |
Definition at line 10 of file rlstatemachine.cpp.
|
virtual |
Definition at line 30 of file rlstatemachine.cpp.
|
virtual |
Definition at line 65 of file rlstatemachine.cpp.
|
virtual |
Definition at line 70 of file rlstatemachine.cpp.
|
virtual |
Definition at line 79 of file rlstatemachine.cpp.
double rlStatemachine::getPlcStateDouble | ( | int | index | ) |
Definition at line 101 of file rlstatemachine.cpp.
float rlStatemachine::getPlcStateFloat | ( | int | index | ) |
Definition at line 93 of file rlstatemachine.cpp.
int rlStatemachine::getPlcStateInt | ( | int | index | ) |
Definition at line 85 of file rlstatemachine.cpp.
int rlStatemachine::getState | ( | ) |
Definition at line 109 of file rlstatemachine.cpp.
rlPlcState * rlStatemachine::getVar | ( | ) |
Definition at line 114 of file rlstatemachine.cpp.
double rlStatemachine::setPlcStateDouble | ( | int | index, |
double | val | ||
) |
Definition at line 55 of file rlstatemachine.cpp.
float rlStatemachine::setPlcStateFloat | ( | int | index, |
float | val | ||
) |
Definition at line 45 of file rlstatemachine.cpp.
int rlStatemachine::setPlcStateInt | ( | int | index, |
int | val | ||
) |
Definition at line 35 of file rlstatemachine.cpp.
|
protected |
Definition at line 82 of file rlstatemachine.h.
|
protected |
Definition at line 80 of file rlstatemachine.h.
|
protected |
Definition at line 80 of file rlstatemachine.h.
|
protected |
Definition at line 81 of file rlstatemachine.h.
|
protected |
Definition at line 83 of file rlstatemachine.h.