Hai All,
I am Implementing finate state machine and approach is as follows:
enum FSM_GATE_STATES { GateOpen=0, GateClose ... ... }; struct FSM_Gate { enum FSM_GATE_STATES ActiveState; }; struct FSM_Gate m_FSM_Gate; void main() { m_FSM_Gate.ActiveState=Gopen; switch(m_FSM_Gate.ActiveState) { Case GateOpen: if(gateOpen_Gateclose()) { m_FSM_Gate.ActiveState=GateClose; } else { //generate out put } break; Case GateClose: //similar implementation break; ... .. } } bit gateOpen_Gateclose() { if(inputTable[1]&&inputTable[2]....n)/*inputs from the field*/ { return 1; } else { return 0; } }
This my approach of FSM... Since the FSM is as single program..I am having 19 states and 38 transition conditions...It is very hard to maintain it as configurable...
Is there any other efficient approach... I need to place the transition conditions in EEPROM give me suggestions... In this program transition condition is like function that is bit gateOpen_gateClose { if(inputTable[]....) { return 1; } else { return 0; } }
I want to make transition as configurable data..... can this function changed in to boolean expresssions???? and stored in EEPROM..Or How to place a function in external EEPROM any linking should be done???..Kindly give me suggestion....
Since the FSM is as single program..I am having 19 states and 38 transition conditions...It is very hard to maintain it as configurable...
I do not know if this will help, but in a few cases I have used this technique (which, by the way, speed up the processing) #define GROUP_MASK 0xf0 #define group0 0 #define group1 0x10 .... #define statea (grupup0 + 0) #define stateb (grupup0 + 1) #define stateq (grupup1 + 0)
switch (state & GROUP_MASK) case group0 ProcessGroup0(); ....
ProcessGroup0 switch (state & ~GROUP_MASK)
erik