Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
authorlbessard
Fri, 27 Jun 2008 09:36:40 +0200
changeset 125 7ec16536bc87
parent 124 4debc565109d
child 126 5c658ecdf6b1
Modifying time qualifier in SFC to take real time enlapsed instead of theoric period time
stage4/generate_c/generate_c_sfc.cc
stage4/generate_c/generate_c_sfcdecl.cc
--- a/stage4/generate_c/generate_c_sfc.cc	Fri Jun 27 09:29:27 2008 +0200
+++ b/stage4/generate_c/generate_c_sfc.cc	Fri Jun 27 09:36:40 2008 +0200
@@ -583,7 +583,18 @@
       }
       
       s4o.print(s4o.indent_spaces +"INT i;\n");
-      s4o.print(s4o.indent_spaces +"BOOL transition;\n\n");
+      s4o.print(s4o.indent_spaces +"BOOL transition;\n");
+      s4o.print(s4o.indent_spaces +"TIME elapsed_time, current_time;\n\n");
+      
+      /* generate elapsed_time initialisations */
+      s4o.print(s4o.indent_spaces + "// Calculate elapsed_time\n");
+      s4o.print(s4o.indent_spaces +"current_time = __CURRENT_TIME;\n");
+      s4o.print(s4o.indent_spaces +"elapsed_time = __time_sub(current_time, ");
+      print_variable_prefix();
+      s4o.print("lasttick_time);\n");
+      s4o.print(s4o.indent_spaces);
+      print_variable_prefix();
+      s4o.print("lasttick_time = current_time;\n");
       
       /* generate step initialisations */
       s4o.print(s4o.indent_spaces + "// Steps initialisation\n");
@@ -604,9 +615,7 @@
       print_variable_prefix();
       s4o.print("step_list[i].elapsed_time = __time_add(");
       print_variable_prefix();
-      s4o.print("step_list[i].elapsed_time, ");
-      print_variable_prefix();
-      s4o.print("period);\n");
+      s4o.print("step_list[i].elapsed_time, elapsed_time);\n");
       s4o.indent_left();
       s4o.print(s4o.indent_spaces + "}\n");
       s4o.indent_left();
@@ -636,9 +645,7 @@
       print_variable_prefix();
       s4o.print("action_list[i].set_remaining_time = __time_sub(");
       print_variable_prefix();
-      s4o.print("action_list[i].set_remaining_time, ");
-      print_variable_prefix();
-      s4o.print("period);\n");
+      s4o.print("action_list[i].set_remaining_time, elapsed_time);\n");
       s4o.print(s4o.indent_spaces + "if (");
       s4o.print("__le_TIME(2, ");
       print_variable_prefix();
@@ -663,9 +670,7 @@
       print_variable_prefix();
       s4o.print("action_list[i].reset_remaining_time = __time_sub(");
       print_variable_prefix();
-      s4o.print("action_list[i].reset_remaining_time, ");
-      print_variable_prefix();
-      s4o.print("period);\n");
+      s4o.print("action_list[i].reset_remaining_time, elapsed_time);\n");
       s4o.print(s4o.indent_spaces + "if (");
       s4o.print("__le_TIME(2, ");
       print_variable_prefix();
--- a/stage4/generate_c/generate_c_sfcdecl.cc	Fri Jun 27 09:29:27 2008 +0200
+++ b/stage4/generate_c/generate_c_sfcdecl.cc	Fri Jun 27 09:36:40 2008 +0200
@@ -103,8 +103,8 @@
           s4o.print_integer(transition_number);
           s4o.print("];\n");
           
-          /* period declaration */
-          s4o.print(s4o.indent_spaces + "TIME period;\n");
+          /* last_ticktime declaration */
+          s4o.print(s4o.indent_spaces + "TIME lasttick_time;\n");
           break;
         case sfcinit_sd:
           s4o.print(s4o.indent_spaces);
@@ -157,14 +157,12 @@
           s4o.print(s4o.indent_spaces);
           print_variable_prefix();
           s4o.print("action_list[i] = temp_action;\n");
-          
-          /* period initialisation */
-          s4o.print(s4o.indent_spaces);
-          print_variable_prefix();
-          s4o.print("period = __time_to_timespec(1, common_ticktime__, 0, 0, 0, 0);\n");
-          
           s4o.indent_left();
           s4o.print(s4o.indent_spaces + "}\n");
+          
+          /* last_ticktime initialisation */
+          print_variable_prefix();
+          s4o.print("lasttick_time = __CURRENT_TIME;\n");
           break;
         case stepdef_sd:
           s4o.print("// Steps definitions\n");