Slave controller for AEB and QA item
Controller_Slave.c
- Committer:
- AndreaAndreoli
- Date:
- 2016-07-11
- Revision:
- 1:370626c9b451
- Parent:
- 0:88fb7562377b
File content as of revision 1:370626c9b451:
/* * Academic License - for use in teaching, academic research, and meeting * course requirements at degree granting institutions only. Not for * government, commercial, or other organizational use. * * File: Controller_Slave.c * * Code generated for Simulink model 'Controller_Slave'. * * Model version : 1.7 * Simulink Coder version : 8.10 (R2016a) 10-Feb-2016 * C/C++ source code generated on : Sun Jul 10 15:19:51 2016 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex * Code generation objectives: Unspecified * Validation result: Not run */ #include "Controller_Slave.h" /* Named constants for Chart: '<S1>/AEB_QA' */ #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)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)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) #define Controller_Slave_IN_WARNING ((uint8_T)3U) #define Controller__IN_SLAVE_ACTIVATION ((uint8_T)3U) /* Named constants for Chart: '<S1>/select_command' */ #define Controller_Slave_IN_BLINK ((uint8_T)1U) #define Controller_Slave_IN_BLINK_OFF ((uint8_T)1U) #define Controller_Slave_IN_BLINK_ON ((uint8_T)2U) #define Controller_Slave_IN_OFF1 ((uint8_T)2U) #define Controller_Slave_IN_ON ((uint8_T)3U) /* Forward declaration for local functions */ static void Controller_Slave_AEB_QA(const uint8_T *Memory, real_T Controller_Slave_U_V, real_T Controller_Slave_U_D_S, boolean_T Controller_Slave_U_QA_EN, uint8_T *Controller_Slave_Y_BRAKE, uint8_T *Controller_Slave_Y_ACC, uint8_T *Controller_Slave_Y_LED_RED, uint8_T *Controller_Slave_Y_LED_GREEN, uint8_T *Controller_Slave_Y_SLAVE, B_Controller_Slave_T *Controller_Slave_B, DW_Controller_Slave_T *Controller_Slave_DW); /*===========* * Constants * *===========*/ #define RT_PI 3.14159265358979323846 #define RT_PIF 3.1415927F #define RT_LN_10 2.30258509299404568402 #define RT_LN_10F 2.3025851F #define RT_LOG10E 0.43429448190325182765 #define RT_LOG10EF 0.43429449F #define RT_E 2.7182818284590452354 #define RT_EF 2.7182817F /* * UNUSED_PARAMETER(x) * Used to specify that a function parameter (argument) is required but not * accessed by the function body. */ #ifndef UNUSED_PARAMETER # if defined(__LCC__) # define UNUSED_PARAMETER(x) /* do nothing */ # else /* * This is the semi-ANSI standard way of indicating that an * unused function parameter is required. */ # define UNUSED_PARAMETER(x) (void) (x) # endif #endif /* Function for Chart: '<S1>/AEB_QA' */ static void Controller_Slave_AEB_QA(const uint8_T *Memory, real_T Controller_Slave_U_V, real_T Controller_Slave_U_D_S, boolean_T Controller_Slave_U_QA_EN, uint8_T *Controller_Slave_Y_BRAKE, uint8_T *Controller_Slave_Y_ACC, uint8_T *Controller_Slave_Y_LED_RED, uint8_T *Controller_Slave_Y_LED_GREEN, uint8_T *Controller_Slave_Y_SLAVE, B_Controller_Slave_T *Controller_Slave_B, DW_Controller_Slave_T *Controller_Slave_DW) { real_T K; /* During 'AEB_QA': '<S2>:35' */ /* During 'ERRORS_CHECK_THREAD': '<S2>:80' */ switch (Controller_Slave_DW->is_ERRORS_CHECK_THREAD) { case Controller_Slave_IN_ERR: /* During 'ERR': '<S2>:89' */ break; case Controller_Slave_IN_OK: /* Inport: '<Root>/V' incorporates: * Inport: '<Root>/D_S' */ /* During 'OK': '<S2>:94' */ /* '<S2>:83:1' sf_internal_predicateOutput = ... */ /* '<S2>:83:1' V > 180 || D > 200; */ if ((Controller_Slave_U_V > 180.0) || (Controller_Slave_U_D_S > 200.0)) { /* Transition: '<S2>:83' */ Controller_Slave_DW->is_ERRORS_CHECK_THREAD = Controller_Slave_IN_ERR; /* Entry 'ERR': '<S2>:89' */ /* '<S2>:89:1' Led_Red = uint8(1); */ *Controller_Slave_Y_LED_RED = 1U; /* '<S2>:89:1' Slave = uint8(0); */ *Controller_Slave_Y_SLAVE = 0U; /* '<S2>:89:3' En = false; */ Controller_Slave_DW->En = false; /* '<S2>:89:3' Brake = uint8(0); */ *Controller_Slave_Y_BRAKE = 0U; /* '<S2>:89:4' Led_Blue = 0; */ Controller_Slave_B->Led_Blue = 0.0; } else { /* '<S2>:82:1' sf_internal_predicateOutput = ... */ /* '<S2>:82:1' D == 0; */ if (Controller_Slave_U_D_S == 0.0) { /* Transition: '<S2>:82' */ Controller_Slave_DW->is_ERRORS_CHECK_THREAD = Controller_Slave_IN_ERR; /* Entry 'ERR': '<S2>:89' */ /* '<S2>:89:1' Led_Red = uint8(1); */ *Controller_Slave_Y_LED_RED = 1U; /* '<S2>:89:1' Slave = uint8(0); */ *Controller_Slave_Y_SLAVE = 0U; /* '<S2>:89:3' En = false; */ Controller_Slave_DW->En = false; /* '<S2>:89:3' Brake = uint8(0); */ *Controller_Slave_Y_BRAKE = 0U; /* '<S2>:89:4' Led_Blue = 0; */ Controller_Slave_B->Led_Blue = 0.0; } else { /* '<S2>:85:1' sf_internal_predicateOutput = ... */ /* '<S2>:85:1' Master ~= 1 && En == false; */ if ((*Memory != 1) && (!Controller_Slave_DW->En)) { /* Transition: '<S2>:85' */ Controller_Slave_DW->is_ERRORS_CHECK_THREAD = Controller__IN_SLAVE_ACTIVATION; /* Entry 'SLAVE_ACTIVATION': '<S2>:95' */ /* '<S2>:95:1' En = true; */ Controller_Slave_DW->En = true; } } } break; default: /* During 'SLAVE_ACTIVATION': '<S2>:95' */ /* Transition: '<S2>:84' */ Controller_Slave_DW->is_ERRORS_CHECK_THREAD = Controller_Slave_IN_OK; /* Entry 'OK': '<S2>:94' */ /* '<S2>:94:1' Led_Red = uint8(0); */ *Controller_Slave_Y_LED_RED = 0U; /* '<S2>:94:1' Slave = uint8(1); */ *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 */ void Controller_Slave_step(RT_MODEL_Controller_Slave_T *const Controller_Slave_M, real_T Controller_Slave_U_V, real_T Controller_Slave_U_D_S, uint8_T Controller_Slave_U_Master, boolean_T Controller_Slave_U_QA_EN, uint8_T *Controller_Slave_Y_BRAKE, uint8_T *Controller_Slave_Y_ACC, uint8_T *Controller_Slave_Y_LED_RED, uint8_T *Controller_Slave_Y_LED_GREEN, uint8_T *Controller_Slave_Y_LED_BLUE, uint8_T *Controller_Slave_Y_SLAVE) { B_Controller_Slave_T *Controller_Slave_B = ((B_Controller_Slave_T *) Controller_Slave_M->ModelData.blockIO); DW_Controller_Slave_T *Controller_Slave_DW = ((DW_Controller_Slave_T *) Controller_Slave_M->ModelData.dwork); uint8_T Memory; /* Outputs for Atomic SubSystem: '<Root>/Controller_Slave' */ /* Memory: '<S1>/Memory' */ Memory = Controller_Slave_DW->Memory_PreviousInput; /* Chart: '<S1>/AEB_QA' */ /* Gateway: Controller_Slave/AEB_QA */ /* During: Controller_Slave/AEB_QA */ if (Controller_Slave_DW->is_active_c5_Controller_Slave == 0U) { /* Entry: Controller_Slave/AEB_QA */ Controller_Slave_DW->is_active_c5_Controller_Slave = 1U; /* Entry Internal: Controller_Slave/AEB_QA */ /* Entry Internal 'AEB_QA': '<S2>:35' */ /* Entry Internal 'ERRORS_CHECK_THREAD': '<S2>:80' */ /* Transition: '<S2>:81' */ Controller_Slave_DW->is_ERRORS_CHECK_THREAD = Controller_Slave_IN_OK; /* Outport: '<Root>/LED_RED' */ /* Entry 'OK': '<S2>:94' */ /* '<S2>:94:1' Led_Red = uint8(0); */ *Controller_Slave_Y_LED_RED = 0U; /* 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, Controller_Slave_Y_ACC, Controller_Slave_Y_LED_RED, Controller_Slave_Y_LED_GREEN, Controller_Slave_Y_SLAVE, Controller_Slave_B, Controller_Slave_DW); } /* End of Chart: '<S1>/AEB_QA' */ /* Chart: '<S1>/select_command' */ if (Controller_Slave_DW->temporalCounter_i1 < MAX_uint32_T) { Controller_Slave_DW->temporalCounter_i1++; } /* Gateway: Controller_Slave/select_command */ /* During: Controller_Slave/select_command */ if (Controller_Slave_DW->is_active_c6_Controller_Slave == 0U) { /* Entry: Controller_Slave/select_command */ Controller_Slave_DW->is_active_c6_Controller_Slave = 1U; /* Entry Internal: Controller_Slave/select_command */ /* Transition: '<S3>:2' */ Controller_Slave_DW->is_c6_Controller_Slave = Controller_Slave_IN_OFF1; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'OFF1': '<S3>:3' */ /* '<S3>:3:1' led = uint8(0); */ *Controller_Slave_Y_LED_BLUE = 0U; } else { switch (Controller_Slave_DW->is_c6_Controller_Slave) { case Controller_Slave_IN_BLINK: /* During 'BLINK': '<S3>:20' */ /* '<S3>:7:1' sf_internal_predicateOutput = ... */ /* '<S3>:7:1' enable == 1; */ if (Controller_Slave_B->Led_Blue == 1.0) { /* Transition: '<S3>:7' */ /* Exit Internal 'BLINK': '<S3>:20' */ Controller_Slave_DW->is_BLINK = Controller_S_IN_NO_ACTIVE_CHILD; Controller_Slave_DW->is_c6_Controller_Slave = Controller_Slave_IN_ON; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'ON': '<S3>:6' */ /* '<S3>:6:1' led = uint8(1); */ *Controller_Slave_Y_LED_BLUE = 1U; } else { /* '<S3>:21:1' sf_internal_predicateOutput = ... */ /* '<S3>:21:1' enable == 0; */ if (Controller_Slave_B->Led_Blue == 0.0) { /* Transition: '<S3>:21' */ /* Exit Internal 'BLINK': '<S3>:20' */ Controller_Slave_DW->is_BLINK = Controller_S_IN_NO_ACTIVE_CHILD; Controller_Slave_DW->is_c6_Controller_Slave = Controller_Slave_IN_OFF1; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'OFF1': '<S3>:3' */ /* '<S3>:3:1' led = uint8(0); */ *Controller_Slave_Y_LED_BLUE = 0U; } else if (Controller_Slave_DW->is_BLINK == Controller_Slave_IN_BLINK_OFF) { /* During 'BLINK_OFF': '<S3>:11' */ /* '<S3>:14:1' sf_internal_predicateOutput = ... */ /* '<S3>:14:1' after(1-enable,sec); */ if (Controller_Slave_DW->temporalCounter_i1 >= (uint32_T)ceil((1.0 - Controller_Slave_B->Led_Blue) / 0.1 - 1.0E-9)) { /* Transition: '<S3>:14' */ Controller_Slave_DW->is_BLINK = Controller_Slave_IN_BLINK_ON; Controller_Slave_DW->temporalCounter_i1 = 0U; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'BLINK_ON': '<S3>:13' */ /* '<S3>:13:1' led = uint8(1); */ *Controller_Slave_Y_LED_BLUE = 1U; } } else { /* During 'BLINK_ON': '<S3>:13' */ /* '<S3>:15:1' sf_internal_predicateOutput = ... */ /* '<S3>:15:1' after(0.1,sec); */ if (Controller_Slave_DW->temporalCounter_i1 >= 1U) { /* Transition: '<S3>:15' */ Controller_Slave_DW->is_BLINK = Controller_Slave_IN_BLINK_OFF; Controller_Slave_DW->temporalCounter_i1 = 0U; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'BLINK_OFF': '<S3>:11' */ /* '<S3>:11:1' led = uint8(0); */ *Controller_Slave_Y_LED_BLUE = 0U; } } } break; case Controller_Slave_IN_OFF1: /* During 'OFF1': '<S3>:3' */ /* '<S3>:22:1' sf_internal_predicateOutput = ... */ /* '<S3>:22:1' enable == 1; */ if (Controller_Slave_B->Led_Blue == 1.0) { /* Transition: '<S3>:22' */ Controller_Slave_DW->is_c6_Controller_Slave = Controller_Slave_IN_ON; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'ON': '<S3>:6' */ /* '<S3>:6:1' led = uint8(1); */ *Controller_Slave_Y_LED_BLUE = 1U; } else { /* '<S3>:12:1' sf_internal_predicateOutput = ... */ /* '<S3>:12:1' enable >0 && enable <1; */ if ((Controller_Slave_B->Led_Blue > 0.0) && (Controller_Slave_B->Led_Blue < 1.0)) { /* Transition: '<S3>:12' */ Controller_Slave_DW->is_c6_Controller_Slave = Controller_Slave_IN_BLINK; /* Entry Internal 'BLINK': '<S3>:20' */ /* Transition: '<S3>:24' */ Controller_Slave_DW->is_BLINK = Controller_Slave_IN_BLINK_OFF; Controller_Slave_DW->temporalCounter_i1 = 0U; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'BLINK_OFF': '<S3>:11' */ /* '<S3>:11:1' led = uint8(0); */ *Controller_Slave_Y_LED_BLUE = 0U; } } break; default: /* During 'ON': '<S3>:6' */ /* '<S3>:4:1' sf_internal_predicateOutput = ... */ /* '<S3>:4:1' enable == 0; */ if (Controller_Slave_B->Led_Blue == 0.0) { /* Transition: '<S3>:4' */ Controller_Slave_DW->is_c6_Controller_Slave = Controller_Slave_IN_OFF1; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'OFF1': '<S3>:3' */ /* '<S3>:3:1' led = uint8(0); */ *Controller_Slave_Y_LED_BLUE = 0U; } else { /* '<S3>:23:1' sf_internal_predicateOutput = ... */ /* '<S3>:23:1' enable >0 && enable <1; */ if ((Controller_Slave_B->Led_Blue > 0.0) && (Controller_Slave_B->Led_Blue < 1.0)) { /* Transition: '<S3>:23' */ Controller_Slave_DW->is_c6_Controller_Slave = Controller_Slave_IN_BLINK; /* Entry Internal 'BLINK': '<S3>:20' */ /* Transition: '<S3>:24' */ Controller_Slave_DW->is_BLINK = Controller_Slave_IN_BLINK_OFF; Controller_Slave_DW->temporalCounter_i1 = 0U; /* Outport: '<Root>/LED_BLUE' */ /* Entry 'BLINK_OFF': '<S3>:11' */ /* '<S3>:11:1' led = uint8(0); */ *Controller_Slave_Y_LED_BLUE = 0U; } } break; } } /* End of Chart: '<S1>/select_command' */ /* Update for Memory: '<S1>/Memory' incorporates: * Update for Inport: '<Root>/MASTER' */ Controller_Slave_DW->Memory_PreviousInput = Controller_Slave_U_Master; /* End of Outputs for SubSystem: '<Root>/Controller_Slave' */ } /* Model initialize function */ void Controller_Slave_initialize(RT_MODEL_Controller_Slave_T *const Controller_Slave_M, real_T *Controller_Slave_U_V, real_T *Controller_Slave_U_D_S, uint8_T *Controller_Slave_U_Master, boolean_T *Controller_Slave_U_QA_EN, uint8_T *Controller_Slave_Y_BRAKE, uint8_T *Controller_Slave_Y_ACC, uint8_T *Controller_Slave_Y_LED_RED, uint8_T *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 *) Controller_Slave_M->ModelData.blockIO); /* Registration code */ /* block I/O */ (void) memset(((void *) Controller_Slave_B), 0, sizeof(B_Controller_Slave_T)); /* states (dwork) */ (void) memset((void *)Controller_Slave_DW, 0, sizeof(DW_Controller_Slave_T)); /* external inputs */ (*Controller_Slave_U_V) = 0.0; (*Controller_Slave_U_D_S) = 0.0; (*Controller_Slave_U_Master) = 0U; (*Controller_Slave_U_QA_EN) = false; /* external outputs */ (*Controller_Slave_Y_BRAKE) = 0U; (*Controller_Slave_Y_ACC) = 0U; (*Controller_Slave_Y_LED_RED) = 0U; (*Controller_Slave_Y_LED_GREEN) = 0U; (*Controller_Slave_Y_LED_BLUE) = 0U; (*Controller_Slave_Y_SLAVE) = 0U; /* SystemInitialize for Atomic SubSystem: '<Root>/Controller_Slave' */ /* InitializeConditions for Memory: '<S1>/Memory' */ 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; Controller_Slave_DW->is_AEB_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD; Controller_Slave_DW->is_QA_ACTIVE = Controller_S_IN_NO_ACTIVE_CHILD; Controller_Slave_DW->is_ERRORS_CHECK_THREAD = Controller_S_IN_NO_ACTIVE_CHILD; Controller_Slave_DW->is_active_c5_Controller_Slave = 0U; Controller_Slave_DW->En = false; /* SystemInitialize for Chart: '<S1>/select_command' */ Controller_Slave_DW->is_BLINK = Controller_S_IN_NO_ACTIVE_CHILD; Controller_Slave_DW->temporalCounter_i1 = 0U; Controller_Slave_DW->is_active_c6_Controller_Slave = 0U; Controller_Slave_DW->is_c6_Controller_Slave = Controller_S_IN_NO_ACTIVE_CHILD; /* End of SystemInitialize for SubSystem: '<Root>/Controller_Slave' */ } /* Model terminate function */ void Controller_Slave_terminate(RT_MODEL_Controller_Slave_T *const Controller_Slave_M) { /* (no terminate code required) */ UNUSED_PARAMETER(Controller_Slave_M); } /* * File trailer for generated code. * * [EOF] */