/* Function: rtOneStep ======================================================== * * Abstract: * Perform one step of the model. */ static void rt_OneStep(RT_MODEL *S) { real_T tnext; /*********************************************** * Check and see if error status has been set * ***********************************************/ if (rtmGetErrorStatus(S) != NULL) { GBLbuf.stopExecutionFlag = 1; return; } /* enable interrupts here */ tnext = rt_SimGetNextSampleHit(); rtsiSetSolverStopTime(rtmGetRTWSolverInfo(S),tnext); outputs(S, 0); rtExtModeSingleTaskUpload(S); update(S, 0); rt_SimUpdateDiscreteTaskSampleHits(rtmGetNumSampleTimes(S), rtmGetTimingData(S), rtmGetSampleHitPtr(S), rtmGetTPtr(S)); if (rtmGetSampleTime(S,0) == CONTINUOUS_SAMPLE_TIME) { rt_UpdateContinuousStates(S); } rtExtModeCheckEndTrigger(); } /* end rtOneStep */
/* Function: rsimOutputLogUpdate =============================================== * */ static void rsimOutputLogUpdate(SimStruct* S) { double currTime = ssGetT(S); bool logOutput = !ssGetOutputTimesOnly(S); #ifdef DEBUG_TIMING rsimDisplayTimingData(S, sizeof(struct SimStruct_tag), sizeof(struct _ssMdlInfo)); #endif if (gblExtModeEnabled) { rtExtModeOneStep(ssGetRTWExtModeInfo(S), ssGetNumSampleTimes(S), (boolean_T*)&ssGetStopRequested(S)); if (ssGetStopRequested(S)) return; } /* Setup the task times and sample hit flags for the discrete rates */ rsimUpdateDiscreteTaskTimesAndSampleHits(S); if (ssGetErrorStatus(S) != NULL) return; /* * See if we are at an outputTime, and if so set logOutput to true and * increment the next output time index to point to the next entry in * the outputTimes array. */ if ( ssGetNumOutputTimes(S) > 0 && ssGetOutputTimesIndex(S) < ssGetNumOutputTimes(S) ) { time_T nextOutputTime = ssGetNextOutputTime(S); /* utAssert(currTime <= nextOutputTime); */ if (currTime == nextOutputTime) { uint_T idx = ssGetOutputTimesIndex(S); ssSetOutputTimesIndex(S, idx+1); logOutput = 1; /* this is one of the specified output times */ } } ssSetLogOutput(S, logOutput); MdlOutputs(0); if (gblExtModeEnabled) { rtExtModeSingleTaskUpload(S); } if (ssGetLogOutput(S)) { (void)rt_UpdateTXYLogVars(ssGetRTWLogInfo(S), ssGetTPtr(S)); if (ssGetErrorStatus(S) != NULL) return; } MdlUpdate(0); if (ssGetErrorStatus(S) != NULL) return; ssSetLogOutput(S, FALSE); ssSetTimeOfLastOutput(S, currTime); /* Update the timing engine and determine the solver stop time */ rsimUpdateTimingEngineAndSolverStopTime(S); if (ssGetErrorStatus(S) != NULL) return; if (gblExtModeEnabled) { rtExtModeCheckEndTrigger(); } return; } /* rsimOutputLogUpdate */
/* Function: rtOneStep ======================================================== * * Abstract: * Perform one step of the model. This function is modeled such that * it could be called from an interrupt service routine (ISR) with minor * modifications. */ static void rt_OneStep(RT_MODEL *S) { real_T tnext; /*********************************************** * Check and see if base step time is too fast * ***********************************************/ if (GBLbuf.isrOverrun++) { GBLbuf.stopExecutionFlag = 1; return; } /*********************************************** * Check and see if error status has been set * ***********************************************/ if (rtmGetErrorStatus(S) != NULL) { GBLbuf.stopExecutionFlag = 1; return; } /* enable interrupts here */ /* * In a multi-tasking environment, this would be removed from the base rate * and called as a "background" task. */ rtExtModeOneStep(rtmGetRTWExtModeInfo(S), rtmGetNumSampleTimes(S), (boolean_T *)&rtmGetStopRequested(S)); tnext = rt_SimGetNextSampleHit(); rtsiSetSolverStopTime(rtmGetRTWSolverInfo(S),tnext); MdlOutputs(0); rtExtModeSingleTaskUpload(S); /*GBLbuf.errmsg = rt_UpdateTXYLogVars(rtmGetRTWLogInfo(S), rtmGetTPtr(S)); if (GBLbuf.errmsg != NULL) { GBLbuf.stopExecutionFlag = 1; return; }*//*removed logging*/ /*rt_UpdateSigLogVars(rtmGetRTWLogInfo(S), rtmGetTPtr(S));*//*removed logging*/ MdlUpdate(0); rt_SimUpdateDiscreteTaskSampleHits(rtmGetNumSampleTimes(S), rtmGetTimingData(S), rtmGetSampleHitPtr(S), rtmGetTPtr(S)); if (rtmGetSampleTime(S,0) == CONTINUOUS_SAMPLE_TIME) { rt_UpdateContinuousStates(S); } GBLbuf.isrOverrun--; rtExtModeCheckEndTrigger(); } /* end rtOneStep */