Slave controller for AEB and QA item

Files at this revision

API Documentation at this revision

Comitter:
AndreaAndreoli
Date:
Mon Jul 11 10:15:51 2016 +0000
Parent:
0:88fb7562377b
Commit message:
bug fixed;

Changed in this revision

Controller_Slave.c Show annotated file Show diff for this revision Revisions of this file
Controller_Slave.h Show annotated file Show diff for this revision Revisions of this file
rtwtypes.h Show annotated file Show diff for this revision Revisions of this file
--- a/Controller_Slave.c	Wed Jul 06 09:21:22 2016 +0000
+++ b/Controller_Slave.c	Mon Jul 11 10:15:51 2016 +0000
@@ -7,12 +7,12 @@
  *
  * Code generated for Simulink model 'Controller_Slave'.
  *
- * Model version                  : 1.6
+ * Model version                  : 1.7
  * Simulink Coder version         : 8.10 (R2016a) 10-Feb-2016
- * C/C++ source code generated on : Wed Jul 06 11:19:35 2016
+ * C/C++ source code generated on : Sun Jul 10 15:19:51 2016
  *
  * Target selection: ert.tlc
- * Embedded hardware selection: NXP->Cortex-M4
+ * Embedded hardware selection: ARM Compatible->ARM Cortex
  * Code generation objectives: Unspecified
  * Validation result: Not run
  */
@@ -23,11 +23,11 @@
 #define Controller_S_IN_NO_ACTIVE_CHILD ((uint8_T)0U)
 #define Controller_Slave_IN_ACCELERATE ((uint8_T)1U)
 #define Controller_Slave_IN_AEB_ACTIVE ((uint8_T)1U)
-#define Controller_Slave_IN_BRAKE      ((uint8_T)2U)
-#define Controller_Slave_IN_BRAKE_i    ((uint8_T)1U)
+#define Controller_Slave_IN_BRAKE      ((uint8_T)1U)
+#define Controller_Slave_IN_BRAKE_i    ((uint8_T)2U)
 #define Controller_Slave_IN_ERR        ((uint8_T)1U)
-#define Controller_Slave_IN_IDLE       ((uint8_T)3U)
-#define Controller_Slave_IN_IDLE_b     ((uint8_T)2U)
+#define Controller_Slave_IN_IDLE       ((uint8_T)2U)
+#define Controller_Slave_IN_IDLE_b     ((uint8_T)3U)
 #define Controller_Slave_IN_OK         ((uint8_T)2U)
 #define Controller_Slave_IN_QA_ACTIVE  ((uint8_T)2U)
 #define Controller_Slave_IN_READY      ((uint8_T)3U)
@@ -92,290 +92,6 @@
   real_T K;
 
   /* During 'AEB_QA': '<S2>:35' */
-  /* During 'APPLICATION_THREAD': '<S2>:32' */
-  switch (Controller_Slave_DW->is_APPLICATION_THREAD) {
-   case Controller_Slave_IN_AEB_ACTIVE:
-    /* During 'AEB_ACTIVE': '<S2>:1' */
-    /* '<S2>:26:1' sf_internal_predicateOutput = ... */
-    /* '<S2>:26:1' En == false; */
-    if (!Controller_Slave_DW->En) {
-      /* Transition: '<S2>:26' */
-      /* Exit Internal 'AEB_ACTIVE': '<S2>:1' */
-      Controller_Slave_DW->is_AEB_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD;
-      Controller_Slave_DW->is_APPLICATION_THREAD = Controller_Slave_IN_READY;
-
-      /* Entry 'READY': '<S2>:21' */
-      /* '<S2>:21:1' Brake = uint8(0); */
-      *Controller_Slave_Y_BRAKE = 0U;
-
-      /* '<S2>:21:1' Led_Blue = 0; */
-      Controller_Slave_B->Led_Blue = 0.0;
-
-      /* '<S2>:21:1' Led_Green = uint8(0); */
-      *Controller_Slave_Y_LED_GREEN = 0U;
-
-      /* '<S2>:21:4' Acc =uint8(0); */
-      *Controller_Slave_Y_ACC = 0U;
-    } else {
-      /* Inport: '<Root>/QA_EN' incorporates:
-       *  Inport: '<Root>/V'
-       */
-      /* '<S2>:70:1' sf_internal_predicateOutput = ... */
-      /* '<S2>:70:1' QA_En == true && V<30; */
-      if (Controller_Slave_U_QA_EN && (Controller_Slave_U_V < 30.0)) {
-        /* Transition: '<S2>:70' */
-        /* Exit Internal 'AEB_ACTIVE': '<S2>:1' */
-        Controller_Slave_DW->is_AEB_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD;
-        Controller_Slave_DW->is_APPLICATION_THREAD =
-          Controller_Slave_IN_QA_ACTIVE;
-
-        /* Entry 'QA_ACTIVE': '<S2>:69' */
-        /* '<S2>:69:1' K = (V^2)/D; */
-        /* Entry Internal 'QA_ACTIVE': '<S2>:69' */
-        /* Transition: '<S2>:64' */
-        Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_IDLE;
-
-        /* Entry 'IDLE': '<S2>:67' */
-        /* '<S2>:67:1' Brake = uint8(0); */
-        *Controller_Slave_Y_BRAKE = 0U;
-
-        /* '<S2>:67:1' Led_Blue = 0; */
-        Controller_Slave_B->Led_Blue = 0.0;
-
-        /* '<S2>:67:1' Led_Green = uint8(0); */
-        *Controller_Slave_Y_LED_GREEN = 0U;
-
-        /* '<S2>:67:4' Acc = uint8(0); */
-        *Controller_Slave_Y_ACC = 0U;
-      } else {
-        /* Inport: '<Root>/D_S' */
-        /* '<S2>:1:1' K = (V^2)/D; */
-        K = Controller_Slave_U_V * Controller_Slave_U_V / Controller_Slave_U_D_S;
-        switch (Controller_Slave_DW->is_AEB_ACTIVE) {
-         case Controller_Slave_IN_BRAKE_i:
-          /* During 'BRAKE': '<S2>:3' */
-          /* '<S2>:10:1' sf_internal_predicateOutput = ... */
-          /* '<S2>:10:1' K < 100; */
-          if (K < 100.0) {
-            /* Transition: '<S2>:10' */
-            Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_WARNING;
-
-            /* Entry 'WARNING': '<S2>:5' */
-            /* '<S2>:5:1' Brake = uint8(0); */
-            *Controller_Slave_Y_BRAKE = 0U;
-          }
-          break;
-
-         case Controller_Slave_IN_IDLE_b:
-          /* During 'IDLE': '<S2>:6' */
-          /* '<S2>:12:1' sf_internal_predicateOutput = ... */
-          /* '<S2>:12:1' K >= 70; */
-          if (K >= 70.0) {
-            /* Transition: '<S2>:12' */
-            Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_WARNING;
-
-            /* Entry 'WARNING': '<S2>:5' */
-            /* '<S2>:5:1' Brake = uint8(0); */
-            *Controller_Slave_Y_BRAKE = 0U;
-          }
-          break;
-
-         default:
-          /* During 'WARNING': '<S2>:5' */
-          /* '<S2>:9:1' sf_internal_predicateOutput = ... */
-          /* '<S2>:9:1' K  >= 100; */
-          if (K >= 100.0) {
-            /* Transition: '<S2>:9' */
-            Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_BRAKE_i;
-
-            /* Entry 'BRAKE': '<S2>:3' */
-            /* '<S2>:3:1' Brake = uint8(1); */
-            *Controller_Slave_Y_BRAKE = 1U;
-
-            /* '<S2>:3:1' Led_Blue = 1; */
-            Controller_Slave_B->Led_Blue = 1.0;
-          } else {
-            /* '<S2>:11:1' sf_internal_predicateOutput = ... */
-            /* '<S2>:11:1' K < 70; */
-            if (K < 70.0) {
-              /* Transition: '<S2>:11' */
-              Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_IDLE_b;
-
-              /* Entry 'IDLE': '<S2>:6' */
-              /* '<S2>:6:1' Brake = uint8(0); */
-              *Controller_Slave_Y_BRAKE = 0U;
-
-              /* '<S2>:6:1' Led_Blue = 0; */
-              Controller_Slave_B->Led_Blue = 0.0;
-            } else {
-              /* '<S2>:5:1' Led_Blue = (K-70)/30; */
-              Controller_Slave_B->Led_Blue = (K - 70.0) / 30.0;
-            }
-          }
-          break;
-        }
-      }
-    }
-    break;
-
-   case Controller_Slave_IN_QA_ACTIVE:
-    /* Inport: '<Root>/QA_EN' incorporates:
-     *  Inport: '<Root>/V'
-     */
-    /* During 'QA_ACTIVE': '<S2>:69' */
-    /* '<S2>:71:1' sf_internal_predicateOutput = ... */
-    /* '<S2>:71:1' QA_En ~= true || V>=30; */
-    if ((!Controller_Slave_U_QA_EN) || (Controller_Slave_U_V >= 30.0)) {
-      /* Transition: '<S2>:71' */
-      /* Exit Internal 'QA_ACTIVE': '<S2>:69' */
-      Controller_Slave_DW->is_QA_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD;
-      Controller_Slave_DW->is_APPLICATION_THREAD =
-        Controller_Slave_IN_AEB_ACTIVE;
-
-      /* Entry 'AEB_ACTIVE': '<S2>:1' */
-      /* '<S2>:1:1' K = (V^2)/D; */
-      /* Entry Internal 'AEB_ACTIVE': '<S2>:1' */
-      /* Transition: '<S2>:51' */
-      Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_IDLE_b;
-
-      /* Entry 'IDLE': '<S2>:6' */
-      /* '<S2>:6:1' Brake = uint8(0); */
-      *Controller_Slave_Y_BRAKE = 0U;
-
-      /* '<S2>:6:1' Led_Blue = 0; */
-      Controller_Slave_B->Led_Blue = 0.0;
-    } else {
-      /* '<S2>:79:1' sf_internal_predicateOutput = ... */
-      /* '<S2>:79:1' En == false; */
-      if (!Controller_Slave_DW->En) {
-        /* Transition: '<S2>:79' */
-        /* Exit Internal 'QA_ACTIVE': '<S2>:69' */
-        Controller_Slave_DW->is_QA_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD;
-        Controller_Slave_DW->is_APPLICATION_THREAD = Controller_Slave_IN_READY;
-
-        /* Entry 'READY': '<S2>:21' */
-        /* '<S2>:21:1' Brake = uint8(0); */
-        *Controller_Slave_Y_BRAKE = 0U;
-
-        /* '<S2>:21:1' Led_Blue = 0; */
-        Controller_Slave_B->Led_Blue = 0.0;
-
-        /* '<S2>:21:1' Led_Green = uint8(0); */
-        *Controller_Slave_Y_LED_GREEN = 0U;
-
-        /* '<S2>:21:4' Acc =uint8(0); */
-        *Controller_Slave_Y_ACC = 0U;
-      } else {
-        /* Inport: '<Root>/D_S' */
-        /* '<S2>:69:1' K = (V^2)/D; */
-        K = Controller_Slave_U_V * Controller_Slave_U_V / Controller_Slave_U_D_S;
-        switch (Controller_Slave_DW->is_QA_ACTIVE) {
-         case Controller_Slave_IN_ACCELERATE:
-          /* During 'ACCELERATE': '<S2>:68' */
-          /* '<S2>:75:1' sf_internal_predicateOutput = ... */
-          /* '<S2>:75:1' K  >= 100; */
-          if (K >= 100.0) {
-            /* Transition: '<S2>:75' */
-            Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_IDLE;
-
-            /* Entry 'IDLE': '<S2>:67' */
-            /* '<S2>:67:1' Brake = uint8(0); */
-            *Controller_Slave_Y_BRAKE = 0U;
-
-            /* '<S2>:67:1' Led_Blue = 0; */
-            Controller_Slave_B->Led_Blue = 0.0;
-
-            /* '<S2>:67:1' Led_Green = uint8(0); */
-            *Controller_Slave_Y_LED_GREEN = 0U;
-
-            /* '<S2>:67:4' Acc = uint8(0); */
-            *Controller_Slave_Y_ACC = 0U;
-          }
-          break;
-
-         case Controller_Slave_IN_BRAKE:
-          /* During 'BRAKE': '<S2>:65' */
-          /* '<S2>:73:1' sf_internal_predicateOutput = ... */
-          /* '<S2>:73:1' K <= 100; */
-          if (K <= 100.0) {
-            /* Transition: '<S2>:73' */
-            Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_IDLE;
-
-            /* Entry 'IDLE': '<S2>:67' */
-            /* '<S2>:67:1' Brake = uint8(0); */
-            *Controller_Slave_Y_BRAKE = 0U;
-
-            /* '<S2>:67:1' Led_Blue = 0; */
-            Controller_Slave_B->Led_Blue = 0.0;
-
-            /* '<S2>:67:1' Led_Green = uint8(0); */
-            *Controller_Slave_Y_LED_GREEN = 0U;
-
-            /* '<S2>:67:4' Acc = uint8(0); */
-            *Controller_Slave_Y_ACC = 0U;
-          }
-          break;
-
-         default:
-          /* During 'IDLE': '<S2>:67' */
-          /* '<S2>:72:1' sf_internal_predicateOutput = ... */
-          /* '<S2>:72:1' K  > 100; */
-          if (K > 100.0) {
-            /* Transition: '<S2>:72' */
-            Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_BRAKE;
-
-            /* Entry 'BRAKE': '<S2>:65' */
-            /* '<S2>:65:1' Brake = uint8(1); */
-            *Controller_Slave_Y_BRAKE = 1U;
-
-            /* '<S2>:65:1' Led_Blue = 1; */
-            Controller_Slave_B->Led_Blue = 1.0;
-          } else {
-            /* '<S2>:74:1' sf_internal_predicateOutput = ... */
-            /* '<S2>:74:1' K < 100; */
-            if (K < 100.0) {
-              /* Transition: '<S2>:74' */
-              Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_ACCELERATE;
-
-              /* Entry 'ACCELERATE': '<S2>:68' */
-              /* '<S2>:68:1' Led_Green = uint8(1); */
-              *Controller_Slave_Y_LED_GREEN = 1U;
-
-              /* '<S2>:68:1' Acc = uint8(1); */
-              *Controller_Slave_Y_ACC = 1U;
-            }
-          }
-          break;
-        }
-      }
-    }
-    break;
-
-   default:
-    /* During 'READY': '<S2>:21' */
-    /* '<S2>:23:1' sf_internal_predicateOutput = ... */
-    /* '<S2>:23:1' En == true; */
-    if (Controller_Slave_DW->En) {
-      /* Transition: '<S2>:23' */
-      Controller_Slave_DW->is_APPLICATION_THREAD =
-        Controller_Slave_IN_AEB_ACTIVE;
-
-      /* Entry 'AEB_ACTIVE': '<S2>:1' */
-      /* '<S2>:1:1' K = (V^2)/D; */
-      /* Entry Internal 'AEB_ACTIVE': '<S2>:1' */
-      /* Transition: '<S2>:51' */
-      Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_IDLE_b;
-
-      /* Entry 'IDLE': '<S2>:6' */
-      /* '<S2>:6:1' Brake = uint8(0); */
-      *Controller_Slave_Y_BRAKE = 0U;
-
-      /* '<S2>:6:1' Led_Blue = 0; */
-      Controller_Slave_B->Led_Blue = 0.0;
-    }
-    break;
-  }
-
   /* During 'ERRORS_CHECK_THREAD': '<S2>:80' */
   switch (Controller_Slave_DW->is_ERRORS_CHECK_THREAD) {
    case Controller_Slave_IN_ERR:
@@ -459,6 +175,313 @@
     *Controller_Slave_Y_SLAVE = 1U;
     break;
   }
+
+  /* During 'APPLICATION_THREAD': '<S2>:97' */
+  switch (Controller_Slave_DW->is_APPLICATION_THREAD) {
+   case Controller_Slave_IN_AEB_ACTIVE:
+    /* During 'AEB_ACTIVE': '<S2>:106' */
+    /* '<S2>:100:1' sf_internal_predicateOutput = ... */
+    /* '<S2>:100:1' En == false; */
+    if (!Controller_Slave_DW->En) {
+      /* Transition: '<S2>:100' */
+      /* Exit Internal 'AEB_ACTIVE': '<S2>:106' */
+      Controller_Slave_DW->is_AEB_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD;
+
+      /* Exit 'AEB_ACTIVE': '<S2>:106' */
+      /* '<S2>:106:2' Brake = uint8(0); */
+      /* '<S2>:106:3' Led_Blue = 0; */
+      Controller_Slave_DW->is_APPLICATION_THREAD = Controller_Slave_IN_READY;
+
+      /* Entry 'READY': '<S2>:115' */
+      /* '<S2>:115:1' Brake = uint8(0); */
+      *Controller_Slave_Y_BRAKE = 0U;
+
+      /* '<S2>:115:1' Led_Blue = 0; */
+      Controller_Slave_B->Led_Blue = 0.0;
+
+      /* '<S2>:115:1' Led_Green = uint8(0); */
+      *Controller_Slave_Y_LED_GREEN = 0U;
+
+      /* '<S2>:115:4' Acc = uint8(0); */
+      *Controller_Slave_Y_ACC = 0U;
+    } else {
+      /* Inport: '<Root>/QA_EN' incorporates:
+       *  Inport: '<Root>/V'
+       */
+      /* '<S2>:102:1' sf_internal_predicateOutput = ... */
+      /* '<S2>:102:1' QA_En == true && V<30; */
+      if (Controller_Slave_U_QA_EN && (Controller_Slave_U_V < 30.0)) {
+        /* Transition: '<S2>:102' */
+        /* Exit Internal 'AEB_ACTIVE': '<S2>:106' */
+        Controller_Slave_DW->is_AEB_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD;
+
+        /* Exit 'AEB_ACTIVE': '<S2>:106' */
+        /* '<S2>:106:2' Brake = uint8(0); */
+        /* '<S2>:106:3' Led_Blue = 0; */
+        Controller_Slave_DW->is_APPLICATION_THREAD =
+          Controller_Slave_IN_QA_ACTIVE;
+
+        /* Entry 'QA_ACTIVE': '<S2>:118' */
+        /* '<S2>:118:1' K = (V^2)/D; */
+        /* Entry Internal 'QA_ACTIVE': '<S2>:118' */
+        /* Transition: '<S2>:119' */
+        Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_IDLE_b;
+
+        /* Entry 'IDLE': '<S2>:124' */
+        /* '<S2>:124:1' Brake = uint8(0); */
+        *Controller_Slave_Y_BRAKE = 0U;
+
+        /* '<S2>:124:1' Led_Blue = 0; */
+        Controller_Slave_B->Led_Blue = 0.0;
+
+        /* '<S2>:124:1' Led_Green = uint8(0); */
+        *Controller_Slave_Y_LED_GREEN = 0U;
+
+        /* '<S2>:124:4' Acc = uint8(0); */
+        *Controller_Slave_Y_ACC = 0U;
+      } else {
+        /* Inport: '<Root>/D_S' */
+        /* '<S2>:106:1' K = (V^2)/D; */
+        K = Controller_Slave_U_V * Controller_Slave_U_V / Controller_Slave_U_D_S;
+        switch (Controller_Slave_DW->is_AEB_ACTIVE) {
+         case Controller_Slave_IN_BRAKE:
+          /* During 'BRAKE': '<S2>:114' */
+          /* '<S2>:111:1' sf_internal_predicateOutput = ... */
+          /* '<S2>:111:1' K < 100; */
+          if (K < 100.0) {
+            /* Transition: '<S2>:111' */
+            Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_WARNING;
+
+            /* Entry 'WARNING': '<S2>:113' */
+            /* '<S2>:113:1' Brake = uint8(0); */
+            *Controller_Slave_Y_BRAKE = 0U;
+          }
+          break;
+
+         case Controller_Slave_IN_IDLE:
+          /* During 'IDLE': '<S2>:112' */
+          /* '<S2>:108:1' sf_internal_predicateOutput = ... */
+          /* '<S2>:108:1' K >= 70; */
+          if (K >= 70.0) {
+            /* Transition: '<S2>:108' */
+            Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_WARNING;
+
+            /* Entry 'WARNING': '<S2>:113' */
+            /* '<S2>:113:1' Brake = uint8(0); */
+            *Controller_Slave_Y_BRAKE = 0U;
+          }
+          break;
+
+         default:
+          /* During 'WARNING': '<S2>:113' */
+          /* '<S2>:110:1' sf_internal_predicateOutput = ... */
+          /* '<S2>:110:1' K  >= 100; */
+          if (K >= 100.0) {
+            /* Transition: '<S2>:110' */
+            Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_BRAKE;
+
+            /* Entry 'BRAKE': '<S2>:114' */
+            /* '<S2>:114:1' Brake = uint8(1); */
+            *Controller_Slave_Y_BRAKE = 1U;
+
+            /* '<S2>:114:1' Led_Blue = 1; */
+            Controller_Slave_B->Led_Blue = 1.0;
+          } else {
+            /* '<S2>:109:1' sf_internal_predicateOutput = ... */
+            /* '<S2>:109:1' K < 70; */
+            if (K < 70.0) {
+              /* Transition: '<S2>:109' */
+              Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_IDLE;
+
+              /* Entry 'IDLE': '<S2>:112' */
+              /* '<S2>:112:1' Brake = uint8(0); */
+              *Controller_Slave_Y_BRAKE = 0U;
+
+              /* '<S2>:112:1' Led_Blue = 0; */
+              Controller_Slave_B->Led_Blue = 0.0;
+            } else {
+              /* '<S2>:113:1' Led_Blue = (K-70)/30; */
+              Controller_Slave_B->Led_Blue = (K - 70.0) / 30.0;
+            }
+          }
+          break;
+        }
+      }
+    }
+    break;
+
+   case Controller_Slave_IN_QA_ACTIVE:
+    /* Inport: '<Root>/QA_EN' incorporates:
+     *  Inport: '<Root>/V'
+     */
+    /* During 'QA_ACTIVE': '<S2>:118' */
+    /* '<S2>:103:1' sf_internal_predicateOutput = ... */
+    /* '<S2>:103:1' QA_En ~= true || V>=30; */
+    if ((!Controller_Slave_U_QA_EN) || (Controller_Slave_U_V >= 30.0)) {
+      /* Transition: '<S2>:103' */
+      /* Exit Internal 'QA_ACTIVE': '<S2>:118' */
+      Controller_Slave_DW->is_QA_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD;
+
+      /* Exit 'QA_ACTIVE': '<S2>:118' */
+      /* '<S2>:118:2' Brake = uint8(0); */
+      /* '<S2>:118:3' Led_Blue = 0; */
+      /* '<S2>:118:4' Led_Green = uint8(0); */
+      *Controller_Slave_Y_LED_GREEN = 0U;
+
+      /* '<S2>:118:5' Acc = uint8(0); */
+      *Controller_Slave_Y_ACC = 0U;
+      Controller_Slave_DW->is_APPLICATION_THREAD =
+        Controller_Slave_IN_AEB_ACTIVE;
+
+      /* Entry 'AEB_ACTIVE': '<S2>:106' */
+      /* '<S2>:106:1' K = (V^2)/D; */
+      /* Entry Internal 'AEB_ACTIVE': '<S2>:106' */
+      /* Transition: '<S2>:107' */
+      Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_IDLE;
+
+      /* Entry 'IDLE': '<S2>:112' */
+      /* '<S2>:112:1' Brake = uint8(0); */
+      *Controller_Slave_Y_BRAKE = 0U;
+
+      /* '<S2>:112:1' Led_Blue = 0; */
+      Controller_Slave_B->Led_Blue = 0.0;
+    } else {
+      /* '<S2>:101:1' sf_internal_predicateOutput = ... */
+      /* '<S2>:101:1' En == false; */
+      if (!Controller_Slave_DW->En) {
+        /* Transition: '<S2>:101' */
+        /* Exit Internal 'QA_ACTIVE': '<S2>:118' */
+        Controller_Slave_DW->is_QA_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD;
+
+        /* Exit 'QA_ACTIVE': '<S2>:118' */
+        /* '<S2>:118:2' Brake = uint8(0); */
+        /* '<S2>:118:3' Led_Blue = 0; */
+        /* '<S2>:118:4' Led_Green = uint8(0); */
+        /* '<S2>:118:5' Acc = uint8(0); */
+        Controller_Slave_DW->is_APPLICATION_THREAD = Controller_Slave_IN_READY;
+
+        /* Entry 'READY': '<S2>:115' */
+        /* '<S2>:115:1' Brake = uint8(0); */
+        *Controller_Slave_Y_BRAKE = 0U;
+
+        /* '<S2>:115:1' Led_Blue = 0; */
+        Controller_Slave_B->Led_Blue = 0.0;
+
+        /* '<S2>:115:1' Led_Green = uint8(0); */
+        *Controller_Slave_Y_LED_GREEN = 0U;
+
+        /* '<S2>:115:4' Acc = uint8(0); */
+        *Controller_Slave_Y_ACC = 0U;
+      } else {
+        /* Inport: '<Root>/D_S' */
+        /* '<S2>:118:1' K = (V^2)/D; */
+        K = Controller_Slave_U_V * Controller_Slave_U_V / Controller_Slave_U_D_S;
+        switch (Controller_Slave_DW->is_QA_ACTIVE) {
+         case Controller_Slave_IN_ACCELERATE:
+          /* During 'ACCELERATE': '<S2>:125' */
+          /* '<S2>:120:1' sf_internal_predicateOutput = ... */
+          /* '<S2>:120:1' K  >= 100; */
+          if (K >= 100.0) {
+            /* Transition: '<S2>:120' */
+            Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_IDLE_b;
+
+            /* Entry 'IDLE': '<S2>:124' */
+            /* '<S2>:124:1' Brake = uint8(0); */
+            *Controller_Slave_Y_BRAKE = 0U;
+
+            /* '<S2>:124:1' Led_Blue = 0; */
+            Controller_Slave_B->Led_Blue = 0.0;
+
+            /* '<S2>:124:1' Led_Green = uint8(0); */
+            *Controller_Slave_Y_LED_GREEN = 0U;
+
+            /* '<S2>:124:4' Acc = uint8(0); */
+            *Controller_Slave_Y_ACC = 0U;
+          }
+          break;
+
+         case Controller_Slave_IN_BRAKE_i:
+          /* During 'BRAKE': '<S2>:126' */
+          /* '<S2>:122:1' sf_internal_predicateOutput = ... */
+          /* '<S2>:122:1' K <= 100; */
+          if (K <= 100.0) {
+            /* Transition: '<S2>:122' */
+            Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_IDLE_b;
+
+            /* Entry 'IDLE': '<S2>:124' */
+            /* '<S2>:124:1' Brake = uint8(0); */
+            *Controller_Slave_Y_BRAKE = 0U;
+
+            /* '<S2>:124:1' Led_Blue = 0; */
+            Controller_Slave_B->Led_Blue = 0.0;
+
+            /* '<S2>:124:1' Led_Green = uint8(0); */
+            *Controller_Slave_Y_LED_GREEN = 0U;
+
+            /* '<S2>:124:4' Acc = uint8(0); */
+            *Controller_Slave_Y_ACC = 0U;
+          }
+          break;
+
+         default:
+          /* During 'IDLE': '<S2>:124' */
+          /* '<S2>:121:1' sf_internal_predicateOutput = ... */
+          /* '<S2>:121:1' K  > 100; */
+          if (K > 100.0) {
+            /* Transition: '<S2>:121' */
+            Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_BRAKE_i;
+
+            /* Entry 'BRAKE': '<S2>:126' */
+            /* '<S2>:126:1' Brake = uint8(1); */
+            *Controller_Slave_Y_BRAKE = 1U;
+
+            /* '<S2>:126:1' Led_Blue = 1; */
+            Controller_Slave_B->Led_Blue = 1.0;
+          } else {
+            /* '<S2>:123:1' sf_internal_predicateOutput = ... */
+            /* '<S2>:123:1' K < 100; */
+            if (K < 100.0) {
+              /* Transition: '<S2>:123' */
+              Controller_Slave_DW->is_QA_ACTIVE = Controller_Slave_IN_ACCELERATE;
+
+              /* Entry 'ACCELERATE': '<S2>:125' */
+              /* '<S2>:125:1' Led_Green = uint8(1); */
+              *Controller_Slave_Y_LED_GREEN = 1U;
+
+              /* '<S2>:125:1' Acc = uint8(1); */
+              *Controller_Slave_Y_ACC = 1U;
+            }
+          }
+          break;
+        }
+      }
+    }
+    break;
+
+   default:
+    /* During 'READY': '<S2>:115' */
+    /* '<S2>:99:1' sf_internal_predicateOutput = ... */
+    /* '<S2>:99:1' En == true; */
+    if (Controller_Slave_DW->En) {
+      /* Transition: '<S2>:99' */
+      Controller_Slave_DW->is_APPLICATION_THREAD =
+        Controller_Slave_IN_AEB_ACTIVE;
+
+      /* Entry 'AEB_ACTIVE': '<S2>:106' */
+      /* '<S2>:106:1' K = (V^2)/D; */
+      /* Entry Internal 'AEB_ACTIVE': '<S2>:106' */
+      /* Transition: '<S2>:107' */
+      Controller_Slave_DW->is_AEB_ACTIVE = Controller_Slave_IN_IDLE;
+
+      /* Entry 'IDLE': '<S2>:112' */
+      /* '<S2>:112:1' Brake = uint8(0); */
+      *Controller_Slave_Y_BRAKE = 0U;
+
+      /* '<S2>:112:1' Led_Blue = 0; */
+      Controller_Slave_B->Led_Blue = 0.0;
+    }
+    break;
+  }
 }
 
 /* Model step function */
@@ -488,26 +511,6 @@
 
     /* Entry Internal: Controller_Slave/AEB_QA */
     /* Entry Internal 'AEB_QA': '<S2>:35' */
-    /* Entry Internal 'APPLICATION_THREAD': '<S2>:32' */
-    /* Transition: '<S2>:27' */
-    Controller_Slave_DW->is_APPLICATION_THREAD = Controller_Slave_IN_READY;
-
-    /* Outport: '<Root>/BRAKE' */
-    /* Entry 'READY': '<S2>:21' */
-    /* '<S2>:21:1' Brake = uint8(0); */
-    *Controller_Slave_Y_BRAKE = 0U;
-
-    /* '<S2>:21:1' Led_Blue = 0; */
-    Controller_Slave_B->Led_Blue = 0.0;
-
-    /* Outport: '<Root>/LED_GREEN' */
-    /* '<S2>:21:1' Led_Green = uint8(0); */
-    *Controller_Slave_Y_LED_GREEN = 0U;
-
-    /* Outport: '<Root>/ACC' */
-    /* '<S2>:21:4' Acc =uint8(0); */
-    *Controller_Slave_Y_ACC = 0U;
-
     /* Entry Internal 'ERRORS_CHECK_THREAD': '<S2>:80' */
     /* Transition: '<S2>:81' */
     Controller_Slave_DW->is_ERRORS_CHECK_THREAD = Controller_Slave_IN_OK;
@@ -520,6 +523,26 @@
     /* Outport: '<Root>/SLAVE' */
     /* '<S2>:94:1' Slave = uint8(1); */
     *Controller_Slave_Y_SLAVE = 1U;
+
+    /* Entry Internal 'APPLICATION_THREAD': '<S2>:97' */
+    /* Transition: '<S2>:98' */
+    Controller_Slave_DW->is_APPLICATION_THREAD = Controller_Slave_IN_READY;
+
+    /* Outport: '<Root>/BRAKE' */
+    /* Entry 'READY': '<S2>:115' */
+    /* '<S2>:115:1' Brake = uint8(0); */
+    *Controller_Slave_Y_BRAKE = 0U;
+
+    /* '<S2>:115:1' Led_Blue = 0; */
+    Controller_Slave_B->Led_Blue = 0.0;
+
+    /* Outport: '<Root>/LED_GREEN' */
+    /* '<S2>:115:1' Led_Green = uint8(0); */
+    *Controller_Slave_Y_LED_GREEN = 0U;
+
+    /* Outport: '<Root>/ACC' */
+    /* '<S2>:115:4' Acc = uint8(0); */
+    *Controller_Slave_Y_ACC = 0U;
   } else {
     Controller_Slave_AEB_QA(&Memory, Controller_Slave_U_V,
       Controller_Slave_U_D_S, Controller_Slave_U_QA_EN, Controller_Slave_Y_BRAKE,
@@ -701,6 +724,8 @@
   *Controller_Slave_Y_LED_GREEN, uint8_T *Controller_Slave_Y_LED_BLUE, uint8_T
   *Controller_Slave_Y_SLAVE)
 {
+  P_Controller_Slave_T *Controller_Slave_P = ((P_Controller_Slave_T *)
+    Controller_Slave_M->ModelData.defaultParam);
   DW_Controller_Slave_T *Controller_Slave_DW = ((DW_Controller_Slave_T *)
     Controller_Slave_M->ModelData.dwork);
   B_Controller_Slave_T *Controller_Slave_B = ((B_Controller_Slave_T *)
@@ -732,7 +757,7 @@
 
   /* SystemInitialize for Atomic SubSystem: '<Root>/Controller_Slave' */
   /* InitializeConditions for Memory: '<S1>/Memory' */
-  Controller_Slave_DW->Memory_PreviousInput = 1U;
+  Controller_Slave_DW->Memory_PreviousInput = Controller_Slave_P->Memory_X0;
 
   /* SystemInitialize for Chart: '<S1>/AEB_QA' */
   Controller_Slave_DW->is_APPLICATION_THREAD = Controller_S_IN_NO_ACTIVE_CHILD;
--- a/Controller_Slave.h	Wed Jul 06 09:21:22 2016 +0000
+++ b/Controller_Slave.h	Mon Jul 11 10:15:51 2016 +0000
@@ -7,26 +7,52 @@
  *
  * Code generated for Simulink model 'Controller_Slave'.
  *
- * Model version                  : 1.6
+ * Model version                  : 1.7
  * Simulink Coder version         : 8.10 (R2016a) 10-Feb-2016
- * C/C++ source code generated on : Wed Jul 06 11:19:35 2016
+ * C/C++ source code generated on : Sun Jul 10 15:19:51 2016
  *
  * Target selection: ert.tlc
- * Embedded hardware selection: NXP->Cortex-M4
+ * Embedded hardware selection: ARM Compatible->ARM Cortex
  * Code generation objectives: Unspecified
  * Validation result: Not run
  */
 
 #ifndef RTW_HEADER_Controller_Slave_h_
 #define RTW_HEADER_Controller_Slave_h_
+#include "rtwtypes.h"
 #include <math.h>
 #include <string.h>
+#include <stddef.h>
 #ifndef Controller_Slave_COMMON_INCLUDES_
 # define Controller_Slave_COMMON_INCLUDES_
 #include "rtwtypes.h"
 #endif                                 /* Controller_Slave_COMMON_INCLUDES_ */
 
 /* Macros for accessing real-time model data structure */
+#ifndef rtmGetBlockIO
+# define rtmGetBlockIO(rtm)            ((rtm)->ModelData.blockIO)
+#endif
+
+#ifndef rtmSetBlockIO
+# define rtmSetBlockIO(rtm, val)       ((rtm)->ModelData.blockIO = (val))
+#endif
+
+#ifndef rtmGetDefaultParam
+# define rtmGetDefaultParam(rtm)       ((rtm)->ModelData.defaultParam)
+#endif
+
+#ifndef rtmSetDefaultParam
+# define rtmSetDefaultParam(rtm, val)  ((rtm)->ModelData.defaultParam = (val))
+#endif
+
+#ifndef rtmGetRootDWork
+# define rtmGetRootDWork(rtm)          ((rtm)->ModelData.dwork)
+#endif
+
+#ifndef rtmSetRootDWork
+# define rtmSetRootDWork(rtm, val)     ((rtm)->ModelData.dwork = (val))
+#endif
+
 #ifndef rtmGetErrorStatus
 # define rtmGetErrorStatus(rtm)        ((rtm)->errorStatus)
 #endif
@@ -51,16 +77,26 @@
   uint8_T is_c6_Controller_Slave;      /* '<S1>/select_command' */
   uint8_T is_BLINK;                    /* '<S1>/select_command' */
   uint8_T is_active_c5_Controller_Slave;/* '<S1>/AEB_QA' */
-  uint8_T is_QA_ACTIVE;                /* '<S1>/AEB_QA' */
+  uint8_T is_ERRORS_CHECK_THREAD;      /* '<S1>/AEB_QA' */
   uint8_T is_APPLICATION_THREAD;       /* '<S1>/AEB_QA' */
   uint8_T is_AEB_ACTIVE;               /* '<S1>/AEB_QA' */
-  uint8_T is_ERRORS_CHECK_THREAD;      /* '<S1>/AEB_QA' */
+  uint8_T is_QA_ACTIVE;                /* '<S1>/AEB_QA' */
   boolean_T En;                        /* '<S1>/AEB_QA' */
 } DW_Controller_Slave_T;
 
+/* Parameters (auto storage) */
+struct P_Controller_Slave_T_ {
+  uint8_T Memory_X0;                   /* Computed Parameter: Memory_X0
+                                        * Referenced by: '<S1>/Memory'
+                                        */
+};
+
+/* Parameters (auto storage) */
+typedef struct P_Controller_Slave_T_ P_Controller_Slave_T;
+
 /* Real-time Model Data Structure */
 struct tag_RTM_Controller_Slave_T {
-  const char_T * volatile errorStatus;
+  const char_T *errorStatus;
 
   /*
    * ModelData:
@@ -69,6 +105,7 @@
    */
   struct {
     B_Controller_Slave_T *blockIO;
+    P_Controller_Slave_T *defaultParam;
     DW_Controller_Slave_T *dwork;
   } ModelData;
 };
@@ -102,15 +139,15 @@
  * MATLAB hilite_system command to trace the generated code back
  * to the parent model.  For example,
  *
- * hilite_system('Controller_Model_07_05_v01/Controller/Controller_Slave')    - opens subsystem Controller_Model_07_05_v01/Controller/Controller_Slave
- * hilite_system('Controller_Model_07_05_v01/Controller/Controller_Slave/Kp') - opens and selects block Kp
+ * hilite_system('Controller_Model_07_10_v01/Controller/Controller_Slave')    - opens subsystem Controller_Model_07_10_v01/Controller/Controller_Slave
+ * hilite_system('Controller_Model_07_10_v01/Controller/Controller_Slave/Kp') - opens and selects block Kp
  *
  * Here is the system hierarchy for this model
  *
- * '<Root>' : 'Controller_Model_07_05_v01/Controller'
- * '<S1>'   : 'Controller_Model_07_05_v01/Controller/Controller_Slave'
- * '<S2>'   : 'Controller_Model_07_05_v01/Controller/Controller_Slave/AEB_QA'
- * '<S3>'   : 'Controller_Model_07_05_v01/Controller/Controller_Slave/select_command'
+ * '<Root>' : 'Controller_Model_07_10_v01/Controller'
+ * '<S1>'   : 'Controller_Model_07_10_v01/Controller/Controller_Slave'
+ * '<S2>'   : 'Controller_Model_07_10_v01/Controller/Controller_Slave/AEB_QA'
+ * '<S3>'   : 'Controller_Model_07_10_v01/Controller/Controller_Slave/select_command'
  */
 #endif                                 /* RTW_HEADER_Controller_Slave_h_ */
 
--- a/rtwtypes.h	Wed Jul 06 09:21:22 2016 +0000
+++ b/rtwtypes.h	Mon Jul 11 10:15:51 2016 +0000
@@ -7,12 +7,12 @@
  *
  * Code generated for Simulink model 'Controller_Slave'.
  *
- * Model version                  : 1.6
+ * Model version                  : 1.7
  * Simulink Coder version         : 8.10 (R2016a) 10-Feb-2016
- * C/C++ source code generated on : Wed Jul 06 11:19:35 2016
+ * C/C++ source code generated on : Sun Jul 10 15:19:51 2016
  *
  * Target selection: ert.tlc
- * Embedded hardware selection: NXP->Cortex-M4
+ * Embedded hardware selection: ARM Compatible->ARM Cortex
  * Code generation objectives: Unspecified
  * Validation result: Not run
  */
@@ -33,7 +33,7 @@
 
 /*=======================================================================*
  * Target hardware information
- *   Device type: NXP->Cortex-M4
+ *   Device type: ARM Compatible->ARM Cortex
  *   Number of bits:     char:   8    short:   16    int:  32
  *                       long:  32
  *                       native word size:  32