/* sscc : C CODE OF SORTED EQUATIONS simple - SIMULATION MODE */

/* AUXILIARY DECLARATIONS */

#ifndef STRLEN
#define STRLEN 81
#endif
#define _COND(A,B,C) ((A)?(B):(C))
#ifdef TRACE_ACTION
#include <stdio.h>
#endif
#ifndef NULL
#define NULL ((char*)0)
#endif

#ifndef __EXEC_STATUS_H_LOADED
#define __EXEC_STATUS_H_LOADED

typedef struct {
unsigned int start:1;
unsigned int kill:1;
unsigned int active:1;
unsigned int suspended:1;
unsigned int prev_active:1;
unsigned int prev_suspended:1;
unsigned int exec_index;
unsigned int task_exec_index;
void (*pStart)();
int (*pRet)();
} __ExecStatus;

#endif
#define __ResetExecStatus(status) {\
   status.prev_active = status.active; \
   status.prev_suspended = status.suspended; \
   status.start = status.kill = status.active = status.suspended = 0; }
#define __DSZ(V) (--(V)<=0)
#define BASIC_TYPES_DEFINED
typedef int boolean;
typedef int integer;
typedef char* string;
#define CSIMUL_H_LOADED
typedef struct {char text[STRLEN];} symbolic;
extern void _boolean();
extern boolean _eq_boolean();
extern boolean _ne_boolean();
extern boolean _cond_boolean();
extern char* _boolean_to_text();
extern int _check_boolean();
extern void _text_to_boolean();
extern void _integer();
extern boolean _eq_integer();
extern boolean _ne_integer();
extern integer _cond_integer();
extern char* _integer_to_text();
extern int _check_integer();
extern void _text_to_integer();
extern void _string();
extern boolean _eq_string();
extern boolean _ne_string();
extern string _cond_string();
extern char* _string_to_text();
extern int _check_string();
extern void _text_to_string();
extern void _float();
extern boolean _eq_float();
extern boolean _ne_float();
extern float _cond_float();
extern char* _float_to_text();
extern int _check_float();
extern void _text_to_float();
extern void _double();
extern boolean _eq_double();
extern boolean _ne_double();
extern double _cond_double();
extern char* _double_to_text();
extern int _check_double();
extern void _text_to_double();
extern void _symbolic();
extern boolean _eq_symbolic();
extern boolean _ne_symbolic();
extern symbolic _cond_symbolic();
extern char* _symbolic_to_text();
extern int _check_symbolic();
extern void _text_to_symbolic();
extern char* __PredefinedTypeToText();
#define _true 1
#define _false 0
#define __simple_GENERIC_TEST(TEST) return TEST;
typedef (*__simple_APF)();
extern __simple_APF *__simple_PActionArray;
extern int **__simple_PCheckArray;
struct __SourcePoint {
int linkback;
int line;
int column;
int instance_index;
};
struct __InstanceEntry {
char *module_name;
int father_index;
char *dir_name;
char *file_name;
struct __SourcePoint source_point;
struct __SourcePoint end_point;
struct __SourcePoint instance_point;
};
struct __TaskEntry {
char *name;
int   nb_args_ref;
int   nb_args_val;
int  *type_codes_array;
struct __SourcePoint source_point;
};
struct __SignalEntry {
char *name;
int code;
int variable_index;
int present;
struct __SourcePoint source_point;
};
struct __InputEntry {
char *name;
int hash;
char *type_name;
int is_a_sensor;
int type_code;
int multiple;
int signal_index;
int (*p_check_input)();
int (*p_input_function)();
int present;
struct __SourcePoint source_point;
};
struct __ReturnEntry {
char *name;
int hash;
char *type_name;
int type_code;
int signal_index;
int exec_index;
int (*p_check_input)();
int (*p_input_function)();
int present;
struct __SourcePoint source_point;
};
struct __ImplicationEntry {
int master;
int slave;
struct __SourcePoint source_point;
};
struct __ExclusionEntry {
int *exclusion_list;
struct __SourcePoint source_point;
};
struct __VariableEntry {
char *full_name;
char *short_name;
char *type_name;
int type_code;
int comment_kind;
int is_initialized;
char *p_variable;
char *source_name;
int written;
unsigned char written_in_transition;
unsigned char read_in_transition;
struct __SourcePoint source_point;
};
struct __ExecEntry {
int task_index;
int *var_indexes_array;
char **p_values_array;
struct __SourcePoint source_point;
};
struct __HaltEntry {
struct __SourcePoint source_point;
};
struct __NetEntry {
int known;
int value;
int number_of_source_points;
struct __SourcePoint* source_point_array;
};
struct __ModuleEntry {
char *version_id;
char *name;
int number_of_instances;
int number_of_tasks;
int number_of_signals;
int number_of_inputs;
int number_of_returns;
int number_of_sensors;
int number_of_outputs;
int number_of_locals;
int number_of_exceptions;
int number_of_implications;
int number_of_exclusions;
int number_of_variables;
int number_of_execs;
int number_of_halts;
int number_of_nets;
int number_of_states;
int state;
unsigned short *halt_list;
unsigned short *awaited_list;
unsigned short *emitted_list;
unsigned short *started_list;
unsigned short *killed_list;
unsigned short *suspended_list;
unsigned short *active_list;
int run_time_error_code;
int error_info;
int (*init)();
int (*run)();
int (*reset)();
char *(*show_variable)();
int (*set_variable)();
int (*check_value)();
int (*execute_action)();
struct __InstanceEntry* instance_table;
struct __TaskEntry* task_table;
struct __SignalEntry* signal_table;
struct __InputEntry* input_table;
struct __ReturnEntry* return_table;
struct __ImplicationEntry* implication_table;
struct __ExclusionEntry* exclusion_table;
struct __VariableEntry* variable_table;
struct __ExecEntry* exec_table;
struct __HaltEntry* halt_table;
struct __NetEntry* net_table;
};

                  
/* EXTERN DECLARATIONS */

extern int __CheckVariables();
extern __ResetInput();
extern __ResetExecs();
extern __ResetVariables();
extern __ResetVariableStatus();
extern __AppendToList();
extern __ListCopy();
#ifndef _NO_EXTERN_DEFINITIONS
#endif

/* INITIALIZED CONSTANTS */

/* MEMORY ALLOCATION */

static boolean __simple_V0;
static boolean __simple_V1;
static boolean __simple_V2;

static unsigned short __simple_HaltList[4];
static unsigned short __simple_AwaitedList[5];
static unsigned short __simple_EmittedList[5];
static unsigned short __simple_StartedList[1];
static unsigned short __simple_KilledList[1];
static unsigned short __simple_SuspendedList[1];
static unsigned short __simple_ActiveList[1];
static unsigned short __simple_AllAwaitedList[5]={3,0,1,2};


/* INPUT FUNCTIONS */

simple_I_ignition_on () {
__simple_V0 = _true;
}
simple_IS_ignition_on () {
__simple_V0 = _true;
}
simple_I_ignition_off () {
__simple_V1 = _true;
}
simple_IS_ignition_off () {
__simple_V1 = _true;
}
simple_I_accel () {
__simple_V2 = _true;
}
simple_IS_accel () {
__simple_V2 = _true;
}

/* FUNCTIONS RETURNING NUMBER OF EXEC */

int simple_number_of_execs () {
return (0);
}


/* AUTOMATON (STATE ACTION-TREES) */

/* ACTIONS */

/* PREDEFINED ACTIONS */

/* PRESENT SIGNAL TESTS */

static int __simple_A1 () {
__simple_GENERIC_TEST(__simple_V0);
}
static int __simple_Check1 [] = {1,0,0};
static int __simple_A2 () {
__simple_GENERIC_TEST(__simple_V1);
}
static int __simple_Check2 [] = {1,0,0};
static int __simple_A3 () {
__simple_GENERIC_TEST(__simple_V2);
}
static int __simple_Check3 [] = {1,0,0};

/* OUTPUT ACTIONS */

static int __simple_A4 () {
#ifdef __OUTPUT
simple_O_control_throttle();
#endif
__AppendToList(__simple_EmittedList,3);
return 0;
}
static int __simple_Check4 [] = {1,0,0};

/* ASSIGNMENTS */

/* PROCEDURE CALLS */

/* CONDITIONS */

/* DECREMENTS */

/* START ACTIONS */

/* KILL ACTIONS */

/* SUSPEND ACTIONS */

/* ACTIVATE ACTIONS */

/* WRITE ARGS ACTIONS */

/* RESET ACTIONS */

/* ACTION SEQUENCES */


static int *__simple_CheckArray[] = {
0,__simple_Check1,__simple_Check2,__simple_Check3,__simple_Check4
};
static int **__simple_PCheckArray =  __simple_CheckArray;

/* INIT FUNCTION */

#ifndef NO_INIT
simple_initialize () {
}
#endif

/* SHOW VARIABLE FUNCTION */

char* __simple_show_variable (__V) int __V; {
extern struct __VariableEntry __simple_VariableTable[];
struct __VariableEntry* p_var = &__simple_VariableTable[__V];
if (p_var->type_code < 0) {return __PredefinedTypeToText(p_var->type_code, p_var->p_variable);
} else {
switch (p_var->type_code) {
default: return 0;
}
}
}

/* SET VARIABLE FUNCTION */

static __simple_set_variable(__Type, __pVar, __Text)
int __Type; char* __pVar; char* __Text; {
}

/* CHECK VALUE FUNCTION */

static int __simple_check_value (__Type,__Text) 
int __Type; char* __Text; {
}

/* SIMULATION TABLES */

struct __InstanceEntry __simple_InstanceTable [] = {
{"simple",0,"","auto.strl",{1,31,1,0},{1,51,1,0},{0,0,0,0}},
};

struct __SignalEntry __simple_SignalTable [] = {
{"ignition_on",33,0,0,{1,33,7,0}},
{"ignition_off",33,0,0,{1,33,19,0}},
{"accel",33,0,0,{1,33,32,0}},
{"control_throttle",34,0,0,{1,35,8,0}}};

struct __InputEntry __simple_InputTable [] = {
{"ignition_on",70,0,0,-1,0,0,0,simple_IS_ignition_on,0,{1,33,7,0}},
{"ignition_off",63,0,0,-1,0,1,0,simple_IS_ignition_off,0,{1,33,19,0}},
{"accel",100,0,0,-1,0,2,0,simple_IS_accel,0,{1,33,32,0}}};

struct __VariableEntry __simple_VariableTable [] = {
{"__simple_V0","V0","boolean",-2,2,0,(char*)&__simple_V0,"ignition_on",0,0,0,{1,33,7,0}},
{"__simple_V1","V1","boolean",-2,2,0,(char*)&__simple_V1,"ignition_off",0,0,0,{1,33,19,0}},
{"__simple_V2","V2","boolean",-2,2,0,(char*)&__simple_V2,"accel",0,0,0,{1,33,32,0}}
};

struct __HaltEntry __simple_HaltTable [] = {
{{1,51,1,0}},
{{1,41,6,0}},
{{1,42,13,0}}
};


static __simple__reset_input () {
__simple_V0 = _false;
__simple_V1 = _false;
__simple_V2 = _false;
}


/* MODULE DATA FOR SIMULATION */

int simple();
int simple_reset();

static struct __ModuleEntry __simple_ModuleData = {
"Simulation interface release 4","simple",
1,0,4,3,0,0,1,0,0,0,0,3,0,3,0,0,0,
__simple_HaltList,
__simple_AwaitedList,
__simple_EmittedList,
__simple_StartedList,
__simple_KilledList,
__simple_SuspendedList,
__simple_ActiveList,
0,0,
simple_initialize,simple,simple_reset,
__simple_show_variable,__simple_set_variable,__simple_check_value,0,
__simple_InstanceTable,
0,
__simple_SignalTable,__simple_InputTable,0,
0,0,
__simple_VariableTable,
0,
__simple_HaltTable,
0};

/* REDEFINABLE BIT TYPE */

#ifndef __SSC_BIT_TYPE_DEFINED
typedef char __SSC_BIT_TYPE;
#endif

/* REGISTER VARIABLES */

static __SSC_BIT_TYPE __simple_R[3] = {_true,_false,_false};

/* AUTOMATON ENGINE */

int simple () {
/* AUXILIARY VARIABLES */

static __SSC_BIT_TYPE E[5];

__simple_ModuleData.awaited_list = __simple_AwaitedList;
__ResetModuleEntryBeforeReaction();
E[0] = (__simple_R[1]||__simple_R[2]);
E[1] = (E[0]&&!((__CheckVariables(__simple_CheckArray[2]),
#ifdef TRACE_ACTION
fprintf(stderr, "test 2\n"),
#endif
__simple_A2())));
E[2] = (__simple_R[2]&&E[1]);
E[3] = (E[2]&&(__CheckVariables(__simple_CheckArray[3]),
#ifdef TRACE_ACTION
fprintf(stderr, "test 3\n"),
#endif
__simple_A3()));
if (E[3]) {
__AppendToList(__simple_EmittedList,3);
}
if (E[3]) {
__CheckVariables(__simple_CheckArray[4]);__simple_A4();
#ifdef TRACE_ACTION
fprintf(stderr, "__abc_A4\n");
#endif
}
E[4] = !(_true);
E[1] = (__simple_R[1]&&E[1]);
__simple_R[1] = ((__simple_R[0]||((((E[1]&&!((__CheckVariables(__simple_CheckArray[1]),
#ifdef TRACE_ACTION
fprintf(stderr, "test 1\n"),
#endif
__simple_A1()))))&&__simple_R[1])))||((E[0]&&(__CheckVariables(__simple_CheckArray[2]),
#ifdef TRACE_ACTION
fprintf(stderr, "test 2\n"),
#endif
__simple_A2()))));
__simple_R[2] = ((((E[1]&&(__CheckVariables(__simple_CheckArray[1]),
#ifdef TRACE_ACTION
fprintf(stderr, "test 1\n"),
#endif
__simple_A1())))||((((E[2]&&!((__CheckVariables(__simple_CheckArray[3]),
#ifdef TRACE_ACTION
fprintf(stderr, "test 3\n"),
#endif
__simple_A3()))))&&__simple_R[2])))||E[3]);
E[2] = (__simple_R[1]||__simple_R[2]);
__simple_R[0] = !(_true);
if (__simple_R[1]) { __AppendToList(__simple_HaltList,1); }
if (__simple_R[2]) { __AppendToList(__simple_HaltList,2); }
if (!E[2]) { __AppendToList(__simple_HaltList,0); }
__ResetModuleEntryAfterReaction();
__simple_ModuleData.awaited_list = __simple_AllAwaitedList;
__simple__reset_input();
return E[2];
}

/* AUTOMATON RESET */

int simple_reset () {
__simple_ModuleData.awaited_list = __simple_AwaitedList;
__ResetModuleEntry();
__simple_ModuleData.awaited_list = __simple_AllAwaitedList;
__simple_ModuleData.state = 0;
__simple_R[0] = _true;
__simple_R[1] = _false;
__simple_R[2] = _false;
__simple__reset_input();
return 0;
}
char* CompilationType = "Compiled Sorted Equations";

int __NumberOfModules = 1;
struct __ModuleEntry* __ModuleTable[] = {
&__simple_ModuleData
};
