stage4/generate_c/generate_c_sfc.cc
changeset 149 05ca171a3d57
parent 141 d2dc99c319b6
child 155 e094c92cf197
equal deleted inserted replaced
148:912bdab1eca8 149:05ca171a3d57
    83       search_var_instance_decl = new search_var_instance_decl_c(scope);
    83       search_var_instance_decl = new search_var_instance_decl_c(scope);
    84       this->set_variable_prefix(variable_prefix);
    84       this->set_variable_prefix(variable_prefix);
    85     }
    85     }
    86     
    86     
    87     ~generate_c_sfc_elements_c(void) {
    87     ~generate_c_sfc_elements_c(void) {
       
    88       transition_list.clear();
    88       delete generate_c_il;
    89       delete generate_c_il;
    89       delete generate_c_st;
    90       delete generate_c_st;
    90       delete generate_c_code;
    91       delete generate_c_code;
    91       delete search_var_instance_decl;
    92       delete search_var_instance_decl;
    92     }
    93     }
   621       s4o.print(s4o.indent_spaces +"TIME elapsed_time, current_time;\n\n");
   622       s4o.print(s4o.indent_spaces +"TIME elapsed_time, current_time;\n\n");
   622       
   623       
   623       /* generate elapsed_time initialisations */
   624       /* generate elapsed_time initialisations */
   624       s4o.print(s4o.indent_spaces + "// Calculate elapsed_time\n");
   625       s4o.print(s4o.indent_spaces + "// Calculate elapsed_time\n");
   625       s4o.print(s4o.indent_spaces +"current_time = __CURRENT_TIME;\n");
   626       s4o.print(s4o.indent_spaces +"current_time = __CURRENT_TIME;\n");
   626       s4o.print(s4o.indent_spaces +"elapsed_time = __time_sub(current_time, ");
   627       s4o.print(s4o.indent_spaces +"elapsed_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, current_time, ");
   627       print_variable_prefix();
   628       print_variable_prefix();
   628       s4o.print("__lasttick_time);\n");
   629       s4o.print("__lasttick_time);\n");
   629       s4o.print(s4o.indent_spaces);
   630       s4o.print(s4o.indent_spaces);
   630       print_variable_prefix();
   631       print_variable_prefix();
   631       s4o.print("__lasttick_time = current_time;\n");
   632       s4o.print("__lasttick_time = current_time;\n");
   645       print_variable_prefix();
   646       print_variable_prefix();
   646       s4o.print("__step_list[i].state) {\n");
   647       s4o.print("__step_list[i].state) {\n");
   647       s4o.indent_right();
   648       s4o.indent_right();
   648       s4o.print(s4o.indent_spaces);
   649       s4o.print(s4o.indent_spaces);
   649       print_variable_prefix();
   650       print_variable_prefix();
   650       s4o.print("__step_list[i].elapsed_time = __time_add(");
   651       s4o.print("__step_list[i].elapsed_time = __time_add(__BOOL_LITERAL(TRUE), NULL, ");
   651       print_variable_prefix();
   652       print_variable_prefix();
   652       s4o.print("__step_list[i].elapsed_time, elapsed_time);\n");
   653       s4o.print("__step_list[i].elapsed_time, elapsed_time);\n");
   653       s4o.indent_left();
   654       s4o.indent_left();
   654       s4o.print(s4o.indent_spaces + "}\n");
   655       s4o.print(s4o.indent_spaces + "}\n");
   655       s4o.indent_left();
   656       s4o.indent_left();
   669       s4o.print("__action_list[i].set = 0;\n");
   670       s4o.print("__action_list[i].set = 0;\n");
   670       s4o.print(s4o.indent_spaces);
   671       s4o.print(s4o.indent_spaces);
   671       print_variable_prefix();
   672       print_variable_prefix();
   672       s4o.print("__action_list[i].reset = 0;\n");
   673       s4o.print("__action_list[i].reset = 0;\n");
   673       s4o.print(s4o.indent_spaces + "if (");
   674       s4o.print(s4o.indent_spaces + "if (");
   674       s4o.print("__gt_TIME(2, ");
   675       s4o.print("__TIME_CMP(");
   675       print_variable_prefix();
   676       print_variable_prefix();
   676       s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n");
   677       s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) > 0) {\n");
   677       s4o.indent_right();
   678       s4o.indent_right();
   678       s4o.print(s4o.indent_spaces);
   679       s4o.print(s4o.indent_spaces);
   679       print_variable_prefix();
   680       print_variable_prefix();
   680       s4o.print("__action_list[i].set_remaining_time = __time_sub(");
   681       s4o.print("__action_list[i].set_remaining_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, ");
   681       print_variable_prefix();
   682       print_variable_prefix();
   682       s4o.print("__action_list[i].set_remaining_time, elapsed_time);\n");
   683       s4o.print("__action_list[i].set_remaining_time, elapsed_time);\n");
   683       s4o.print(s4o.indent_spaces + "if (");
   684       s4o.print(s4o.indent_spaces + "if (");
   684       s4o.print("__le_TIME(2, ");
   685       s4o.print("__TIME_CMP(");
   685       print_variable_prefix();
   686       print_variable_prefix();
   686       s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n");
   687       s4o.print("__action_list[i].set_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) <= 0) {\n");
   687       s4o.indent_right();
   688       s4o.indent_right();
   688       s4o.print(s4o.indent_spaces);
   689       s4o.print(s4o.indent_spaces);
   689       print_variable_prefix();
   690       print_variable_prefix();
   690       s4o.print("__action_list[i].set_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n");
   691       s4o.print("__action_list[i].set_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n");
   691       s4o.print(s4o.indent_spaces);
   692       s4o.print(s4o.indent_spaces);
   694       s4o.indent_left();
   695       s4o.indent_left();
   695       s4o.print(s4o.indent_spaces + "}\n");
   696       s4o.print(s4o.indent_spaces + "}\n");
   696       s4o.indent_left();
   697       s4o.indent_left();
   697       s4o.print(s4o.indent_spaces + "}\n");
   698       s4o.print(s4o.indent_spaces + "}\n");
   698       s4o.print(s4o.indent_spaces + "if (");
   699       s4o.print(s4o.indent_spaces + "if (");
   699       s4o.print("__gt_TIME(2, ");
   700       s4o.print("__TIME_CMP(");
   700       print_variable_prefix();
   701       print_variable_prefix();
   701       s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n");
   702       s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) > 0) {\n");
   702       s4o.indent_right();
   703       s4o.indent_right();
   703       s4o.print(s4o.indent_spaces);
   704       s4o.print(s4o.indent_spaces);
   704       print_variable_prefix();
   705       print_variable_prefix();
   705       s4o.print("__action_list[i].reset_remaining_time = __time_sub(");
   706       s4o.print("__action_list[i].reset_remaining_time = __time_sub(__BOOL_LITERAL(TRUE), NULL, ");
   706       print_variable_prefix();
   707       print_variable_prefix();
   707       s4o.print("__action_list[i].reset_remaining_time, elapsed_time);\n");
   708       s4o.print("__action_list[i].reset_remaining_time, elapsed_time);\n");
   708       s4o.print(s4o.indent_spaces + "if (");
   709       s4o.print(s4o.indent_spaces + "if (");
   709       s4o.print("__le_TIME(2, ");
   710       s4o.print("__TIME_CMP(");
   710       print_variable_prefix();
   711       print_variable_prefix();
   711       s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0))) {\n");
   712       s4o.print("__action_list[i].reset_remaining_time, __time_to_timespec(1, 0, 0, 0, 0, 0)) <= 0) {\n");
   712       s4o.indent_right();
   713       s4o.indent_right();
   713       s4o.print(s4o.indent_spaces);
   714       s4o.print(s4o.indent_spaces);
   714       print_variable_prefix();
   715       print_variable_prefix();
   715       s4o.print("__action_list[i].reset_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n");
   716       s4o.print("__action_list[i].reset_remaining_time = __time_to_timespec(1, 0, 0, 0, 0, 0);\n");
   716       s4o.print(s4o.indent_spaces);
   717       s4o.print(s4o.indent_spaces);