]> rtime.felk.cvut.cz Git - ert_linux.git/commitdiff
Move ext mode communiction out of the real-time thread
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 12 Jul 2013 08:50:33 +0000 (10:50 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 12 Jul 2013 08:50:33 +0000 (10:50 +0200)
ert_linux/ert_linux_multitasking_main.tlc

index aa40ed1d8f32678d27cef2ea4bad0e33112d620a..96e7fd0f9878f32810d819c4e348ff07a0691b53 100644 (file)
@@ -34,6 +34,7 @@
   #include <semaphore.h>                 /* Semaphores library header file */\r
   #include <time.h>\r
   #include <stdlib.h>\r
+  #include <unistd.h>\r
   #include "%<modelName>.h"              /* Model's header file */\r
   #include "rtwtypes.h"                  /* MathWorks types */\r
   %if extMode == 1\r
 \r
       %if extMode == 1\r
        rtExtModeCheckEndTrigger();\r
-        rtExtModeOneStep(rtmGetRTWExtModeInfo(RT_MDL),\r
-                         NUMST,\r
-                         (boolean_T *)&rtmGetStopRequested(RT_MDL));\r
       %endif\r
 \r
       next.tv_sec += period.tv_sec;\r
     sched_param.sched_priority = MAX_PRIO;\r
     CHECK0(pthread_attr_setschedparam(&attr, &sched_param));\r
     CHECK0(pthread_create(&base_rate_thread, &attr, base_rate, NULL));\r
+    CHECK0(pthread_attr_destroy(&attr));\r
+\r
+    %if extMode == 1\r
+      /* External mode */\r
+      while(rtmGetErrorStatus(%<modelName>_M) == NULL && !rtmGetStopRequested(%<modelName>_M)) {\r
+        rtExtModeOneStep(rtmGetRTWExtModeInfo(RT_MDL), NUMST, (boolean_T *)&rtmGetStopRequested(RT_MDL));\r
+       usleep(%<FEVAL("uint32", fundamentalStepSize * 1000000)>);\r
+      }\r
+    %endif\r
 \r
     /* Wait for threads to finish */\r
-    CHECK0(pthread_attr_destroy(&attr));\r
     pthread_join(base_rate_thread, NULL);\r
     %foreach i = numSampleTimes\r
       %if i == 0 || i == 1 && tid01Eq\r