- modified and improved various env. drivers

- implemented string array object
This commit is contained in:
zolliker
2006-06-20 13:29:32 +00:00
parent 8b12033cb2
commit c1bbdb935e
19 changed files with 1495 additions and 499 deletions

16
fsm.c
View File

@@ -10,6 +10,7 @@ M. Zolliker, Aug 2004
#include <assert.h>
#include <time.h>
#include "fsm.h"
#include "statistics.h"
#define MAXSTACK 8
@@ -32,6 +33,7 @@ struct Fsm {
static Fsm *fsm = NULL;
static FsmFunc callFunc = NULL;
static Statistics *taskStat = NULL;
void FsmWait(long delay) {
assert(fsm);
@@ -45,17 +47,27 @@ void FsmSpeed(Fsm *task) {
int FsmTaskHandler(Fsm *task) {
long line;
Statistics *old;
if (taskStat == NULL) {
taskStat=StatisticsNew("<fsm>");
}
old = StatisticsBegin(taskStat);
if (task->pause) {
task->handler(task->obj);
StatisticsEnd(old);
return 1;
}
if (task->pc >= 0) { /* task->pc < 0 means stop current function */
if (task->till != 0) {
if (time(NULL) < task->till) return 1; /* wait */
if (time(NULL) < task->till) {
StatisticsEnd(old);
return 1; /* wait */
}
task->till = 0;
}
if (task->handler(task->obj) == 0) {
StatisticsEnd(old);
return 1; /* wait for answer */
}
fsm = task;
@@ -72,6 +84,7 @@ int FsmTaskHandler(Fsm *task) {
}
fsm = NULL;
}
StatisticsEnd(old);
if (task->pc <= 0) {
if (task->sp == 0) {
return (task->obj != NULL); /* finish task only when explicitely stopped */
@@ -111,6 +124,7 @@ int FsmStop(Fsm *task, FsmFunc func) {
int i;
if (task == NULL) task = fsm;
if (func == NULL) return 0;
assert(task);
for (i=0; i < task->sp; i++) {
if (func == task->stack[i].func) {