diff --git a/HVAC_model.c b/HVAC_model.c new file mode 100644 index 0000000..7191e83 --- /dev/null +++ b/HVAC_model.c @@ -0,0 +1,1665 @@ +/* + * File: HVAC_model.c + * + * Code generated for Simulink model 'HVAC_model'. + * + * Model version : 1.604 + * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 + * C/C++ source code generated on : Fri Feb 13 13:56:38 2026 + * + * Target selection: ert.tlc + * Embedded hardware selection: ARM Compatible->ARM Cortex-M + * Emulation hardware selection: + * Differs from embedded hardware (MATLAB Host) + * Code generation objectives: Unspecified + * Validation result: Not run + */ + +#include "HVAC_model.h" +#include +#include "HVAC_model_private.h" +#include "HVAC_model_types.h" +#include +#include + +/* Exported block states */ +ActuatorCmdBus Actuator_Ch0_Command_Model;/* '/Data Store Memory15' */ +CmdBusStatus Status_Sensor_Model; /* '/Data Store Memory' */ +CmdBusError CCU_Errors_Model; /* '/Data Store Memory3' */ + +/* Block signals (default storage) */ +B rtB; + +/* Block states (default storage) */ +DW rtDW; + +/* Real-time model */ +static RT_MODEL rtM_; +RT_MODEL *const rtM = &rtM_; +int16_t look1_iu16tdIs16_binlcs(uint16_t u0, const uint16_t bp0[], const double + table[], uint32_t maxIndex) +{ + double frac; + double yL_0d0; + int32_t tmp_1; + uint32_t iLeft; + int16_t tmp; + int16_t tmp_0; + + /* Column-major Lookup 1-D + Search method: 'binary' + Use previous index: 'off' + Interpolation method: 'Linear point-slope' + Extrapolation method: 'Clip' + Use last breakpoint for index at or above upper limit: 'off' + Remove protection against out-of-range input in generated code: 'off' + */ + /* Prelookup - Index and Fraction + Index Search method: 'binary' + Extrapolation method: 'Clip' + Use previous index: 'off' + Use last breakpoint for index at or above upper limit: 'off' + Remove protection against out-of-range input in generated code: 'off' + */ + if (u0 <= bp0[0U]) { + iLeft = 0U; + frac = 0.0; + } else if (u0 < bp0[maxIndex]) { + uint32_t bpIdx; + uint32_t iRght; + + /* Binary Search */ + bpIdx = maxIndex >> 1U; + iLeft = 0U; + iRght = maxIndex; + while (iRght - iLeft > 1U) { + if (u0 < bp0[bpIdx]) { + iRght = bpIdx; + } else { + iLeft = bpIdx; + } + + bpIdx = (iRght + iLeft) >> 1U; + } + + uint16_t bpLeftVar; + bpLeftVar = bp0[iLeft]; + frac = (double)((uint32_t)u0 - bpLeftVar) / (double)((uint32_t)bp0[iLeft + + 1U] - bpLeftVar); + } else { + iLeft = maxIndex - 1U; + frac = 1.0; + } + + /* Column-major Interpolation 1-D + Interpolation method: 'Linear point-slope' + Use last breakpoint for index at or above upper limit: 'off' + Overflow mode: 'saturate' + */ + yL_0d0 = table[iLeft]; + if (yL_0d0 < 32768.0) { + if (yL_0d0 >= -32768.0) { + tmp = (int16_t)yL_0d0; + } else { + tmp = INT16_MIN; + } + } else { + tmp = INT16_MAX; + } + + frac *= table[iLeft + 1U] - yL_0d0; + if (frac < 32768.0) { + if (frac >= -32768.0) { + tmp_0 = (int16_t)frac; + } else { + tmp_0 = INT16_MIN; + } + } else { + tmp_0 = INT16_MAX; + } + + tmp_1 = tmp + tmp_0; + if (tmp_1 > 32767) { + tmp_1 = 32767; + } else if (tmp_1 < -32768) { + tmp_1 = -32768; + } + + return (int16_t)tmp_1; +} + +/* + * Output and update for action system: + * '/If Action Subsystem3' + * '/If Action Subsystem3' + * '/If Action Subsystem3' + * '/If Action Subsystem3' + * '/If Action Subsystem3' + * '/If Action Subsystem3' + * '/If Action Subsystem3' + */ +void IfActionSubsystem3(int8_t rtu_stepIn, int8_t *rty_step) +{ + int32_t i; + + /* BusCreator: '/Bus Creator' incorporates: + * DataStoreWrite: '/Data Store Write' + * SignalConversion generated from: '/Bus Creator' + * */ + for (i = 0; i < 9; i++) { + Actuator_Ch0_Command_Model.POS[i] = 0U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 0U; + Actuator_Ch0_Command_Model.COM[i] = 0U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 0U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 0U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 0U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + } + + /* End of BusCreator: '/Bus Creator' */ + + /* SignalConversion generated from: '/stepIn' */ + *rty_step = rtu_stepIn; +} + +/* + * Output and update for atomic system: + * '/MAX POSITION' + * '/MAX POSITION' + */ +void MAXPOSITION(int16_t rty_y[9]) +{ + int32_t i; + + /* : y = step; */ + /* : fprintf('SIMULINK POSITION '); */ + printf("SIMULINK POSITION "); + fflush(stdout); + + /* : for i = 1:numel(step) */ + for (i = 0; i < 9; i++) { + /* : fprintf('%d ', int16(step(i))); */ + printf("%d ", rty_y[i]); + fflush(stdout); + } + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); +} + +/* + * Output and update for atomic system: + * '/MAX POSITION1' + * '/MAX POSITION1' + */ +void MAXPOSITION1(int8_t rty_y[9]) +{ + int32_t i; + + /* : y = step; */ + /* : fprintf('SIMULINK Stall_Slave '); */ + printf("SIMULINK Stall_Slave "); + fflush(stdout); + + /* : for i = 1:numel(step) */ + for (i = 0; i < 9; i++) { + /* : fprintf('%d ', int16(step(i))); */ + printf("%d ", (int16_t)rty_y[i]); + fflush(stdout); + } + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); +} + +/* + * Output and update for atomic system: + * '/MAX POSITION' + * '/MAX POSITION' + */ +void MAXPOSITION_l(const double rtu_step[9], double rty_y[9]) +{ + int32_t i; + + /* : y = step; */ + memcpy(&rty_y[0], &rtu_step[0], 9U * sizeof(double)); + + /* : fprintf('SIMULINK MAX POSITION '); */ + printf("SIMULINK MAX POSITION "); + fflush(stdout); + + /* : for i = 1:numel(step) */ + for (i = 0; i < 9; i++) { + /* : fprintf('%f ', step(i)); */ + printf("%f ", rtu_step[i]); + fflush(stdout); + } + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); +} + +/* Model step function */ +void HVAC_model_step(void) +{ + double rtb_Divide1_j[9]; + double rtb_y_gj[9]; + double rtb_Divide1_n; + int32_t i; + int16_t rtb_y_ff[9]; + int16_t rtb_Switch_f; + int8_t rtb_y_b[9]; + int8_t rtb_Switch_l4; + bool rtb_RelationalOperator_j[9]; + bool rtb_FailCond; + bool rtb_LogicalOperator1; + bool rtb_LogicalOperator1_b; + bool rtb_LogicalOperator1_f; + bool rtb_LogicalOperator1_i; + bool rtb_LogicalOperator1_k; + bool rtb_LogicalOperator1_ln; + bool rtb_LogicalOperator1_n; + bool tmp; + + /* Product: '/Divide1' incorporates: + * Constant: '/Constant' + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read1' + * Product: '/Divide' + */ + rtb_Divide1_n = (double)rtDW.ADC_Data_Model.Sensor_Ambient_Temp / 4095.0 * 5.0; + + /* Logic: '/Logical Operator' incorporates: + * Constant: '/Constant' + * Constant: '/Constant' + * RelationalOperator: '/Compare' + * RelationalOperator: '/Compare' + */ + rtb_FailCond = ((rtb_Divide1_n < 0.1) || (rtb_Divide1_n > 4.9)); + + /* Logic: '/Logical Operator1' incorporates: + * Constant: '/Constant' + * DataStoreRead: '/Data Store Read4' + * RelationalOperator: '/Compare' + * Sum: '/Subtract' + * UnitDelay: '/t_start_delay_private ' + */ + rtb_LogicalOperator1 = (rtb_FailCond && (rtDW.t_now - + rtDW.t_start_delay_private_DSTATE >= 3000U)); + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant2' + * DataStoreRead: '/Data Store Read1' + * Lookup_n-D: '/1-D Lookup Table' + */ + if (rtb_LogicalOperator1) { + rtb_Switch_f = 100; + } else { + rtb_Switch_f = look1_iu16tdIs16_binlcs + (rtDW.ADC_Data_Model.Sensor_Ambient_Temp, rtConstP.pooled15, + rtConstP.uDLookupTable_tableData, 1023U); + } + + /* End of Switch: '/Switch' */ + + /* MATLAB Function: '/Write Ambient' */ + /* : fprintf('Ambient = %d * 0.1 C\n',Ambient); */ + printf("Ambient = %d * 0.1 C\n", rtb_Switch_f); + fflush(stdout); + + /* MATLAB Function: '/Write ERROR' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + /* : if(AmbientErr) */ + if (rtb_LogicalOperator1) { + /* : fprintf('CCU_Body_Err.CCU_AmbienTemptSenErr_Stat = 0x1 (Failure), Sensor_Ambient_Temp = %u\n',Sensor_Ambient_Temp); */ + printf("CCU_Body_Err.CCU_AmbienTemptSenErr_Stat = 0x1 (Failure), Sensor_Ambient_Temp = %u\n", + rtDW.ADC_Data_Model.Sensor_Ambient_Temp); + fflush(stdout); + } + + /* End of MATLAB Function: '/Write ERROR' */ + + /* Switch: '/Switch' incorporates: + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator3' + * Logic: '/Logical Operator4' + * UnitDelay: '/Cond_prev_private ' + * UnitDelay: '/t_start_delay_private ' + */ + if (rtb_FailCond && (!rtDW.Cond_prev_private_DSTATE)) { + rtDW.t_start_delay_private_DSTATE = rtDW.t_now; + } + + /* End of Switch: '/Switch' */ + + /* Product: '/Divide1' incorporates: + * Constant: '/Constant' + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read1' + * Product: '/Divide' + */ + rtb_Divide1_n = (double)rtDW.ADC_Data_Model.Sensor_Evap_Temp / 4095.0 * 5.0; + + /* Logic: '/Logical Operator' incorporates: + * Constant: '/Constant' + * Constant: '/Constant' + * RelationalOperator: '/Compare' + * RelationalOperator: '/Compare' + */ + rtb_LogicalOperator1 = ((rtb_Divide1_n < 0.1) || (rtb_Divide1_n > 4.9)); + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant' + * Constant: '/Constant2' + * DataStoreRead: '/Data Store Read1' + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator1' + * Lookup_n-D: '/1-D Lookup Table' + * MATLAB Function: '/Write ERROR' + * RelationalOperator: '/Compare' + * Sum: '/Subtract' + * UnitDelay: '/t_start_delay_private ' + */ + /* : if(EvapFErr) */ + if (rtb_LogicalOperator1 && (rtDW.t_now - rtDW.t_start_delay_private_DSTATE_p >= + 3000U)) { + rtb_Switch_f = -100; + + /* : fprintf('CCU_Body_Err.CCU_EvaTempSenErrF_Stat = 0x1 (Failure), Sensor_Evap_Temp = %u\n',Sensor_Evap_Temp); */ + printf("CCU_Body_Err.CCU_EvaTempSenErrF_Stat = 0x1 (Failure), Sensor_Evap_Temp = %u\n", + rtDW.ADC_Data_Model.Sensor_Evap_Temp); + fflush(stdout); + } else { + rtb_Switch_f = look1_iu16tdIs16_binlcs(rtDW.ADC_Data_Model.Sensor_Evap_Temp, + rtConstP.pooled15, rtConstP.pooled1, 1023U); + } + + /* End of Switch: '/Switch' */ + + /* MATLAB Function: '/Write Eva_F' */ + /* : fprintf('Eva_F = %d * 0.1 C\n',Eva_F); */ + printf("Eva_F = %d * 0.1 C\n", rtb_Switch_f); + fflush(stdout); + + /* Switch: '/Switch' incorporates: + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator3' + * Logic: '/Logical Operator4' + * UnitDelay: '/Cond_prev_private ' + * UnitDelay: '/t_start_delay_private ' + */ + if (rtb_LogicalOperator1 && (!rtDW.Cond_prev_private_DSTATE_h)) { + rtDW.t_start_delay_private_DSTATE_p = rtDW.t_now; + } + + /* End of Switch: '/Switch' */ + + /* Product: '/Divide1' incorporates: + * Constant: '/Constant' + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read1' + * Product: '/Divide' + */ + rtb_Divide1_n = (double)rtDW.ADC_Data_Model.Sensor_Rear_Evap_Temp / 4095.0 * + 5.0; + + /* Logic: '/Logical Operator' incorporates: + * Constant: '/Constant' + * Constant: '/Constant' + * RelationalOperator: '/Compare' + * RelationalOperator: '/Compare' + */ + rtb_LogicalOperator1_f = ((rtb_Divide1_n < 0.1) || (rtb_Divide1_n > 4.9)); + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant' + * Constant: '/Constant2' + * DataStoreRead: '/Data Store Read1' + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator1' + * Lookup_n-D: '/1-D Lookup Table' + * MATLAB Function: '/Write ERROR' + * RelationalOperator: '/Compare' + * Sum: '/Subtract' + * UnitDelay: '/t_start_delay_private ' + */ + /* : if(EvapRErr) */ + if (rtb_LogicalOperator1_f && (rtDW.t_now - + rtDW.t_start_delay_private_DSTATE_pk >= 3000U)) { + rtb_Switch_f = -100; + + /* : fprintf('CCU_Body_Err.CCU_EvaTempSenErrR_Stat = 0x1 (Failure), Sensor_Rear_Evap_Temp = %u\n',Sensor_Rear_Evap_Temp); */ + printf("CCU_Body_Err.CCU_EvaTempSenErrR_Stat = 0x1 (Failure), Sensor_Rear_Evap_Temp = %u\n", + rtDW.ADC_Data_Model.Sensor_Rear_Evap_Temp); + fflush(stdout); + } else { + rtb_Switch_f = look1_iu16tdIs16_binlcs + (rtDW.ADC_Data_Model.Sensor_Rear_Evap_Temp, rtConstP.pooled15, + rtConstP.pooled1, 1023U); + } + + /* End of Switch: '/Switch' */ + + /* MATLAB Function: '/Write Eva_F' */ + /* : fprintf('Eva_R = %d * 0.1 C\n',Eva_R); */ + printf("Eva_R = %d * 0.1 C\n", rtb_Switch_f); + fflush(stdout); + + /* Switch: '/Switch' incorporates: + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator3' + * Logic: '/Logical Operator4' + * UnitDelay: '/Cond_prev_private ' + * UnitDelay: '/t_start_delay_private ' + */ + if (rtb_LogicalOperator1_f && (!rtDW.Cond_prev_private_DSTATE_i)) { + rtDW.t_start_delay_private_DSTATE_pk = rtDW.t_now; + } + + /* End of Switch: '/Switch' */ + + /* Product: '/Divide1' incorporates: + * Constant: '/Constant' + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read1' + * Product: '/Divide' + */ + rtb_Divide1_n = (double)rtDW.ADC_Data_Model.Sensor_Incar_Temp_FL / 4095.0 * + 5.0; + + /* Logic: '/Logical Operator' incorporates: + * Constant: '/Constant' + * Constant: '/Constant' + * RelationalOperator: '/Compare' + * RelationalOperator: '/Compare' + */ + rtb_LogicalOperator1_k = ((rtb_Divide1_n < 0.15) || (rtb_Divide1_n > 4.9)); + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant' + * Constant: '/Constant2' + * DataStoreRead: '/Data Store Read1' + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator1' + * Lookup_n-D: '/1-D Lookup Table' + * MATLAB Function: '/Write ERROR' + * RelationalOperator: '/Compare' + * Sum: '/Subtract' + * UnitDelay: '/t_start_delay_private ' + */ + /* : if(IncarFLErr) */ + if (rtb_LogicalOperator1_k && (rtDW.t_now - + rtDW.t_start_delay_private_DSTATE_b >= 3000U)) { + rtb_Switch_f = 200; + + /* : fprintf('CCU_Body_Err.CCU_IncarTempErrF_Stat = 0x1 (Failure), Sensor_Incar_Temp_FL = %u\n',Sensor_Incar_Temp_FL); */ + printf("CCU_Body_Err.CCU_IncarTempErrF_Stat = 0x1 (Failure), Sensor_Incar_Temp_FL = %u\n", + rtDW.ADC_Data_Model.Sensor_Incar_Temp_FL); + fflush(stdout); + } else { + rtb_Switch_f = look1_iu16tdIs16_binlcs + (rtDW.ADC_Data_Model.Sensor_Incar_Temp_FL, rtConstP.pooled15, + rtConstP.pooled2, 1023U); + } + + /* End of Switch: '/Switch' */ + + /* MATLAB Function: '/Write IncarFL' */ + /* : fprintf('IncarFL = %d * 0.1 C\n',IncarFL); */ + printf("IncarFL = %d * 0.1 C\n", rtb_Switch_f); + fflush(stdout); + + /* Switch: '/Switch' incorporates: + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator3' + * Logic: '/Logical Operator4' + * UnitDelay: '/Cond_prev_private ' + * UnitDelay: '/t_start_delay_private ' + */ + if (rtb_LogicalOperator1_k && (!rtDW.Cond_prev_private_DSTATE_c)) { + rtDW.t_start_delay_private_DSTATE_b = rtDW.t_now; + } + + /* End of Switch: '/Switch' */ + + /* Product: '/Divide1' incorporates: + * Constant: '/Constant' + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read1' + * Product: '/Divide' + */ + rtb_Divide1_n = (double)rtDW.ADC_Data_Model.Sensor_Incar_Temp_FR / 4095.0 * + 5.0; + + /* Logic: '/Logical Operator' incorporates: + * Constant: '/Constant' + * Constant: '/Constant' + * RelationalOperator: '/Compare' + * RelationalOperator: '/Compare' + */ + rtb_LogicalOperator1_b = ((rtb_Divide1_n < 0.15) || (rtb_Divide1_n > 4.9)); + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant' + * Constant: '/Constant2' + * DataStoreRead: '/Data Store Read1' + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator1' + * Lookup_n-D: '/1-D Lookup Table' + * MATLAB Function: '/Write ERROR' + * RelationalOperator: '/Compare' + * Sum: '/Subtract' + * UnitDelay: '/t_start_delay_private ' + */ + /* : if(IncarFRErr) */ + if (rtb_LogicalOperator1_b && (rtDW.t_now - + rtDW.t_start_delay_private_DSTATE_g >= 3000U)) { + rtb_Switch_f = 200; + + /* : fprintf('CCU_Body_Err.CCU_IncarTempErrR_Stat = 0x1 (Failure), Sensor_Incar_Temp_FR = %u\n',Sensor_Incar_Temp_FR); */ + printf("CCU_Body_Err.CCU_IncarTempErrR_Stat = 0x1 (Failure), Sensor_Incar_Temp_FR = %u\n", + rtDW.ADC_Data_Model.Sensor_Incar_Temp_FR); + fflush(stdout); + } else { + rtb_Switch_f = look1_iu16tdIs16_binlcs + (rtDW.ADC_Data_Model.Sensor_Incar_Temp_FR, rtConstP.pooled15, + rtConstP.pooled2, 1023U); + } + + /* End of Switch: '/Switch' */ + + /* MATLAB Function: '/Write IncarFR' */ + /* : fprintf('IncarFR = %d * 0.1 C\n',IncarFR); */ + printf("IncarFR = %d * 0.1 C\n", rtb_Switch_f); + fflush(stdout); + + /* Switch: '/Switch' incorporates: + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator3' + * Logic: '/Logical Operator4' + * UnitDelay: '/Cond_prev_private ' + * UnitDelay: '/t_start_delay_private ' + */ + if (rtb_LogicalOperator1_b && (!rtDW.Cond_prev_private_DSTATE_hm)) { + rtDW.t_start_delay_private_DSTATE_g = rtDW.t_now; + } + + /* End of Switch: '/Switch' */ + + /* Product: '/Divide1' incorporates: + * Constant: '/Constant' + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read1' + * Product: '/Divide' + */ + rtb_Divide1_n = (double)rtDW.ADC_Data_Model.Sensor_Incar_Temp_RL / 4095.0 * + 5.0; + + /* Logic: '/Logical Operator' incorporates: + * Constant: '/Constant' + * Constant: '/Constant' + * RelationalOperator: '/Compare' + * RelationalOperator: '/Compare' + */ + rtb_LogicalOperator1_ln = ((rtb_Divide1_n < 0.15) || (rtb_Divide1_n > 4.9)); + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant' + * Constant: '/Constant2' + * DataStoreRead: '/Data Store Read1' + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator1' + * Lookup_n-D: '/1-D Lookup Table' + * MATLAB Function: '/Write ERROR' + * RelationalOperator: '/Compare' + * Sum: '/Subtract' + * UnitDelay: '/t_start_delay_private ' + */ + /* : if(IncarRLErr) */ + if (rtb_LogicalOperator1_ln && (rtDW.t_now - + rtDW.t_start_delay_private_DSTATE_j >= 3000U)) { + rtb_Switch_f = 200; + + /* : fprintf('CCU_Body_Err.CCU_IncarTempErrF_Stat = 0x1 (Failure), Sensor_Incar_Temp_RL = %u\n',Sensor_Incar_Temp_RL); */ + printf("CCU_Body_Err.CCU_IncarTempErrF_Stat = 0x1 (Failure), Sensor_Incar_Temp_RL = %u\n", + rtDW.ADC_Data_Model.Sensor_Incar_Temp_RL); + fflush(stdout); + } else { + rtb_Switch_f = look1_iu16tdIs16_binlcs + (rtDW.ADC_Data_Model.Sensor_Incar_Temp_RL, rtConstP.pooled15, + rtConstP.pooled2, 1023U); + } + + /* End of Switch: '/Switch' */ + + /* MATLAB Function: '/Write IncarRL' */ + /* : fprintf('IncarRL = %d * 0.1 C\n',IncarRL); */ + printf("IncarRL = %d * 0.1 C\n", rtb_Switch_f); + fflush(stdout); + + /* Switch: '/Switch' incorporates: + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator3' + * Logic: '/Logical Operator4' + * UnitDelay: '/Cond_prev_private ' + * UnitDelay: '/t_start_delay_private ' + */ + if (rtb_LogicalOperator1_ln && (!rtDW.Cond_prev_private_DSTATE_b)) { + rtDW.t_start_delay_private_DSTATE_j = rtDW.t_now; + } + + /* End of Switch: '/Switch' */ + + /* Product: '/Divide1' incorporates: + * Constant: '/Constant' + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read1' + * Product: '/Divide' + */ + rtb_Divide1_n = (double)rtDW.ADC_Data_Model.Sensor_Incar_Temp_RR / 4095.0 * + 5.0; + + /* Logic: '/Logical Operator' incorporates: + * Constant: '/Constant' + * Constant: '/Constant' + * RelationalOperator: '/Compare' + * RelationalOperator: '/Compare' + */ + rtb_LogicalOperator1_i = ((rtb_Divide1_n < 0.15) || (rtb_Divide1_n > 4.9)); + + /* Logic: '/Logical Operator1' incorporates: + * Constant: '/Constant' + * DataStoreRead: '/Data Store Read4' + * RelationalOperator: '/Compare' + * Sum: '/Subtract' + * UnitDelay: '/t_start_delay_private ' + */ + rtb_LogicalOperator1_n = (rtb_LogicalOperator1_i && (rtDW.t_now - + rtDW.t_start_delay_private_DSTATE_c >= 3000U)); + + /* BusCreator: '/Bus Creator' incorporates: + * DataStoreWrite: '/Data Store Write' + * DataTypeConversion: '/Data Type Conversion' + */ + CCU_Errors_Model.CCU_IncarTempErrF_Stat = 0U; + CCU_Errors_Model.CCU_IncarTempErrR_Stat = rtb_LogicalOperator1_n; + CCU_Errors_Model.CCU_DuctTempSenErrF_Stat = 0U; + CCU_Errors_Model.CCU_DuctTempSenErrR_Stat = 0U; + CCU_Errors_Model.CCU_EvaTempSenErrF_Stat = 0U; + CCU_Errors_Model.CCU_EvaTempSenErrR_Stat = 0U; + CCU_Errors_Model.CCU_DeflectorSwErrF_Stat = 0U; + CCU_Errors_Model.CCU_DeflectorSwErrR_Stat = 0U; + CCU_Errors_Model.CCU_PressSenErr_Stat = 0U; + CCU_Errors_Model.CCU_AmbienTemptSenErr_Stat = 0U; + CCU_Errors_Model.CCU_SealingValveErr_Stat = 0U; + CCU_Errors_Model.CCU_ETXVerr_Stat = 0U; + CCU_Errors_Model.CCU_HVACfanOrTXVerrF_Stat = 0U; + CCU_Errors_Model.CCU_HVACfanOrTXVerrR_Stat = 0U; + CCU_Errors_Model.CCU_ActuatorErrF_Stat = 0U; + CCU_Errors_Model.CCU_ActuatorErrR_Stat = 0U; + CCU_Errors_Model.CCU_UltravioletErr_Stat = 0U; + CCU_Errors_Model.CCU_VinRecordErr_Stat = 0U; + CCU_Errors_Model.CCU_AirQualSenErr_Stat = 0U; + CCU_Errors_Model.CCU_CommErr_Stat = 0U; + CCU_Errors_Model.CCU_TWVerr_Stat = 0U; + CCU_Errors_Model.CCU_IonizationErr_Stat = 0U; + CCU_Errors_Model.CCU_AromaErr_Stat = 0U; + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant2' + * DataStoreRead: '/Data Store Read1' + * Lookup_n-D: '/1-D Lookup Table' + */ + if (rtb_LogicalOperator1_n) { + rtb_Switch_f = 200; + } else { + rtb_Switch_f = look1_iu16tdIs16_binlcs + (rtDW.ADC_Data_Model.Sensor_Incar_Temp_RR, rtConstP.pooled15, + rtConstP.pooled2, 1023U); + } + + /* End of Switch: '/Switch' */ + + /* BusCreator: '/Bus Creator' incorporates: + * DataStoreWrite: '/Data Store Write' + */ + Status_Sensor_Model.Battery = 0; + Status_Sensor_Model.AMB = 0; + Status_Sensor_Model.Incar_FL = 0; + Status_Sensor_Model.Incar_FR = 0; + Status_Sensor_Model.Incar_RL = 0; + Status_Sensor_Model.Incar_RR = rtb_Switch_f; + Status_Sensor_Model.Eva_F = 0; + Status_Sensor_Model.Eva_R = 0; + Status_Sensor_Model.Pressure = 0; + Status_Sensor_Model.Duct_FL_Upper = 0; + Status_Sensor_Model.Duct_FL_Lower = 0; + Status_Sensor_Model.Duct_FR_Upper = 0; + Status_Sensor_Model.Duct_FR_Lower = 0; + Status_Sensor_Model.Duct_RL = 0; + Status_Sensor_Model.Duct_RR = 0; + Status_Sensor_Model.Duct_Side_FL = 0; + Status_Sensor_Model.Duct_Side_FR = 0; + Status_Sensor_Model.Duct_Side_RL = 0; + Status_Sensor_Model.Duct_Side_RR = 0; + Status_Sensor_Model.AQS = 0; + + /* MATLAB Function: '/Write ERROR' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + /* : if(IncarRRErr) */ + if (rtb_LogicalOperator1_n) { + /* : fprintf('CCU_Body_Err.CCU_IncarTempErrR_Stat = 0x1 (Failure), Sensor_Incar_Temp_RR = %u\n',Sensor_Incar_Temp_RR); */ + printf("CCU_Body_Err.CCU_IncarTempErrR_Stat = 0x1 (Failure), Sensor_Incar_Temp_RR = %u\n", + rtDW.ADC_Data_Model.Sensor_Incar_Temp_RR); + fflush(stdout); + } + + /* End of MATLAB Function: '/Write ERROR' */ + + /* MATLAB Function: '/Write IncarFL' */ + /* : fprintf('IncarRR = %d * 0.1 C\n',IncarRR); */ + printf("IncarRR = %d * 0.1 C\n", rtb_Switch_f); + fflush(stdout); + + /* Switch: '/Switch' incorporates: + * DataStoreRead: '/Data Store Read4' + * Logic: '/Logical Operator3' + * Logic: '/Logical Operator4' + * UnitDelay: '/Cond_prev_private ' + * UnitDelay: '/t_start_delay_private ' + */ + if (rtb_LogicalOperator1_i && (!rtDW.Cond_prev_private_DSTATE_g)) { + rtDW.t_start_delay_private_DSTATE_c = rtDW.t_now; + } + + /* End of Switch: '/Switch' */ + + /* Switch: '/Switch' incorporates: + * Constant: '/Constant1' + * DataStoreRead: '/Data Store Read' + * DataStoreRead: '/Data Store Read2' + */ + if (rtDW.stepSig_private > 0) { + rtb_Switch_l4 = rtDW.stepSig_private; + } else { + rtb_Switch_l4 = 1; + } + + /* End of Switch: '/Switch' */ + + /* SwitchCase: '/Switch Case' */ + switch (rtb_Switch_l4) { + case 1: + /* Outputs for IfAction SubSystem: '/Stop Mode' incorporates: + * ActionPort: '/Action Port' + */ + /* If: '/If1' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + */ + if ((rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 == 0) && + (rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0 == 0)) { + /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: + * ActionPort: '/Action Port' + */ + /* BusCreator: '/Bus Creator' incorporates: + * DataStoreWrite: '/Data Store Write' + * SignalConversion generated from: '/Bus Creator' + * */ + for (i = 0; i < 9; i++) { + Actuator_Ch0_Command_Model.POS[i] = 0U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 2U; + Actuator_Ch0_Command_Model.COM[i] = 1U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 0U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 0U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 0U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + } + + /* End of BusCreator: '/Bus Creator' */ + + /* Merge: '/Merge' incorporates: + * Constant: '/Constant' + * Sum: '/step inc' + */ + rtB.Merge = (int8_t)(rtb_Switch_l4 + 1); + + /* End of Outputs for SubSystem: '/If Action Subsystem2' */ + } else { + /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: + * ActionPort: '/Action Port' + */ + IfActionSubsystem3(rtb_Switch_l4, &rtB.Merge); + + /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + } + + /* End of If: '/If1' */ + /* End of Outputs for SubSystem: '/Stop Mode' */ + break; + + case 2: + /* Outputs for IfAction SubSystem: '/Initial CPOS Min' incorporates: + * ActionPort: '/Action Port' + */ + /* If: '/If' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + */ + if ((rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 == 0) && + (rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0 == 0)) { + /* Outputs for IfAction SubSystem: '/If Action Subsystem' incorporates: + * ActionPort: '/Action Port' + */ + /* BusCreator: '/Bus Creator' incorporates: + * DataStoreWrite: '/Data Store Write2' + * SignalConversion generated from: '/Bus Creator' + * */ + for (i = 0; i < 9; i++) { + Actuator_Ch0_Command_Model.POS[i] = 6000U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 0U; + Actuator_Ch0_Command_Model.COM[i] = 2U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 0U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 0U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 0U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + } + + /* End of BusCreator: '/Bus Creator' */ + + /* MATLAB Function: '/Initial CPOS Min' */ + /* : y = step; */ + /* : fprintf('SIMULINK Initial CPOS Min - 6000\n'); */ + printf("SIMULINK Initial CPOS Min - 6000\n"); + fflush(stdout); + + /* Merge: '/Merge' incorporates: + * Constant: '/Constant' + * Merge: '/Merge' + * SignalConversion generated from: '/step' + * Sum: '/step inc' + */ + rtB.Merge = (int8_t)(rtb_Switch_l4 + 1); + + /* End of Outputs for SubSystem: '/If Action Subsystem' */ + } else { + /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: + * ActionPort: '/Action Port' + */ + /* BusCreator: '/Bus Creator' incorporates: + * DataStoreWrite: '/Data Store Write' + * SignalConversion generated from: '/Bus Creator' + * */ + for (i = 0; i < 9; i++) { + Actuator_Ch0_Command_Model.POS[i] = 0U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 0U; + Actuator_Ch0_Command_Model.COM[i] = 0U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 0U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 0U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 0U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + } + + /* End of BusCreator: '/Bus Creator' */ + + /* Merge: '/Merge' incorporates: + * Merge: '/Merge' + * SignalConversion generated from: '/stepIn1' + */ + rtB.Merge = rtb_Switch_l4; + + /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + } + + /* End of If: '/If' */ + /* End of Outputs for SubSystem: '/Initial CPOS Min' */ + break; + + case 3: + /* Outputs for IfAction SubSystem: '/Normal Mode' incorporates: + * ActionPort: '/Action Port' + */ + /* MATLAB Function: '/MAX POSITION1' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + */ + /* : fprintf('Busy_Ch0_private '); */ + printf("Busy_Ch0_private "); + fflush(stdout); + + /* : for i = 1:numel(Busy_Ch0_private) */ + /* : fprintf('%d ', int16(Busy_Ch0_private(i))); */ + printf("%d ", (int16_t)rtDW.Actuator_Ch0_Status_Model.Busy_Ch0); + fflush(stdout); + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); + + /* MATLAB Function: '/MAX POSITION2' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write1' + */ + /* : fprintf('Error_Connect_Ch0_private '); */ + printf("Error_Connect_Ch0_private "); + fflush(stdout); + + /* : for i = 1:numel(Busy_Ch0_private) */ + /* : fprintf('%d ', int16(Busy_Ch0_private(i))); */ + printf("%d ", (int16_t)rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0); + fflush(stdout); + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); + + /* If: '/If1' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + */ + if ((rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 == 0) && + (rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0 == 0)) { + /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: + * ActionPort: '/Action Port' + */ + /* BusCreator: '/Bus Creator' incorporates: + * DataStoreWrite: '/Data Store Write1' + * SignalConversion generated from: '/Bus Creator' + * */ + for (i = 0; i < 9; i++) { + Actuator_Ch0_Command_Model.POS[i] = 0U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 0U; + Actuator_Ch0_Command_Model.COM[i] = 1U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 0U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 0U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 0U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + } + + /* End of BusCreator: '/Bus Creator' */ + + /* MATLAB Function: '/Normal Mode' */ + /* : y = step; */ + /* : fprintf('SIMULINK Normal Mode\n'); */ + printf("SIMULINK Normal Mode\n"); + fflush(stdout); + + /* Merge: '/Merge' incorporates: + * Constant: '/Constant' + * SignalConversion generated from: '/step' + * Sum: '/step inc' + */ + rtB.Merge = (int8_t)(rtb_Switch_l4 + 1); + + /* End of Outputs for SubSystem: '/If Action Subsystem2' */ + } else { + /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: + * ActionPort: '/Action Port' + */ + IfActionSubsystem3(rtb_Switch_l4, &rtB.Merge); + + /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + } + + /* End of If: '/If1' */ + /* End of Outputs for SubSystem: '/Normal Mode' */ + break; + + case 4: + /* Outputs for IfAction SubSystem: '/Move to position Min' incorporates: + * ActionPort: '/Action Port' + */ + /* If: '/If1' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + */ + if ((rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 == 0) && + (rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0 == 0)) { + /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: + * ActionPort: '/Action Port' + */ + /* BusCreator: '/Bus Creator' incorporates: + * Constant: '/Constant1' + * Constant: '/Constant10' + * Constant: '/Constant11' + * Constant: '/Constant14' + * Constant: '/Constant2' + * Constant: '/Constant9' + * DataStoreWrite: '/Data Store Write7' + * SignalConversion generated from: '/Bus Creator' + * */ + for (i = 0; i < 9; i++) { + Actuator_Ch0_Command_Model.POS[i] = 1U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 0U; + Actuator_Ch0_Command_Model.COM[i] = 3U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 1U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 1U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 3U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + } + + /* End of BusCreator: '/Bus Creator' */ + + /* MATLAB Function: '/Move to position Min' */ + /* : y = step; */ + /* : fprintf('SIMULINK Move to position Min - 1\n'); */ + printf("SIMULINK Move to position Min - 1\n"); + fflush(stdout); + + /* Merge: '/Merge' incorporates: + * Constant: '/Constant' + * SignalConversion generated from: '/step' + * Sum: '/step inc' + */ + rtB.Merge = (int8_t)(rtb_Switch_l4 + 1); + + /* End of Outputs for SubSystem: '/If Action Subsystem2' */ + } else { + /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: + * ActionPort: '/Action Port' + */ + IfActionSubsystem3(rtb_Switch_l4, &rtB.Merge); + + /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + } + + /* End of If: '/If1' */ + /* End of Outputs for SubSystem: '/Move to position Min' */ + break; + + case 5: + /* Outputs for IfAction SubSystem: '/Check Stall Min' incorporates: + * ActionPort: '/Action Port' + */ + /* RelationalOperator: '/Relational Operator1' incorporates: + * DataStoreRead: '/Data Store Read1' + * RelationalOperator: '/Relational Operator' + */ + for (i = 0; i < 9; i++) { + rtb_RelationalOperator_j[i] = + (rtDW.Actuator_Ch0_Status_Model.in_Act_Stall_Slave_Ch0[i] == 1); + } + + /* End of RelationalOperator: '/Relational Operator1' */ + + /* Logic: '/Logical Operator2' incorporates: + * RelationalOperator: '/Relational Operator' + */ + rtb_LogicalOperator1_n = rtb_RelationalOperator_j[0]; + for (i = 0; i < 8; i++) { + rtb_LogicalOperator1_n = (rtb_LogicalOperator1_n || + rtb_RelationalOperator_j[i + 1]); + } + + /* RelationalOperator: '/Relational Operator' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + for (i = 0; i < 9; i++) { + rtb_RelationalOperator_j[i] = + (rtDW.Actuator_Ch0_Status_Model.in_CPOS_ALL_Ch0[i] == 1); + } + + /* End of RelationalOperator: '/Relational Operator' */ + + /* Logic: '/Logical Operator1' incorporates: + * RelationalOperator: '/Relational Operator' + */ + tmp = rtb_RelationalOperator_j[0]; + for (i = 0; i < 8; i++) { + tmp = (tmp || rtb_RelationalOperator_j[i + 1]); + } + + /* If: '/If2' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + * DataTypeConversion: '/Data Type Conversion' + * DataTypeConversion: '/Data Type Conversion1' + * Logic: '/Logical Operator' + * Logic: '/Logical Operator1' + * Logic: '/Logical Operator2' + */ + if ((rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 == 0) && + (rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0 == 0) && + (rtb_LogicalOperator1_n || tmp)) { + /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: + * ActionPort: '/Action Port' + */ + /* DataStoreWrite: '/Data Store Write1' */ + for (i = 0; i < 9; i++) { + rtDW.MinPositionCh0_private[i] = + rtDW.Actuator_Ch0_Status_Model.in_CPOS_ALL_Ch0[i]; + } + + /* End of DataStoreWrite: '/Data Store Write1' */ + + /* Merge: '/Merge' incorporates: + * Constant: '/Constant' + * Sum: '/step inc' + */ + rtB.Merge = (int8_t)(rtb_Switch_l4 + 1); + + /* MATLAB Function: '/MIN POSITION' */ + /* : y = step; */ + /* : fprintf('SIMULINK Min_position_Ch0 '); */ + printf("SIMULINK Min_position_Ch0 "); + fflush(stdout); + + /* : for i = 1:numel(step) */ + for (i = 0; i < 9; i++) { + /* : fprintf('%d ', int16(step(i))); */ + printf("%d ", rtDW.Actuator_Ch0_Status_Model.in_CPOS_ALL_Ch0[i]); + fflush(stdout); + } + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); + + /* End of MATLAB Function: '/MIN POSITION' */ + /* End of Outputs for SubSystem: '/If Action Subsystem2' */ + } else { + /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: + * ActionPort: '/Action Port' + */ + IfActionSubsystem3(rtb_Switch_l4, &rtB.Merge); + + /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + } + + /* End of If: '/If2' */ + /* End of Outputs for SubSystem: '/Check Stall Min' */ + for (i = 0; i < 9; i++) { + /* Outputs for IfAction SubSystem: '/Check Stall Min' incorporates: + * ActionPort: '/Action Port' + */ + rtb_y_ff[i] = rtDW.Actuator_Ch0_Status_Model.in_CPOS_ALL_Ch0[i]; + + /* End of Outputs for SubSystem: '/Check Stall Min' */ + } + + /* Outputs for IfAction SubSystem: '/Check Stall Min' incorporates: + * ActionPort: '/Action Port' + */ + /* MATLAB Function: '/MAX POSITION' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + MAXPOSITION(rtb_y_ff); + + /* End of Outputs for SubSystem: '/Check Stall Min' */ + for (i = 0; i < 9; i++) { + /* Outputs for IfAction SubSystem: '/Check Stall Min' incorporates: + * ActionPort: '/Action Port' + */ + rtb_y_b[i] = rtDW.Actuator_Ch0_Status_Model.in_Act_Stall_Slave_Ch0[i]; + + /* End of Outputs for SubSystem: '/Check Stall Min' */ + } + + /* Outputs for IfAction SubSystem: '/Check Stall Min' incorporates: + * ActionPort: '/Action Port' + */ + /* MATLAB Function: '/MAX POSITION1' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + MAXPOSITION1(rtb_y_b); + + /* End of Outputs for SubSystem: '/Check Stall Min' */ + break; + + case 6: + /* Outputs for IfAction SubSystem: '/Initial CPOS Max' incorporates: + * ActionPort: '/Action Port' + */ + /* If: '/If1' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + */ + if ((rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 == 0) && + (rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0 == 0)) { + /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: + * ActionPort: '/Action Port' + */ + /* BusCreator: '/Bus Creator' incorporates: + * DataStoreWrite: '/Data Store Write2' + * SignalConversion generated from: '/Bus Creator' + * */ + for (i = 0; i < 9; i++) { + Actuator_Ch0_Command_Model.POS[i] = 1U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 0U; + Actuator_Ch0_Command_Model.COM[i] = 2U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 0U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 0U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 0U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + } + + /* End of BusCreator: '/Bus Creator' */ + + /* MATLAB Function: '/Initial CPOS Max' */ + /* : y = step; */ + /* : fprintf('SIMULINK Initial CPOS Max - 1\n'); */ + printf("SIMULINK Initial CPOS Max - 1\n"); + fflush(stdout); + + /* Merge: '/Merge' incorporates: + * Constant: '/Constant' + * SignalConversion generated from: '/step' + * Sum: '/step inc' + */ + rtB.Merge = (int8_t)(rtb_Switch_l4 + 1); + + /* End of Outputs for SubSystem: '/If Action Subsystem2' */ + } else { + /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: + * ActionPort: '/Action Port' + */ + IfActionSubsystem3(rtb_Switch_l4, &rtB.Merge); + + /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + } + + /* End of If: '/If1' */ + /* End of Outputs for SubSystem: '/Initial CPOS Max' */ + break; + + case 7: + /* Outputs for IfAction SubSystem: '/Move to position Max' incorporates: + * ActionPort: '/Action Port' + */ + /* If: '/If1' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + */ + if ((rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 == 0) && + (rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0 == 0)) { + /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: + * ActionPort: '/Action Port' + */ + /* BusCreator: '/Bus Creator' incorporates: + * Constant: '/Constant1' + * Constant: '/Constant10' + * Constant: '/Constant11' + * Constant: '/Constant14' + * Constant: '/Constant2' + * Constant: '/Constant9' + * DataStoreWrite: '/Data Store Write7' + * SignalConversion generated from: '/Bus Creator' + * */ + for (i = 0; i < 9; i++) { + Actuator_Ch0_Command_Model.POS[i] = 6000U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 0U; + Actuator_Ch0_Command_Model.COM[i] = 3U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 1U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 1U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 3U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + } + + /* End of BusCreator: '/Bus Creator' */ + + /* MATLAB Function: '/Move to position Max' */ + /* : y = step; */ + /* : fprintf('SIMULINK Move to position Max - 6000\n'); */ + printf("SIMULINK Move to position Max - 6000\n"); + fflush(stdout); + + /* Merge: '/Merge' incorporates: + * Constant: '/Constant' + * SignalConversion generated from: '/step' + * Sum: '/step inc' + */ + rtB.Merge = (int8_t)(rtb_Switch_l4 + 1); + + /* End of Outputs for SubSystem: '/If Action Subsystem2' */ + } else { + /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: + * ActionPort: '/Action Port' + */ + IfActionSubsystem3(rtb_Switch_l4, &rtB.Merge); + + /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + } + + /* End of If: '/If1' */ + /* End of Outputs for SubSystem: '/Move to position Max' */ + break; + + case 8: + /* Outputs for IfAction SubSystem: '/Check Stall Max' incorporates: + * ActionPort: '/Action Port' + */ + /* RelationalOperator: '/Relational Operator1' incorporates: + * DataStoreRead: '/Data Store Read1' + * RelationalOperator: '/Relational Operator' + */ + for (i = 0; i < 9; i++) { + rtb_RelationalOperator_j[i] = + (rtDW.Actuator_Ch0_Status_Model.in_Act_Stall_Slave_Ch0[i] == 1); + } + + /* End of RelationalOperator: '/Relational Operator1' */ + + /* Logic: '/Logical Operator2' incorporates: + * RelationalOperator: '/Relational Operator' + */ + rtb_LogicalOperator1_n = rtb_RelationalOperator_j[0]; + for (i = 0; i < 8; i++) { + rtb_LogicalOperator1_n = (rtb_LogicalOperator1_n || + rtb_RelationalOperator_j[i + 1]); + } + + /* RelationalOperator: '/Relational Operator' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + for (i = 0; i < 9; i++) { + rtb_RelationalOperator_j[i] = + (rtDW.Actuator_Ch0_Status_Model.in_CPOS_ALL_Ch0[i] == 6000); + } + + /* End of RelationalOperator: '/Relational Operator' */ + + /* Logic: '/Logical Operator1' incorporates: + * RelationalOperator: '/Relational Operator' + */ + tmp = rtb_RelationalOperator_j[0]; + for (i = 0; i < 8; i++) { + tmp = (tmp || rtb_RelationalOperator_j[i + 1]); + } + + /* If: '/If2' incorporates: + * DataStoreRead: '/Data Store Read1' + * DataStoreWrite: '/Data Store Write' + * DataStoreWrite: '/Data Store Write1' + * DataTypeConversion: '/Data Type Conversion' + * DataTypeConversion: '/Data Type Conversion1' + * Logic: '/Logical Operator' + * Logic: '/Logical Operator1' + * Logic: '/Logical Operator2' + */ + if ((rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 == 0) && + (rtDW.Actuator_Ch0_Status_Model.Error_Connect_Ch0 == 0) && + (rtb_LogicalOperator1_n || tmp)) { + /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: + * ActionPort: '/Action Port' + */ + /* DataStoreWrite: '/Data Store Write1' */ + for (i = 0; i < 9; i++) { + rtDW.MinPositionCh0_private[i] = + rtDW.Actuator_Ch0_Status_Model.in_CPOS_ALL_Ch0[i]; + } + + /* End of DataStoreWrite: '/Data Store Write1' */ + + /* Merge: '/Merge' incorporates: + * Constant: '/Constant' + * Sum: '/step inc' + */ + rtB.Merge = (int8_t)(rtb_Switch_l4 + 1); + + /* MATLAB Function: '/MIN POSITION' */ + /* : y = step; */ + /* : fprintf('SIMULINK Max_position_Ch0 '); */ + printf("SIMULINK Max_position_Ch0 "); + fflush(stdout); + + /* : for i = 1:numel(step) */ + for (i = 0; i < 9; i++) { + /* : fprintf('%d ', int16(step(i))); */ + printf("%d ", rtDW.Actuator_Ch0_Status_Model.in_CPOS_ALL_Ch0[i]); + fflush(stdout); + } + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); + + /* End of MATLAB Function: '/MIN POSITION' */ + /* End of Outputs for SubSystem: '/If Action Subsystem2' */ + } else { + /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: + * ActionPort: '/Action Port' + */ + IfActionSubsystem3(rtb_Switch_l4, &rtB.Merge); + + /* End of Outputs for SubSystem: '/If Action Subsystem3' */ + } + + /* End of If: '/If2' */ + /* End of Outputs for SubSystem: '/Check Stall Max' */ + for (i = 0; i < 9; i++) { + /* Outputs for IfAction SubSystem: '/Check Stall Max' incorporates: + * ActionPort: '/Action Port' + */ + rtb_y_ff[i] = rtDW.Actuator_Ch0_Status_Model.in_CPOS_ALL_Ch0[i]; + + /* End of Outputs for SubSystem: '/Check Stall Max' */ + } + + /* Outputs for IfAction SubSystem: '/Check Stall Max' incorporates: + * ActionPort: '/Action Port' + */ + /* MATLAB Function: '/MAX POSITION' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + MAXPOSITION(rtb_y_ff); + + /* End of Outputs for SubSystem: '/Check Stall Max' */ + for (i = 0; i < 9; i++) { + /* Outputs for IfAction SubSystem: '/Check Stall Max' incorporates: + * ActionPort: '/Action Port' + */ + rtb_y_b[i] = rtDW.Actuator_Ch0_Status_Model.in_Act_Stall_Slave_Ch0[i]; + + /* End of Outputs for SubSystem: '/Check Stall Max' */ + } + + /* Outputs for IfAction SubSystem: '/Check Stall Max' incorporates: + * ActionPort: '/Action Port' + */ + /* MATLAB Function: '/MAX POSITION1' incorporates: + * DataStoreRead: '/Data Store Read1' + */ + MAXPOSITION1(rtb_y_b); + + /* End of Outputs for SubSystem: '/Check Stall Max' */ + break; + + case 9: + /* Outputs for IfAction SubSystem: '/Homing' incorporates: + * ActionPort: '/Action Port' + */ + /* Merge: '/Merge' incorporates: + * SignalConversion generated from: '/stepIn' + */ + rtB.Merge = rtb_Switch_l4; + + /* Outputs for IfAction SubSystem: '/Switch Case Action Subsystem2' incorporates: + * ActionPort: '/Action Port' + */ + /* SwitchCase: '/Switch Case' incorporates: + * BusCreator: '/Bus Creator' + * DataStoreWrite: '/Data Store Write1' + * MATLAB Function: '/MAX POSITION' + */ + CCU_Errors_Model.CCU_IncarTempErrF_Stat = 0U; + CCU_Errors_Model.CCU_IncarTempErrR_Stat = 0U; + CCU_Errors_Model.CCU_DuctTempSenErrF_Stat = 0U; + CCU_Errors_Model.CCU_DuctTempSenErrR_Stat = 0U; + CCU_Errors_Model.CCU_EvaTempSenErrF_Stat = 0U; + CCU_Errors_Model.CCU_EvaTempSenErrR_Stat = 0U; + CCU_Errors_Model.CCU_DeflectorSwErrF_Stat = 0U; + CCU_Errors_Model.CCU_DeflectorSwErrR_Stat = 0U; + CCU_Errors_Model.CCU_PressSenErr_Stat = 0U; + CCU_Errors_Model.CCU_AmbienTemptSenErr_Stat = 0U; + CCU_Errors_Model.CCU_SealingValveErr_Stat = 0U; + CCU_Errors_Model.CCU_ETXVerr_Stat = 0U; + CCU_Errors_Model.CCU_HVACfanOrTXVerrF_Stat = 0U; + CCU_Errors_Model.CCU_HVACfanOrTXVerrR_Stat = 0U; + CCU_Errors_Model.CCU_ActuatorErrF_Stat = 0U; + CCU_Errors_Model.CCU_ActuatorErrR_Stat = 0U; + CCU_Errors_Model.CCU_UltravioletErr_Stat = 0U; + CCU_Errors_Model.CCU_VinRecordErr_Stat = 0U; + CCU_Errors_Model.CCU_AirQualSenErr_Stat = 0U; + CCU_Errors_Model.CCU_CommErr_Stat = 0U; + CCU_Errors_Model.CCU_TWVerr_Stat = 0U; + CCU_Errors_Model.CCU_IonizationErr_Stat = 0U; + CCU_Errors_Model.CCU_AromaErr_Stat = 0U; + + /* : for i = 1:numel(ErrCallibration) */ + for (i = 0; i < 9; i++) { + /* BusCreator: '/Bus Creator1' incorporates: + * DataStoreWrite: '/Data Store Write' + * SignalConversion generated from: '/Bus Creator1' + * */ + Actuator_Ch0_Command_Model.POS[i] = 0U; + Actuator_Ch0_Command_Model.BUS_ADR[i] = 0U; + Actuator_Ch0_Command_Model.MODE[i] = 2U; + Actuator_Ch0_Command_Model.COM[i] = 0U; + Actuator_Ch0_Command_Model.Stall_SET[i] = 0U; + Actuator_Ch0_Command_Model.Lnoise_SET[i] = 0U; + Actuator_Ch0_Command_Model.Autos_SET[i] = 0U; + Actuator_Ch0_Command_Model.Speed_SET[i] = 0U; + Actuator_Ch0_Command_Model.Coils_Stop_SET[i] = 0U; + + /* DataStoreWrite: '/Data Store Write' incorporates: + * Logic: '/Logical Operator' + */ + rtDW.ErrorCalibrationCh0_private[i] = false; + + /* Product: '/Divide1' incorporates: + * Constant: '/ACT1' + * DataStoreRead: '/MAX ACT1T ' + * DataStoreRead: '/MIN ACT1T ' + * Sum: '/ACT1T' + */ + rtb_Divide1_j[i] = (double)(int16_t)(rtDW.MaxPositionCh0_private[i] - + rtDW.MinPositionCh0_private[i]) / (double)rtConstP.pooled18[i]; + } + + MAXPOSITION_l(rtb_Divide1_j, rtb_y_gj); + + /* End of SwitchCase: '/Switch Case' */ + /* End of Outputs for SubSystem: '/Switch Case Action Subsystem2' */ + + /* MATLAB Function: '/MAX POSITION' incorporates: + * DataStoreRead: '/Data Store Read2' + */ + /* : y = step; */ + /* : fprintf('SIMULINK MAX POSITION '); */ + printf("SIMULINK MAX POSITION "); + fflush(stdout); + + /* : for i = 1:numel(step) */ + for (i = 0; i < 9; i++) { + /* : fprintf('%d ', int16(step(i))); */ + printf("%d ", rtDW.MaxPositionCh0_private[i]); + fflush(stdout); + } + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); + + /* End of MATLAB Function: '/MAX POSITION' */ + + /* MATLAB Function: '/MIN POSITION' incorporates: + * DataStoreRead: '/Data Store Read3' + */ + /* : y = step; */ + /* : fprintf('SIMULINK MIN POSITION '); */ + printf("SIMULINK MIN POSITION "); + fflush(stdout); + + /* : for i = 1:numel(step) */ + for (i = 0; i < 9; i++) { + /* : fprintf('%d ', int16(step(i))); */ + printf("%d ", rtDW.MinPositionCh0_private[i]); + fflush(stdout); + } + + /* : fprintf('\n'); */ + printf("\n"); + fflush(stdout); + + /* End of MATLAB Function: '/MIN POSITION' */ + /* End of Outputs for SubSystem: '/Homing' */ + break; + } + + /* End of SwitchCase: '/Switch Case' */ + + /* DataStoreWrite: '/Finish write stepSig' */ + rtDW.stepSig_private = rtB.Merge; + + /* MATLAB Function: '/Write Ignition' */ + /* : fprintf('step = %d\n',step); */ + printf("step = %d\n", rtb_Switch_l4); + fflush(stdout); + + /* Update for UnitDelay: '/Cond_prev_private ' */ + rtDW.Cond_prev_private_DSTATE = rtb_FailCond; + + /* Update for UnitDelay: '/Cond_prev_private ' */ + rtDW.Cond_prev_private_DSTATE_h = rtb_LogicalOperator1; + + /* Update for UnitDelay: '/Cond_prev_private ' */ + rtDW.Cond_prev_private_DSTATE_i = rtb_LogicalOperator1_f; + + /* Update for UnitDelay: '/Cond_prev_private ' */ + rtDW.Cond_prev_private_DSTATE_c = rtb_LogicalOperator1_k; + + /* Update for UnitDelay: '/Cond_prev_private ' */ + rtDW.Cond_prev_private_DSTATE_hm = rtb_LogicalOperator1_b; + + /* Update for UnitDelay: '/Cond_prev_private ' */ + rtDW.Cond_prev_private_DSTATE_b = rtb_LogicalOperator1_ln; + + /* Update for UnitDelay: '/Cond_prev_private ' */ + rtDW.Cond_prev_private_DSTATE_g = rtb_LogicalOperator1_i; +} + +/* Model initialize function */ +void HVAC_model_initialize(void) +{ + /* (no initialization code required) */ +} + +/* Model terminate function */ +void HVAC_model_terminate(void) +{ + /* (no terminate code required) */ +} + +/* + * File trailer for generated code. + * + * [EOF] + */ diff --git a/Model_actuator.h b/HVAC_model.h similarity index 51% rename from Model_actuator.h rename to HVAC_model.h index 74b1ffd..e191d33 100644 --- a/Model_actuator.h +++ b/HVAC_model.h @@ -1,11 +1,11 @@ /* - * File: Model_actuator.h + * File: HVAC_model.h * - * Code generated for Simulink model 'Model_actuator'. + * Code generated for Simulink model 'HVAC_model'. * - * Model version : 1.588 + * Model version : 1.604 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Thu Feb 12 13:08:42 2026 + * C/C++ source code generated on : Fri Feb 13 13:56:38 2026 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M @@ -15,16 +15,16 @@ * Validation result: Not run */ -#ifndef Model_actuator_h_ -#define Model_actuator_h_ -#ifndef Model_actuator_COMMON_INCLUDES_ -#define Model_actuator_COMMON_INCLUDES_ +#ifndef HVAC_model_h_ +#define HVAC_model_h_ +#ifndef HVAC_model_COMMON_INCLUDES_ +#define HVAC_model_COMMON_INCLUDES_ #include #include #include -#endif /* Model_actuator_COMMON_INCLUDES_ */ +#endif /* HVAC_model_COMMON_INCLUDES_ */ -#include "Model_actuator_types.h" +#include "HVAC_model_types.h" /* Macros for accessing real-time model data structure */ #ifndef rtmGetErrorStatus @@ -40,43 +40,32 @@ /* Block signals (default storage) */ typedef struct { - int8_t Merge; /* '/Merge' */ + int8_t Merge; /* '/Merge' */ } B; /* Block states (default storage) for system '' */ typedef struct { - ActuatorCmdBusInput controllerDataInput;/* '/Data Store Memory17' */ + ActuatorCmdBusInput Actuator_Ch0_Status_Model;/* '/Data Store Memory17' */ CmdBusADCData ADC_Data_Model; /* '/Data Store Memory2' */ - uint32_t t_start_delay_private_DSTATE;/* '/t_start_delay_private ' */ - uint32_t t_start_delay_private_DSTATE_p;/* '/t_start_delay_private ' */ - uint32_t t_start_delay_private_DSTATE_pk;/* '/t_start_delay_private ' */ - uint32_t t_start_delay_private_DSTATE_b;/* '/t_start_delay_private ' */ - uint32_t t_start_delay_private_DSTATE_g;/* '/t_start_delay_private ' */ - uint32_t t_start_delay_private_DSTATE_j;/* '/t_start_delay_private ' */ - uint32_t t_start_delay_private_DSTATE_c;/* '/t_start_delay_private ' */ - uint32_t t_now; /* '/Data Store Memory5' */ - int16_t Min_position_Ch0[9]; /* '/Data Store Memory12' */ - int16_t Max_position_Ch0[9]; /* '/Data Store Memory13' */ - uint16_t pos_loc[9]; /* '/Data Store Memory4' */ - int8_t UnitDelay_DSTATE; /* '/Unit Delay' */ - bool Cond_prev_private_DSTATE; /* '/Cond_prev_private ' */ - bool Cond_prev_private_DSTATE_h; /* '/Cond_prev_private ' */ - bool Cond_prev_private_DSTATE_i; /* '/Cond_prev_private ' */ - bool Cond_prev_private_DSTATE_c; /* '/Cond_prev_private ' */ - bool Cond_prev_private_DSTATE_hm; /* '/Cond_prev_private ' */ - bool Cond_prev_private_DSTATE_b; /* '/Cond_prev_private ' */ - bool Cond_prev_private_DSTATE_g; /* '/Cond_prev_private ' */ - int8_t stepSig; /* '/Data Store Memory' */ - uint8_t mode_loc[9]; /* '/Data Store Memory1' */ - uint8_t Error_Connect_Ch0; /* '/Data Store Memory10' */ - uint8_t Busy_Ch0; /* '/Data Store Memory14' */ - uint8_t com_loc[9]; /* '/Data Store Memory2' */ - uint8_t busAdr_loc[9]; /* '/Data Store Memory3' */ - uint8_t stall_set_loc[9]; /* '/Data Store Memory5' */ - uint8_t lnoise_set_loc[9]; /* '/Data Store Memory6' */ - uint8_t autos_set_loc[9]; /* '/Data Store Memory7' */ - uint8_t speed_set_loc[9]; /* '/Data Store Memory8' */ - uint8_t coils_stop_set_loc[9]; /* '/Data Store Memory9' */ + uint32_t t_start_delay_private_DSTATE;/* '/t_start_delay_private ' */ + uint32_t t_start_delay_private_DSTATE_p;/* '/t_start_delay_private ' */ + uint32_t t_start_delay_private_DSTATE_pk;/* '/t_start_delay_private ' */ + uint32_t t_start_delay_private_DSTATE_b;/* '/t_start_delay_private ' */ + uint32_t t_start_delay_private_DSTATE_g;/* '/t_start_delay_private ' */ + uint32_t t_start_delay_private_DSTATE_j;/* '/t_start_delay_private ' */ + uint32_t t_start_delay_private_DSTATE_c;/* '/t_start_delay_private ' */ + uint32_t t_now; /* '/Data Store Memory5' */ + int16_t MinPositionCh0_private[9]; /* '/Data Store Memory12' */ + int16_t MaxPositionCh0_private[9]; /* '/Data Store Memory13' */ + bool Cond_prev_private_DSTATE; /* '/Cond_prev_private ' */ + bool Cond_prev_private_DSTATE_h; /* '/Cond_prev_private ' */ + bool Cond_prev_private_DSTATE_i; /* '/Cond_prev_private ' */ + bool Cond_prev_private_DSTATE_c; /* '/Cond_prev_private ' */ + bool Cond_prev_private_DSTATE_hm; /* '/Cond_prev_private ' */ + bool Cond_prev_private_DSTATE_b; /* '/Cond_prev_private ' */ + bool Cond_prev_private_DSTATE_g; /* '/Cond_prev_private ' */ + int8_t stepSig_private; /* '/Data Store Memory' */ + bool ErrorCalibrationCh0_private[9]; /* '/Data Store Memory1' */ } DW; /* Constant parameters (default storage) */ @@ -113,7 +102,14 @@ typedef struct { * '/1-D Lookup Table' * '/1-D Lookup Table' */ - uint16_t pooled14[1024]; + uint16_t pooled15[1024]; + + /* Pooled Parameter (Expression: [5900 6100 6050 6010 5990 5800 6015 0 8500]) + * Referenced by: + * '/ACT1' + * '/ACT1' + */ + uint16_t pooled18[9]; } ConstP; /* Real-time Model Data Structure */ @@ -138,14 +134,14 @@ extern const ConstP rtConstP; * states and exports their symbols. * */ -extern ActuatorCmdBus controllerData; /* '/Data Store Memory15' */ +extern ActuatorCmdBus Actuator_Ch0_Command_Model;/* '/Data Store Memory15' */ extern CmdBusStatus Status_Sensor_Model;/* '/Data Store Memory' */ -extern CmdBusError CCU_Errors_Model; /* '/Data Store Memory3' */ +extern CmdBusError CCU_Errors_Model; /* '/Data Store Memory3' */ /* Model entry point functions */ -extern void Model_actuator_initialize(void); -extern void Model_actuator_step(void); -extern void Model_actuator_terminate(void); +extern void HVAC_model_initialize(void); +extern void HVAC_model_step(void); +extern void HVAC_model_terminate(void); /* Real-time Model object */ extern RT_MODEL *const rtM; @@ -153,10 +149,32 @@ extern RT_MODEL *const rtM; /*- * These blocks were eliminated from the model due to optimizations: * - * Block '/Display1' : Unused code path elimination - * Block '/Display2' : Unused code path elimination - * Block '/Display3' : Unused code path elimination - * Block '/Display3' : Unused code path elimination + * Block '/ACT1' : Unused code path elimination + * Block '/ACT1T' : Unused code path elimination + * Block '/Compare' : Unused code path elimination + * Block '/Constant' : Unused code path elimination + * Block '/Compare' : Unused code path elimination + * Block '/Constant' : Unused code path elimination + * Block '/Constant' : Unused code path elimination + * Block '/Constant1' : Unused code path elimination + * Block '/Divide1' : Unused code path elimination + * Block '/Logical Operator' : Unused code path elimination + * Block '/Switch' : Unused code path elimination + * Block '/Constant' : Unused code path elimination + * Block '/Constant1' : Unused code path elimination + * Block '/Constant2' : Unused code path elimination + * Block '/step inc' : Unused code path elimination + * Block '/Compare' : Unused code path elimination + * Block '/Constant' : Unused code path elimination + * Block '/Compare' : Unused code path elimination + * Block '/Constant' : Unused code path elimination + * Block '/Constant' : Unused code path elimination + * Block '/Constant1' : Unused code path elimination + * Block '/Constant2' : Unused code path elimination + * Block '/Logical Operator1' : Unused code path elimination + * Block '/step inc' : Unused code path elimination + * Block '/Display3' : Unused code path elimination + * Block '/Data Type Conversion' : Eliminate redundant data type conversion */ /*- @@ -173,189 +191,139 @@ extern RT_MODEL *const rtM; * * Here is the system hierarchy for this model * - * '' : 'Model_actuator' - * '' : 'Model_actuator/ACP' - * '' : 'Model_actuator/LIN' - * '' : 'Model_actuator/ACP/Ambient' - * '' : 'Model_actuator/ACP/EvapF' - * '' : 'Model_actuator/ACP/EvapR' - * '' : 'Model_actuator/ACP/IncarFL' - * '' : 'Model_actuator/ACP/IncarFR' - * '' : 'Model_actuator/ACP/IncarRL' - * '' : 'Model_actuator/ACP/IncarRR' - * '' : 'Model_actuator/ACP/PRINT BTS5120_2EKA_ShutoffValvePowerTXV1' - * '' : 'Model_actuator/ACP/PRINT BTS5120_2EKA_ShutoffValvePowerTXV2' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ChannelPTCPower1' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ChannelPTCPower2' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_FrontIncarMotor' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_RearIncarMotor' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ReservePowerSupply' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ShutOFFValveFront' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ShutOFFValveRear' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_TwoWayValve' - * '' : 'Model_actuator/ACP/PRINT IGN_ANS' - * '' : 'Model_actuator/ACP/PRINT Ignition' - * '' : 'Model_actuator/ACP/PRINT PBATT_CHECK' - * '' : 'Model_actuator/ACP/PRINT Pressure_DIAG' - * '' : 'Model_actuator/ACP/PRINT Reserve_Sensor_Duct_Temp_1' - * '' : 'Model_actuator/ACP/PRINT Reserve_Sensor_Duct_Temp_2' - * '' : 'Model_actuator/ACP/PRINT Sensor_AC_Pressure' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct1' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct2' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct3' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct4' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct5' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct6' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct1' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct2' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct3' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct4' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct5' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct6' - * '' : 'Model_actuator/ACP/PRINT VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB' - * '' : 'Model_actuator/ACP/PRINT VN7008AJ_DIAG_RearLINActuatorPowerDriverC' - * '' : 'Model_actuator/ACP/PRINT VN7008AJ_FrontLINActuatorPowerDriverAB' - * '' : 'Model_actuator/ACP/PRINT VN7008AJ_RearLINActuatorPowerDriverC' - * '' : 'Model_actuator/ACP/Ambient/CAN ERROR' - * '' : 'Model_actuator/ACP/Ambient/Compare To Constant' - * '' : 'Model_actuator/ACP/Ambient/Compare To Constant1' - * '' : 'Model_actuator/ACP/Ambient/Compare To Constant2' - * '' : 'Model_actuator/ACP/Ambient/RealTime_Timer' - * '' : 'Model_actuator/ACP/Ambient/Status_Sensor_Model' - * '' : 'Model_actuator/ACP/Ambient/UDS ERROR' - * '' : 'Model_actuator/ACP/Ambient/Write Ambient' - * '' : 'Model_actuator/ACP/Ambient/Write ERROR' - * '' : 'Model_actuator/ACP/EvapF/CAN ERROR' - * '' : 'Model_actuator/ACP/EvapF/Compare To Constant' - * '' : 'Model_actuator/ACP/EvapF/Compare To Constant1' - * '' : 'Model_actuator/ACP/EvapF/Compare To Constant2' - * '' : 'Model_actuator/ACP/EvapF/RealTime_Timer' - * '' : 'Model_actuator/ACP/EvapF/Status_Sensor_Model' - * '' : 'Model_actuator/ACP/EvapF/UDS ERROR' - * '' : 'Model_actuator/ACP/EvapF/Write ERROR' - * '' : 'Model_actuator/ACP/EvapF/Write Eva_F' - * '' : 'Model_actuator/ACP/EvapR/CAN ERROR' - * '' : 'Model_actuator/ACP/EvapR/Compare To Constant' - * '' : 'Model_actuator/ACP/EvapR/Compare To Constant1' - * '' : 'Model_actuator/ACP/EvapR/Compare To Constant2' - * '' : 'Model_actuator/ACP/EvapR/RealTime_Timer' - * '' : 'Model_actuator/ACP/EvapR/Status_Sensor_Model' - * '' : 'Model_actuator/ACP/EvapR/UDS ERROR' - * '' : 'Model_actuator/ACP/EvapR/Write ERROR' - * '' : 'Model_actuator/ACP/EvapR/Write Eva_F' - * '' : 'Model_actuator/ACP/IncarFL/CAN ERROR' - * '' : 'Model_actuator/ACP/IncarFL/Compare To Constant' - * '' : 'Model_actuator/ACP/IncarFL/Compare To Constant1' - * '' : 'Model_actuator/ACP/IncarFL/Compare To Constant2' - * '' : 'Model_actuator/ACP/IncarFL/RealTime_Timer' - * '' : 'Model_actuator/ACP/IncarFL/Status_Sensor_Model' - * '' : 'Model_actuator/ACP/IncarFL/UDS ERROR' - * '' : 'Model_actuator/ACP/IncarFL/Write ERROR' - * '' : 'Model_actuator/ACP/IncarFL/Write IncarFL' - * '' : 'Model_actuator/ACP/IncarFR/CAN ERROR' - * '' : 'Model_actuator/ACP/IncarFR/Compare To Constant' - * '' : 'Model_actuator/ACP/IncarFR/Compare To Constant1' - * '' : 'Model_actuator/ACP/IncarFR/Compare To Constant2' - * '' : 'Model_actuator/ACP/IncarFR/RealTime_Timer' - * '' : 'Model_actuator/ACP/IncarFR/Status_Sensor_Model' - * '' : 'Model_actuator/ACP/IncarFR/UDS ERROR' - * '' : 'Model_actuator/ACP/IncarFR/Write ERROR' - * '' : 'Model_actuator/ACP/IncarFR/Write IncarFR' - * '' : 'Model_actuator/ACP/IncarRL/CAN ERROR' - * '' : 'Model_actuator/ACP/IncarRL/Compare To Constant' - * '' : 'Model_actuator/ACP/IncarRL/Compare To Constant1' - * '' : 'Model_actuator/ACP/IncarRL/Compare To Constant2' - * '' : 'Model_actuator/ACP/IncarRL/RealTime_Timer' - * '' : 'Model_actuator/ACP/IncarRL/Status_Sensor_Model' - * '' : 'Model_actuator/ACP/IncarRL/UDS ERROR' - * '' : 'Model_actuator/ACP/IncarRL/Write ERROR' - * '' : 'Model_actuator/ACP/IncarRL/Write IncarRL' - * '' : 'Model_actuator/ACP/IncarRR/CAN ERROR' - * '' : 'Model_actuator/ACP/IncarRR/Compare To Constant' - * '' : 'Model_actuator/ACP/IncarRR/Compare To Constant1' - * '' : 'Model_actuator/ACP/IncarRR/Compare To Constant2' - * '' : 'Model_actuator/ACP/IncarRR/RealTime_Timer' - * '' : 'Model_actuator/ACP/IncarRR/Status_Sensor_Model' - * '' : 'Model_actuator/ACP/IncarRR/UDS ERROR' - * '' : 'Model_actuator/ACP/IncarRR/Write ERROR' - * '' : 'Model_actuator/ACP/IncarRR/Write IncarFL' - * '' : 'Model_actuator/ACP/PRINT BTS5120_2EKA_ShutoffValvePowerTXV1/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5120_2EKA_ShutoffValvePowerTXV2/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ChannelPTCPower1/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ChannelPTCPower2/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_FrontIncarMotor/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_RearIncarMotor/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ReservePowerSupply/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ShutOFFValveFront/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_ShutOFFValveRear/Write' - * '' : 'Model_actuator/ACP/PRINT BTS5180_2EKA_TwoWayValve/Write' - * '' : 'Model_actuator/ACP/PRINT IGN_ANS/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Ignition/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT PBATT_CHECK/Write' - * '' : 'Model_actuator/ACP/PRINT Pressure_DIAG/Write' - * '' : 'Model_actuator/ACP/PRINT Reserve_Sensor_Duct_Temp_1/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Reserve_Sensor_Duct_Temp_2/Write' - * '' : 'Model_actuator/ACP/PRINT Sensor_AC_Pressure/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct1/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct2/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct3/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct4/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct5/Write' - * '' : 'Model_actuator/ACP/PRINT Sensor_Front_Duct6/Write' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct1/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct2/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct3/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct4/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct5/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT Sensor_Rear_Duct6/Write Ignition' - * '' : 'Model_actuator/ACP/PRINT VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB/Write' - * '' : 'Model_actuator/ACP/PRINT VN7008AJ_DIAG_RearLINActuatorPowerDriverC/Write' - * '' : 'Model_actuator/ACP/PRINT VN7008AJ_FrontLINActuatorPowerDriverAB/Write' - * '' : 'Model_actuator/ACP/PRINT VN7008AJ_RearLINActuatorPowerDriverC/Write' - * '' : 'Model_actuator/LIN/CHANEL0' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Max' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Min' - * '' : 'Model_actuator/LIN/CHANEL0/Homing' - * '' : 'Model_actuator/LIN/CHANEL0/Homing1' - * '' : 'Model_actuator/LIN/CHANEL0/Initial CPOS Max' - * '' : 'Model_actuator/LIN/CHANEL0/Initial CPOS Min' - * '' : 'Model_actuator/LIN/CHANEL0/Move to position Max' - * '' : 'Model_actuator/LIN/CHANEL0/Move to position Min' - * '' : 'Model_actuator/LIN/CHANEL0/Normal Mode' - * '' : 'Model_actuator/LIN/CHANEL0/Stop Mode' - * '' : 'Model_actuator/LIN/CHANEL0/Subsystem' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Max/If Action Subsystem2' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Max/If Action Subsystem3' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Max/MAX POSITION' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Max/MAX POSITION1' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Max/If Action Subsystem2/MIN POSITION' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Min/If Action Subsystem2' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Min/If Action Subsystem3' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Min/MAX POSITION' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Min/MAX POSITION1' - * '' : 'Model_actuator/LIN/CHANEL0/Check Stall Min/If Action Subsystem2/MIN POSITION' - * '' : 'Model_actuator/LIN/CHANEL0/Homing/MAX POSITION' - * '' : 'Model_actuator/LIN/CHANEL0/Homing/MIN POSITION' - * '' : 'Model_actuator/LIN/CHANEL0/Initial CPOS Max/If Action Subsystem2' - * '' : 'Model_actuator/LIN/CHANEL0/Initial CPOS Max/If Action Subsystem3' - * '' : 'Model_actuator/LIN/CHANEL0/Initial CPOS Max/If Action Subsystem2/Initial CPOS Max' - * '' : 'Model_actuator/LIN/CHANEL0/Initial CPOS Min/If Action Subsystem' - * '' : 'Model_actuator/LIN/CHANEL0/Initial CPOS Min/If Action Subsystem3' - * '' : 'Model_actuator/LIN/CHANEL0/Initial CPOS Min/If Action Subsystem/Initial CPOS Min' - * '' : 'Model_actuator/LIN/CHANEL0/Move to position Max/If Action Subsystem2' - * '' : 'Model_actuator/LIN/CHANEL0/Move to position Max/If Action Subsystem3' - * '' : 'Model_actuator/LIN/CHANEL0/Move to position Max/If Action Subsystem2/Move to position Max' - * '' : 'Model_actuator/LIN/CHANEL0/Move to position Min/If Action Subsystem2' - * '' : 'Model_actuator/LIN/CHANEL0/Move to position Min/If Action Subsystem3' - * '' : 'Model_actuator/LIN/CHANEL0/Move to position Min/If Action Subsystem2/Move to position Min' - * '' : 'Model_actuator/LIN/CHANEL0/Normal Mode/If Action Subsystem2' - * '' : 'Model_actuator/LIN/CHANEL0/Normal Mode/If Action Subsystem3' - * '' : 'Model_actuator/LIN/CHANEL0/Normal Mode/If Action Subsystem2/Normal Mode' - * '' : 'Model_actuator/LIN/CHANEL0/Stop Mode/If Action Subsystem2' - * '' : 'Model_actuator/LIN/CHANEL0/Stop Mode/If Action Subsystem3' - * '' : 'Model_actuator/LIN/CHANEL0/Stop Mode/If Action Subsystem2/stop mode' + * '' : 'HVAC_model' + * '' : 'HVAC_model/ACP' + * '' : 'HVAC_model/LIN' + * '' : 'HVAC_model/ACP/Ambient' + * '' : 'HVAC_model/ACP/EvapF' + * '' : 'HVAC_model/ACP/EvapR' + * '' : 'HVAC_model/ACP/IncarFL' + * '' : 'HVAC_model/ACP/IncarFR' + * '' : 'HVAC_model/ACP/IncarRL' + * '' : 'HVAC_model/ACP/IncarRR' + * '' : 'HVAC_model/ACP/Ambient/CAN ERROR' + * '' : 'HVAC_model/ACP/Ambient/Compare To Constant' + * '' : 'HVAC_model/ACP/Ambient/Compare To Constant1' + * '' : 'HVAC_model/ACP/Ambient/Compare To Constant2' + * '' : 'HVAC_model/ACP/Ambient/RealTime_Timer' + * '' : 'HVAC_model/ACP/Ambient/Status_Sensor_Model' + * '' : 'HVAC_model/ACP/Ambient/UDS ERROR' + * '' : 'HVAC_model/ACP/Ambient/Write Ambient' + * '' : 'HVAC_model/ACP/Ambient/Write ERROR' + * '' : 'HVAC_model/ACP/EvapF/CAN ERROR' + * '' : 'HVAC_model/ACP/EvapF/Compare To Constant' + * '' : 'HVAC_model/ACP/EvapF/Compare To Constant1' + * '' : 'HVAC_model/ACP/EvapF/Compare To Constant2' + * '' : 'HVAC_model/ACP/EvapF/RealTime_Timer' + * '' : 'HVAC_model/ACP/EvapF/Status_Sensor_Model' + * '' : 'HVAC_model/ACP/EvapF/UDS ERROR' + * '' : 'HVAC_model/ACP/EvapF/Write ERROR' + * '' : 'HVAC_model/ACP/EvapF/Write Eva_F' + * '' : 'HVAC_model/ACP/EvapR/CAN ERROR' + * '' : 'HVAC_model/ACP/EvapR/Compare To Constant' + * '' : 'HVAC_model/ACP/EvapR/Compare To Constant1' + * '' : 'HVAC_model/ACP/EvapR/Compare To Constant2' + * '' : 'HVAC_model/ACP/EvapR/RealTime_Timer' + * '' : 'HVAC_model/ACP/EvapR/Status_Sensor_Model' + * '' : 'HVAC_model/ACP/EvapR/UDS ERROR' + * '' : 'HVAC_model/ACP/EvapR/Write ERROR' + * '' : 'HVAC_model/ACP/EvapR/Write Eva_F' + * '' : 'HVAC_model/ACP/IncarFL/CAN ERROR' + * '' : 'HVAC_model/ACP/IncarFL/Compare To Constant' + * '' : 'HVAC_model/ACP/IncarFL/Compare To Constant1' + * '' : 'HVAC_model/ACP/IncarFL/Compare To Constant2' + * '' : 'HVAC_model/ACP/IncarFL/RealTime_Timer' + * '' : 'HVAC_model/ACP/IncarFL/Status_Sensor_Model' + * '' : 'HVAC_model/ACP/IncarFL/UDS ERROR' + * '' : 'HVAC_model/ACP/IncarFL/Write ERROR' + * '' : 'HVAC_model/ACP/IncarFL/Write IncarFL' + * '' : 'HVAC_model/ACP/IncarFR/CAN ERROR' + * '' : 'HVAC_model/ACP/IncarFR/Compare To Constant' + * '' : 'HVAC_model/ACP/IncarFR/Compare To Constant1' + * '' : 'HVAC_model/ACP/IncarFR/Compare To Constant2' + * '' : 'HVAC_model/ACP/IncarFR/RealTime_Timer' + * '' : 'HVAC_model/ACP/IncarFR/Status_Sensor_Model' + * '' : 'HVAC_model/ACP/IncarFR/UDS ERROR' + * '' : 'HVAC_model/ACP/IncarFR/Write ERROR' + * '' : 'HVAC_model/ACP/IncarFR/Write IncarFR' + * '' : 'HVAC_model/ACP/IncarRL/CAN ERROR' + * '' : 'HVAC_model/ACP/IncarRL/Compare To Constant' + * '' : 'HVAC_model/ACP/IncarRL/Compare To Constant1' + * '' : 'HVAC_model/ACP/IncarRL/Compare To Constant2' + * '' : 'HVAC_model/ACP/IncarRL/RealTime_Timer' + * '' : 'HVAC_model/ACP/IncarRL/Status_Sensor_Model' + * '' : 'HVAC_model/ACP/IncarRL/UDS ERROR' + * '' : 'HVAC_model/ACP/IncarRL/Write ERROR' + * '' : 'HVAC_model/ACP/IncarRL/Write IncarRL' + * '' : 'HVAC_model/ACP/IncarRR/CAN ERROR' + * '' : 'HVAC_model/ACP/IncarRR/Compare To Constant' + * '' : 'HVAC_model/ACP/IncarRR/Compare To Constant1' + * '' : 'HVAC_model/ACP/IncarRR/Compare To Constant2' + * '' : 'HVAC_model/ACP/IncarRR/RealTime_Timer' + * '' : 'HVAC_model/ACP/IncarRR/Status_Sensor_Model' + * '' : 'HVAC_model/ACP/IncarRR/UDS ERROR' + * '' : 'HVAC_model/ACP/IncarRR/Write ERROR' + * '' : 'HVAC_model/ACP/IncarRR/Write IncarFL' + * '' : 'HVAC_model/LIN/CHANEL0' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Max' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Min' + * '' : 'HVAC_model/LIN/CHANEL0/Homing' + * '' : 'HVAC_model/LIN/CHANEL0/Initial CPOS Max' + * '' : 'HVAC_model/LIN/CHANEL0/Initial CPOS Min' + * '' : 'HVAC_model/LIN/CHANEL0/Move to position Max' + * '' : 'HVAC_model/LIN/CHANEL0/Move to position Min' + * '' : 'HVAC_model/LIN/CHANEL0/Normal Mode' + * '' : 'HVAC_model/LIN/CHANEL0/Stop Mode' + * '' : 'HVAC_model/LIN/CHANEL0/Write Ignition' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Max/If Action Subsystem2' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Max/If Action Subsystem3' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Max/MAX POSITION' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Max/MAX POSITION1' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Max/If Action Subsystem2/MIN POSITION' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Min/If Action Subsystem2' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Min/If Action Subsystem3' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Min/MAX POSITION' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Min/MAX POSITION1' + * '' : 'HVAC_model/LIN/CHANEL0/Check Stall Min/If Action Subsystem2/MIN POSITION' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/MAX POSITION' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/MIN POSITION' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem1' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem2' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem/Compare To Constant' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem/Compare To Constant1' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem1/CAN ERROR' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem1/Compare To Constant' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem1/MAX POSITION' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem1/UDS ERROR' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem1/CAN ERROR/Write ERROR' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem2/CAN ERROR' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem2/Compare To Constant3' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem2/Compare To Constant4' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem2/MAX POSITION' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem2/UDS ERROR' + * '' : 'HVAC_model/LIN/CHANEL0/Homing/Switch Case Action Subsystem2/CAN ERROR/Write ERROR' + * '' : 'HVAC_model/LIN/CHANEL0/Initial CPOS Max/If Action Subsystem2' + * '' : 'HVAC_model/LIN/CHANEL0/Initial CPOS Max/If Action Subsystem3' + * '' : 'HVAC_model/LIN/CHANEL0/Initial CPOS Max/If Action Subsystem2/Initial CPOS Max' + * '' : 'HVAC_model/LIN/CHANEL0/Initial CPOS Min/If Action Subsystem' + * '' : 'HVAC_model/LIN/CHANEL0/Initial CPOS Min/If Action Subsystem3' + * '' : 'HVAC_model/LIN/CHANEL0/Initial CPOS Min/If Action Subsystem/Initial CPOS Min' + * '' : 'HVAC_model/LIN/CHANEL0/Move to position Max/If Action Subsystem2' + * '' : 'HVAC_model/LIN/CHANEL0/Move to position Max/If Action Subsystem3' + * '' : 'HVAC_model/LIN/CHANEL0/Move to position Max/If Action Subsystem2/Move to position Max' + * '' : 'HVAC_model/LIN/CHANEL0/Move to position Min/If Action Subsystem2' + * '' : 'HVAC_model/LIN/CHANEL0/Move to position Min/If Action Subsystem3' + * '' : 'HVAC_model/LIN/CHANEL0/Move to position Min/If Action Subsystem2/Move to position Min' + * '' : 'HVAC_model/LIN/CHANEL0/Normal Mode/If Action Subsystem2' + * '' : 'HVAC_model/LIN/CHANEL0/Normal Mode/If Action Subsystem3' + * '' : 'HVAC_model/LIN/CHANEL0/Normal Mode/MAX POSITION1' + * '' : 'HVAC_model/LIN/CHANEL0/Normal Mode/MAX POSITION2' + * '' : 'HVAC_model/LIN/CHANEL0/Normal Mode/If Action Subsystem2/Normal Mode' + * '' : 'HVAC_model/LIN/CHANEL0/Stop Mode/If Action Subsystem2' + * '' : 'HVAC_model/LIN/CHANEL0/Stop Mode/If Action Subsystem3' */ -#endif /* Model_actuator_h_ */ +#endif /* HVAC_model_h_ */ /* * File trailer for generated code. diff --git a/Model_actuator_data.c b/HVAC_model_data.c similarity index 98% rename from Model_actuator_data.c rename to HVAC_model_data.c index 5149b37..b67f084 100644 --- a/Model_actuator_data.c +++ b/HVAC_model_data.c @@ -1,11 +1,11 @@ /* - * File: Model_actuator_data.c + * File: HVAC_model_data.c * - * Code generated for Simulink model 'Model_actuator'. + * Code generated for Simulink model 'HVAC_model'. * - * Model version : 1.588 + * Model version : 1.604 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Thu Feb 12 13:08:42 2026 + * C/C++ source code generated on : Fri Feb 13 13:56:38 2026 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M @@ -15,7 +15,7 @@ * Validation result: Not run */ -#include "Model_actuator.h" +#include "HVAC_model.h" /* Constant parameters (default storage) */ const ConstP rtConstP = { @@ -421,7 +421,14 @@ const ConstP rtConstP = { 3948U, 3952U, 3956U, 3960U, 3964U, 3968U, 3972U, 3976U, 3980U, 3984U, 3988U, 3992U, 3996U, 4000U, 4004U, 4008U, 4012U, 4016U, 4020U, 4024U, 4028U, 4032U, 4036U, 4040U, 4044U, 4048U, 4052U, 4056U, 4060U, 4064U, 4068U, 4072U, 4076U, - 4080U, 4084U, 4088U, 4092U } + 4080U, 4084U, 4088U, 4092U }, + + /* Pooled Parameter (Expression: [5900 6100 6050 6010 5990 5800 6015 0 8500]) + * Referenced by: + * '/ACT1' + * '/ACT1' + */ + { 5900U, 6100U, 6050U, 6010U, 5990U, 5800U, 6015U, 0U, 8500U } }; /* diff --git a/Model_actuator_private.h b/HVAC_model_private.h similarity index 52% rename from Model_actuator_private.h rename to HVAC_model_private.h index 5cd20b1..8da5414 100644 --- a/Model_actuator_private.h +++ b/HVAC_model_private.h @@ -1,11 +1,11 @@ /* - * File: Model_actuator_private.h + * File: HVAC_model_private.h * - * Code generated for Simulink model 'Model_actuator'. + * Code generated for Simulink model 'HVAC_model'. * - * Model version : 1.588 + * Model version : 1.604 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Thu Feb 12 13:08:42 2026 + * C/C++ source code generated on : Fri Feb 13 13:56:38 2026 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M @@ -15,21 +15,21 @@ * Validation result: Not run */ -#ifndef Model_actuator_private_h_ -#define Model_actuator_private_h_ +#ifndef HVAC_model_private_h_ +#define HVAC_model_private_h_ #include #include -#include "Model_actuator_types.h" -#include "Model_actuator.h" +#include "HVAC_model_types.h" +#include "HVAC_model.h" extern int16_t look1_iu16tdIs16_binlcs(uint16_t u0, const uint16_t bp0[], const double table[], uint32_t maxIndex); -extern void IfActionSubsystem3(int8_t rtu_stepIn, int8_t *rty_step, uint8_t - rtd_com_loc[9]); -extern void MAXPOSITION(const int16_t rtu_step[9], int16_t rty_y[9]); -extern void MAXPOSITION1(const int8_t rtu_step[9], int8_t rty_y[9]); +extern void IfActionSubsystem3(int8_t rtu_stepIn, int8_t *rty_step); +extern void MAXPOSITION(int16_t rty_y[9]); +extern void MAXPOSITION1(int8_t rty_y[9]); +extern void MAXPOSITION_l(const double rtu_step[9], double rty_y[9]); -#endif /* Model_actuator_private_h_ */ +#endif /* HVAC_model_private_h_ */ /* * File trailer for generated code. diff --git a/Model_actuator_types.h b/HVAC_model_types.h similarity index 92% rename from Model_actuator_types.h rename to HVAC_model_types.h index dcfa1c4..888626e 100644 --- a/Model_actuator_types.h +++ b/HVAC_model_types.h @@ -1,11 +1,11 @@ /* - * File: Model_actuator_types.h + * File: HVAC_model_types.h * - * Code generated for Simulink model 'Model_actuator'. + * Code generated for Simulink model 'HVAC_model'. * - * Model version : 1.588 + * Model version : 1.604 * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Thu Feb 12 13:08:42 2026 + * C/C++ source code generated on : Fri Feb 13 13:56:38 2026 * * Target selection: ert.tlc * Embedded hardware selection: ARM Compatible->ARM Cortex-M @@ -15,9 +15,40 @@ * Validation result: Not run */ -#ifndef Model_actuator_types_h_ -#define Model_actuator_types_h_ +#ifndef HVAC_model_types_h_ +#define HVAC_model_types_h_ #include +#ifndef DEFINED_TYPEDEF_FOR_CmdBusError_ +#define DEFINED_TYPEDEF_FOR_CmdBusError_ + +typedef struct { + uint8_t CCU_IncarTempErrF_Stat; + uint8_t CCU_IncarTempErrR_Stat; + uint8_t CCU_DuctTempSenErrF_Stat; + uint8_t CCU_DuctTempSenErrR_Stat; + uint8_t CCU_EvaTempSenErrF_Stat; + uint8_t CCU_EvaTempSenErrR_Stat; + uint8_t CCU_DeflectorSwErrF_Stat; + uint8_t CCU_DeflectorSwErrR_Stat; + uint8_t CCU_PressSenErr_Stat; + uint8_t CCU_AmbienTemptSenErr_Stat; + uint8_t CCU_SealingValveErr_Stat; + uint8_t CCU_ETXVerr_Stat; + uint8_t CCU_HVACfanOrTXVerrF_Stat; + uint8_t CCU_HVACfanOrTXVerrR_Stat; + uint8_t CCU_ActuatorErrF_Stat; + uint8_t CCU_ActuatorErrR_Stat; + uint8_t CCU_UltravioletErr_Stat; + uint8_t CCU_VinRecordErr_Stat; + uint8_t CCU_AirQualSenErr_Stat; + uint8_t CCU_CommErr_Stat; + uint8_t CCU_TWVerr_Stat; + uint8_t CCU_IonizationErr_Stat; + uint8_t CCU_AromaErr_Stat; +} CmdBusError; + +#endif + #ifndef DEFINED_TYPEDEF_FOR_CmdBusStatus_ #define DEFINED_TYPEDEF_FOR_CmdBusStatus_ @@ -93,37 +124,6 @@ typedef struct { #endif -#ifndef DEFINED_TYPEDEF_FOR_CmdBusError_ -#define DEFINED_TYPEDEF_FOR_CmdBusError_ - -typedef struct { - uint8_t CCU_IncarTempErrF_Stat; - uint8_t CCU_IncarTempErrR_Stat; - uint8_t CCU_DuctTempSenErrF_Stat; - uint8_t CCU_DuctTempSenErrR_Stat; - uint8_t CCU_EvaTempSenErrF_Stat; - uint8_t CCU_EvaTempSenErrR_Stat; - uint8_t CCU_DeflectorSwErrF_Stat; - uint8_t CCU_DeflectorSwErrR_Stat; - uint8_t CCU_PressSenErr_Stat; - uint8_t CCU_AmbienTemptSenErr_Stat; - uint8_t CCU_SealingValveErr_Stat; - uint8_t CCU_ETXVerr_Stat; - uint8_t CCU_HVACfanOrTXVerrF_Stat; - uint8_t CCU_HVACfanOrTXVerrR_Stat; - uint8_t CCU_ActuatorErrF_Stat; - uint8_t CCU_ActuatorErrR_Stat; - uint8_t CCU_UltravioletErr_Stat; - uint8_t CCU_VinRecordErr_Stat; - uint8_t CCU_AirQualSenErr_Stat; - uint8_t CCU_CommErr_Stat; - uint8_t CCU_TWVerr_Stat; - uint8_t CCU_IonizationErr_Stat; - uint8_t CCU_AromaErr_Stat; -} CmdBusError; - -#endif - #ifndef DEFINED_TYPEDEF_FOR_ActuatorCmdBus_ #define DEFINED_TYPEDEF_FOR_ActuatorCmdBus_ @@ -154,6 +154,8 @@ typedef struct { int8_t in_Act_Err4_Permanent_Electrical_Ch0[9]; int8_t in_Act_Stall_Slave_Ch0[9]; int8_t in_Act_Reset_Ch0[9]; + uint8_t Busy_Ch0; + uint8_t Error_Connect_Ch0; } ActuatorCmdBusInput; #endif @@ -161,7 +163,7 @@ typedef struct { /* Forward declaration for rtModel */ typedef struct tag_RTM RT_MODEL; -#endif /* Model_actuator_types_h_ */ +#endif /* HVAC_model_types_h_ */ /* * File trailer for generated code. diff --git a/Model_Task.c b/Model_Task.c index 485921e..b9a4024 100644 --- a/Model_Task.c +++ b/Model_Task.c @@ -4,7 +4,8 @@ #include "Model_Task.h" #include #include -#include "Model_actuator.h" +#include "HVAC_model.h" +#include "memory.h" #define LOG_SIGN "Model" #define LOGGER env->logger @@ -13,7 +14,7 @@ void ModelTask_Init( tModelTask *env, tLoggerInterface *logger ) { - Model_actuator_initialize(); + HVAC_model_initialize(); env->access = osMutexNew(NULL); env->logger = logger; InitThreadAtrStatic(&env->thread.attr, "ModelTask", env->thread.controlBlock, env->thread.stack, osPriorityNormal); @@ -23,17 +24,15 @@ void ModelTask_Init( static bool setActuatorBusy(tModelTask *env) { for (uint8_t i = 0; i < 9; ++i) { - if (controllerData.COM[i] != 0) { + if (Actuator_Ch0_Command_Model.COM[i] != 0) { #if (LOG_LIN_ACTUATOR == 1) LoggerInfoStatic(LOGGER, LOG_SIGN, "DETECT COMMAND") #endif env->triggerCommand = true; - for (uint8_t j = 0; j < 9; ++j) { - env->numCommand[j] = controllerData.COM[j]; - } + memcpy(&env->triggerActuatorCmdBus_1, &Actuator_Ch0_Command_Model, sizeof(ActuatorCmdBus)); - rtDW.Busy_Ch0 = 1; + rtDW.Actuator_Ch0_Status_Model.Busy_Ch0 = 1; return true; } } @@ -47,12 +46,12 @@ static _Noreturn void ModelTask_Thread(tModelTask *env) { //LoggerFormatInfo(LOGGER, LOG_SIGN, "in_Busy_Ch0 = %d in_Act_Stall_Slave_Ch0 = %d", rtU.in_Busy_Ch0, rtU.in_Act_Stall_Slave_Ch0[7]) - Model_actuator_step(); + HVAC_model_step(); setActuatorBusy(env); env->isUpdate = true; osMutexRelease(env->access); } - SystemDelayMs(250); + SystemDelayMs(100); } } diff --git a/Model_Task.h b/Model_Task.h index 553862e..8efa132 100644 --- a/Model_Task.h +++ b/Model_Task.h @@ -8,6 +8,7 @@ #include #include "stdbool.h" #include "LoggerInterface.h" +#include "HVAC_model.h" typedef struct { @@ -16,7 +17,10 @@ typedef struct { tLoggerInterface *logger; bool triggerCommand; - uint8_t numCommand[9]; + ActuatorCmdBus triggerActuatorCmdBus_1; + ActuatorCmdBus triggerActuatorCmdBus_2; + ActuatorCmdBus triggerActuatorCmdBus_3; + //uint8_t numCommand[9]; bool isUpdate; diff --git a/Model_actuator.c b/Model_actuator.c deleted file mode 100644 index 5c2f8c5..0000000 --- a/Model_actuator.c +++ /dev/null @@ -1,1731 +0,0 @@ -/* - * File: Model_actuator.c - * - * Code generated for Simulink model 'Model_actuator'. - * - * Model version : 1.588 - * Simulink Coder version : 24.1 (R2024a) 19-Nov-2023 - * C/C++ source code generated on : Thu Feb 12 13:08:42 2026 - * - * Target selection: ert.tlc - * Embedded hardware selection: ARM Compatible->ARM Cortex-M - * Emulation hardware selection: - * Differs from embedded hardware (MATLAB Host) - * Code generation objectives: Unspecified - * Validation result: Not run - */ - -#include "Model_actuator.h" -#include -#include "Model_actuator_private.h" -#include -#include "Model_actuator_types.h" - -/* Exported block states */ -ActuatorCmdBus controllerData; /* '/Data Store Memory15' */ -CmdBusStatus Status_Sensor_Model; /* '/Data Store Memory' */ -CmdBusError CCU_Errors_Model; /* '/Data Store Memory3' */ - -/* Block signals (default storage) */ -B rtB; - -/* Block states (default storage) */ -DW rtDW; - -/* Real-time model */ -static RT_MODEL rtM_; -RT_MODEL *const rtM = &rtM_; -int16_t look1_iu16tdIs16_binlcs(uint16_t u0, const uint16_t bp0[], const double - table[], uint32_t maxIndex) -{ - double frac; - double yL_0d0; - int32_t tmp_1; - uint32_t iLeft; - int16_t tmp; - int16_t tmp_0; - - /* Column-major Lookup 1-D - Search method: 'binary' - Use previous index: 'off' - Interpolation method: 'Linear point-slope' - Extrapolation method: 'Clip' - Use last breakpoint for index at or above upper limit: 'off' - Remove protection against out-of-range input in generated code: 'off' - */ - /* Prelookup - Index and Fraction - Index Search method: 'binary' - Extrapolation method: 'Clip' - Use previous index: 'off' - Use last breakpoint for index at or above upper limit: 'off' - Remove protection against out-of-range input in generated code: 'off' - */ - if (u0 <= bp0[0U]) { - iLeft = 0U; - frac = 0.0; - } else if (u0 < bp0[maxIndex]) { - uint32_t bpIdx; - uint32_t iRght; - - /* Binary Search */ - bpIdx = maxIndex >> 1U; - iLeft = 0U; - iRght = maxIndex; - while (iRght - iLeft > 1U) { - if (u0 < bp0[bpIdx]) { - iRght = bpIdx; - } else { - iLeft = bpIdx; - } - - bpIdx = (iRght + iLeft) >> 1U; - } - - uint16_t bpLeftVar; - bpLeftVar = bp0[iLeft]; - frac = (double)((uint32_t)u0 - bpLeftVar) / (double)((uint32_t)bp0[iLeft + - 1U] - bpLeftVar); - } else { - iLeft = maxIndex - 1U; - frac = 1.0; - } - - /* Column-major Interpolation 1-D - Interpolation method: 'Linear point-slope' - Use last breakpoint for index at or above upper limit: 'off' - Overflow mode: 'saturate' - */ - yL_0d0 = table[iLeft]; - if (yL_0d0 < 32768.0) { - if (yL_0d0 >= -32768.0) { - tmp = (int16_t)yL_0d0; - } else { - tmp = INT16_MIN; - } - } else { - tmp = INT16_MAX; - } - - frac *= table[iLeft + 1U] - yL_0d0; - if (frac < 32768.0) { - if (frac >= -32768.0) { - tmp_0 = (int16_t)frac; - } else { - tmp_0 = INT16_MIN; - } - } else { - tmp_0 = INT16_MAX; - } - - tmp_1 = tmp + tmp_0; - if (tmp_1 > 32767) { - tmp_1 = 32767; - } else if (tmp_1 < -32768) { - tmp_1 = -32768; - } - - return (int16_t)tmp_1; -} - -/* - * Output and update for action system: - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - * '/If Action Subsystem3' - */ -void IfActionSubsystem3(int8_t rtu_stepIn, int8_t *rty_step, uint8_t - rtd_com_loc[9]) -{ - int32_t i; - - /* DataStoreWrite: '/Data Store Write3' */ - for (i = 0; i < 9; i++) { - rtd_com_loc[i] = 0U; - } - - /* End of DataStoreWrite: '/Data Store Write3' */ - - /* SignalConversion generated from: '/stepIn' */ - *rty_step = rtu_stepIn; -} - -/* - * Output and update for atomic system: - * '/MAX POSITION' - * '/MAX POSITION' - */ -void MAXPOSITION(const int16_t rtu_step[9], int16_t rty_y[9]) -{ - int32_t i; - - /* : y = step; */ - for (i = 0; i < 9; i++) { - rty_y[i] = rtu_step[i]; - } - - /* : fprintf('SIMULINK POSITION '); */ - printf("SIMULINK POSITION "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtu_step[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); -} - -/* - * Output and update for atomic system: - * '/MAX POSITION1' - * '/MAX POSITION1' - */ -void MAXPOSITION1(const int8_t rtu_step[9], int8_t rty_y[9]) -{ - int32_t i; - - /* : y = step; */ - for (i = 0; i < 9; i++) { - rty_y[i] = rtu_step[i]; - } - - /* : fprintf('SIMULINK Stall_Slave '); */ - printf("SIMULINK Stall_Slave "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", (int16_t)rtu_step[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); -} - -/* Model step function */ -void Model_actuator_step(void) -{ - double rtb_Divide1; - int32_t i; - int16_t rtb_y_ff[9]; - int16_t rtb_Switch_f; - int8_t rtb_y_b[9]; - bool rtb_RelationalOperator_j[9]; - bool rtb_FailCond; - bool rtb_LogicalOperator1; - bool rtb_LogicalOperator1_b; - bool rtb_LogicalOperator1_f; - bool rtb_LogicalOperator1_i; - bool rtb_LogicalOperator1_k; - bool rtb_LogicalOperator1_ln; - bool rtb_LogicalOperator1_n; - bool tmp; - - /* Product: '/Divide1' incorporates: - * Constant: '/Constant' - * Constant: '/Constant1' - * DataStoreRead: '/Data Store Read1' - * Product: '/Divide' - */ - rtb_Divide1 = (double)rtDW.ADC_Data_Model.Sensor_Ambient_Temp / 4095.0 * 5.0; - - /* Logic: '/Logical Operator' incorporates: - * Constant: '/Constant' - * Constant: '/Constant' - * RelationalOperator: '/Compare' - * RelationalOperator: '/Compare' - */ - rtb_FailCond = ((rtb_Divide1 < 0.1) || (rtb_Divide1 > 4.9)); - - /* Logic: '/Logical Operator1' incorporates: - * Constant: '/Constant' - * DataStoreRead: '/Data Store Read4' - * RelationalOperator: '/Compare' - * Sum: '/Subtract' - * UnitDelay: '/t_start_delay_private ' - */ - rtb_LogicalOperator1 = (rtb_FailCond && (rtDW.t_now - - rtDW.t_start_delay_private_DSTATE >= 3000U)); - - /* Switch: '/Switch' incorporates: - * Constant: '/Constant2' - * DataStoreRead: '/Data Store Read1' - * Lookup_n-D: '/1-D Lookup Table' - */ - if (rtb_LogicalOperator1) { - rtb_Switch_f = 100; - } else { - rtb_Switch_f = look1_iu16tdIs16_binlcs - (rtDW.ADC_Data_Model.Sensor_Ambient_Temp, rtConstP.pooled14, - rtConstP.uDLookupTable_tableData, 1023U); - } - - /* End of Switch: '/Switch' */ - - /* MATLAB Function: '/Write Ambient' */ - /* : fprintf('Ambient = %d * 0.1�C\n',Ambient); */ - printf("Ambient = %d * 0.1�C\n", rtb_Switch_f); - fflush(stdout); - - /* MATLAB Function: '/Write ERROR' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : if(AmbientErr) */ - if (rtb_LogicalOperator1) { - /* : fprintf('CCU_Body_Err.CCU_AmbienTemptSenErr_Stat = 0x1 (Failure), Sensor_Ambient_Temp = %u\n',Sensor_Ambient_Temp); */ - printf("CCU_Body_Err.CCU_AmbienTemptSenErr_Stat = 0x1 (Failure), Sensor_Ambient_Temp = %u\n", - rtDW.ADC_Data_Model.Sensor_Ambient_Temp); - fflush(stdout); - } - - /* End of MATLAB Function: '/Write ERROR' */ - - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator3' - * Logic: '/Logical Operator4' - * UnitDelay: '/Cond_prev_private ' - * UnitDelay: '/t_start_delay_private ' - */ - if (rtb_FailCond && (!rtDW.Cond_prev_private_DSTATE)) { - rtDW.t_start_delay_private_DSTATE = rtDW.t_now; - } - - /* End of Switch: '/Switch' */ - - /* Product: '/Divide1' incorporates: - * Constant: '/Constant' - * Constant: '/Constant1' - * DataStoreRead: '/Data Store Read1' - * Product: '/Divide' - */ - rtb_Divide1 = (double)rtDW.ADC_Data_Model.Sensor_Evap_Temp / 4095.0 * 5.0; - - /* Logic: '/Logical Operator' incorporates: - * Constant: '/Constant' - * Constant: '/Constant' - * RelationalOperator: '/Compare' - * RelationalOperator: '/Compare' - */ - rtb_LogicalOperator1 = ((rtb_Divide1 < 0.1) || (rtb_Divide1 > 4.9)); - - /* Switch: '/Switch' incorporates: - * Constant: '/Constant2' - * Constant: '/Constant' - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator1' - * Lookup_n-D: '/1-D Lookup Table' - * MATLAB Function: '/Write ERROR' - * RelationalOperator: '/Compare' - * Sum: '/Subtract' - * UnitDelay: '/t_start_delay_private ' - */ - /* : if(EvapFErr) */ - if (rtb_LogicalOperator1 && (rtDW.t_now - rtDW.t_start_delay_private_DSTATE_p >= - 3000U)) { - rtb_Switch_f = -100; - - /* : fprintf('CCU_Body_Err.CCU_EvaTempSenErrF_Stat = 0x1 (Failure), Sensor_Evap_Temp = %u\n',Sensor_Evap_Temp); */ - printf("CCU_Body_Err.CCU_EvaTempSenErrF_Stat = 0x1 (Failure), Sensor_Evap_Temp = %u\n", - rtDW.ADC_Data_Model.Sensor_Evap_Temp); - fflush(stdout); - } else { - rtb_Switch_f = look1_iu16tdIs16_binlcs(rtDW.ADC_Data_Model.Sensor_Evap_Temp, - rtConstP.pooled14, rtConstP.pooled1, 1023U); - } - - /* End of Switch: '/Switch' */ - - /* MATLAB Function: '/Write Eva_F' */ - /* : fprintf('Eva_F = %d * 0.1�C\n',Eva_F); */ - printf("Eva_F = %d * 0.1�C\n", rtb_Switch_f); - fflush(stdout); - - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator3' - * Logic: '/Logical Operator4' - * UnitDelay: '/Cond_prev_private ' - * UnitDelay: '/t_start_delay_private ' - */ - if (rtb_LogicalOperator1 && (!rtDW.Cond_prev_private_DSTATE_h)) { - rtDW.t_start_delay_private_DSTATE_p = rtDW.t_now; - } - - /* End of Switch: '/Switch' */ - - /* Product: '/Divide1' incorporates: - * Constant: '/Constant' - * Constant: '/Constant1' - * DataStoreRead: '/Data Store Read1' - * Product: '/Divide' - */ - rtb_Divide1 = (double)rtDW.ADC_Data_Model.Sensor_Rear_Evap_Temp / 4095.0 * 5.0; - - /* Logic: '/Logical Operator' incorporates: - * Constant: '/Constant' - * Constant: '/Constant' - * RelationalOperator: '/Compare' - * RelationalOperator: '/Compare' - */ - rtb_LogicalOperator1_f = ((rtb_Divide1 < 0.1) || (rtb_Divide1 > 4.9)); - - /* Switch: '/Switch' incorporates: - * Constant: '/Constant2' - * Constant: '/Constant' - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator1' - * Lookup_n-D: '/1-D Lookup Table' - * MATLAB Function: '/Write ERROR' - * RelationalOperator: '/Compare' - * Sum: '/Subtract' - * UnitDelay: '/t_start_delay_private ' - */ - /* : if(EvapRErr) */ - if (rtb_LogicalOperator1_f && (rtDW.t_now - - rtDW.t_start_delay_private_DSTATE_pk >= 3000U)) { - rtb_Switch_f = -100; - - /* : fprintf('CCU_Body_Err.CCU_EvaTempSenErrR_Stat = 0x1 (Failure), Sensor_Rear_Evap_Temp = %u\n',Sensor_Rear_Evap_Temp); */ - printf("CCU_Body_Err.CCU_EvaTempSenErrR_Stat = 0x1 (Failure), Sensor_Rear_Evap_Temp = %u\n", - rtDW.ADC_Data_Model.Sensor_Rear_Evap_Temp); - fflush(stdout); - } else { - rtb_Switch_f = look1_iu16tdIs16_binlcs - (rtDW.ADC_Data_Model.Sensor_Rear_Evap_Temp, rtConstP.pooled14, - rtConstP.pooled1, 1023U); - } - - /* End of Switch: '/Switch' */ - - /* MATLAB Function: '/Write Eva_F' */ - /* : fprintf('Eva_R = %d * 0.1�C\n',Eva_R); */ - printf("Eva_R = %d * 0.1�C\n", rtb_Switch_f); - fflush(stdout); - - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator3' - * Logic: '/Logical Operator4' - * UnitDelay: '/Cond_prev_private ' - * UnitDelay: '/t_start_delay_private ' - */ - if (rtb_LogicalOperator1_f && (!rtDW.Cond_prev_private_DSTATE_i)) { - rtDW.t_start_delay_private_DSTATE_pk = rtDW.t_now; - } - - /* End of Switch: '/Switch' */ - - /* Product: '/Divide1' incorporates: - * Constant: '/Constant' - * Constant: '/Constant1' - * DataStoreRead: '/Data Store Read1' - * Product: '/Divide' - */ - rtb_Divide1 = (double)rtDW.ADC_Data_Model.Sensor_Incar_Temp_FL / 4095.0 * 5.0; - - /* Logic: '/Logical Operator' incorporates: - * Constant: '/Constant' - * Constant: '/Constant' - * RelationalOperator: '/Compare' - * RelationalOperator: '/Compare' - */ - rtb_LogicalOperator1_k = ((rtb_Divide1 < 0.15) || (rtb_Divide1 > 4.9)); - - /* Switch: '/Switch' incorporates: - * Constant: '/Constant2' - * Constant: '/Constant' - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator1' - * Lookup_n-D: '/1-D Lookup Table' - * MATLAB Function: '/Write ERROR' - * RelationalOperator: '/Compare' - * Sum: '/Subtract' - * UnitDelay: '/t_start_delay_private ' - */ - /* : if(IncarFLErr) */ - if (rtb_LogicalOperator1_k && (rtDW.t_now - - rtDW.t_start_delay_private_DSTATE_b >= 3000U)) { - rtb_Switch_f = 200; - - /* : fprintf('CCU_Body_Err.CCU_IncarTempErrF_Stat = 0x1 (Failure), Sensor_Incar_Temp_FL = %u\n',Sensor_Incar_Temp_FL); */ - printf("CCU_Body_Err.CCU_IncarTempErrF_Stat = 0x1 (Failure), Sensor_Incar_Temp_FL = %u\n", - rtDW.ADC_Data_Model.Sensor_Incar_Temp_FL); - fflush(stdout); - } else { - rtb_Switch_f = look1_iu16tdIs16_binlcs - (rtDW.ADC_Data_Model.Sensor_Incar_Temp_FL, rtConstP.pooled14, - rtConstP.pooled2, 1023U); - } - - /* End of Switch: '/Switch' */ - - /* MATLAB Function: '/Write IncarFL' */ - /* : fprintf('IncarFL = %d * 0.1�C\n',IncarFL); */ - printf("IncarFL = %d * 0.1�C\n", rtb_Switch_f); - fflush(stdout); - - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator3' - * Logic: '/Logical Operator4' - * UnitDelay: '/Cond_prev_private ' - * UnitDelay: '/t_start_delay_private ' - */ - if (rtb_LogicalOperator1_k && (!rtDW.Cond_prev_private_DSTATE_c)) { - rtDW.t_start_delay_private_DSTATE_b = rtDW.t_now; - } - - /* End of Switch: '/Switch' */ - - /* Product: '/Divide1' incorporates: - * Constant: '/Constant' - * Constant: '/Constant1' - * DataStoreRead: '/Data Store Read1' - * Product: '/Divide' - */ - rtb_Divide1 = (double)rtDW.ADC_Data_Model.Sensor_Incar_Temp_FR / 4095.0 * 5.0; - - /* Logic: '/Logical Operator' incorporates: - * Constant: '/Constant' - * Constant: '/Constant' - * RelationalOperator: '/Compare' - * RelationalOperator: '/Compare' - */ - rtb_LogicalOperator1_b = ((rtb_Divide1 < 0.15) || (rtb_Divide1 > 4.9)); - - /* Switch: '/Switch' incorporates: - * Constant: '/Constant2' - * Constant: '/Constant' - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator1' - * Lookup_n-D: '/1-D Lookup Table' - * MATLAB Function: '/Write ERROR' - * RelationalOperator: '/Compare' - * Sum: '/Subtract' - * UnitDelay: '/t_start_delay_private ' - */ - /* : if(IncarFRErr) */ - if (rtb_LogicalOperator1_b && (rtDW.t_now - - rtDW.t_start_delay_private_DSTATE_g >= 3000U)) { - rtb_Switch_f = 200; - - /* : fprintf('CCU_Body_Err.CCU_IncarTempErrR_Stat = 0x1 (Failure), Sensor_Incar_Temp_FR = %u\n',Sensor_Incar_Temp_FR); */ - printf("CCU_Body_Err.CCU_IncarTempErrR_Stat = 0x1 (Failure), Sensor_Incar_Temp_FR = %u\n", - rtDW.ADC_Data_Model.Sensor_Incar_Temp_FR); - fflush(stdout); - } else { - rtb_Switch_f = look1_iu16tdIs16_binlcs - (rtDW.ADC_Data_Model.Sensor_Incar_Temp_FR, rtConstP.pooled14, - rtConstP.pooled2, 1023U); - } - - /* End of Switch: '/Switch' */ - - /* MATLAB Function: '/Write IncarFR' */ - /* : fprintf('IncarFR = %d * 0.1�C\n',IncarFR); */ - printf("IncarFR = %d * 0.1�C\n", rtb_Switch_f); - fflush(stdout); - - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator3' - * Logic: '/Logical Operator4' - * UnitDelay: '/Cond_prev_private ' - * UnitDelay: '/t_start_delay_private ' - */ - if (rtb_LogicalOperator1_b && (!rtDW.Cond_prev_private_DSTATE_hm)) { - rtDW.t_start_delay_private_DSTATE_g = rtDW.t_now; - } - - /* End of Switch: '/Switch' */ - - /* Product: '/Divide1' incorporates: - * Constant: '/Constant' - * Constant: '/Constant1' - * DataStoreRead: '/Data Store Read1' - * Product: '/Divide' - */ - rtb_Divide1 = (double)rtDW.ADC_Data_Model.Sensor_Incar_Temp_RL / 4095.0 * 5.0; - - /* Logic: '/Logical Operator' incorporates: - * Constant: '/Constant' - * Constant: '/Constant' - * RelationalOperator: '/Compare' - * RelationalOperator: '/Compare' - */ - rtb_LogicalOperator1_ln = ((rtb_Divide1 < 0.15) || (rtb_Divide1 > 4.9)); - - /* Switch: '/Switch' incorporates: - * Constant: '/Constant2' - * Constant: '/Constant' - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator1' - * Lookup_n-D: '/1-D Lookup Table' - * MATLAB Function: '/Write ERROR' - * RelationalOperator: '/Compare' - * Sum: '/Subtract' - * UnitDelay: '/t_start_delay_private ' - */ - /* : if(IncarRLErr) */ - if (rtb_LogicalOperator1_ln && (rtDW.t_now - - rtDW.t_start_delay_private_DSTATE_j >= 3000U)) { - rtb_Switch_f = 200; - - /* : fprintf('CCU_Body_Err.CCU_IncarTempErrF_Stat = 0x1 (Failure), Sensor_Incar_Temp_RL = %u\n',Sensor_Incar_Temp_RL); */ - printf("CCU_Body_Err.CCU_IncarTempErrF_Stat = 0x1 (Failure), Sensor_Incar_Temp_RL = %u\n", - rtDW.ADC_Data_Model.Sensor_Incar_Temp_RL); - fflush(stdout); - } else { - rtb_Switch_f = look1_iu16tdIs16_binlcs - (rtDW.ADC_Data_Model.Sensor_Incar_Temp_RL, rtConstP.pooled14, - rtConstP.pooled2, 1023U); - } - - /* End of Switch: '/Switch' */ - - /* MATLAB Function: '/Write IncarRL' */ - /* : fprintf('IncarRL = %d * 0.1�C\n',IncarRL); */ - printf("IncarRL = %d * 0.1�C\n", rtb_Switch_f); - fflush(stdout); - - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator3' - * Logic: '/Logical Operator4' - * UnitDelay: '/Cond_prev_private ' - * UnitDelay: '/t_start_delay_private ' - */ - if (rtb_LogicalOperator1_ln && (!rtDW.Cond_prev_private_DSTATE_b)) { - rtDW.t_start_delay_private_DSTATE_j = rtDW.t_now; - } - - /* End of Switch: '/Switch' */ - - /* Product: '/Divide1' incorporates: - * Constant: '/Constant' - * Constant: '/Constant1' - * DataStoreRead: '/Data Store Read1' - * Product: '/Divide' - */ - rtb_Divide1 = (double)rtDW.ADC_Data_Model.Sensor_Incar_Temp_RR / 4095.0 * 5.0; - - /* Logic: '/Logical Operator' incorporates: - * Constant: '/Constant' - * Constant: '/Constant' - * RelationalOperator: '/Compare' - * RelationalOperator: '/Compare' - */ - rtb_LogicalOperator1_i = ((rtb_Divide1 < 0.15) || (rtb_Divide1 > 4.9)); - - /* Logic: '/Logical Operator1' incorporates: - * Constant: '/Constant' - * DataStoreRead: '/Data Store Read4' - * RelationalOperator: '/Compare' - * Sum: '/Subtract' - * UnitDelay: '/t_start_delay_private ' - */ - rtb_LogicalOperator1_n = (rtb_LogicalOperator1_i && (rtDW.t_now - - rtDW.t_start_delay_private_DSTATE_c >= 3000U)); - - /* BusCreator: '/Bus Creator' incorporates: - * DataStoreWrite: '/Data Store Write' - * DataTypeConversion: '/Data Type Conversion' - */ - CCU_Errors_Model.CCU_IncarTempErrF_Stat = 0U; - CCU_Errors_Model.CCU_IncarTempErrR_Stat = rtb_LogicalOperator1_n; - CCU_Errors_Model.CCU_DuctTempSenErrF_Stat = 0U; - CCU_Errors_Model.CCU_DuctTempSenErrR_Stat = 0U; - CCU_Errors_Model.CCU_EvaTempSenErrF_Stat = 0U; - CCU_Errors_Model.CCU_EvaTempSenErrR_Stat = 0U; - CCU_Errors_Model.CCU_DeflectorSwErrF_Stat = 0U; - CCU_Errors_Model.CCU_DeflectorSwErrR_Stat = 0U; - CCU_Errors_Model.CCU_PressSenErr_Stat = 0U; - CCU_Errors_Model.CCU_AmbienTemptSenErr_Stat = 0U; - CCU_Errors_Model.CCU_SealingValveErr_Stat = 0U; - CCU_Errors_Model.CCU_ETXVerr_Stat = 0U; - CCU_Errors_Model.CCU_HVACfanOrTXVerrF_Stat = 0U; - CCU_Errors_Model.CCU_HVACfanOrTXVerrR_Stat = 0U; - CCU_Errors_Model.CCU_ActuatorErrF_Stat = 0U; - CCU_Errors_Model.CCU_ActuatorErrR_Stat = 0U; - CCU_Errors_Model.CCU_UltravioletErr_Stat = 0U; - CCU_Errors_Model.CCU_VinRecordErr_Stat = 0U; - CCU_Errors_Model.CCU_AirQualSenErr_Stat = 0U; - CCU_Errors_Model.CCU_CommErr_Stat = 0U; - CCU_Errors_Model.CCU_TWVerr_Stat = 0U; - CCU_Errors_Model.CCU_IonizationErr_Stat = 0U; - CCU_Errors_Model.CCU_AromaErr_Stat = 0U; - - /* Switch: '/Switch' incorporates: - * Constant: '/Constant2' - * DataStoreRead: '/Data Store Read1' - * Lookup_n-D: '/1-D Lookup Table' - */ - if (rtb_LogicalOperator1_n) { - rtb_Switch_f = 200; - } else { - rtb_Switch_f = look1_iu16tdIs16_binlcs - (rtDW.ADC_Data_Model.Sensor_Incar_Temp_RR, rtConstP.pooled14, - rtConstP.pooled2, 1023U); - } - - /* End of Switch: '/Switch' */ - - /* BusCreator: '/Bus Creator' incorporates: - * DataStoreWrite: '/Data Store Write' - */ - Status_Sensor_Model.Battery = 0; - Status_Sensor_Model.AMB = 0; - Status_Sensor_Model.Incar_FL = 0; - Status_Sensor_Model.Incar_FR = 0; - Status_Sensor_Model.Incar_RL = 0; - Status_Sensor_Model.Incar_RR = rtb_Switch_f; - Status_Sensor_Model.Eva_F = 0; - Status_Sensor_Model.Eva_R = 0; - Status_Sensor_Model.Pressure = 0; - Status_Sensor_Model.Duct_FL_Upper = 0; - Status_Sensor_Model.Duct_FL_Lower = 0; - Status_Sensor_Model.Duct_FR_Upper = 0; - Status_Sensor_Model.Duct_FR_Lower = 0; - Status_Sensor_Model.Duct_RL = 0; - Status_Sensor_Model.Duct_RR = 0; - Status_Sensor_Model.Duct_Side_FL = 0; - Status_Sensor_Model.Duct_Side_FR = 0; - Status_Sensor_Model.Duct_Side_RL = 0; - Status_Sensor_Model.Duct_Side_RR = 0; - Status_Sensor_Model.AQS = 0; - - /* MATLAB Function: '/Write ERROR' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : if(IncarRRErr) */ - if (rtb_LogicalOperator1_n) { - /* : fprintf('CCU_Body_Err.CCU_IncarTempErrR_Stat = 0x1 (Failure), Sensor_Incar_Temp_RR = %u\n',Sensor_Incar_Temp_RR); */ - printf("CCU_Body_Err.CCU_IncarTempErrR_Stat = 0x1 (Failure), Sensor_Incar_Temp_RR = %u\n", - rtDW.ADC_Data_Model.Sensor_Incar_Temp_RR); - fflush(stdout); - } - - /* End of MATLAB Function: '/Write ERROR' */ - - /* MATLAB Function: '/Write IncarFL' */ - /* : fprintf('IncarRR = %d * 0.1�C\n',IncarRR); */ - printf("IncarRR = %d * 0.1�C\n", rtb_Switch_f); - fflush(stdout); - - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read4' - * Logic: '/Logical Operator3' - * Logic: '/Logical Operator4' - * UnitDelay: '/Cond_prev_private ' - * UnitDelay: '/t_start_delay_private ' - */ - if (rtb_LogicalOperator1_i && (!rtDW.Cond_prev_private_DSTATE_g)) { - rtDW.t_start_delay_private_DSTATE_c = rtDW.t_now; - } - - /* End of Switch: '/Switch' */ - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5120_2EKA_ShutoffValvePowerTXV1 = %u\n',data); */ - printf("ACP BTS5120_2EKA_ShutoffValvePowerTXV1 = %u\n", - rtDW.ADC_Data_Model.BTS5120_2EKA_ShutoffValvePowerTXV1); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5120_2EKA_ShutoffValvePowerTXV2 = %u\n',data); */ - printf("ACP BTS5120_2EKA_ShutoffValvePowerTXV2 = %u\n", - rtDW.ADC_Data_Model.BTS5120_2EKA_ShutoffValvePowerTXV2); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5180_2EKA_ChannelPTCPower1 = %u\n',data); */ - printf("ACP BTS5180_2EKA_ChannelPTCPower1 = %u\n", - rtDW.ADC_Data_Model.BTS5180_2EKA_ChannelPTCPower1); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5180_2EKA_ChannelPTCPower2 = %u\n',data); */ - printf("ACP BTS5180_2EKA_ChannelPTCPower2 = %u\n", - rtDW.ADC_Data_Model.BTS5180_2EKA_ChannelPTCPower2); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5180_2EKA_FrontIncarMotor = %u\n',data); */ - printf("ACP BTS5180_2EKA_FrontIncarMotor = %u\n", - rtDW.ADC_Data_Model.BTS5180_2EKA_FrontIncarMotor); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5180_2EKA_RearIncarMotor = %u\n',data); */ - printf("ACP BTS5180_2EKA_RearIncarMotor = %u\n", - rtDW.ADC_Data_Model.BTS5180_2EKA_RearIncarMotor); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5180_2EKA_ReservePowerSupply = %u\n',data); */ - printf("ACP BTS5180_2EKA_ReservePowerSupply = %u\n", - rtDW.ADC_Data_Model.BTS5180_2EKA_ReservePowerSupply); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5180_2EKA_ShutOFFValveFront = %u\n',data); */ - printf("ACP BTS5180_2EKA_ShutOFFValveFront = %u\n", - rtDW.ADC_Data_Model.BTS5180_2EKA_ShutOFFValveFront); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5180_2EKA_ShutOFFValveRear = %u\n',data); */ - printf("ACP BTS5180_2EKA_ShutOFFValveRear = %u\n", - rtDW.ADC_Data_Model.BTS5180_2EKA_ShutOFFValveRear); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP BTS5180_2EKA_TwoWayValve = %u\n',data); */ - printf("ACP BTS5180_2EKA_TwoWayValve = %u\n", - rtDW.ADC_Data_Model.BTS5180_2EKA_TwoWayValve); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP IGN_ANS = %u\n',IGN_ANS); */ - printf("ACP IGN_ANS = %u\n", rtDW.ADC_Data_Model.IGN_ANS); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Ignition = %u\n',Ignition); */ -// printf("ACP Ignition = %u\n", rtDW.ADC_Data_Model.Ignition); -// fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP PBATT_CHECK = %u\n',data); */ - printf("ACP PBATT_CHECK = %u\n", rtDW.ADC_Data_Model.PBATT_CHECK); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Pressure_DIAG = %u\n',data); */ - printf("ACP Pressure_DIAG = %u\n", rtDW.ADC_Data_Model.Pressure_DIAG); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Reserve_Sensor_Duct_Temp_1 = %u\n',data); */ - printf("ACP Reserve_Sensor_Duct_Temp_1 = %u\n", - rtDW.ADC_Data_Model.Reserve_Sensor_Duct_Temp_1); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Reserve_Sensor_Duct_Temp_2 = %u\n',data); */ - printf("ACP Reserve_Sensor_Duct_Temp_2 = %u\n", - rtDW.ADC_Data_Model.Reserve_Sensor_Duct_Temp_2); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_AC_Pressure = %u\n',Sensor_AC_Pressure); */ - printf("ACP Sensor_AC_Pressure = %u\n", rtDW.ADC_Data_Model.Sensor_AC_Pressure); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Front_Duct1 = %u\n',Sensor_Front_Duct1); */ - printf("ACP Sensor_Front_Duct1 = %u\n", rtDW.ADC_Data_Model.Sensor_Front_Duct1); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Front_Duct2 = %u\n',Sensor_Front_Duct2); */ - printf("ACP Sensor_Front_Duct2 = %u\n", rtDW.ADC_Data_Model.Sensor_Front_Duct2); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Front_Duct3 = %u\n',Sensor_Front_Duct3); */ - printf("ACP Sensor_Front_Duct3 = %u\n", rtDW.ADC_Data_Model.Sensor_Front_Duct3); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Front_Duct4 = %u\n',Sensor_Front_Duct4); */ - printf("ACP Sensor_Front_Duct4 = %u\n", rtDW.ADC_Data_Model.Sensor_Front_Duct4); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Front_Duct5 = %u\n',data); */ - printf("ACP Sensor_Front_Duct5 = %u\n", rtDW.ADC_Data_Model.Sensor_Front_Duct5); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Front_Duct6 = %u\n',data); */ - printf("ACP Sensor_Front_Duct6 = %u\n", rtDW.ADC_Data_Model.Sensor_Front_Duct6); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Rear_Duct1 = %u\n',Sensor_Rear_Duct1); */ - printf("ACP Sensor_Rear_Duct1 = %u\n", rtDW.ADC_Data_Model.Sensor_Rear_Duct1); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Rear_Duct2 = %u\n',Sensor_Rear_Duct2); */ - printf("ACP Sensor_Rear_Duct2 = %u\n", rtDW.ADC_Data_Model.Sensor_Rear_Duct2); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Rear_Duct3 = %u\n',Sensor_Rear_Duct3); */ - printf("ACP Sensor_Rear_Duct3 = %u\n", rtDW.ADC_Data_Model.Sensor_Rear_Duct3); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Rear_Duct4 = %u\n',Sensor_Rear_Duct4); */ - printf("ACP Sensor_Rear_Duct4 = %u\n", rtDW.ADC_Data_Model.Sensor_Rear_Duct4); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Rear_Duct5 = %u\n',Sensor_Rear_Duct5); */ - printf("ACP Sensor_Rear_Duct5 = %u\n", rtDW.ADC_Data_Model.Sensor_Rear_Duct5); - fflush(stdout); - - /* MATLAB Function: '/Write Ignition' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP Sensor_Rear_Duct6 = %u\n',Sensor_Rear_Duct6); */ - printf("ACP Sensor_Rear_Duct6 = %u\n", rtDW.ADC_Data_Model.Sensor_Rear_Duct6); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB = %u\n',data); */ - printf("ACP VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB = %u\n", - rtDW.ADC_Data_Model.VN7008AJ_DIAG_FrontLINActuatorPowerDriverAB); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP VN7008AJ_DIAG_RearLINActuatorPowerDriverC = %u\n',data); */ - printf("ACP VN7008AJ_DIAG_RearLINActuatorPowerDriverC = %u\n", - rtDW.ADC_Data_Model.VN7008AJ_DIAG_RearLINActuatorPowerDriverC); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP VN7008AJ_FrontLINActuatorPowerDriverAB = %u\n',data); */ - printf("ACP VN7008AJ_FrontLINActuatorPowerDriverAB = %u\n", - rtDW.ADC_Data_Model.VN7008AJ_FrontLINActuatorPowerDriverAB); - fflush(stdout); - - /* MATLAB Function: '/Write' incorporates: - * DataStoreRead: '/Data Store Read1' - */ - /* : fprintf('ACP VN7008AJ_RearLINActuatorPowerDriverC = %u\n',data); */ - printf("ACP VN7008AJ_RearLINActuatorPowerDriverC = %u\n", - rtDW.ADC_Data_Model.VN7008AJ_RearLINActuatorPowerDriverC); - fflush(stdout); - - /* Switch: '/Switch' incorporates: - * DataStoreRead: '/Data Store Read' - */ - if (rtDW.stepSig < 1) { - /* Switch: '/Switch' incorporates: - * Constant: '/Constant1' - */ - rtDW.UnitDelay_DSTATE = 1; - } - - /* End of Switch: '/Switch' */ - - /* SwitchCase: '/Switch Case' */ - switch (rtDW.UnitDelay_DSTATE) { - case 1: - /* Outputs for IfAction SubSystem: '/Stop Mode' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read2' - */ - if ((rtDW.Busy_Ch0 == 0) && (rtDW.Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write2' */ - rtDW.mode_loc[i] = 2U; - - /* DataStoreWrite: '/Data Store Write3' */ - rtDW.com_loc[i] = 1U; - } - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * Merge: '/Merge' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* MATLAB Function: '/stop mode' */ - /* : y = step; */ - /* : fprintf('SIMULINK Stop Mode\n'); */ - printf("SIMULINK Stop Mode\n"); - fflush(stdout); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - /* Merge: '/Merge' */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Stop Mode' */ - break; - - case 2: - /* Outputs for IfAction SubSystem: '/Initial CPOS Min' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If' incorporates: - * DataStoreRead: '/Data Store Read' - * DataStoreRead: '/Data Store Read1' - */ - if ((rtDW.Busy_Ch0 == 0) && (rtDW.Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write' */ - rtDW.pos_loc[i] = 6000U; - - /* DataStoreWrite: '/Data Store Write1' */ - rtDW.com_loc[i] = 2U; - } - - /* MATLAB Function: '/Initial CPOS Min' */ - /* : y = step; */ - /* : fprintf('SIMULINK Initial CPOS Min - 6000\n'); */ - printf("SIMULINK Initial CPOS Min - 6000\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * Merge: '/Merge' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - /* DataStoreWrite: '/Data Store Write3' */ - for (i = 0; i < 9; i++) { - rtDW.com_loc[i] = 0U; - } - - /* End of DataStoreWrite: '/Data Store Write3' */ - - /* Merge: '/Merge' incorporates: - * Merge: '/Merge' - * SignalConversion generated from: '/stepIn1' - */ - rtB.Merge = rtDW.UnitDelay_DSTATE; - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If' */ - /* End of Outputs for SubSystem: '/Initial CPOS Min' */ - break; - - case 3: - /* Outputs for IfAction SubSystem: '/Normal Mode' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read2' - */ - if ((rtDW.Busy_Ch0 == 0) && (rtDW.Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write' */ - rtDW.mode_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write2' */ - rtDW.com_loc[i] = 1U; - } - - /* MATLAB Function: '/Normal Mode' */ - /* : y = step; */ - /* : fprintf('SIMULINK Normal Mode\n'); */ - printf("SIMULINK Normal Mode\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Normal Mode' */ - break; - - case 4: - /* Outputs for IfAction SubSystem: '/Move to position Min' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read2' - */ - if ((rtDW.Busy_Ch0 == 0) && (rtDW.Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write1' */ - rtDW.stall_set_loc[i] = 1U; - - /* DataStoreWrite: '/Data Store Write3' incorporates: - * Constant: '/Constant2' - */ - rtDW.lnoise_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write2' */ - rtDW.com_loc[i] = 3U; - - /* DataStoreWrite: '/Data Store Write4' incorporates: - * Constant: '/Constant4' - */ - rtDW.autos_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write5' incorporates: - * Constant: '/Constant5' - */ - rtDW.speed_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write6' incorporates: - * Constant: '/Constant6' - */ - rtDW.coils_stop_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write' */ - rtDW.pos_loc[i] = 1U; - } - - /* MATLAB Function: '/Move to position Min' */ - /* : y = step; */ - /* : fprintf('SIMULINK Move to position Min - 1\n'); */ - printf("SIMULINK Move to position Min - 1\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Move to position Min' */ - break; - - case 5: - /* Outputs for IfAction SubSystem: '/Check Stall Min' incorporates: - * ActionPort: '/Action Port' - */ - /* RelationalOperator: '/Relational Operator1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write5' - */ - for (i = 0; i < 9; i++) { - rtb_RelationalOperator_j[i] = - (rtDW.controllerDataInput.in_Act_Stall_Slave_Ch0[i] == 1); - } - - /* End of RelationalOperator: '/Relational Operator1' */ - - /* Logic: '/Logical Operator2' */ - rtb_LogicalOperator1_n = rtb_RelationalOperator_j[0]; - for (i = 0; i < 8; i++) { - rtb_LogicalOperator1_n = (rtb_LogicalOperator1_n || - rtb_RelationalOperator_j[i + 1]); - } - - /* RelationalOperator: '/Relational Operator' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write1' - */ - for (i = 0; i < 9; i++) { - rtb_RelationalOperator_j[i] = (rtDW.controllerDataInput.in_CPOS_ALL_Ch0[i] - == 1); - } - - /* End of RelationalOperator: '/Relational Operator' */ - - /* Logic: '/Logical Operator1' */ - tmp = rtb_RelationalOperator_j[0]; - for (i = 0; i < 8; i++) { - tmp = (tmp || rtb_RelationalOperator_j[i + 1]); - } - - /* If: '/If2' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read2' - * DataTypeConversion: '/Data Type Conversion' - * DataTypeConversion: '/Data Type Conversion1' - * Logic: '/Logical Operator' - * Logic: '/Logical Operator1' - * Logic: '/Logical Operator2' - */ - if ((rtDW.Busy_Ch0 == 0) && (rtDW.Error_Connect_Ch0 == 0) && - (rtb_LogicalOperator1_n || tmp)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - /* DataStoreWrite: '/Data Store Write1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write1' - */ - for (i = 0; i < 9; i++) { - rtDW.Min_position_Ch0[i] = rtDW.controllerDataInput.in_CPOS_ALL_Ch0[i]; - } - - /* End of DataStoreWrite: '/Data Store Write1' */ - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* MATLAB Function: '/MIN POSITION' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write1' - */ - /* : y = step; */ - /* : fprintf('SIMULINK Min_position_Ch0 '); */ - printf("SIMULINK Min_position_Ch0 "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtDW.controllerDataInput.in_CPOS_ALL_Ch0[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); - - /* End of MATLAB Function: '/MIN POSITION' */ - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If2' */ - - /* MATLAB Function: '/MAX POSITION' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write1' - */ - MAXPOSITION(rtDW.controllerDataInput.in_CPOS_ALL_Ch0, rtb_y_ff); - - /* MATLAB Function: '/MAX POSITION1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write5' - */ - MAXPOSITION1(rtDW.controllerDataInput.in_Act_Stall_Slave_Ch0, rtb_y_b); - - /* End of Outputs for SubSystem: '/Check Stall Min' */ - break; - - case 6: - /* Outputs for IfAction SubSystem: '/Initial CPOS Max' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read2' - */ - if ((rtDW.Busy_Ch0 == 0) && (rtDW.Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write' */ - rtDW.pos_loc[i] = 1U; - - /* DataStoreWrite: '/Data Store Write1' */ - rtDW.com_loc[i] = 2U; - } - - /* MATLAB Function: '/Initial CPOS Max' */ - /* : y = step; */ - /* : fprintf('SIMULINK Initial CPOS Max - 1\n'); */ - printf("SIMULINK Initial CPOS Max - 1\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Initial CPOS Max' */ - break; - - case 7: - /* Outputs for IfAction SubSystem: '/Move to position Max' incorporates: - * ActionPort: '/Action Port' - */ - /* If: '/If1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read2' - */ - if ((rtDW.Busy_Ch0 == 0) && (rtDW.Error_Connect_Ch0 == 0)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - for (i = 0; i < 9; i++) { - /* DataStoreWrite: '/Data Store Write1' */ - rtDW.stall_set_loc[i] = 1U; - - /* DataStoreWrite: '/Data Store Write3' incorporates: - * Constant: '/Constant2' - */ - rtDW.lnoise_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write2' */ - rtDW.com_loc[i] = 3U; - - /* DataStoreWrite: '/Data Store Write4' incorporates: - * Constant: '/Constant4' - */ - rtDW.autos_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write5' incorporates: - * Constant: '/Constant5' - */ - rtDW.speed_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write6' incorporates: - * Constant: '/Constant6' - */ - rtDW.coils_stop_set_loc[i] = 0U; - - /* DataStoreWrite: '/Data Store Write' */ - rtDW.pos_loc[i] = 6000U; - } - - /* MATLAB Function: '/Move to position Max' */ - /* : y = step; */ - /* : fprintf('SIMULINK Move to position Max - 6000\n'); */ - printf("SIMULINK Move to position Max - 6000\n"); - fflush(stdout); - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * SignalConversion generated from: '/step' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If1' */ - /* End of Outputs for SubSystem: '/Move to position Max' */ - break; - - case 8: - /* Outputs for IfAction SubSystem: '/Check Stall Max' incorporates: - * ActionPort: '/Action Port' - */ - /* RelationalOperator: '/Relational Operator1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write5' - */ - for (i = 0; i < 9; i++) { - rtb_RelationalOperator_j[i] = - (rtDW.controllerDataInput.in_Act_Stall_Slave_Ch0[i] == 1); - } - - /* End of RelationalOperator: '/Relational Operator1' */ - - /* Logic: '/Logical Operator2' */ - rtb_LogicalOperator1_n = rtb_RelationalOperator_j[0]; - for (i = 0; i < 8; i++) { - rtb_LogicalOperator1_n = (rtb_LogicalOperator1_n || - rtb_RelationalOperator_j[i + 1]); - } - - /* RelationalOperator: '/Relational Operator' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write1' - */ - for (i = 0; i < 9; i++) { - rtb_RelationalOperator_j[i] = (rtDW.controllerDataInput.in_CPOS_ALL_Ch0[i] - == 6000); - } - - /* End of RelationalOperator: '/Relational Operator' */ - - /* Logic: '/Logical Operator1' */ - tmp = rtb_RelationalOperator_j[0]; - for (i = 0; i < 8; i++) { - tmp = (tmp || rtb_RelationalOperator_j[i + 1]); - } - - /* If: '/If2' incorporates: - * DataStoreRead: '/Data Store Read3' - * DataStoreRead: '/Data Store Read4' - * DataTypeConversion: '/Data Type Conversion' - * DataTypeConversion: '/Data Type Conversion1' - * Logic: '/Logical Operator' - * Logic: '/Logical Operator1' - * Logic: '/Logical Operator2' - */ - if ((rtDW.Busy_Ch0 == 0) && (rtDW.Error_Connect_Ch0 == 0) && - (rtb_LogicalOperator1_n || tmp)) { - /* Outputs for IfAction SubSystem: '/If Action Subsystem2' incorporates: - * ActionPort: '/Action Port' - */ - /* DataStoreWrite: '/Data Store Write1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write1' - */ - for (i = 0; i < 9; i++) { - rtDW.Max_position_Ch0[i] = rtDW.controllerDataInput.in_CPOS_ALL_Ch0[i]; - } - - /* End of DataStoreWrite: '/Data Store Write1' */ - - /* Merge: '/Merge' incorporates: - * Constant: '/Constant' - * Sum: '/step inc' - */ - rtB.Merge = (int8_t)(rtDW.UnitDelay_DSTATE + 1); - - /* MATLAB Function: '/MIN POSITION' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write1' - */ - /* : y = step; */ - /* : fprintf('SIMULINK Max_position_Ch0 '); */ - printf("SIMULINK Max_position_Ch0 "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtDW.controllerDataInput.in_CPOS_ALL_Ch0[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); - - /* End of MATLAB Function: '/MIN POSITION' */ - /* End of Outputs for SubSystem: '/If Action Subsystem2' */ - } else { - /* Outputs for IfAction SubSystem: '/If Action Subsystem3' incorporates: - * ActionPort: '/Action Port' - */ - IfActionSubsystem3(rtDW.UnitDelay_DSTATE, &rtB.Merge, rtDW.com_loc); - - /* End of Outputs for SubSystem: '/If Action Subsystem3' */ - } - - /* End of If: '/If2' */ - - /* MATLAB Function: '/MAX POSITION' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write1' - */ - MAXPOSITION(rtDW.controllerDataInput.in_CPOS_ALL_Ch0, rtb_y_ff); - - /* MATLAB Function: '/MAX POSITION1' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreWrite: '/Data Store Write5' - */ - MAXPOSITION1(rtDW.controllerDataInput.in_Act_Stall_Slave_Ch0, rtb_y_b); - - /* End of Outputs for SubSystem: '/Check Stall Max' */ - break; - - case 9: - /* Outputs for IfAction SubSystem: '/Homing' incorporates: - * ActionPort: '/Action Port' - */ - /* DataStoreWrite: '/Data Store Write3' */ - for (i = 0; i < 9; i++) { - rtDW.com_loc[i] = 0U; - } - - /* End of DataStoreWrite: '/Data Store Write3' */ - - /* Merge: '/Merge' incorporates: - * SignalConversion generated from: '/stepIn1' - */ - rtB.Merge = 0; - - /* MATLAB Function: '/MAX POSITION' incorporates: - * DataStoreRead: '/Data Store Read2' - */ - /* : y = step; */ - /* : fprintf('SIMULINK MAX POSITION '); */ - printf("SIMULINK MAX POSITION "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtDW.Max_position_Ch0[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); - - /* End of MATLAB Function: '/MAX POSITION' */ - - /* MATLAB Function: '/MIN POSITION' incorporates: - * DataStoreRead: '/Data Store Read3' - */ - /* : y = step; */ - /* : fprintf('SIMULINK MIN POSITION '); */ - printf("SIMULINK MIN POSITION "); - fflush(stdout); - - /* : for i = 1:numel(step) */ - for (i = 0; i < 9; i++) { - /* : fprintf('%d ', int16(step(i))); */ - printf("%d ", rtDW.Min_position_Ch0[i]); - fflush(stdout); - } - - /* : fprintf('\n'); */ - printf("\n"); - fflush(stdout); - - /* End of MATLAB Function: '/MIN POSITION' */ - /* End of Outputs for SubSystem: '/Homing' */ - break; - - case 0: - /* Outputs for IfAction SubSystem: '/Homing1' incorporates: - * ActionPort: '/Action Port' - */ - /* Merge: '/Merge' incorporates: - * SignalConversion generated from: '/stepIn' - */ - rtB.Merge = rtDW.UnitDelay_DSTATE; - - /* End of Outputs for SubSystem: '/Homing1' */ - break; - } - - /* End of SwitchCase: '/Switch Case' */ - - /* DataStoreWrite: '/Start write stepSig' incorporates: - * Constant: '/Constant1' - */ - rtDW.stepSig = 1; - - /* BusCreator: '/Bus Creator' incorporates: - * DataStoreRead: '/Data Store Read1' - * DataStoreRead: '/Data Store Read2' - * DataStoreRead: '/Data Store Read3' - * DataStoreRead: '/Data Store Read4' - * DataStoreRead: '/Data Store Read5' - * DataStoreRead: '/Data Store Read6' - * DataStoreRead: '/Data Store Read7' - * DataStoreRead: '/Data Store Read8' - * DataStoreRead: '/Data Store Read9' - * DataStoreWrite: '/Data Store Write' - */ - for (i = 0; i < 9; i++) { - controllerData.POS[i] = rtDW.pos_loc[i]; - controllerData.BUS_ADR[i] = rtDW.busAdr_loc[i]; - controllerData.MODE[i] = rtDW.mode_loc[i]; - controllerData.COM[i] = rtDW.com_loc[i]; - controllerData.Stall_SET[i] = rtDW.stall_set_loc[i]; - controllerData.Lnoise_SET[i] = rtDW.lnoise_set_loc[i]; - controllerData.Autos_SET[i] = rtDW.autos_set_loc[i]; - controllerData.Speed_SET[i] = rtDW.speed_set_loc[i]; - controllerData.Coils_Stop_SET[i] = rtDW.coils_stop_set_loc[i]; - } - - /* End of BusCreator: '/Bus Creator' */ - - /* Update for UnitDelay: '/Cond_prev_private ' */ - rtDW.Cond_prev_private_DSTATE = rtb_FailCond; - - /* Update for UnitDelay: '/Cond_prev_private ' */ - rtDW.Cond_prev_private_DSTATE_h = rtb_LogicalOperator1; - - /* Update for UnitDelay: '/Cond_prev_private ' */ - rtDW.Cond_prev_private_DSTATE_i = rtb_LogicalOperator1_f; - - /* Update for UnitDelay: '/Cond_prev_private ' */ - rtDW.Cond_prev_private_DSTATE_c = rtb_LogicalOperator1_k; - - /* Update for UnitDelay: '/Cond_prev_private ' */ - rtDW.Cond_prev_private_DSTATE_hm = rtb_LogicalOperator1_b; - - /* Update for UnitDelay: '/Cond_prev_private ' */ - rtDW.Cond_prev_private_DSTATE_b = rtb_LogicalOperator1_ln; - - /* Update for UnitDelay: '/Cond_prev_private ' */ - rtDW.Cond_prev_private_DSTATE_g = rtb_LogicalOperator1_i; - - /* Update for Switch: '/Switch' incorporates: - * UnitDelay: '/Unit Delay' - */ - rtDW.UnitDelay_DSTATE = rtB.Merge; -} - -/* Model initialize function */ -void Model_actuator_initialize(void) -{ - /* (no initialization code required) */ -} - -/* Model terminate function */ -void Model_actuator_terminate(void) -{ - /* (no terminate code required) */ -} - -/* - * File trailer for generated code. - * - * [EOF] - */