partial fix to issue #76 - calculate task periods with 1ms (instead of 1ns) resolution. Allows for tasks with periods larger than 4.295s, but smaller than 50 days.
authorMario de Sousa <msousa@fe.up.pt>
Tue, 25 Dec 2018 12:15:29 +0000
changeset 1077 b37de6a9ad7f
parent 1076 efaa818ef637
child 1078 81e2a100db14
child 1079 585445abc4a2
partial fix to issue #76 - calculate task periods with 1ms (instead of 1ns) resolution. Allows for tasks with periods larger than 4.295s, but smaller than 50 days.
stage4/generate_c/generate_c.cc
--- a/stage4/generate_c/generate_c.cc	Tue Dec 25 11:10:11 2018 +0000
+++ b/stage4/generate_c/generate_c.cc	Tue Dec 25 12:15:29 2018 +0000
@@ -544,7 +544,7 @@
 /***********************************************************************/
 /***********************************************************************/
 
-#define MILLISECOND 1000000
+#define MILLISECOND 1
 #define SECOND 1000 * MILLISECOND
 
 unsigned long long calculate_time(symbol_c *symbol) {
@@ -567,10 +567,6 @@
     /* SYM_REF5(interval_c, days, hours, minutes, seconds, milliseconds) */
       unsigned long long int time_ull = 0; 
       long double            time_ld  = 0;
-      /*
-      const unsigned long long int MILLISECOND = 1000000;
-      const unsigned long long int      SECOND = 1000 * MILLISECOND
-      */
       
       if (NULL != interval->milliseconds) {
         if      (VALID_CVALUE( int64, interval->milliseconds) &&           GET_CVALUE( int64, interval->milliseconds) < 0) ERROR; // interval elements should always be positive!
@@ -2670,6 +2666,8 @@
 
         config_s4o.print("unsigned long long common_ticktime__ = ");
         config_s4o.print_long_long_integer(common_ticktime);
+        config_s4o.print(" * ");
+        config_s4o.print_long_long_integer(1000000 / MILLISECOND);
         config_s4o.print("; /*ns*/\n");
         config_s4o.print("unsigned long greatest_tick_count__ = (unsigned long)");
         config_s4o.print_long_integer(calculate_common_ticktime.get_greatest_tick_count());