- fixed errors occured after intendation command in fsm mechanism

This commit is contained in:
zolliker
2009-02-25 14:50:47 +00:00
parent e762ecb6a1
commit 69af09fe54
14 changed files with 63 additions and 23 deletions

24
fsm.c
View File

@@ -49,6 +49,13 @@ void FsmSpeed(Fsm * task)
task->till = time(NULL);
}
long FsmPc(void) {
if (fsm) {
return fsm->pc;
}
return -1;
}
int FsmTaskHandler(Fsm * task)
{
long line;
@@ -74,6 +81,8 @@ int FsmTaskHandler(Fsm * task)
}
fsm = task;
task->pc = task->func(task->pc, task->obj);
if (task->pc > 0)
task->pc++; /* go to next line (case must be one line after return) */
while (callFunc) {
assert(fsm->sp < MAXSTACK);
fsm->stack[fsm->sp].pc = task->pc;
@@ -83,11 +92,14 @@ int FsmTaskHandler(Fsm * task)
fsm->func = callFunc;
callFunc = NULL;
task->pc = fsm->func(fsm->pc, fsm->obj);
if (task->pc > 0)
task->pc++; /* go to next line (case must be one line after return) */
}
fsm = NULL;
}
StatisticsEnd(old);
if (task->pc <= 0) {
task->pc = 0;
if (task->sp == 0) {
return (task->obj != NULL); /* finish task only when explicitely stopped */
}
@@ -165,18 +177,6 @@ void FsmPause(Fsm * task, int pause)
task->pause = pause;
}
long FsmCallOld(long pc, FsmFunc func)
{
assert(fsm);
assert(fsm->sp < MAXSTACK);
fsm->stack[fsm->sp].pc = pc;
fsm->stack[fsm->sp].func = fsm->func;
fsm->sp++;
fsm->func = func;
fsm->pc = 0;
return fsm->func(fsm->pc, fsm->obj);
}
void FsmCall(FsmFunc func)
{
assert(fsm);