//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Automatic generated C-code by the application: // FSM Editor v0.5r8 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Methodology: Switch-case state. [v1.2r2] //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Exported function: void f_arg(void); //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Initialization proposed by the user (Start). // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #include "mapa_bit.h" #include "tipos.h" // Tiempo de espera para entrar en el modo impulsional y Tiempo de seguridad #define TIMEms(t) ((t)/5) #define DELAYms(t) (arg_DELAY_MAX - TIMEms((t))) #define arg_DELAY_MAX TIMEms(10000) // 10s #define arg_tmrStart() {arg_timer = arg_DELAY_MAX;} #define arg_T_Impuls DELAYms(400) #define arg_T_Pulse DELAYms(30) #define arg_T_Protec 0 // DELAYms(arg_DELAY_MAX) #define arg_tmrEnd(t) (arg_timer <= (t)) #define arg_tmrStep() {if(arg_timer > 0){ arg_timer--;}} // Variables del módulo static tipoTimer16 arg_timer; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Initialization proposed by the user (End). //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Automatic initialization (Start). // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // States index. #define i_ESPERANDO 0 #define i_ABRE_MANUAL 1 #define i_ABREIMPULSMAN 2 #define i_PARADEABRIR_A 3 #define i_ABREIMPGRAND 4 #define i_PARADEABRIR_B 5 #define i_ABREIMPSERIAL 6 #define i_PULSGAC 7 #define i_INITGAC 8 #define i_CIERRAMANUAL 9 #define i_PARADECERRAR 10 // Index variable. static unsigned char ind_f_arg = i_ESPERANDO; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Automatic initialization (End). //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // FSM dispatcher function to be called by the O.S. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void f_arg(void) { // User actions to be executed before analyse the state. // Preprocesos bl.ARG_O = bi.PR_ARG_O || (bi.PL_ARG_O && bi.I_CONDA && (!bi.PR_ARG_F)); bl.ARG_F = bi.PR_ARG_F || (bi.PL_ARG_F && bi.I_CONDA && (!bi.PR_ARG_O)); // Avanza el reloj arg_tmrStep(); // Next state analyser. switch(ind_f_arg){ case i_ESPERANDO: // State actions (Moore). bo.M_ARG_O= 0; bo.M_ARG_F= 0; arg_tmrStart(); // Next state selection. if(bl.ARG_O){ // [1]. // Pointing to the next state. ind_f_arg = i_ABRE_MANUAL; }else if(bm.ARG_GRA_O){ // [2]. // Transition actions (Meally). bo.M_ARG_O= 1; // Pointing to the next state. ind_f_arg = i_ABREIMPGRAND; }else if(bl.ARG_F){ // [3]. // Transition actions (Meally). bo.M_ARG_F= 1; // Pointing to the next state. ind_f_arg = i_CIERRAMANUAL; }else if(bm.ARG_GRA_F){ // [4]. // Transition actions (Meally). bo.M_ARG_F= 1; // Pointing to the next state. ind_f_arg = i_PULSGAC; }else if(bm.S_ARG_O){ // [5]. // Transition actions (Meally). bo.M_ARG_O= 1; // Pointing to the next state. ind_f_arg = i_ABREIMPSERIAL; } break; case i_ABRE_MANUAL: // Next state selection. if(bi.A_ARG_END || arg_tmrEnd(arg_T_Protec)){ // [1]. // Pointing to the next state. ind_f_arg = i_PARADEABRIR_A; }else if(bl.ARG_O){ // [2]. }else if(arg_tmrEnd(arg_T_Impuls)){ // [3]. // Pointing to the next state. ind_f_arg = i_ABREIMPULSMAN; }else { // [4]. // Transition actions (Meally). bo.M_ARG_O = 0; // Pointing to the next state. ind_f_arg = i_ESPERANDO; } break; case i_ABREIMPULSMAN: // Next state selection. if(bl.ARG_O || bi.A_ARG_END || bm.ARG_GRA_F || bl.ARG_F || arg_tmrEnd(arg_T_Protec)){ // [1]. // Pointing to the next state. ind_f_arg = i_PARADEABRIR_A; }else if(bm.ARG_GRA_O){ // [2]. // Pointing to the next state. ind_f_arg = i_ABREIMPGRAND; } break; case i_PARADEABRIR_A: // State actions (Moore). bo.M_ARG_O= 0; bm.ARG_GRA_O= 0; // Next state selection. if(!bi.PR_ARG_O && !bi.PR_ARG_F){ // Pointing to the next state. ind_f_arg = i_PARADEABRIR_B; } break; case i_ABREIMPGRAND: // Next state selection. if(!bm.ARG_GRA_O || bl.ARG_O || bi.A_ARG_END || bl.ARG_F || arg_tmrEnd(arg_T_Protec)){ // Pointing to the next state. ind_f_arg = i_PARADEABRIR_A; } break; case i_PARADEABRIR_B: // Next state selection. if((!bl.ARG_O && !bl.ARG_F)|| bi.PR_ARG_O || bi.PR_ARG_F){ // Pointing to the next state. ind_f_arg = i_ESPERANDO; } break; case i_ABREIMPSERIAL: // Next state selection. if(bl.ARG_O || bl.ARG_F || bi.A_ARG_END || arg_tmrEnd(arg_T_Protec)){ // Transition actions (Meally). bm.ARG_GRA_F= 0; bm.S_ARG_O= 0; // Pointing to the next state. ind_f_arg = i_PARADEABRIR_A; } break; case i_PULSGAC: // Next state selection. if(arg_tmrEnd(arg_T_Pulse)){ // Transition actions (Meally). bo.M_ARG_F= 0; // Pointing to the next state. ind_f_arg = i_INITGAC; } break; case i_INITGAC: // Next state selection. if(!bm.ARG_GRA_F){ // [1]. // Pointing to the next state. ind_f_arg = i_ESPERANDO; }else if(arg_tmrEnd(arg_T_Impuls)){ // [2]. // Transition actions (Meally). bo.M_ARG_F= 1; // Pointing to the next state. ind_f_arg = i_CIERRAMANUAL; } break; case i_CIERRAMANUAL: // Next state selection. if(bi.A_ARG_END || arg_tmrEnd(arg_T_Protec)|| (!bl.ARG_F && !bm.ARG_GRA_F)){ // Pointing to the next state. ind_f_arg = i_PARADECERRAR; } break; case i_PARADECERRAR: // State actions (Moore). bo.M_ARG_F= 0; bm.ARG_GRA_F= 0; // Next state selection. if(!bl.ARG_F){ // Pointing to the next state. ind_f_arg = i_ESPERANDO; } break; } } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // End of the automatic generated C-code. //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++