/* Model output function */ void RA4_student_output(void) { /* Reset subsysRan breadcrumbs */ srClearBC(RA4_student_DW.Controller_SubsysRanBC); /* UnitDelay: '<Root>/Unit Delay2' */ RA4_student_B.UnitDelay2[0] = RA4_student_DW.UnitDelay2_DSTATE[0]; RA4_student_B.UnitDelay2[1] = RA4_student_DW.UnitDelay2_DSTATE[1]; RA4_student_B.UnitDelay2[2] = RA4_student_DW.UnitDelay2_DSTATE[2]; /* UnitDelay: '<Root>/Unit Delay1' */ RA4_student_B.UnitDelay1 = RA4_student_DW.UnitDelay1_DSTATE; /* RTW Generated Level2 S-Function Block: '<S2>/Robot Arm_sfcn' (Robot_sf) */ { SimStruct *rts = RA4_student_M->childSfunctions[1]; sfcnOutputs(rts, 0); } /* Outputs for Enabled SubSystem: '<Root>/Controller' incorporates: * EnablePort: '<S1>/Enable' */ if (RA4_student_B.RobotArm_sfcn_o1 > 0.0) { if (!RA4_student_DW.Controller_MODE) { RA4_student_DW.Controller_MODE = true; } } else { if (RA4_student_DW.Controller_MODE) { RA4_student_DW.Controller_MODE = false; } } if (RA4_student_DW.Controller_MODE) { /* Sum: '<S1>/Sum4' incorporates: * Constant: '<S1>/Feedforward R' * Constant: '<S1>/Reference R' * Gain: '<S3>/Gain' * Sum: '<S1>/Sum2' */ RA4_student_B.Sum4 = (RA4_student_P.ReferenceR_Value - RA4_student_B.RobotArm_sfcn_o2[0]) * RA4_student_P.Gain_Gain + RA4_student_P.FeedforwardR_Value; /* Sum: '<S1>/Sum5' incorporates: * Constant: '<S1>/Feedforward X' * Constant: '<S1>/Reference X' * Gain: '<S4>/Gain' * Sum: '<S1>/Sum1' */ RA4_student_B.Sum5 = (RA4_student_P.ReferenceX_Value - RA4_student_B.RobotArm_sfcn_o2[1]) * RA4_student_P.Gain_Gain_e + RA4_student_P.FeedforwardX_Value; /* Sum: '<S1>/Sum6' incorporates: * Constant: '<S1>/Feedforward Z' * Constant: '<S1>/Reference Z' * Gain: '<S5>/Gain' * Sum: '<S1>/Sum3' */ RA4_student_B.Sum6 = (RA4_student_P.ReferenceZ_Value - RA4_student_B.RobotArm_sfcn_o2[2]) * RA4_student_P.Gain_Gain_l + RA4_student_P.FeedforwardZ_Value; /* Constant: '<S1>/Reference Solenoid' */ RA4_student_B.ReferenceSolenoid = RA4_student_P.ReferenceSolenoid_Value; /* Level2 S-Function Block: '<S6>/S-Function' (sf_rt_scope) */ { SimStruct *rts = RA4_student_M->childSfunctions[0]; sfcnOutputs(rts, 0); } srUpdateBC(RA4_student_DW.Controller_SubsysRanBC); } /* End of Outputs for SubSystem: '<Root>/Controller' */ }
/* Model output function */ void udpRead_output(void) { char_T *sErr; int32_T samplesRead; boolean_T rtb_Compare; int32_T s5_iter; real_T tmp; int32_T exitg1; int32_T exitg2; /* Reset subsysRan breadcrumbs */ srClearBC(udpRead_DW.ForIteratorSubsystem_SubsysRanB); /* Reset subsysRan breadcrumbs */ srClearBC(udpRead_DW.ForIteratorSubsystem1_SubsysRan); /* Reset subsysRan breadcrumbs */ srClearBC(udpRead_DW.EnabledSubsystem_SubsysRanBC); /* S-Function (sdspFromNetwork): '<Root>/UDP Receive' */ sErr = GetErrorBuffer(&udpRead_DW.UDPReceive_NetworkLib[0U]); samplesRead = 31; LibOutputs_Network(&udpRead_DW.UDPReceive_NetworkLib[0U], &udpRead_B.UDPReceive_o1[0U], &samplesRead); if (*sErr != 0) { rtmSetErrorStatus(udpRead_M, sErr); rtmSetStopRequested(udpRead_M, 1); } udpRead_B.UDPReceive_o2 = (uint16_T)samplesRead; /* End of S-Function (sdspFromNetwork): '<Root>/UDP Receive' */ /* RelationalOperator: '<S1>/Compare' incorporates: * Constant: '<S1>/Constant' */ rtb_Compare = (udpRead_B.UDPReceive_o2 > udpRead_P.Constant_Value_p); /* Outputs for Enabled SubSystem: '<Root>/Enabled Subsystem' incorporates: * EnablePort: '<S2>/Enable' */ if (rtb_Compare) { if (!udpRead_DW.EnabledSubsystem_MODE) { udpRead_DW.EnabledSubsystem_MODE = true; } /* Outputs for Iterator SubSystem: '<S2>/For Iterator Subsystem1' incorporates: * ForIterator: '<S5>/For Iterator' */ /* Selector: '<S5>/Selector' incorporates: * Selector: '<S5>/Selector1' * Selector: '<S5>/Selector2' */ s5_iter = 24; do { exitg2 = 0; if (udpRead_P.Constant1_Value < 0.0) { tmp = ceil(udpRead_P.Constant1_Value); } else { tmp = floor(udpRead_P.Constant1_Value); } if (rtIsNaN(tmp) || rtIsInf(tmp)) { tmp = 0.0; } else { tmp = fmod(tmp, 4.294967296E+9); } if (s5_iter - 23 <= (tmp < 0.0 ? -(int32_T)(uint32_T)-tmp : (int32_T) (uint32_T)tmp)) { udpRead_B.Selector = udpRead_B.UDPReceive_o1[s5_iter]; udpRead_B.Selector1 = udpRead_B.UDPReceive_o1[s5_iter + 2]; udpRead_B.Selector2 = udpRead_B.UDPReceive_o1[s5_iter + 4]; srUpdateBC(udpRead_DW.ForIteratorSubsystem1_SubsysRan); s5_iter++; } else { exitg2 = 1; } } while (exitg2 == 0); /* End of Outputs for SubSystem: '<S2>/For Iterator Subsystem1' */ /* Outputs for Iterator SubSystem: '<S2>/For Iterator Subsystem' incorporates: * ForIterator: '<S4>/For Iterator' */ s5_iter = 1; do { exitg1 = 0; if (udpRead_P.Constant_Value < 0.0) { tmp = ceil(udpRead_P.Constant_Value); } else { tmp = floor(udpRead_P.Constant_Value); } if (rtIsNaN(tmp) || rtIsInf(tmp)) { tmp = 0.0; } else { tmp = fmod(tmp, 4.294967296E+9); } if (s5_iter <= (tmp < 0.0 ? -(int32_T)(uint32_T)-tmp : (int32_T)(uint32_T) tmp)) { udpRead_B.Selector_d = udpRead_B.UDPReceive_o1[s5_iter - 1]; udpRead_B.Selector1_f = udpRead_B.UDPReceive_o1[s5_iter + 3]; udpRead_B.Selector2_f = udpRead_B.UDPReceive_o1[s5_iter + 7]; udpRead_B.Compare = (s5_iter == udpRead_P.CompareToConstant_const); udpRead_B.Selector3 = udpRead_B.UDPReceive_o1[s5_iter + 11]; udpRead_B.Selector4 = udpRead_B.UDPReceive_o1[s5_iter + 15]; udpRead_B.Selector5 = udpRead_B.UDPReceive_o1[s5_iter + 19]; srUpdateBC(udpRead_DW.ForIteratorSubsystem_SubsysRanB); s5_iter++; } else { exitg1 = 1; } } while (exitg1 == 0); /* End of Outputs for SubSystem: '<S2>/For Iterator Subsystem' */ srUpdateBC(udpRead_DW.EnabledSubsystem_SubsysRanBC); } else { if (udpRead_DW.EnabledSubsystem_MODE) { udpRead_DW.EnabledSubsystem_MODE = false; } } /* End of Outputs for SubSystem: '<Root>/Enabled Subsystem' */ /* Switch: '<S3>/Init' incorporates: * Constant: '<S3>/Initial Condition' * Logic: '<S3>/FixPt Logical Operator' * UnitDelay: '<S3>/FixPt Unit Delay1' * UnitDelay: '<S3>/FixPt Unit Delay2' */ if (rtb_Compare || (udpRead_DW.FixPtUnitDelay2_DSTATE != 0)) { udpRead_B.Init = udpRead_P.UnitDelayResettable_vinit; } else { udpRead_B.Init = udpRead_DW.FixPtUnitDelay1_DSTATE; } /* End of Switch: '<S3>/Init' */ /* Switch: '<S3>/Reset' incorporates: * Constant: '<S3>/Initial Condition' * DataTypeConversion: '<Root>/Data Type Conversion' * Sum: '<Root>/Sum' */ if (rtb_Compare) { udpRead_B.Xnew = udpRead_P.UnitDelayResettable_vinit; } else { udpRead_B.Xnew = 1.0F + udpRead_B.Init; } /* End of Switch: '<S3>/Reset' */ }