 | Code: /* sscc : C CODE OF SORTED EQUATIONS lego1 - 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)(); void (*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(boolean*, boolean); extern boolean _eq_boolean(boolean, boolean); extern boolean _ne_boolean(boolean, boolean); extern boolean _cond_boolean(boolean ,boolean ,boolean); extern char* _boolean_to_text(boolean); extern int _check_boolean(char*); extern void _text_to_boolean(boolean*, char*); extern void _integer(integer*, integer); extern boolean _eq_integer(integer, integer); extern boolean _ne_integer(integer, integer); extern integer _cond_integer(boolean ,integer ,integer); extern char* _integer_to_text(integer); extern int _check_integer(char*); extern void _text_to_integer(integer*, char*); extern void _string(string, string); extern boolean _eq_string(string, string); extern boolean _ne_string(string, string); extern string _cond_string(boolean ,string ,string); extern char* _string_to_text(string); extern int _check_string(char*); extern void _text_to_string(string, char*); extern void _float(float*, float); extern boolean _eq_float(float, float); extern boolean _ne_float(float, float); extern float _cond_float(boolean ,float ,float); extern char* _float_to_text(float); extern int _check_float(char*); extern void _text_to_float(float*, char*); extern void _double(double*, double); extern boolean _eq_double(double, double); extern boolean _ne_double(double, double); extern double _cond_double(boolean ,double ,double); extern char* _double_to_text(double); extern int _check_double(char*); extern void _text_to_double(double*, char*); extern void _symbolic(symbolic*, symbolic); extern boolean _eq_symbolic(symbolic, symbolic); extern boolean _ne_symbolic(symbolic, symbolic); extern symbolic _cond_symbolic(boolean ,symbolic ,symbolic); extern char* _symbolic_to_text(symbolic); extern int _check_symbolic(char*); extern void _text_to_symbolic(symbolic*, char*); extern char* __PredefinedTypeToText(int, char*); #define _true 1 #define _false 0 #define __lego1_GENERIC_TEST(TEST) return TEST; typedef void (*__lego1_APF)(); static __lego1_APF *__lego1_PActionArray; static int **__lego1_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; int number_of_emit_source_points; struct __SourcePoint* emit_source_point_array; int number_of_present_source_points; struct __SourcePoint* present_source_point_array; int number_of_access_source_points; struct __SourcePoint* access_source_point_array; }; 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)(char*); void (*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)(char*); void (*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; void (*init)(); int (*run)(); int (*reset)(); char *(*show_variable)(int); void (*set_variable)(int, char*, char*); int (*check_value)(int, char*); 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; };
#include "example2.h"
/* EXTERN DECLARATIONS */
extern int __CheckVariables(int*); extern void __ResetInput(); extern void __ResetExecs(); extern void __ResetVariables(); extern void __ResetVariableStatus(); extern void __AppendToList(unsigned short*, unsigned short); extern void __ListCopy(unsigned short*, unsigned short**); extern void __WriteVariable(int); extern void __ResetVariable(int); extern void __ResetModuleEntry(); extern void __ResetModuleEntryBeforeReaction(); extern void __ResetModuleEntryAfterReaction(); #ifndef _NO_EXTERN_DEFINITIONS #ifndef _NO_CONSTANT_DEFINITIONS #ifndef _MOTOR_FWD_DEFINED #ifndef MOTOR_FWD extern integer MOTOR_FWD; #endif #endif #ifndef _MOTOR_REV_DEFINED #ifndef MOTOR_REV extern integer MOTOR_REV; #endif #endif #ifndef _MAX_SPEED_DEFINED #ifndef MAX_SPEED extern integer MAX_SPEED; #endif #endif #endif #endif
/* INITIALIZED CONSTANTS */
/* MEMORY ALLOCATION */
static boolean __lego1_V0; static boolean __lego1_V1; static integer __lego1_V2; static integer __lego1_V3; static integer __lego1_V4; static integer __lego1_V5; static char __lego1_V6[STRLEN]; static integer __lego1_V7;
static unsigned short __lego1_HaltList[2]; static unsigned short __lego1_AwaitedList[8]; static unsigned short __lego1_EmittedList[8]; static unsigned short __lego1_StartedList[1]; static unsigned short __lego1_KilledList[1]; static unsigned short __lego1_SuspendedList[1]; static unsigned short __lego1_ActiveList[1]; static unsigned short __lego1_AllAwaitedList[8]={2,0,1};
/* INPUT FUNCTIONS */
void lego1_I_TOUCH_1 () { __lego1_V0 = _true; } void lego1_IS_TOUCH_1 () { __lego1_V0 = _true; } void lego1_I_TOUCH_3 () { __lego1_V1 = _true; } void lego1_IS_TOUCH_3 () { __lego1_V1 = _true; }
/* FUNCTIONS RETURNING NUMBER OF EXEC */
int lego1_number_of_execs () { return (0); }
/* AUTOMATON (STATE ACTION-TREES) */
/* ACTIONS */
/* PREDEFINED ACTIONS */
/* PRESENT SIGNAL TESTS */
static int __lego1_A1 () { __lego1_GENERIC_TEST(__lego1_V0); } static int __lego1_Check1 [] = {1,0,0}; static int __lego1_A2 () { __lego1_GENERIC_TEST(__lego1_V1); } static int __lego1_Check2 [] = {1,0,0};
/* OUTPUT ACTIONS */
static void __lego1_A3 () { #ifdef __OUTPUT lego1_O_MOTOR_A_SPEED(__lego1_V2); #endif __AppendToList(__lego1_EmittedList,2); } static int __lego1_Check3 [] = {1,0,0}; static void __lego1_A4 () { #ifdef __OUTPUT lego1_O_MOTOR_C_SPEED(__lego1_V3); #endif __AppendToList(__lego1_EmittedList,3); } static int __lego1_Check4 [] = {1,0,0}; static void __lego1_A5 () { #ifdef __OUTPUT lego1_O_MOTOR_A_DIR(__lego1_V4); #endif __AppendToList(__lego1_EmittedList,4); } static int __lego1_Check5 [] = {1,0,0}; static void __lego1_A6 () { #ifdef __OUTPUT lego1_O_MOTOR_C_DIR(__lego1_V5); #endif __AppendToList(__lego1_EmittedList,5); } static int __lego1_Check6 [] = {1,0,0}; static void __lego1_A7 () { #ifdef __OUTPUT lego1_O_CPUTS(__lego1_V6); #endif __AppendToList(__lego1_EmittedList,6); } static int __lego1_Check7 [] = {1,0,0};
/* ASSIGNMENTS */
static void __lego1_A8 () { __lego1_V0 = _false; } static int __lego1_Check8 [] = {1,0,1,0}; static void __lego1_A9 () { __lego1_V1 = _false; } static int __lego1_Check9 [] = {1,0,1,1}; static void __lego1_A10 () { __lego1_V2 = MAX_SPEED/2; } static int __lego1_Check10 [] = {1,0,1,2}; static void __lego1_A11 () { __lego1_V3 = MAX_SPEED/2; } static int __lego1_Check11 [] = {1,0,1,3};
/* PROCEDURE CALLS */
/* CONDITIONS */
/* DECREMENTS */
/* START ACTIONS */
/* KILL ACTIONS */
/* SUSPEND ACTIONS */
/* ACTIVATE ACTIONS */
/* WRITE ARGS ACTIONS */
/* RESET ACTIONS */
static void __lego1_A12 () { ; __ResetVariable(2); } static int __lego1_Check12 [] = {1,0,0}; static void __lego1_A13 () { ; __ResetVariable(3); } static int __lego1_Check13 [] = {1,0,0}; static void __lego1_A14 () { ; __ResetVariable(4); } static int __lego1_Check14 [] = {1,0,0}; static void __lego1_A15 () { ; __ResetVariable(5); } static int __lego1_Check15 [] = {1,0,0}; static void __lego1_A16 () { ; __ResetVariable(6); } static int __lego1_Check16 [] = {1,0,0}; static void __lego1_A17 () { ; __ResetVariable(7); } static int __lego1_Check17 [] = {1,0,0};
/* ACTION SEQUENCES */
static int *__lego1_CheckArray[] = { 0, __lego1_Check1, __lego1_Check2, __lego1_Check3, __lego1_Check4, __lego1_Check5, __lego1_Check6, __lego1_Check7, __lego1_Check8, __lego1_Check9, __lego1_Check10, __lego1_Check11, __lego1_Check12, __lego1_Check13, __lego1_Check14, __lego1_Check15, __lego1_Check16, __lego1_Check17 }; static int **__lego1_PCheckArray = __lego1_CheckArray;
/* INIT FUNCTION */
#ifndef NO_INIT void lego1_initialize () { } #endif
/* SHOW VARIABLE FUNCTION */
char* __lego1_show_variable (int __V) { extern struct __VariableEntry __lego1_VariableTable[]; struct __VariableEntry* p_var = &__lego1_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 void __lego1_set_variable(int __Type, char* __pVar, char* __Text) { }
/* CHECK VALUE FUNCTION */
static int __lego1_check_value (int __Type, char* __Text) { return 0; }
/* SIMULATION TABLES */
struct __InstanceEntry __lego1_InstanceTable [] = { {"lego1",0,".","example2.strl",{1,1,2,0},{1,13,8,0},{0,0,0,0}}, };
struct __SignalEntry __lego1_SignalTable [] = { {"TOUCH_1",33,0,0,{1,2,7,0},0,(void*) NULL,0,(void*) NULL,0,(void*) NULL}, {"TOUCH_3",33,0,0,{1,2,16,0},0,(void*) NULL,0,(void*) NULL,0,(void*) NULL}, {"MOTOR_A_SPEED",2,2,0,{1,3,8,0},0,(void*) NULL,0,(void*) NULL,0,(void*) NULL}, {"MOTOR_C_SPEED",2,3,0,{1,3,32,0},0,(void*) NULL,0,(void*) NULL,0,(void*) NULL}, {"MOTOR_A_DIR",2,4,0,{1,4,8,0},0,(void*) NULL,0,(void*) NULL,0,(void*) NULL}, {"MOTOR_C_DIR",2,5,0,{1,4,30,0},0,(void*) NULL,0,(void*) NULL,0,(void*) NULL}, {"CPUTS",2,6,0,{1,5,8,0},0,(void*) NULL,0,(void*) NULL,0,(void*) NULL}};
struct __InputEntry __lego1_InputTable [] = { {"TOUCH_1",26,0,0,-1,0,0,0,lego1_IS_TOUCH_1,0,{1,2,7,0}}, {"TOUCH_3",28,0,0,-1,0,1,0,lego1_IS_TOUCH_3,0,{1,2,16,0}}};
static int __lego1_ExclusionEntry0[] = {2,0,1};
struct __ExclusionEntry __lego1_ExclusionTable [] = { {__lego1_ExclusionEntry0,{1,6,10,0}} };
struct __VariableEntry __lego1_VariableTable [] = { {"__lego1_V0","V0","boolean",-2,2,0,(char*)&__lego1_V0,"TOUCH_1",0,0,0,{1,2,7,0}}, {"__lego1_V1","V1","boolean",-2,2,0,(char*)&__lego1_V1,"TOUCH_3",0,0,0,{1,2,16,0}}, {"__lego1_V2","V2","integer",-3,1,0,(char*)&__lego1_V2,"MOTOR_A_SPEED",0,0,0,{1,3,8,0}}, {"__lego1_V3","V3","integer",-3,1,0,(char*)&__lego1_V3,"MOTOR_C_SPEED",0,0,0,{1,3,32,0}}, {"__lego1_V4","V4","integer",-3,1,0,(char*)&__lego1_V4,"MOTOR_A_DIR",0,0,0,{1,4,8,0}}, {"__lego1_V5","V5","integer",-3,1,0,(char*)&__lego1_V5,"MOTOR_C_DIR",0,0,0,{1,4,30,0}}, {"__lego1_V6","V6","string",-4,1,0,__lego1_V6,"CPUTS",0,0,0,{1,5,8,0}}, {"__lego1_V7","V7","integer",-3,0,0,(char*)&__lego1_V7,"t",0,0,0,{1,9,5,0}} };
struct __HaltEntry __lego1_HaltTable [] = { {{1,13,8,0}} };
static void __lego1__reset_input () { __lego1_V0 = _false; __lego1_V1 = _false; }
/* MODULE DATA FOR SIMULATION */
int lego1(); int lego1_reset();
static struct __ModuleEntry __lego1_ModuleData = { "Simulation interface release 5","lego1", 1,0,7,2,0,0,5,0,0,0,1,8,0,1,0,0,0, __lego1_HaltList, __lego1_AwaitedList, __lego1_EmittedList, __lego1_StartedList, __lego1_KilledList, __lego1_SuspendedList, __lego1_ActiveList, 0,0, lego1_initialize,lego1,lego1_reset, __lego1_show_variable,__lego1_set_variable,__lego1_check_value,0, __lego1_InstanceTable, 0, __lego1_SignalTable,__lego1_InputTable,0, 0,__lego1_ExclusionTable, __lego1_VariableTable, 0, __lego1_HaltTable, 0};
/* REDEFINABLE BIT TYPE */
#ifndef __SSC_BIT_TYPE_DEFINED typedef char __SSC_BIT_TYPE; #endif
/* REGISTER VARIABLES */
static __SSC_BIT_TYPE __lego1_R[1] = {_true};
/* AUTOMATON ENGINE */
int lego1 () { /* AUXILIARY VARIABLES */
static __SSC_BIT_TYPE E[2];
__lego1_ModuleData.awaited_list = __lego1_AwaitedList; __ResetModuleEntryBeforeReaction(); if (__lego1_R[0]) { __AppendToList(__lego1_EmittedList,2); __AppendToList(__lego1_EmittedList,3); } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[12]);__lego1_A12(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A12\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[13]);__lego1_A13(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A13\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[14]);__lego1_A14(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A14\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[15]);__lego1_A15(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A15\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[16]);__lego1_A16(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A16\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[17]);__lego1_A17(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A17\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[10]);__lego1_A10(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A10\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[3]);__lego1_A3(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A3\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[11]);__lego1_A11(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A11\n"); #endif } if (__lego1_R[0]) { __CheckVariables(__lego1_CheckArray[4]);__lego1_A4(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A4\n"); #endif } if (!(_true)) { __CheckVariables(__lego1_CheckArray[5]);__lego1_A5(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A5\n"); #endif } if (!(_true)) { __CheckVariables(__lego1_CheckArray[6]);__lego1_A6(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A6\n"); #endif } if (!(_true)) { __CheckVariables(__lego1_CheckArray[7]);__lego1_A7(); #ifdef TRACE_ACTION fprintf(stderr, "__lego1_A7\n"); #endif } E[0] = __lego1_R[0]; E[1] = !(_true); __lego1_R[0] = !(_true); if (!E[1]) { __AppendToList(__lego1_HaltList,0); } __ResetModuleEntryAfterReaction(); __lego1_ModuleData.awaited_list = __lego1_AllAwaitedList; __lego1__reset_input(); return E[1]; }
/* AUTOMATON RESET */
int lego1_reset () { __lego1_ModuleData.awaited_list = __lego1_AwaitedList; __ResetModuleEntry(); __lego1_ModuleData.awaited_list = __lego1_AllAwaitedList; __lego1_ModuleData.state = 0; __lego1_R[0] = _true; __lego1__reset_input(); return 0; } char* CompilationType = "Compiled Sorted Equations";
int __NumberOfModules = 1; struct __ModuleEntry* __ModuleTable[] = { &__lego1_ModuleData };
|  |