/* Model update function */ void udpRead_update(void) { /* Update for UnitDelay: '<S3>/FixPt Unit Delay2' incorporates: * Constant: '<S3>/FixPt Constant' */ udpRead_DW.FixPtUnitDelay2_DSTATE = udpRead_P.FixPtConstant_Value; /* Update for UnitDelay: '<S3>/FixPt Unit Delay1' */ udpRead_DW.FixPtUnitDelay1_DSTATE = udpRead_B.Xnew; /* signal main to stop simulation */ { /* Sample time: [0.001s, 0.0s] */ if ((rtmGetTFinal(udpRead_M)!=-1) && !((rtmGetTFinal(udpRead_M)-udpRead_M->Timing.taskTime0) > udpRead_M->Timing.taskTime0 * (DBL_EPSILON))) { rtmSetErrorStatus(udpRead_M, "Simulation finished"); } if (rtmGetStopRequested(udpRead_M)) { rtmSetErrorStatus(udpRead_M, "Simulation finished"); } } /* Update absolute time for base rate */ /* The "clockTick0" counts the number of times the code of this task has * been executed. The absolute time is the multiplication of "clockTick0" * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not * overflow during the application lifespan selected. */ udpRead_M->Timing.taskTime0 = (++udpRead_M->Timing.clockTick0) * udpRead_M->Timing.stepSize0; }
/* Model step function */ void Hammerstein_step(void) { /* DiscreteStateSpace: '<S1>/LinearModel' */ { Hammerstein_B.LinearModel = Hammerstein_P.LinearModel_C* Hammerstein_DWork.LinearModel_DSTATE; } /* Level2 S-Function Block: '<S1>/Pwlinear1' (sfunpwlinear) */ { SimStruct *rts = Hammerstein_M->childSfunctions[0]; ssSetOutputPortSignal(rts, 0, &Hammerstein_Y.Out1); sfcnOutputs(rts, 0); } /* Level2 S-Function Block: '<S1>/Pwlinear' (sfunpwlinear) */ { SimStruct *rts = Hammerstein_M->childSfunctions[1]; sfcnOutputs(rts, 0); } /* Update for DiscreteStateSpace: '<S1>/LinearModel' */ { Hammerstein_DWork.LinearModel_DSTATE = Hammerstein_B.Pwlinear + Hammerstein_P.LinearModel_A*Hammerstein_DWork.LinearModel_DSTATE; } /* Matfile logging */ rt_UpdateTXYLogVars(Hammerstein_M->rtwLogInfo, (Hammerstein_M->Timing.t)); /* signal main to stop simulation */ { /* Sample time: [0.06s, 0.0s] */ if ((rtmGetTFinal(Hammerstein_M)!=-1) && !((rtmGetTFinal(Hammerstein_M)-Hammerstein_M->Timing.t[0]) > Hammerstein_M->Timing.t[0] * (DBL_EPSILON))) { rtmSetErrorStatus(Hammerstein_M, "Simulation finished"); } if (rtmGetStopRequested(Hammerstein_M)) { rtmSetErrorStatus(Hammerstein_M, "Simulation finished"); } } /* Update absolute time for base rate */ /* The "clockTick0" counts the number of times the code of this task has * been executed. The absolute time is the multiplication of "clockTick0" * and "Timing.stepSize0". Size of "clockTick0" ensures timer will not * overflow during the application lifespan selected. * Timer of this task consists of two 32 bit unsigned integers. * The two integers represent the low bits Timing.clockTick0 and the high bits * Timing.clockTickH0. When the low bit overflows to 0, the high bits increment. */ if (!(++Hammerstein_M->Timing.clockTick0)) { ++Hammerstein_M->Timing.clockTickH0; } Hammerstein_M->Timing.t[0] = Hammerstein_M->Timing.clockTick0 * Hammerstein_M->Timing.stepSize0 + Hammerstein_M->Timing.clockTickH0 * Hammerstein_M->Timing.stepSize0 * 4294967296.0; }
int main(int argc, char **argv) { printf("**starting the model**\n"); fflush(stdout); rtmSetErrorStatus(Model_M, 0); rtExtModeParseArgs(argc, (const char_T **)argv, NULL); /* Initialize model */ Model_initialize(); /* External mode */ rtSetTFinalForExtMode(&rtmGetTFinal(Model_M)); rtExtModeCheckInit(1); { boolean_T rtmStopReq = false; rtExtModeWaitForStartPkt(Model_M->extModeInfo, 1, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(Model_M, true); } } rtERTExtModeStartMsg(); /* Call RTOS Initialization funcation */ prosRTOSInit(0.2, 0); /* Wait for stop semaphore */ mw_osSemaphoreWaitEver(&stopSem); return 0; }
/* Model initialize function */ void motorController_initialize(boolean_T firstTime) { if (firstTime) { /* registration code */ /* initialize error status */ rtmSetErrorStatus(motorController_M, (const char_T *)0); /* data type work */ { int_T i; real_T *dwork_ptr = (real_T *) &motorController_DWork.SpeedReg_DSTATE; for (i = 0; i < 2; i++) { dwork_ptr[i] = 0.0; } } /* external inputs */ motorController_U.delta_r_sp = 0.0; motorController_U.delta_r_act = 0.0; motorController_U.angular_rate = 0.0; motorController_U.current = 0.0; /* external outputs */ motorController_Y.voltage = 0.0; } }
void baseRateTask(void *arg) { runModel = (rtmGetErrorStatus(Model_M) == (NULL)) && !rtmGetStopRequested (Model_M); while (runModel) { mw_osSemaphoreWaitEver(&baserateTaskSem); /* External mode */ { boolean_T rtmStopReq = false; rtExtModePauseIfNeeded(Model_M->extModeInfo, 1, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(Model_M, true); } if (rtmGetStopRequested(Model_M) == true) { rtmSetErrorStatus(Model_M, "Simulation finished"); break; } } Model_step(); /* Get model outputs here */ rtExtModeCheckEndTrigger(); runModel = (rtmGetErrorStatus(Model_M) == (NULL)) && !rtmGetStopRequested (Model_M); } runModel = 0; terminateTask(arg); taskDelete((void *)0); }
/* Model initialize function */ void model_jxz_initialize(RT_MODEL_model_jxz *const model_jxz_M) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(model_jxz_M, (NULL)); }
/* Model initialize function */ void floribot_accu_watchdog_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(floribot_accu_watchdog_M, (NULL)); /* states (dwork) */ (void) memset((void *)&floribot_accu_watchdog_DW, 0, sizeof(DW_floribot_accu_watchdog_T)); /* external inputs */ (void) memset((void *)&floribot_accu_watchdog_U, 0, sizeof(ExtU_floribot_accu_watchdog_T)); /* external outputs */ floribot_accu_watchdog_Y.accu_low = FALSE; /* InitializeConditions for Chart: '<Root>/Chart' */ floribot_accu_watchdog_DW.is_active_c1_floribot_accu_watc = 0U; floribot_accu_watchdog_DW.is_c1_floribot_accu_watchdog = floribot_acc_IN_NO_ACTIVE_CHILD; /* InitializeConditions for Outport: '<Root>/accu_low' incorporates: * InitializeConditions for Chart: '<Root>/Chart' */ floribot_accu_watchdog_Y.accu_low = FALSE; }
/* Model initialize function */ void c2000_profiler_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(c2000_profiler_M, (NULL)); /* states (dwork) */ (void) memset((void *)&c2000_profiler_DWork, 0, sizeof(D_Work_c2000_profiler)); /* external inputs */ (void) memset((void *)&c2000_profiler_U, 0, sizeof(ExternalInputs_c2000_profiler)); /* external outputs */ (void) memset(&c2000_profiler_Y.Voltageoutputs[0], 0, 3U*sizeof(int32_T)); /* InitializeConditions for UnitDelay: '<S7>/Unit Delay' */ c2000_profiler_DWork.UnitDelay_DSTATE[0] = c2000_profiler_P.UnitDelay_InitialCondition[0]; c2000_profiler_DWork.UnitDelay_DSTATE[1] = c2000_profiler_P.UnitDelay_InitialCondition[1]; }
/* Model initialize function */ void Delay0_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(Delay0_M, (NULL)); /* states (dwork) */ (void) memset((void *)&Delay0_DW, 0, sizeof(DW_Delay0_T)); /* external inputs */ (void) memset((void *)&Delay0_U, 0, sizeof(ExtU_Delay0_T)); /* external outputs */ (void) memset(&Delay0_Y.Out1[0], 0, 2048U*sizeof(real_T)); { int32_T i; int32_T buffIdx; /* InitializeConditions for S-Function (sdspvdly2): '<S1>/Variable Fractional Delay' */ Delay0_DW.VariableFractionalDelay_BUFF_OF = 44100; buffIdx = 0; for (i = 0; i < 44101; i++) { Delay0_DW.VariableFractionalDelay_BUFF[buffIdx] = 0.0; buffIdx++; } /* End of InitializeConditions for S-Function (sdspvdly2): '<S1>/Variable Fractional Delay' */ } }
/* Model update function */ static void CelpSimulink_update(int_T tid) { { static char sErr[512]; void *device = CelpSimulink_DWork.ToAudioDevice_AudioDevice; AudioDeviceLibrary *adl = (AudioDeviceLibrary*) &CelpSimulink_DWork.ToAudioDevice_AudioDeviceLib[0]; sErr[0] = 0; if (device) adl->deviceUpdate(device, sErr, CelpSimulink_B.DeemphasisFilter, 1, 1); if (*sErr) { DestroyAudioDeviceLibrary(adl); rtmSetErrorStatus(CelpSimulink_M, sErr); rtmSetStopRequested(CelpSimulink_M, 1); } } /* Update absolute time for base rate */ if (!(++CelpSimulink_M->Timing.clockTick0)) ++CelpSimulink_M->Timing.clockTickH0; CelpSimulink_M->Timing.t[0] = CelpSimulink_M->Timing.clockTick0 * CelpSimulink_M->Timing.stepSize0 + CelpSimulink_M->Timing.clockTickH0 * CelpSimulink_M->Timing.stepSize0 * 4294967296.0; UNUSED_PARAMETER(tid); }
void rt_OneStep(ExternalInputs_microwave_combin *input) { static boolean_T OverrunFlag = 0; /* Disable interrupts here */ /* Check for overrun */ if (OverrunFlag) { rtmSetErrorStatus(microwave_combined_M, "Overrun"); return; } OverrunFlag = TRUE; /* Save FPU context here (if necessary) */ /* Re-enable timer or interrupt here */ /* Set model inputs here */ microwave_combined_U = *input; /* Step the model */ microwave_combined_step(); /* Get model outputs here */ check_observers (); /* Indicate task complete */ OverrunFlag = FALSE; /* Disable interrupts here */ /* Restore FPU context here (if necessary) */ /* Enable interrupts here */ }
/* Model terminate function */ void omni_interface_terminate(void) { /* S-Function Block: omni_interface/HIL Initialize (hil_initialize_block) */ { t_boolean is_switching; t_int result; hil_task_stop_all(omni_interface_DWork.HILInitialize_Card); hil_task_delete_all(omni_interface_DWork.HILInitialize_Card); is_switching = false; if ((omni_interface_P.HILInitialize_POTerminate && !is_switching) || (omni_interface_P.HILInitialize_POExit && is_switching)) { omni_interface_DWork.HILInitialize_POValues[0] = omni_interface_P.HILInitialize_POFinal; omni_interface_DWork.HILInitialize_POValues[1] = omni_interface_P.HILInitialize_POFinal; omni_interface_DWork.HILInitialize_POValues[2] = omni_interface_P.HILInitialize_POFinal; result = hil_write_pwm(omni_interface_DWork.HILInitialize_Card, &omni_interface_P.HILInitialize_POChannels[0], 3U, &omni_interface_DWork.HILInitialize_POValues[0]); if (result < 0) { msg_get_error_messageA(NULL, result, _rt_error_message, sizeof (_rt_error_message)); rtmSetErrorStatus(omni_interface_M, _rt_error_message); } } hil_close(omni_interface_DWork.HILInitialize_Card); omni_interface_DWork.HILInitialize_Card = NULL; } /* S-Function Block: omni_interface/Stream Answer (stream_answer_block) */ { if (omni_interface_DWork.StreamAnswer_Client != NULL) { stream_close(omni_interface_DWork.StreamAnswer_Client); omni_interface_DWork.StreamAnswer_Client = NULL; } if (omni_interface_DWork.StreamAnswer_Listener != NULL) { stream_close(omni_interface_DWork.StreamAnswer_Listener); omni_interface_DWork.StreamAnswer_Listener = NULL; } } /* S-Function Block: omni_interface/Stream Answer1 (stream_answer_block) */ { if (omni_interface_DWork.StreamAnswer1_Client != NULL) { stream_close(omni_interface_DWork.StreamAnswer1_Client); omni_interface_DWork.StreamAnswer1_Client = NULL; } if (omni_interface_DWork.StreamAnswer1_Listener != NULL) { stream_close(omni_interface_DWork.StreamAnswer1_Listener); omni_interface_DWork.StreamAnswer1_Listener = NULL; } } /* External mode */ rtExtModeShutdown(1); }
/* Model initialize function */ void LookupTableDynamic_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(LookupTableDynamic_M, (NULL)); /* block I/O */ /* exported global signals */ LookupTableDynamic_Constant_1[0] = 0.0; LookupTableDynamic_Constant_1[1] = 0.0; LookupTableDynamic_Constant_1[2] = 0.0; LookupTableDynamic_Constant1_1[0] = 0.0; LookupTableDynamic_Constant1_1[1] = 0.0; LookupTableDynamic_Constant1_1[2] = 0.0; LookupTableDynamic_LookupTableDynamic_1 = 0.0; /* external inputs */ LookupTableDynamic_In1_1 = 0.0; /* Start for Constant: '<Root>/Constant' */ LookupTableDynamic_Constant_1[0] = LookupTableDynamic_P.Constant_Value[0]; LookupTableDynamic_Constant_1[1] = LookupTableDynamic_P.Constant_Value[1]; LookupTableDynamic_Constant_1[2] = LookupTableDynamic_P.Constant_Value[2]; /* Start for Constant: '<Root>/Constant1' */ LookupTableDynamic_Constant1_1[0] = LookupTableDynamic_P.Constant1_Value[0]; LookupTableDynamic_Constant1_1[1] = LookupTableDynamic_P.Constant1_Value[1]; LookupTableDynamic_Constant1_1[2] = LookupTableDynamic_P.Constant1_Value[2]; }
/* Model initialize function */ void Assignment_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(Assignment_M, (NULL)); /* block I/O */ /* exported global signals */ Assignment_Constant_1[0] = 0.0; Assignment_Constant_1[1] = 0.0; Assignment_Constant_1[2] = 0.0; Assignment_Constant_1[3] = 0.0; Assignment_Assignment_1[0] = 0.0; Assignment_Assignment_1[1] = 0.0; Assignment_Assignment_1[2] = 0.0; Assignment_Assignment_1[3] = 0.0; /* external inputs */ Assignment_In1_1 = 0.0; /* ConstCode for Constant: '<Root>/Constant' */ Assignment_Constant_1[0] = 0.0; Assignment_Constant_1[1] = 0.0; Assignment_Constant_1[2] = 0.0; Assignment_Constant_1[3] = 0.0; }
/* Model terminate function */ void Crane_terminate(void) { /* S-Function Block: <S10>/Block#1 */ { if (rt_mech_visited_Crane_63fd34a2 == 1) { _rtMech_PWORK *mechWork = (_rtMech_PWORK *) Crane_DWork.Block1_PWORK; if (mechWork->mechanism->destroyEngine != NULL) { (mechWork->mechanism->destroyEngine)(mechWork->mechanism); } } if ((--rt_mech_visited_Crane_63fd34a2) == 0 ) { rt_mech_visited_loc_Crane_63fd34a2 = 0; } } /* S-Function Block: Crane/Falcon (falcon_block) */ { t_error result; result = falcon_close(Crane_DWork.Falcon_Falcon); if (result < 0) { msg_get_error_messageA(NULL, result, _rt_error_message, sizeof (_rt_error_message)); rtmSetErrorStatus(Crane_M, _rt_error_message); return; } } /* External mode */ rtExtModeShutdown(2); }
/* Derivatives for root system: '<Root>' */ void Crane_derivatives(void) { /* S-Function Block: <S10>/Block#1 */ { _rtMech_PWORK *mechWork = (_rtMech_PWORK *) Crane_DWork.Block1_PWORK; if (sFcnDerivativesMethod(mechWork->mechanism, &((StateDerivatives_Crane *) Crane_M->ModelData.derivs)->Block1_CSTATE[0])) { { const ErrorRecord *err = getErrorMsg(); static char_T errorMsg[1024]; sprintf(errorMsg, err->errorMsg, err->blocks[0], err->blocks[1], err->blocks[2], err->blocks[3], err->blocks[4]); rtmSetErrorStatus(Crane_M, errorMsg); return; } } } /* Derivatives for Integrator: '<S9>/Integrator' */ ((StateDerivatives_Crane *) Crane_M->ModelData.derivs)->Integrator_CSTATE[0] = Crane_B.Sum[0]; ((StateDerivatives_Crane *) Crane_M->ModelData.derivs)->Integrator_CSTATE[1] = Crane_B.Sum[1]; ((StateDerivatives_Crane *) Crane_M->ModelData.derivs)->Integrator_CSTATE[2] = Crane_B.Sum[2]; }
/* * Associating rt_OneStep with a real-time clock or interrupt service routine * is what makes the generated code "real-time". The function rt_OneStep is * always associated with the base rate of the model. Subrates are managed * by the base rate from inside the generated code. Enabling/disabling * interrupts and floating point context switches are target specific. This * example code indicates where these should take place relative to executing * the generated code step function. Overrun behavior should be tailored to * your application needs. This example simply sets an error status in the * real-time model and returns from rt_OneStep. */ void rt_OneStep(void) { static boolean_T OverrunFlag = 0; /* Disable interrupts here */ /* Check for overrun */ if (OverrunFlag) { rtmSetErrorStatus(Wrap_To_Zero_M, "Overrun"); return; } OverrunFlag = true; /* Save FPU context here (if necessary) */ /* Re-enable timer or interrupt here */ /* Set model inputs here */ /* Step the model */ Wrap_To_Zero_step(); /* Get model outputs here */ /* Indicate task complete */ OverrunFlag = false; /* Disable interrupts here */ /* Restore FPU context here (if necessary) */ /* Enable interrupts here */ }
/* Model initialize function */ void watering_controller_AVR_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(watering_controller_AVR_M, (NULL)); /* states (dwork) */ (void) memset((void *)&watering_controller_AVR_DW, 0, sizeof(DW_watering_controller_AVR_T)); /* external inputs */ (void) memset((void *)&watering_controller_AVR_U, 0, sizeof(ExtU_watering_controller_AVR_T)); /* external outputs */ watering_controller_AVR_Y.ValveRelay = 0U; /* InitializeConditions for Chart: '<Root>/Watering_Controller' */ watering_controller_AVR_DW.is_automatic_mode = watering_con_IN_NO_ACTIVE_CHILD; watering_controller_AVR_DW.is_manual_mode = watering_con_IN_NO_ACTIVE_CHILD; watering_controller_AVR_DW.is_active_c3_watering_controlle = 0U; watering_controller_AVR_DW.is_c3_watering_controller_AVR = watering_con_IN_NO_ACTIVE_CHILD; }
/* * Associating rt_OneStep with a real-time clock or interrupt service routine * is what makes the generated code "real-time". The function rt_OneStep is * always associated with the base rate of the model. Subrates are managed * by the base rate from inside the generated code. Enabling/disabling * interrupts and floating point context switches are target specific. This * example code indicates where these should take place relative to executing * the generated code step function. Overrun behavior should be tailored to * your application needs. This example simply sets an error status in the * real-time model and returns from rt_OneStep. */ void rt_OneStep(void) { /* Disable interrupts here */ /* Check for overrun */ if (OverrunFlag++) { rtmSetErrorStatus(Pos_Controller_M, "Overrun"); return; } /* Save FPU context here (if necessary) */ /* Re-enable timer or interrupt here */ /* Set model inputs here */ /* Step the model */ Pos_Controller_step(); /* Get model outputs here */ /* Indicate task complete */ OverrunFlag--; /* Disable interrupts here */ /* Restore FPU context here (if necessary) */ /* Enable interrupts here */ }
void rt_OneStep(void) { static boolean_T OverrunFlag = 0; /* Disable interrupts here */ /* Check for overrun */ if (OverrunFlag) { rtmSetErrorStatus(Skydog_path_planning_M, "Overrun"); return; } OverrunFlag = TRUE; /* Save FPU context here (if necessary) */ /* Re-enable timer or interrupt here */ /* Set model inputs here */ /* Step the model */ Skydog_path_planning_step(); /* Get model outputs here */ /* Indicate task complete */ OverrunFlag = FALSE; /* Disable interrupts here */ /* Restore FPU context here (if necessary) */ /* Enable interrupts here */ }
extern void _do_assertion(const char * expression, const char * file_name, int line_number) { string_format(GBLbuf.message, sizeof(GBLbuf.message), "Assertion in %s at line %d: (%s) is false", file_name, line_number, expression); rtmSetErrorStatus(Crane_M, GBLbuf.message); }
int main(void) { volatile boolean_T runModel = 1; float modelBaseRate = 2.0; float systemClock = 0; init(); MW_Arduino_Init(); rtmSetErrorStatus(test_motor_M, 0); /* initialize external mode */ rtParseArgsForExtMode(0, NULL); test_motor_initialize(); sei(); /* External mode */ rtSetTFinalForExtMode(&rtmGetTFinal(test_motor_M)); rtExtModeCheckInit(1); { boolean_T rtmStopReq = false; rtExtModeWaitForStartPkt(test_motor_M->extModeInfo, 1, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(test_motor_M, true); } } rtERTExtModeStartMsg(); cli(); configureArduinoAVRTimer(); runModel = (rtmGetErrorStatus(test_motor_M) == (NULL)) && !rtmGetStopRequested (test_motor_M); sei(); sei(); while (runModel) { /* External mode */ { boolean_T rtmStopReq = false; rtExtModeOneStep(test_motor_M->extModeInfo, 1, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(test_motor_M, true); } } runModel = (rtmGetErrorStatus(test_motor_M) == (NULL)) && !rtmGetStopRequested (test_motor_M); } rtExtModeShutdown(1); /* Disable rt_OneStep() here */ /* Terminate model */ test_motor_terminate(); cli(); return 0; }
void rt_OneStep(void) { if (OverrunFlag++) { rtmSetErrorStatus(Pos_Controller_M, "Overrun"); return; } Pos_Controller_step(); OverrunFlag--; }
void baseRateTask(void *arg) { baseRateInfo_t info = *((baseRateInfo_t *)arg); MW_setTaskPeriod(info.period, info.signo); while ((rtmGetErrorStatus(motorControlTask_M) == (NULL)) && !rtmGetStopRequested(motorControlTask_M) ) { /* Wait for the next timer interrupt */ if (MW_sigWaitWithOverrunDetection(&info.sigMask) == 1) { printf("Overrun - rate for base rate task too fast.\n"); fflush(stdout); } /* External mode */ { boolean_T rtmStopReq = false; rtExtModePauseIfNeeded(motorControlTask_M->extModeInfo, 2, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(motorControlTask_M, true); } if (rtmGetStopRequested(motorControlTask_M) == true) { rtmSetErrorStatus(motorControlTask_M, "Simulation finished"); break; } } /* External mode */ { boolean_T rtmStopReq = false; rtExtModeOneStep(motorControlTask_M->extModeInfo, 2, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(motorControlTask_M, true); } } motorControlTask_output(); /* Get model outputs here */ /* External mode */ rtExtModeUploadCheckTrigger(2); { /* Sample time: [0.0s, 0.0s] */ rtExtModeUpload(0, motorControlTask_M->Timing.t[0]); } { /* Sample time: [0.02s, 0.0s] */ rtExtModeUpload(1, ((motorControlTask_M->Timing.clockTick1) * 0.02)); } motorControlTask_update(); rtExtModeCheckEndTrigger(); } /* while */ sem_post(&stopSem); }
void rt_OneStep(RT_MODEL_DroneRS_Compensator_T *const DroneRS_Compensator_M) { static boolean_T OverrunFlag = false; /* Disable interrupts here */ /* Check for overrun */ if (OverrunFlag) { rtmSetErrorStatus(DroneRS_Compensator_M, "Overrun"); return; } OverrunFlag = true; /* Save FPU context here (if necessary) */ /* Re-enable timer or interrupt here */ /* Set model inputs here */ /* Step the model */ DroneRS_Compensator_step(DroneRS_Compensator_M, DroneRS_Compensator_U_controlModePosVSAtt_flagin, DroneRS_Compensator_U_pos_refin, DroneRS_Compensator_U_attRS_refin, DroneRS_Compensator_U_ddx, DroneRS_Compensator_U_ddy, DroneRS_Compensator_U_ddz, DroneRS_Compensator_U_p, DroneRS_Compensator_U_q, DroneRS_Compensator_U_r, DroneRS_Compensator_U_altitude_sonar, DroneRS_Compensator_U_prs, DroneRS_Compensator_U_opticalFlowRS_datin, DroneRS_Compensator_U_sensordatabiasRS_datin, DroneRS_Compensator_U_posVIS_datin, DroneRS_Compensator_U_usePosVIS_flagin, DroneRS_Compensator_U_batteryStatus_datin, DroneRS_Compensator_Y_motorsRS_cmdout, &DroneRS_Compensator_Y_X, &DroneRS_Compensator_Y_Y, &DroneRS_Compensator_Y_Z, &DroneRS_Compensator_Y_yaw, &DroneRS_Compensator_Y_pitch, &DroneRS_Compensator_Y_roll, &DroneRS_Compensator_Y_dx, &DroneRS_Compensator_Y_dy, &DroneRS_Compensator_Y_dz, &DroneRS_Compensator_Y_pb, &DroneRS_Compensator_Y_qb, &DroneRS_Compensator_Y_rb, &DroneRS_Compensator_Y_controlModePosVSAtt_flagout, DroneRS_Compensator_Y_poseRS_refout, &DroneRS_Compensator_Y_ddxb, &DroneRS_Compensator_Y_ddyb, &DroneRS_Compensator_Y_ddzb, &DroneRS_Compensator_Y_pa, &DroneRS_Compensator_Y_qa, &DroneRS_Compensator_Y_ra, &DroneRS_Compensator_Y_altitude_sonarb, &DroneRS_Compensator_Y_prsb, DroneRS_Compensator_Y_opticalFlowRS_datout, DroneRS_Compensator_Y_sensordatabiasRS_datout, DroneRS_Compensator_Y_posVIS_datout, &DroneRS_Compensator_Y_usePosVIS_flagout, DroneRS_Compensator_Y_batteryStatus_datout); /* Get model outputs here */ /* Indicate task complete */ OverrunFlag = false; /* Disable interrupts here */ /* Restore FPU context here (if necessary) */ /* Enable interrupts here */ }
/* Model initialize function */ void Kalman_Sim_initialize(void) { /* Registration code */ /* initialize non-finites */ rt_InitInfAndNaN(sizeof(real_T)); /* initialize error status */ rtmSetErrorStatus(Kalman_Sim_M, (NULL)); /* block I/O */ /* exported global signals */ Out2 = 0.0; Out1[0] = 0.0F; Out1[1] = 0.0F; Out1[2] = 0.0F; /* states (dwork) */ (void) memset((void *)&Kalman_Sim_DWork, 0, sizeof(D_Work_Kalman_Sim)); /* external inputs */ (void) memset(fgyro,0, 3*sizeof(real32_T)); (void) memset(facc,0, 3*sizeof(real32_T)); (void) memset(fmag,0, 3*sizeof(real32_T)); /* Start for DiscretePulseGenerator: '<Root>/Pulse Generator' */ Kalman_Sim_DWork.clockTickCounter = 0; { int32_T i; /* InitializeConditions for UnitDelay: '<S1>/Unit Delay' */ for (i = 0; i < 6; i++) { Kalman_Sim_DWork.UnitDelay_DSTATE[i] = Kalman_Sim_P.UnitDelay_X0[i]; } /* InitializeConditions for UnitDelay: '<S1>/Unit Delay1' */ memcpy((void *)(&Kalman_Sim_DWork.UnitDelay1_DSTATE[0]), (void *) (&Kalman_Sim_P.UnitDelay1_X0[0]), 36U * sizeof(real32_T)); /* InitializeConditions for UnitDelay: '<S1>/Unit Delay2' */ for (i = 0; i < 6; i++) { Kalman_Sim_DWork.UnitDelay2_DSTATE[i] = Kalman_Sim_P.UnitDelay2_X0[i]; } /* InitializeConditions for UnitDelay: '<S1>/Unit Delay3' */ memcpy((void *)(&Kalman_Sim_DWork.UnitDelay3_DSTATE[0]), (void *) (&Kalman_Sim_P.UnitDelay3_X0[0]), 36U * sizeof(real32_T)); } }
/* Model initialize function */ void Subsystem_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(Subsystem_M, (NULL)); /* external inputs */ Subsystem_In1_1 = 0.0; }
/* Model initialize function */ void Goto_From_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(Goto_From_M, (NULL)); /* external inputs */ Goto_From_In1_1 = 0.0; }
/* Model initialize function */ void Display_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(Display_M, (NULL)); /* external inputs */ Display_In1_1 = 0.0; }
/* Model initialize function */ void untitled_initialize(void) { /* Registration code */ /* initialize error status */ rtmSetErrorStatus(untitled_M, (NULL)); /* Start for S-Function (armcortexa_LedWrite_sfcn): '<Root>/LED' */ MW_ledInit(untitled_P.LED_p1); }