In the attached Autosar based Simulink model ("autosar_multirunnables_non_virtual_outports.slx"), both the inputs to the 'Merge' block which is located before the 'PPort_DE4' outport block are controlled by 'If Action Subsystems'. The above model is a modified version of the Simulink model used in this example – http://www.mathworks.com/help/ecoder/examples/autosar-code-generation-for-multiple-runnable-entities.html
The first input to the 'Merge' block is controlled by the 'If Action Subsystem' present in the runnable named – 'Runnable2_subsystem' and the second input to the 'Merge' block is controlled by another 'If Action Subsystem' present in the runnable named – 'Runnable3_subsystem'.
When we generate code from this model, we expect to see two function calls which write to the outport 'PPort_DE4' within an "if" conditional statement. But in the generated code we see the following –
155 if (rtDWork.Output_DSTATE_d >= rtDWork.DiscreteTimeIntegrator_DSTATE) {156 /* Outputs for IfAction SubSystem: '<S6>/If Action Subsystem' incorporates:157 * ActionPort: '<S9>/Action Port'158 */159 rtB.In1_l = rtDWork.Output_DSTATE_d;160161 /* End of Outputs for SubSystem: '<S6>/If Action Subsystem' */162 }163164 /* End of If: '<S6>/If' */165 /* End of Outputs for SubSystem: '<S2>/ExplicitWrite' */166167 /* Outport: '<Root>/PPort_DE4' incorporates:168 * SignalConversion: '<S2>/OutportBufferForSubtracter'169 */170 Rte_IWrite_Runnable2_PPort_DE4(rtB.In1_l);
The "Rte_IWrite_Runnable2_PPort_DE4(rtB.In1_l);" function call corresponding to the write from Runnable2 is not present in the "if" conditional statement. Similarly the write function call corresponding to 'Runnable3' is as follows –
245 if (rtDWork.Output_DSTATE >= rtb_TmpSignalConversionAtIn1Out * tmp[0]) {246 /* Outputs for IfAction SubSystem: '<S11>/If Action Subsystem' incorporates:247 * ActionPort: '<S14>/Action Port'248 */249 rtB.In1 = rtDWork.Output_DSTATE;250251 /* End of Outputs for SubSystem: '<S11>/If Action Subsystem' */252 }253254 /* End of If: '<S11>/If' */255 /* End of Outputs for SubSystem: '<S3>/ExplicitWrite' */256257 /* Outport: '<Root>/PPort_DE4' incorporates:258 * SignalConversion: '<S3>/OutportBufferForMultiplier'259 */260 Rte_IWrite_Runnable3_PPort_DE4(rtB.In1);
How can we ensure that both the Rte_IWrite statements are present within the conditional statements?
Best Answer