stage4/generate_cc/generate_cc_sfc.cc
changeset 17 38754701ac41
child 18 e6af5eb5f546
equal deleted inserted replaced
16:e8b99f896416 17:38754701ac41
       
     1 /*
       
     2  * (c) 2007 Mario de Sousa, Laurent Bessard
       
     3  *
       
     4  * Offered to the public under the terms of the GNU General Public License
       
     5  * as published by the Free Software Foundation; either version 2 of the
       
     6  * License, or (at your option) any later version.
       
     7  *
       
     8  * This program is distributed in the hope that it will be useful, but
       
     9  * WITHOUT ANY WARRANTY; without even the implied warranty of
       
    10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
       
    11  * Public License for more details.
       
    12  *
       
    13  * This code is made available on the understanding that it will not be
       
    14  * used in safety-critical situations without a full and competent review.
       
    15  */
       
    16 
       
    17 /*
       
    18  * An IEC 61131-3 IL and ST compiler.
       
    19  *
       
    20  * Based on the
       
    21  * FINAL DRAFT - IEC 61131-3, 2nd Ed. (2001-12-10)
       
    22  *
       
    23  */
       
    24 
       
    25 
       
    26 /*
       
    27  * Conversion of sfc networks (i.e. SFC code).
       
    28  *
       
    29  * This is part of the 4th stage that generates
       
    30  * a c++ source program equivalent to the SFC, IL and ST
       
    31  * code.
       
    32  */
       
    33 
       
    34 
       
    35 
       
    36 /***********************************************************************/
       
    37 /***********************************************************************/
       
    38 /***********************************************************************/
       
    39 /***********************************************************************/
       
    40 
       
    41 class generate_cc_sfc_transitiontest_c: public generate_cc_base_c {
       
    42   
       
    43   private:
       
    44     generate_cc_il_c *generate_cc_il;
       
    45     generate_cc_st_c *generate_cc_st;
       
    46     
       
    47   public:
       
    48     generate_cc_sfc_transitiontest_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL)
       
    49     : generate_cc_base_c(s4o_ptr) {
       
    50       generate_cc_il = new generate_cc_il_c(s4o_ptr, scope, variable_prefix);
       
    51       generate_cc_st = new generate_cc_st_c(s4o_ptr, scope, variable_prefix);
       
    52       this->set_variable_prefix(variable_prefix);
       
    53     }
       
    54     
       
    55     ~generate_cc_sfc_transitiontest_c(void) {
       
    56       delete generate_cc_il;
       
    57       delete generate_cc_st;
       
    58     }
       
    59 
       
    60     void print_step_argument(symbol_c *step_name, const char* argument) {
       
    61       print_variable_prefix();
       
    62       s4o.print("step_list[");
       
    63       step_name->accept(*this);
       
    64       s4o.print("].");
       
    65       s4o.print(argument);
       
    66     }
       
    67     
       
    68     void print_reset_step(symbol_c *step_name) {
       
    69       s4o.print(s4o.indent_spaces);
       
    70       print_step_argument(step_name, "state");
       
    71       s4o.print(" = 0;\n" + s4o.indent_spaces + "if (");
       
    72       print_step_argument(step_name, "pulse");
       
    73       s4o.print(" != 1 {\n");
       
    74       s4o.indent_right();
       
    75       s4o.print(s4o.indent_spaces);
       
    76       print_step_argument(step_name, "pulse");
       
    77       s4o.print(" = 2;\n");
       
    78       s4o.indent_left();
       
    79       s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces + "else {\n");
       
    80       s4o.indent_right();
       
    81       s4o.print(s4o.indent_spaces);
       
    82       print_step_argument(step_name, "pulse");
       
    83       s4o.print(" = 0;\n");
       
    84       s4o.indent_left();
       
    85       s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces);
       
    86       print_step_argument(step_name, "elapsed_time");
       
    87       s4o.print(" = __time_to_timespec(1, 0, 0, 0, 0, 0);");
       
    88     }
       
    89     
       
    90     void print_set_step(symbol_c *step_name) {
       
    91       s4o.print(s4o.indent_spaces);
       
    92       print_step_argument(step_name, "state");
       
    93       s4o.print(" = 1;\n" + s4o.indent_spaces);
       
    94       print_step_argument(step_name, "pulse");
       
    95       s4o.print(" = 1;");
       
    96     } 
       
    97     
       
    98     void print_steps_state_test(steps_c *symbol) {
       
    99       if (symbol->step_name != NULL) {
       
   100         print_step_argument(symbol->step_name, "state");
       
   101       }
       
   102       if (symbol->step_name_list != NULL) {
       
   103         for(int i = 0; i < ((list_c*)symbol->step_name_list)->n; i++) {
       
   104           print_step_argument(((list_c*)symbol->step_name_list)->elements[i], "state");
       
   105           if (i < ((list_c*)symbol->step_name_list)->n - 1) {
       
   106             s4o.print(" && ");
       
   107           }
       
   108         }
       
   109       }
       
   110     }
       
   111       
       
   112     void print_reset_steps(steps_c *symbol) {
       
   113       if (symbol->step_name != NULL) {
       
   114         print_reset_step(symbol->step_name);
       
   115         s4o.print("\n");
       
   116       }
       
   117       if (symbol->step_name_list != NULL) {
       
   118         for(int i = 0; i < ((list_c*)symbol->step_name_list)->n; i++) {
       
   119           print_reset_step(((list_c*)symbol->step_name_list)->elements[i]);
       
   120           s4o.print("\n");
       
   121         }
       
   122       }
       
   123     }
       
   124 
       
   125     void print_set_steps(steps_c *symbol) {
       
   126       if (symbol->step_name != NULL) {
       
   127         print_set_step(symbol->step_name);
       
   128         s4o.print("\n");
       
   129       }
       
   130       if (symbol->step_name_list != NULL) {
       
   131         for(int i = 0; i < ((list_c*)symbol->step_name_list)->n; i++) {
       
   132           print_set_step(((list_c*)symbol->step_name_list)->elements[i]);
       
   133           s4o.print("\n");
       
   134         }
       
   135       }
       
   136     }
       
   137 
       
   138 /*********************************************/
       
   139 /* B.1.6  Sequential function chart elements */
       
   140 /*********************************************/
       
   141     
       
   142     void *visit(initial_step_c *symbol) {return NULL;}
       
   143     
       
   144     void *visit(step_c *symbol) {return NULL;}
       
   145 
       
   146     void *visit(transition_c *symbol) {
       
   147       s4o.print(s4o.indent_spaces + "if (");
       
   148       print_steps_state_test((steps_c *)symbol->from_steps);
       
   149       s4o.print(") {\n");
       
   150       s4o.indent_right();
       
   151       
       
   152       // Calculate transition value
       
   153       if (symbol->transition_condition_il != NULL) {
       
   154         generate_cc_il->declare_backup_variable();
       
   155         s4o.print(s4o.indent_spaces);
       
   156         symbol->transition_condition_il->accept(*generate_cc_il);
       
   157         s4o.print("if (");
       
   158         generate_cc_il->print_backup_variable();
       
   159         s4o.print(") {\n");
       
   160       }
       
   161       if (symbol->transition_condition_st != NULL) {
       
   162         s4o.print(s4o.indent_spaces + "if (");
       
   163         symbol->transition_condition_st->accept(*generate_cc_st);
       
   164         s4o.print(") {\n");
       
   165       }
       
   166       
       
   167       s4o.indent_right();      
       
   168       print_reset_steps((steps_c *)symbol->from_steps);
       
   169       print_set_steps((steps_c *)symbol->to_steps);      
       
   170       s4o.indent_left();
       
   171 
       
   172       s4o.print(s4o.indent_spaces + "}\n");
       
   173       s4o.indent_left();
       
   174       s4o.print(s4o.indent_spaces + "}\n\n");
       
   175       return NULL;
       
   176     }
       
   177     
       
   178     void *visit(action_c *symbol) {return NULL;}
       
   179 
       
   180 }; /* generate_cc_sfc_transitiontest_c */
       
   181 
       
   182 
       
   183 
       
   184 
       
   185 /***********************************************************************/
       
   186 /***********************************************************************/
       
   187 /***********************************************************************/
       
   188 /***********************************************************************/
       
   189 
       
   190 class generate_cc_sfc_stepassociation_c: public generate_cc_base_c {
       
   191   
       
   192   private:
       
   193     symbol_c *current_step;
       
   194     symbol_c *current_action;
       
   195   
       
   196   public:
       
   197     generate_cc_sfc_stepassociation_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL)
       
   198     : generate_cc_base_c(s4o_ptr) {
       
   199       this->set_variable_prefix(variable_prefix);
       
   200     }
       
   201 
       
   202     void print_step_argument(symbol_c *step_name, const char* argument) {
       
   203       print_variable_prefix();
       
   204       s4o.print("step_list[");
       
   205       step_name->accept(*this);
       
   206       s4o.print("].");
       
   207       s4o.print(argument);
       
   208     }
       
   209 
       
   210     void print_action_argument(symbol_c *action_name, const char* argument) {
       
   211       print_variable_prefix();
       
   212       s4o.print("action_list[");
       
   213       action_name->accept(*this);
       
   214       s4o.print("].");
       
   215       s4o.print(argument);
       
   216     }
       
   217 
       
   218 /*********************************************/
       
   219 /* B.1.6  Sequential function chart elements */
       
   220 /*********************************************/
       
   221     
       
   222     void *visit(initial_step_c *symbol) {
       
   223       s4o.print(s4o.indent_spaces + "// ");
       
   224       symbol->step_name->accept(*this);
       
   225       s4o.print(" action associations\n");
       
   226       current_step = symbol->step_name;
       
   227       symbol->action_association_list->accept(*this);
       
   228       return NULL;
       
   229     }
       
   230     
       
   231     void *visit(step_c *symbol) {
       
   232       s4o.print(s4o.indent_spaces + "// ");
       
   233       symbol->step_name->accept(*this);
       
   234       s4o.print(" action associations\n");
       
   235       current_step = symbol->step_name;
       
   236       symbol->action_association_list->accept(*this);
       
   237       return NULL;
       
   238     }
       
   239 
       
   240     void *visit(transition_c *symbol) {return NULL;}
       
   241     
       
   242     void *visit(action_c *symbol) {return NULL;}
       
   243 
       
   244     void *visit(action_association_list_c* symbol) {
       
   245       print_list(symbol, "", "\n", "\n\n");
       
   246       return NULL;
       
   247     }
       
   248 
       
   249     void *visit(action_association_c *symbol) {
       
   250       if (symbol->action_qualifier != NULL) {
       
   251         current_action = symbol->action_name;
       
   252         symbol->action_qualifier->accept(*this);
       
   253       }
       
   254       else {
       
   255         s4o.print(s4o.indent_spaces + "if (");
       
   256         print_step_argument(current_step, "state");
       
   257         s4o.print(") {\n");
       
   258         s4o.indent_right();
       
   259         s4o.print(s4o.indent_spaces);
       
   260         print_action_argument(symbol->action_name, "state");
       
   261         s4o.print(" = 1;\n");
       
   262         s4o.indent_left();
       
   263         s4o.print(s4o.indent_spaces + "}");
       
   264       }
       
   265       return NULL;
       
   266     }
       
   267 
       
   268     void *visit(action_qualifier_c *symbol) {
       
   269       char *qualifier = (char *)symbol->action_qualifier->accept(*this);
       
   270       
       
   271       s4o.print(s4o.indent_spaces + "if (");
       
   272       if (strcmp(qualifier, "N") == 0) {
       
   273         print_step_argument(current_step, "state");
       
   274       }
       
   275       if (strcmp(qualifier, "P") == 0 || strcmp(qualifier, "SD") == 0 || 
       
   276           strcmp(qualifier, "DS") == 0 || strcmp(qualifier, "SL") == 0) {
       
   277         print_step_argument(current_step, "pulse");
       
   278         s4o.print(" == 1");
       
   279       }
       
   280       if (strcmp(qualifier, "D") == 0 || strcmp(qualifier, "L") == 0) {
       
   281         print_step_argument(current_step, "state");
       
   282         s4o.print(" && ");
       
   283         print_step_argument(current_step, "elapsed_time");
       
   284         if (strcmp(qualifier, "D") == 0) {
       
   285           s4o.print(" >= ");
       
   286         }
       
   287         else {
       
   288           s4o.print(" < ");
       
   289         }
       
   290         symbol->action_time->accept(*this);  
       
   291       }
       
   292       s4o.print(") {\n");
       
   293       s4o.indent_right();
       
   294       s4o.print(s4o.indent_spaces);
       
   295       if (strcmp(qualifier, "N") == 0 || strcmp(qualifier, "P") == 0 ||
       
   296           strcmp(qualifier, "D") == 0 || strcmp(qualifier, "L") == 0) {
       
   297         print_action_argument(current_action, "state");
       
   298         s4o.print(" = 1;\n");  
       
   299       }
       
   300       if (strcmp(qualifier, "SD") == 0 || strcmp(qualifier, "DS") == 0 || 
       
   301           strcmp(qualifier, "SL") == 0) {
       
   302         if (strcmp(qualifier, "SL") == 0) {
       
   303           print_action_argument(current_action, "reset_remaining_time");  
       
   304         }
       
   305         else {
       
   306           print_action_argument(current_action, "set_remaining_time");
       
   307         }
       
   308         s4o.print(" = ");
       
   309         symbol->action_time->accept(*this);
       
   310         s4o.print(";\n");
       
   311       }
       
   312       s4o.indent_left();
       
   313       s4o.print(s4o.indent_spaces + "}");
       
   314       if (strcmp(qualifier, "DS") == 0) {
       
   315         print_step_argument(current_step, "pulse");
       
   316         s4o.print(" == 2) {\n");
       
   317         s4o.indent_right();
       
   318         s4o.print(s4o.indent_spaces);
       
   319         print_action_argument(current_action, "set_remaining_time");
       
   320         s4o.print(" = __time_to_timespec(1, 0, 0, 0, 0, 0);\n");
       
   321       }
       
   322       return NULL;
       
   323     }
       
   324 
       
   325     void *visit(qualifier_c *symbol) {
       
   326       return (void *)symbol->value;
       
   327     }
       
   328 
       
   329     void *visit(timed_qualifier_c *symbol) {
       
   330       return (void *)symbol->value;
       
   331     }
       
   332 
       
   333 }; /* generate_cc_sfc_actiondecl_c */
       
   334 
       
   335 
       
   336 
       
   337 
       
   338 /***********************************************************************/
       
   339 /***********************************************************************/
       
   340 /***********************************************************************/
       
   341 /***********************************************************************/
       
   342 
       
   343 class generate_cc_sfc_actionexecution_c: public generate_cc_base_c {
       
   344   
       
   345   private:
       
   346     generate_cc_SFC_IL_ST_c *generate_cc_code;
       
   347     
       
   348   public:
       
   349     generate_cc_sfc_actionexecution_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL)
       
   350     : generate_cc_base_c(s4o_ptr) {
       
   351       generate_cc_code = new generate_cc_SFC_IL_ST_c(s4o_ptr, scope, variable_prefix);
       
   352       this->set_variable_prefix(variable_prefix);
       
   353     }
       
   354     
       
   355     ~generate_cc_sfc_actionexecution_c(void) {
       
   356       delete generate_cc_code;
       
   357     }
       
   358 
       
   359 /*********************************************/
       
   360 /* B.1.6  Sequential function chart elements */
       
   361 /*********************************************/
       
   362     
       
   363     void *visit(initial_step_c *symbol) {return NULL;}
       
   364     
       
   365     void *visit(step_c *symbol) {return NULL;}
       
   366 
       
   367     void *visit(transition_c *symbol) {return NULL;}
       
   368     
       
   369     void *visit(action_c *symbol) {
       
   370       s4o.print(s4o.indent_spaces + "if(");
       
   371       print_variable_prefix();
       
   372       s4o.print("action_list[");
       
   373       symbol->action_name->accept(*this);
       
   374       s4o.print("].state) {");
       
   375       s4o.indent_right();
       
   376       
       
   377       // generate action code
       
   378       symbol->function_block_body->accept(*generate_cc_code);
       
   379       
       
   380       s4o.indent_left();
       
   381       s4o.print(s4o.indent_spaces + "}\n\n");
       
   382       return NULL;
       
   383     }
       
   384 
       
   385 }; /* generate_cc_sfc_actiondecl_c */
       
   386  
       
   387  
       
   388  
       
   389 /***********************************************************************/
       
   390 /***********************************************************************/
       
   391 /***********************************************************************/
       
   392 /***********************************************************************/
       
   393 
       
   394 class generate_cc_sfc_c: public generate_cc_typedecl_c {
       
   395   
       
   396   private:
       
   397     generate_cc_sfc_transitiontest_c *generate_cc_sfc_transitiontest;
       
   398     generate_cc_sfc_stepassociation_c *generate_cc_sfc_stepassociation;
       
   399     generate_cc_sfc_actionexecution_c *generate_cc_sfc_actionexecution;
       
   400   
       
   401   public:
       
   402     generate_cc_sfc_c(stage4out_c *s4o_ptr, symbol_c *scope, const char *variable_prefix = NULL)
       
   403     : generate_cc_typedecl_c(s4o_ptr) {
       
   404       generate_cc_sfc_transitiontest = new generate_cc_sfc_transitiontest_c(s4o_ptr, scope, variable_prefix);
       
   405       generate_cc_sfc_stepassociation = new generate_cc_sfc_stepassociation_c(s4o_ptr, scope, variable_prefix);
       
   406       generate_cc_sfc_actionexecution = new generate_cc_sfc_actionexecution_c(s4o_ptr, scope, variable_prefix);
       
   407       this->set_variable_prefix(variable_prefix);
       
   408     }
       
   409   
       
   410     virtual ~generate_cc_sfc_c(void) {
       
   411       delete generate_cc_sfc_transitiontest;
       
   412       delete generate_cc_sfc_stepassociation;
       
   413       delete generate_cc_sfc_actionexecution;
       
   414     }
       
   415 
       
   416 /*********************************************/
       
   417 /* B.1.6  Sequential function chart elements */
       
   418 /*********************************************/
       
   419 
       
   420     void *visit(sfc_network_c *symbol) {
       
   421       s4o.print(s4o.indent_spaces +"INT i;\n\n");
       
   422       s4o.print(s4o.indent_spaces +"BOOL transition;\n\n");
       
   423             
       
   424       /* generate step initilizations */
       
   425       s4o.print(s4o.indent_spaces + "// Steps initialisation\n");
       
   426       s4o.print(s4o.indent_spaces + "for (i = 0; i < ");
       
   427       print_variable_prefix();
       
   428       s4o.print("nb_steps; i++) {\n");
       
   429       s4o.indent_right();
       
   430       s4o.print(s4o.indent_spaces);
       
   431       print_variable_prefix();
       
   432       s4o.print("step_list[i].pulse = 0;\n");
       
   433       s4o.print(s4o.indent_spaces + "if (");
       
   434       print_variable_prefix();
       
   435       s4o.print("step_list[i].state) {\n");
       
   436       s4o.indent_right();
       
   437       s4o.print(s4o.indent_spaces);
       
   438       print_variable_prefix();
       
   439       s4o.print("step_list[i].elapsed_time = __add_timespec(");
       
   440       print_variable_prefix();
       
   441       s4o.print("step_list[i].elapsed_time, PERIOD);\n");
       
   442       s4o.indent_left();
       
   443       s4o.print(s4o.indent_spaces + "}\n");
       
   444       s4o.indent_left();
       
   445       s4o.print(s4o.indent_spaces + "}\n");
       
   446 
       
   447       /* generate action initilizations */
       
   448       s4o.print(s4o.indent_spaces + "// Actions initialisation\n");
       
   449       s4o.print(s4o.indent_spaces + "for (i = 0; i < ");
       
   450       print_variable_prefix();
       
   451       s4o.print("nb_actions; i++) {\n");
       
   452       s4o.indent_right();
       
   453       s4o.print(s4o.indent_spaces);
       
   454       print_variable_prefix();
       
   455       s4o.print("action_list[i].state = 0;\n");
       
   456       s4o.print(s4o.indent_spaces);
       
   457       print_variable_prefix();
       
   458       s4o.print("action_list[i].set = 0;\n");
       
   459       s4o.print(s4o.indent_spaces);
       
   460       print_variable_prefix();
       
   461       s4o.print("action_list[i].reset = 0;\n");
       
   462       s4o.print(s4o.indent_spaces + "if (");
       
   463       print_variable_prefix();
       
   464       s4o.print("__compare_timespec(>, action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) {\n");
       
   465       s4o.indent_right();
       
   466       s4o.print(s4o.indent_spaces);
       
   467       print_variable_prefix();
       
   468       s4o.print("action_list[i].set_remaining_time = __sub_timespec(");
       
   469       print_variable_prefix();
       
   470       s4o.print("action_list[i].set_remaining_time, PERIOD);\n");
       
   471       s4o.print(s4o.indent_spaces + "if (");
       
   472       print_variable_prefix();
       
   473       s4o.print("__compare_timespec(<=, action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) {\n");
       
   474       s4o.indent_right();
       
   475       s4o.print(s4o.indent_spaces);
       
   476       print_variable_prefix();
       
   477       s4o.print("action_list[i].set_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n");
       
   478       s4o.print(s4o.indent_spaces);
       
   479       print_variable_prefix();
       
   480       s4o.print("action_list[i].set = 1;\n");
       
   481       s4o.indent_left();
       
   482       s4o.print(s4o.indent_spaces + "}\n");
       
   483       s4o.indent_left();
       
   484       s4o.print(s4o.indent_spaces + "}\n");
       
   485       s4o.print(s4o.indent_spaces + "if (");
       
   486       print_variable_prefix();
       
   487       s4o.print("__compare_timespec(>, action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) {\n");
       
   488       s4o.indent_right();
       
   489       s4o.print(s4o.indent_spaces);
       
   490       print_variable_prefix();
       
   491       s4o.print("action_list[i].reset_remaining_time = __sub_timespec(");
       
   492       print_variable_prefix();
       
   493       s4o.print("action_list[i].reset_remaining_time, PERIOD);\n");
       
   494       s4o.print(s4o.indent_spaces + "if (");
       
   495       print_variable_prefix();
       
   496       s4o.print("__compare_timespec(<=, action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) {\n");
       
   497       s4o.indent_right();
       
   498       s4o.print(s4o.indent_spaces);
       
   499       print_variable_prefix();
       
   500       s4o.print("action_list[i].reset_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n");
       
   501       s4o.print(s4o.indent_spaces);
       
   502       print_variable_prefix();
       
   503       s4o.print("action_list[i].reset = 1;\n");
       
   504       s4o.indent_left();
       
   505       s4o.print(s4o.indent_spaces + "}\n");
       
   506       s4o.indent_left();
       
   507       s4o.print(s4o.indent_spaces + "}\n");
       
   508       s4o.indent_left();
       
   509       s4o.print(s4o.indent_spaces + "}\n\n");
       
   510       
       
   511       /* generate transition tests */
       
   512       s4o.print(s4o.indent_spaces + "// Transitions fire test\n");
       
   513       symbol->accept(*generate_cc_sfc_transitiontest);
       
   514       s4o.print("\n");
       
   515       
       
   516        /* generate step association */
       
   517       s4o.print(s4o.indent_spaces + "// Steps association\n");
       
   518       symbol->accept(*generate_cc_sfc_stepassociation);
       
   519       s4o.print("\n");
       
   520       
       
   521       /* generate action state evaluation */
       
   522       s4o.print(s4o.indent_spaces + "// Actions state evaluation\n");
       
   523       s4o.print(s4o.indent_spaces + "for (i = 0; i < ");
       
   524       print_variable_prefix();
       
   525       s4o.print("nb_actions; i++) {\n");
       
   526       s4o.indent_right();
       
   527       s4o.print(s4o.indent_spaces + "if (");
       
   528       print_variable_prefix();
       
   529       s4o.print("action_list[i].set) {\n");
       
   530       s4o.indent_right();
       
   531       s4o.print(s4o.indent_spaces);
       
   532       print_variable_prefix();
       
   533       s4o.print("action_list[i].stored = 1;\n");
       
   534       s4o.indent_left();
       
   535       s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces + "if (");
       
   536       print_variable_prefix();
       
   537       s4o.print("action_list[i].set) {\n");
       
   538       s4o.indent_right();
       
   539       s4o.print(s4o.indent_spaces);
       
   540       print_variable_prefix();
       
   541       s4o.print("action_list[i].set_remaining_time = 0;\n" + s4o.indent_spaces);
       
   542       print_variable_prefix();
       
   543       s4o.print("action_list[i].reset_remaining_time = 0;\n" + s4o.indent_spaces);
       
   544       print_variable_prefix();
       
   545       s4o.print("action_list[i].stored = 0;\n");
       
   546       s4o.indent_left();
       
   547       s4o.print(s4o.indent_spaces + "}\n" + s4o.indent_spaces);
       
   548       print_variable_prefix();
       
   549       s4o.print("action_list[i].state |= ");
       
   550       print_variable_prefix();
       
   551       s4o.print("action_list[i].stored;\n");
       
   552       s4o.indent_left();
       
   553       s4o.print(s4o.indent_spaces + "}\n\n");
       
   554       
       
   555       /* generate action execution */
       
   556       s4o.print(s4o.indent_spaces + "// Actions execution\n");
       
   557       symbol->accept(*generate_cc_sfc_actionexecution);
       
   558       s4o.print("\n");
       
   559       
       
   560       return NULL;
       
   561     }
       
   562 
       
   563     void generate(sequential_function_chart_c *sfc) {
       
   564       sfc->accept(*this);
       
   565     }
       
   566 
       
   567 }; /* generate_cc_sfc_c */