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); }
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 baseRateTask(void *arg) { runModel = (rtmGetErrorStatus(ArduinoSim_M) == (NULL)); while (runModel) { sem_wait(&baserateTaskSem); ArduinoSim_step(); // Get model outputs here runModel = (rtmGetErrorStatus(ArduinoSim_M) == (NULL)); } sem_post(&termSem); pthread_exit((void *)0); }
/* 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 */
/* * The example "main" function illustrates what is required by your * application code to initialize, execute, and terminate the generated code. * Attaching rt_OneStep to a real-time clock is target specific. This example * illustates how you do this relative to initializing the model. */ int_T main(int_T argc, const char_T *argv[]) { /* Initialize model */ Pos_Controller_initialize(); /* Attach rt_OneStep to a timer or interrupt service routine with * period 0.005 seconds (the model's base sample time) here. The * call syntax for rt_OneStep is * * rt_OneStep(); */ printf("Warning: The simulation will run forever. " "Generated ERT main won't simulate model step behavior. " "To change this behavior select the 'MAT-file logging' option.\n"); fflush((NULL)); while (rtmGetErrorStatus(Pos_Controller_M) == (NULL)) { /* Perform other application tasks here */ } /* Disable rt_OneStep() here */ /* Terminate model */ Pos_Controller_terminate(); return 0; }
void baseRateTask(void *arg) { runModel = (rtmGetErrorStatus(VesselSimulator_M) == (NULL)) && !rtmGetStopRequested(VesselSimulator_M); while (runModel) { sem_wait(&baserateTaskSem); VesselSimulator_step(); // Get model outputs here runModel = (rtmGetErrorStatus(VesselSimulator_M) == (NULL)) && !rtmGetStopRequested(VesselSimulator_M); } sem_post(&termSem); pthread_exit((void *)0); }
void baseRateTask(void *arg) { runModel = (rtmGetErrorStatus(main_M) == (NULL)) && !rtmGetStopRequested (main_M); while (runModel) { sem_wait(&baserateTaskSem); main_step(); /* Get model outputs here */ runModel = (rtmGetErrorStatus(main_M) == (NULL)) && !rtmGetStopRequested (main_M); } sem_post(&termSem); pthread_exit((void *)0); }
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); }
/* * The example "main" function illustrates what is required by your * application code to initialize, execute, and terminate the generated code. * Attaching rt_OneStep to a real-time clock is target specific. This example * illustates how you do this relative to initializing the model. */ int_T main(int_T argc, const char *argv[]) { /* Unused arguments */ (void)(argc); (void)(argv); /* Pack model data into RTM */ DroneRS_Compensator_M->ModelData.defaultParam = &DroneRS_Compensator_P; DroneRS_Compensator_M->ModelData.blockIO = &DroneRS_Compensator_B; DroneRS_Compensator_M->ModelData.dwork = &DroneRS_Compensator_DW; /* Initialize model */ DroneRS_Compensator_initialize(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); /* The MAT-file logging option selected; therefore, simulating * the model step behavior (in non real-time). Running this * code produces results that can be loaded into MATLAB. */ while (rtmGetErrorStatus(DroneRS_Compensator_M) == (NULL)) { rt_OneStep(DroneRS_Compensator_M); } /* Matfile logging */ rt_StopDataLogging(MATFILE, DroneRS_Compensator_M->rtwLogInfo); /* Disable rt_OneStep() here */ return 0; }
/* The "main" function initializes and executes the generated code. */ int_T main(int_T argc, const char_T *argv[]) { /************************ * initialize the model * ************************/ #define LATCH_0_31_IMB_INTERRUPT_LEVELS 3 /* Enable all IRQ levels on the UIMB */ initIrqModule(LATCH_0_31_IMB_INTERRUPT_LEVELS); /* Initialize model */ exp03_initialize(1); { float period ; /* Set the timeout period of the Programmable Interrupt Timer * which will driver rtOneStep */ setPitModuleIrqLevel(RT_ONE_STEP_IRQ); period = setPitPeriod(TIMER_TICK_PERIOD, OSCILLATOR_FREQ); if (period < 0) { /* Unable to achive this period */ exit(1); } } #if INTEGER_CODE==0 registerIRQ_Handler( RT_ONE_STEP_IRQ, rt_OneStep , NULL , FLOAT_USED_IN_ISR); #else registerIRQ_Handler( RT_ONE_STEP_IRQ, rt_OneStep , NULL , FLOAT_NOT_USED_IN_ISR); #endif EnablePitFreeze; /* Make sure we can stop the ISR during debug */ EnablePitInterrupt; /* Enable the timer interrupt */ EnablePit; /* Start the timer counting */ /* Enable External Interrupts */ EIE(); while (rtmGetErrorStatus(exp03_M) == NULL) { boolean_T rtmStopReq = false; /* Optionally call an extern Background Task */ #ifdef __BACKGROUNDTASK__ BACKGROUNDTASK(); #endif } }
/* rt_OneStep is called from a timer interrupt service routine. It is called at * the base-rate of the model. */ void rt_OneStep(MPC555_IRQ_LEVEL level) { /* Clear the interrupt that triggered this function */ ClearPitIRQ; /*********************************************** * Check if base-rate step time is too fast * ***********************************************/ if (OverrunFlags[0] > BASE_RATE_MAX_OVERRUNS) { rtmSetErrorStatus(exp03_M, "Overrun"); } /************************************************* * Check if an error status has been set * * by an overrun or by the generated code. * *************************************************/ if (rtmGetErrorStatus(exp03_M) != NULL) { return; } /*********************************************** * Increment the overruns flag ***********************************************/ if (OverrunFlags[0]++) { return; } while (OverrunFlags[0] > 0 ) { /* Re-enable interrupts here */ EIE(); /* Set model inputs here */ /************** * Step model * **************/ exp03_step(); /* Get model outputs here */ /* Get model outputs here */ /* Service Watchdog Timer */ SERVICE_WATCHDOG_TIMER; /* Disable interrupts */ EID(); /************************** * Decrement overrun flag * **************************/ OverrunFlags[0]--; } }
void baseRateTask(void *arg) { baseRateInfo_t info = *((baseRateInfo_t *)arg); MW_setTaskPeriod(info.period, info.signo); while ((rtmGetErrorStatus(Serial_M) == (NULL)) && !rtmGetStopRequested (Serial_M) ) { /* Wait for the next timer interrupt */ MW_sigWait(&info.sigMask); /* External mode */ { boolean_T rtmStopReq = false; rtExtModePauseIfNeeded(Serial_M->extModeInfo, 2, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(Serial_M, true); } if (rtmGetStopRequested(Serial_M) == true) { rtmSetErrorStatus(Serial_M, "Simulation finished"); break; } } /* External mode */ { boolean_T rtmStopReq = false; rtExtModeOneStep(Serial_M->extModeInfo, 2, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(Serial_M, true); } } Serial_output(); /* Get model outputs here */ /* External mode */ rtExtModeUploadCheckTrigger(2); { /* Sample time: [0.0s, 0.0s] */ rtExtModeUpload(0, Serial_M->Timing.t[0]); } { /* Sample time: [0.05s, 0.0s] */ rtExtModeUpload(1, ((Serial_M->Timing.clockTick1) * 0.05)); } Serial_update(); rtExtModeCheckEndTrigger(); } /* while */ sem_post(&stopSem); }
void MdlStart(void) { /* FromWorkspace Block: <Root>/From Workspace */ { static real_T pTimeValues[] = { 0.0 }; static int16_T pDataValues[] = { 24576, 21375, 13255, 3838, -3129, -5793, -5063, -3838, -5063, -9789, -16384, -21375, -21447, -15423, -5063, 5793, 13255, 15423, 13255, 9789, 8192, 9789, 13255, 15423, 13255, 5793, -5063, -15423, -21447, -21375, -16384, -9789, -5063, -3838, -5063, -5793, -3129, 3838, 13255, 21375, 24576, 21375, 13255, 3838, -3129, -5793, -5063, -3838, -5063, -9789, -16384, -21375, -21447, -15423, -5063, 5793, 13255, 15423, 13255, 9789, 8192, 9789, 13255, 15423 }; fi_mdl_radix2fft_withscaling_DWork.FromWorkspace_PWORK.TimePtr = (void *) pTimeValues; fi_mdl_radix2fft_withscaling_DWork.FromWorkspace_PWORK.DataPtr = (void *) pDataValues; fi_mdl_radix2fft_withscaling_DWork.FromWorkspace_IWORK.PrevIndex = 0; } /* ToWorkspace Block: <Root>/To Workspace */ { int_T dimensions[2] = {1, 64}; fi_mdl_radix2fft_withscaling_DWork.ToWorkspace_PWORK.LoggedData = rt_CreateLogVar( fi_mdl_radix2fft_withscaling_M->rtwLogInfo, 0.0, rtmGetTFinal(fi_mdl_radix2fft_withscaling_M), fi_mdl_radix2fft_withscaling_M->Timing.stepSize0, &(rtmGetErrorStatus(fi_mdl_radix2fft_withscaling_M)), "y_sim", SS_DOUBLE, 0, 1, 0, 64, 2, dimensions, 0, 1, 0.25, 1); if (fi_mdl_radix2fft_withscaling_DWork.ToWorkspace_PWORK.LoggedData == NULL) return; } MdlInitialize(); }
/* Model initialize function */ void model1_initialize(void) { /* Registration code */ /* initialize non-finites */ rt_InitInfAndNaN(sizeof(real_T)); /* initialize real-time model */ (void) memset((void *)model1_M, 0, sizeof(RT_MODEL_model1_T)); rtmSetTFinal(model1_M, 2.0); model1_M->Timing.stepSize0 = 5.0E-5; /* Setup for data logging */ { static RTWLogInfo rt_DataLoggingInfo; model1_M->rtwLogInfo = &rt_DataLoggingInfo; } /* Setup for data logging */ { rtliSetLogXSignalInfo(model1_M->rtwLogInfo, (NULL)); rtliSetLogXSignalPtrs(model1_M->rtwLogInfo, (NULL)); rtliSetLogT(model1_M->rtwLogInfo, "tout"); rtliSetLogX(model1_M->rtwLogInfo, ""); rtliSetLogXFinal(model1_M->rtwLogInfo, ""); rtliSetLogVarNameModifier(model1_M->rtwLogInfo, "rt_"); rtliSetLogFormat(model1_M->rtwLogInfo, 0); rtliSetLogMaxRows(model1_M->rtwLogInfo, 1000); rtliSetLogDecimation(model1_M->rtwLogInfo, 1); rtliSetLogY(model1_M->rtwLogInfo, ""); rtliSetLogYSignalInfo(model1_M->rtwLogInfo, (NULL)); rtliSetLogYSignalPtrs(model1_M->rtwLogInfo, (NULL)); } /* states (dwork) */ (void) memset((void *)&model1_DW, 0, sizeof(DW_model1_T)); /* Matfile logging */ rt_StartDataLoggingWithStartTime(model1_M->rtwLogInfo, 0.0, rtmGetTFinal (model1_M), model1_M->Timing.stepSize0, (&rtmGetErrorStatus(model1_M))); /* Enable for Sin: '<S11>/Sine Wave A' */ model1_DW.systemEnable = 1; /* Enable for Sin: '<S11>/Sine Wave B' */ model1_DW.systemEnable_i = 1; /* Enable for Sin: '<S11>/Sine Wave C' */ model1_DW.systemEnable_g = 1; }
/* Function: main ------------------------------------------- * * Abstract: * Entry point into the code. */ void main(void) { volatile boolean_T noErr; init_board(); rtmSetErrorStatus(Batman_Code_M, 0); Batman_Code_initialize(); config_schedulerTimer(); noErr = rtmGetErrorStatus(Batman_Code_M) == (NULL); enable_interrupts(); while (noErr ) { idletask_num1(); noErr = rtmGetErrorStatus(Batman_Code_M) == (NULL); } /* Disable rt_OneStep() here */ /* Terminate model */ Batman_Code_terminate(); disable_interrupts(); }
int main(void) { nrk_setup_ports(); volatile boolean_T noErr; float modelBaseRate = 0.5; float systemClock = 0; SystemCoreClockUpdate(); UNUSED(modelBaseRate); UNUSED(systemClock); rtmSetErrorStatus(simulinkmodeltoblinkLed_M, 0); simulinkmodeltoblinkLed_initialize(); /* No scheduler to configure */ ; noErr = rtmGetErrorStatus(simulinkmodeltoblinkLed_M) == (NULL); /* No interrupts to enable */ ; ; while (noErr ) { rt_OneStep(); noErr = rtmGetErrorStatus(simulinkmodeltoblinkLed_M) == (NULL); } /* Disable rt_OneStep() here */ /* Terminate model */ simulinkmodeltoblinkLed_terminate(); ; nrk_led_set (RED_LED); return 0; }
void baseRateTask(void *arg) { baseRateInfo_t info = *((baseRateInfo_t *)arg); MW_setTaskPeriod(info.period, info.signo); while ((rtmGetErrorStatus(raspberrypi_audioequalizer_M) == (NULL)) && !rtmGetStopRequested(raspberrypi_audioequalizer_M) ) { /* Wait for the next timer interrupt */ MW_sigWait(&info.sigMask); /* External mode */ { boolean_T rtmStopReq = FALSE; rtExtModePauseIfNeeded(raspberrypi_audioequalizer_M->extModeInfo, 1, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(raspberrypi_audioequalizer_M, TRUE); } if (rtmGetStopRequested(raspberrypi_audioequalizer_M) == TRUE) { rtmSetErrorStatus(raspberrypi_audioequalizer_M, "Simulation finished"); break; } } /* External mode */ { boolean_T rtmStopReq = FALSE; rtExtModeOneStep(raspberrypi_audioequalizer_M->extModeInfo, 1, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(raspberrypi_audioequalizer_M, TRUE); } } raspberrypi_audioequalizer_output(); /* Get model outputs here */ /* External mode */ rtExtModeUploadCheckTrigger(1); { /* Sample time: [0.1s, 0.0s] */ rtExtModeUpload(0, raspberrypi_audioequalizer_M->Timing.taskTime0); } raspberrypi_audioequalizer_update(); rtExtModeCheckEndTrigger(); } /* while */ sem_post(&stopSem); }
int main(void) { volatile boolean_T runModel = 1; float modelBaseRate = 0.1; float systemClock = 100; SystemCoreClockUpdate(); UNUSED(modelBaseRate); UNUSED(systemClock); rtmSetErrorStatus(Controller_M, 0); Controller_initialize(); runModel = rtmGetErrorStatus(Controller_M) == (NULL); while (runModel) { rt_OneStep(); runModel = rtmGetErrorStatus(Controller_M) == (NULL); } /* Disable rt_OneStep() here */ /* Terminate model */ Controller_terminate(); return 0; }
void baseRateTask(void *arg) { baseRateInfo_t info = *((baseRateInfo_t *)arg); MW_setTaskPeriod(info.period, info.signo); while (rtmGetErrorStatus(testA_M) == (NULL) ) { /* Wait for the next timer interrupt */ MW_sigWait(&info.sigMask); testA_output(); /* Get model outputs here */ testA_update(); } /* while */ sem_post(&stopSem); }
void baseRateTask(void *arg) { baseRateInfo_t info = *((baseRateInfo_t *)arg); MW_setTaskPeriod(info.period, info.signo); while ((rtmGetErrorStatus(beagleboard_communication_M) == (NULL)) && !rtmGetStopRequested(beagleboard_communication_M) ) { /* Wait for the next timer interrupt */ MW_sigWait(&info.sigMask); beagleboard_communication_output(); /* Get model outputs here */ beagleboard_communication_update(); } /* while */ sem_post(&stopSem); }
int main(int argc, char *argv[]){ ros::init(argc,argv,"position_control"); ros::NodeHandle nh("~"); Pos_Controller_U.consigne[0]=0; Pos_Controller_U.consigne[1]=0; Pos_Controller_U.consigne[2]=1; Pos_Controller_U.yaw_cons=0; Pos_Controller_U.yaw_is_relative=0; /* Initialize model */ Pos_Controller_initialize(); ros::Subscriber consigneSubscriber = nh.subscribe("/position_target",1,target_callback); tf::TransformListener tf_listener; twistPublisher = nh.advertise<geometry_msgs::Twist>("/cmd_vel",1); #ifdef DEBUG_POS_CONTROLLER_OUTPUTS epsPublisher = nh.advertise<geometry_msgs::Pose>("eps",1); vis_pub = nh.advertise<visualization_msgs::Marker>( "visualization_marker", 0 ); odomSpeedPublisher = nh.advertise<nav_msgs::Odometry>("/absolute_speed_command",1); #endif ros::ServiceServer enable_service = nh.advertiseService("enable",setEnabled); ros::ServiceServer switch_rel_yaw = nh.advertiseService("enable_relative_yaw",setRelativeYaw); ros::Rate rate(5.0); while (ros::ok() && rtmGetErrorStatus(Pos_Controller_M) == (NULL)) { if(_enabled){ tf::StampedTransform transform; try{ tf_listener.lookupTransform("/nav", "/base_link", ros::Time(0), transform); } catch (tf::TransformException ex){ ROS_ERROR("%s",ex.what()); } transform_callback(transform); } ros::spinOnce(); step_PID(); rate.sleep(); } /* Terminate model */ Pos_Controller_terminate(); return 0; }
/** * This function is called when the START button is pushed from zenom. * * @return If you return 0, the control starts and the doloop() function is * called periodically. If you return nonzero, the control will not start. */ int ZenomMatlab::start() { fprintf(stderr, "\n** starting the model **\n"); START(rtM); if (rtmGetErrorStatus(rtM) != NULL) { fprintf(stderr, "Failed in target initialization.\n"); TERMINATE(rtM); return 0; } fprintf(stderr, "starting done!\n"); return 0; }
int_T main(int_T argc, const char_T *argv[]) { /* How many steps to run? */ if (argc != 2) { printf("Usage: microwave_type [STEPS]\n"); } int num_steps = strtol(argv[1], NULL, 0); if (errno || num_steps == 0) { perror("Error parsing num steps.\n"); exit(1); } /* Initialize model */ microwave_combined_initialize(1); // used to have an argument: 1. /* Create symbolic inputs beforehand */ //make_input_symbolic(); int step_num; ExternalInputs_microwave_combin inputs[num_steps]; int i; for (i=0; i<num_steps; i++) { make_input_symbolic( &(inputs[i])); } /* Attach rt_OneStep to a timer or interrupt service routine with * period 1.0 seconds (the model's base sample time) here. The * call syntax for rt_OneStep is * * rt_OneStep(); */ step_num = 0; while (rtmGetErrorStatus(microwave_combined_M) == (NULL) && step_num < num_steps) { /* Perform other application tasks here */ rt_OneStep( &(inputs[step_num])); step_num++; } /* Disable rt_OneStep() here */ /* Terminate model */ microwave_combined_terminate(); return 0; }
int_T main(void) { unsigned long oldtime = 0L; unsigned long actualtime; init(); XbeeIO_initialize(); #ifdef _RTT_USE_SERIAL0_ Serial_begin(0, 9600); #endif #ifdef _RTT_USE_SERIAL1_ Serial_begin(1, 9600); #endif #ifdef _RTT_USE_SERIAL2_ Serial_begin(2, 9600); #endif #ifdef _RTT_USE_SERIAL3_ Serial_begin(3, 9600); #endif /* The main step loop */ while (rtmGetErrorStatus(XbeeIO_M) == (NULL)) { actualtime = micros(); if ((unsigned long) (actualtime - oldtime) >= STEP_SIZE) { oldtime = actualtime; XbeeIO_output(); /* Get model outputs here */ XbeeIO_update(); } } XbeeIO_terminate(); return 0; }
/* 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(void) { /* Disable interrupts here */ /*********************************************** * Check and see if base step time is too fast * ***********************************************/ if (OverrunFlags[0]++) { rtmSetErrorStatus(RT_MDL, "Overrun"); } /************************************************* * Check and see if an error status has been set * * by an overrun or by the generated code. * *************************************************/ if (rtmGetErrorStatus(RT_MDL) != NULL) { return; } /* Save FPU context here (if necessary) */ /* Reenable interrupts here */ /* Set model inputs here */ /************** * Step model * **************/ MODEL_STEP(); /* Get model outputs here */ /************************** * Decrement overrun flag * **************************/ OverrunFlags[0]--; rtExtModeCheckEndTrigger(); /* Disable interrupts here */ /* Restore FPU context here (if necessary) */ /* Reenable interrupts here */ } /* end rtOneStep */
void BonebrakerController::MatlabUpdate() {//Matlab Autogenerated code static boolean_T OverrunFlag = 0; if (OverrunFlag) { rtmSetErrorStatus(quadrotor_controller_M, "Overrun"); return; } OverrunFlag = TRUE; quadrotor_controller_step(); OverrunFlag = FALSE; if((rtmGetErrorStatus(quadrotor_controller_M) == (NULL)) && !rtmGetStopRequested(quadrotor_controller_M)) { rtExtModeCheckEndTrigger(); }else { rtExtModeShutdown(1); } }
/* Function: rt_TermModel ==================================================== * * Abstract: * Terminates the model and prints the error status * */ int_T rt_TermModel(void) { MODEL_TERMINATE(); { const char_T *errStatus = (const char_T *) (rtmGetErrorStatus(RT_MDL)); int_T i; if (errStatus != NULL && strcmp(errStatus, "Simulation finished")) { (void)printf("%s\n", errStatus); for (i = 0; i < NUMST; i++) { if (OverrunFlags[i]) { (void)printf("ISR overrun - sampling rate too" "fast for sample time index %d.\n", i); } } return(1); } } return(0); }
int main(int argc, char **argv) { int ret; baseRateInfo_t info; pthread_attr_t attr; pthread_t baseRateThread; size_t stackSize; unsigned long cpuMask = 0x1; unsigned int len = sizeof(cpuMask); printf("**starting the model**\n"); fflush(stdout); rtmSetErrorStatus(beagleboard_communication_M, 0); /* Unused arguments */ (void)(argc); (void)(argv); /* All threads created by this process must run on a single CPU */ ret = sched_setaffinity(0, len, (cpu_set_t *) &cpuMask); CHECK_STATUS(ret, "sched_setaffinity"); /* Initialize semaphore used for thread synchronization */ ret = sem_init(&stopSem, 0, 0); CHECK_STATUS(ret, "sem_init:stopSem"); /* Create threads executing the Simulink model */ pthread_attr_init(&attr); ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); CHECK_STATUS(ret, "pthread_attr_setinheritsched"); ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); CHECK_STATUS(ret, "pthread_attr_setdetachstate"); /* PTHREAD_STACK_MIN is the minimum stack size required to start a thread */ stackSize = 64000 + PTHREAD_STACK_MIN; ret = pthread_attr_setstacksize(&attr, stackSize); CHECK_STATUS(ret, "pthread_attr_setstacksize"); /* Block signal used for timer notification */ info.period = 0.01; info.signo = SIGRTMIN; sigemptyset(&info.sigMask); MW_blockSignal(info.signo, &info.sigMask); signal(SIGTERM, MW_exitHandler); /* kill */ signal(SIGHUP, MW_exitHandler); /* kill -HUP */ signal(SIGINT, MW_exitHandler); /* Interrupt from keyboard */ signal(SIGQUIT, MW_exitHandler); /* Quit from keyboard */ beagleboard_communication_initialize(); /* Create base rate task */ ret = pthread_create(&baseRateThread, &attr, (void *) baseRateTask, (void *) &info); CHECK_STATUS(ret, "pthread_create"); pthread_attr_destroy(&attr); /* Wait for a stopping condition. */ MW_sem_wait(&stopSem); /* Received stop signal */ printf("**stopping the model**\n"); if (rtmGetErrorStatus(beagleboard_communication_M) != NULL) { printf("\n**%s**\n", rtmGetErrorStatus(beagleboard_communication_M)); } /* Disable rt_OneStep() here */ /* Terminate model */ beagleboard_communication_terminate(); return 0; }
int main(int argc, char **argv) { int ret; baseRateInfo_t info; pthread_attr_t attr; pthread_t baseRateThread; size_t stackSize; unsigned long cpuMask = 0x1; unsigned int len = sizeof(cpuMask); printf("**starting the model**\n"); fflush(stdout); rtmSetErrorStatus(raspberrypi_audioequalizer_M, 0); rtExtModeParseArgs(argc, (const char_T **)argv, NULL); /* All threads created by this process must run on a single CPU */ ret = sched_setaffinity(0, len, (cpu_set_t *) &cpuMask); CHECK_STATUS(ret, "sched_setaffinity"); /* Initialize semaphore used for thread synchronization */ ret = sem_init(&stopSem, 0, 0); CHECK_STATUS(ret, "sem_init:stopSem"); /* Create threads executing the Simulink model */ pthread_attr_init(&attr); ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); CHECK_STATUS(ret, "pthread_attr_setinheritsched"); ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); CHECK_STATUS(ret, "pthread_attr_setdetachstate"); /* PTHREAD_STACK_MIN is the minimum stack size required to start a thread */ stackSize = 64000 + PTHREAD_STACK_MIN; ret = pthread_attr_setstacksize(&attr, stackSize); CHECK_STATUS(ret, "pthread_attr_setstacksize"); /* Block signal used for timer notification */ info.period = 0.1; info.signo = SIGRTMIN; sigemptyset(&info.sigMask); MW_blockSignal(info.signo, &info.sigMask); signal(SIGTERM, MW_exitHandler); /* kill */ signal(SIGHUP, MW_exitHandler); /* kill -HUP */ signal(SIGINT, MW_exitHandler); /* Interrupt from keyboard */ signal(SIGQUIT, MW_exitHandler); /* Quit from keyboard */ raspberrypi_audioequalizer_initialize(); /* External mode */ rtSetTFinalForExtMode(&rtmGetTFinal(raspberrypi_audioequalizer_M)); rtExtModeCheckInit(1); { boolean_T rtmStopReq = FALSE; rtExtModeWaitForStartPkt(raspberrypi_audioequalizer_M->extModeInfo, 1, &rtmStopReq); if (rtmStopReq) { rtmSetStopRequested(raspberrypi_audioequalizer_M, TRUE); } } rtERTExtModeStartMsg(); /* Create base rate task */ ret = pthread_create(&baseRateThread, &attr, (void *) baseRateTask, (void *) &info); CHECK_STATUS(ret, "pthread_create"); pthread_attr_destroy(&attr); /* Wait for a stopping condition. */ MW_sem_wait(&stopSem); /* Received stop signal */ printf("**stopping the model**\n"); if (rtmGetErrorStatus(raspberrypi_audioequalizer_M) != NULL) { printf("\n**%s**\n", rtmGetErrorStatus(raspberrypi_audioequalizer_M)); } /* External mode shutdown */ rtExtModeShutdown(1); /* Disable rt_OneStep() here */ /* Terminate model */ raspberrypi_audioequalizer_terminate(); return 0; }
/* Model initialize function */ void xpcosc_initialize(boolean_T firstTime) { (void)firstTime; /* Registration code */ /* initialize non-finites */ rt_InitInfAndNaN(sizeof(real_T)); /* initialize real-time model */ (void) memset((void *)xpcosc_rtM, 0, sizeof(rtModel_xpcosc)); { /* Setup solver object */ rtsiSetSimTimeStepPtr(&xpcosc_rtM->solverInfo, &xpcosc_rtM->Timing.simTimeStep); rtsiSetTPtr(&xpcosc_rtM->solverInfo, &rtmGetTPtr(xpcosc_rtM)); rtsiSetStepSizePtr(&xpcosc_rtM->solverInfo, &xpcosc_rtM->Timing.stepSize0); rtsiSetdXPtr(&xpcosc_rtM->solverInfo, &xpcosc_rtM->ModelData.derivs); rtsiSetContStatesPtr(&xpcosc_rtM->solverInfo, &xpcosc_rtM->ModelData.contStates); rtsiSetNumContStatesPtr(&xpcosc_rtM->solverInfo, &xpcosc_rtM->Sizes.numContStates); rtsiSetErrorStatusPtr(&xpcosc_rtM->solverInfo, (&rtmGetErrorStatus (xpcosc_rtM))); rtsiSetRTModelPtr(&xpcosc_rtM->solverInfo, xpcosc_rtM); } rtsiSetSimTimeStep(&xpcosc_rtM->solverInfo, MAJOR_TIME_STEP); xpcosc_rtM->ModelData.intgData.y = xpcosc_rtM->ModelData.odeY; xpcosc_rtM->ModelData.intgData.f[0] = xpcosc_rtM->ModelData.odeF[0]; xpcosc_rtM->ModelData.intgData.f[1] = xpcosc_rtM->ModelData.odeF[1]; xpcosc_rtM->ModelData.intgData.f[2] = xpcosc_rtM->ModelData.odeF[2]; xpcosc_rtM->ModelData.intgData.f[3] = xpcosc_rtM->ModelData.odeF[3]; xpcosc_rtM->ModelData.contStates = ((real_T *) &xpcosc_X); rtsiSetSolverData(&xpcosc_rtM->solverInfo, (void *) &xpcosc_rtM->ModelData.intgData); rtsiSetSolverName(&xpcosc_rtM->solverInfo,"ode4"); xpcosc_rtM->solverInfoPtr = (&xpcosc_rtM->solverInfo); /* Initialize timing info */ { int_T *mdlTsMap = xpcosc_rtM->Timing.sampleTimeTaskIDArray; mdlTsMap[0] = 0; mdlTsMap[1] = 1; xpcosc_rtM->Timing.sampleTimeTaskIDPtr = (&mdlTsMap[0]); xpcosc_rtM->Timing.sampleTimes = (&xpcosc_rtM->Timing.sampleTimesArray[0]); xpcosc_rtM->Timing.offsetTimes = (&xpcosc_rtM->Timing.offsetTimesArray[0]); /* task periods */ xpcosc_rtM->Timing.sampleTimes[0] = (0.0); xpcosc_rtM->Timing.sampleTimes[1] = (0.001); /* task offsets */ xpcosc_rtM->Timing.offsetTimes[0] = (0.0); xpcosc_rtM->Timing.offsetTimes[1] = (0.0); } rtmSetTPtr(xpcosc_rtM, &xpcosc_rtM->Timing.tArray[0]); { int_T *mdlSampleHits = xpcosc_rtM->Timing.sampleHitArray; mdlSampleHits[0] = 1; mdlSampleHits[1] = 1; xpcosc_rtM->Timing.sampleHits = (&mdlSampleHits[0]); } rtmSetTFinal(xpcosc_rtM, 0.2); xpcosc_rtM->Timing.stepSize0 = 0.001; xpcosc_rtM->Timing.stepSize1 = 0.001; /* Setup for data logging */ { static RTWLogInfo rt_DataLoggingInfo; xpcosc_rtM->rtwLogInfo = &rt_DataLoggingInfo; } /* Setup for data logging */ { /* * Set pointers to the data and signal info each state */ { static int_T rt_LoggedStateWidths[] = { 1, 1 }; static int_T rt_LoggedStateNumDimensions[] = { 1, 1 }; static int_T rt_LoggedStateDimensions[] = { 1, 1 }; static boolean_T rt_LoggedStateIsVarDims[] = { 0, 0 }; static BuiltInDTypeId rt_LoggedStateDataTypeIds[] = { SS_DOUBLE, SS_DOUBLE }; static int_T rt_LoggedStateComplexSignals[] = { 0, 0 }; static const char_T *rt_LoggedStateLabels[] = { "CSTATE", "CSTATE" }; static const char_T *rt_LoggedStateBlockNames[] = { "xpcosc/Integrator1", "xpcosc/Integrator" }; static const char_T *rt_LoggedStateNames[] = { "", "" }; static boolean_T rt_LoggedStateCrossMdlRef[] = { 0, 0 }; static RTWLogDataTypeConvert rt_RTWLogDataTypeConvert[] = { { 0, SS_DOUBLE, SS_DOUBLE, 0, 0, 0, 1.0, 0, 0.0 }, { 0, SS_DOUBLE, SS_DOUBLE, 0, 0, 0, 1.0, 0, 0.0 } }; static RTWLogSignalInfo rt_LoggedStateSignalInfo = { 2, rt_LoggedStateWidths, rt_LoggedStateNumDimensions, rt_LoggedStateDimensions, rt_LoggedStateIsVarDims, (NULL), rt_LoggedStateDataTypeIds, rt_LoggedStateComplexSignals, (NULL), { rt_LoggedStateLabels }, (NULL), (NULL), (NULL), { rt_LoggedStateBlockNames }, { rt_LoggedStateNames }, rt_LoggedStateCrossMdlRef, rt_RTWLogDataTypeConvert }; static void * rt_LoggedStateSignalPtrs[2]; rtliSetLogXSignalPtrs(xpcosc_rtM->rtwLogInfo, (LogSignalPtrsType) rt_LoggedStateSignalPtrs); rtliSetLogXSignalInfo(xpcosc_rtM->rtwLogInfo, &rt_LoggedStateSignalInfo); rt_LoggedStateSignalPtrs[0] = (void*)&xpcosc_X.Integrator1_CSTATE; rt_LoggedStateSignalPtrs[1] = (void*)&xpcosc_X.Integrator_CSTATE; } rtliSetLogT(xpcosc_rtM->rtwLogInfo, "tout"); rtliSetLogX(xpcosc_rtM->rtwLogInfo, "xout"); rtliSetLogXFinal(xpcosc_rtM->rtwLogInfo, ""); rtliSetSigLog(xpcosc_rtM->rtwLogInfo, ""); rtliSetLogVarNameModifier(xpcosc_rtM->rtwLogInfo, "rt_"); rtliSetLogFormat(xpcosc_rtM->rtwLogInfo, 0); rtliSetLogMaxRows(xpcosc_rtM->rtwLogInfo, 0); rtliSetLogDecimation(xpcosc_rtM->rtwLogInfo, 1); /* * Set pointers to the data and signal info for each output */ { static void * rt_LoggedOutputSignalPtrs[] = { &xpcosc_Y.Outport[0] }; rtliSetLogYSignalPtrs(xpcosc_rtM->rtwLogInfo, ((LogSignalPtrsType) rt_LoggedOutputSignalPtrs)); } { static int_T rt_LoggedOutputWidths[] = { 2 }; static int_T rt_LoggedOutputNumDimensions[] = { 1 }; static int_T rt_LoggedOutputDimensions[] = { 2 }; static boolean_T rt_LoggedOutputIsVarDims[] = { 0 }; static int_T* rt_LoggedCurrentSignalDimensions[] = { (NULL) }; static BuiltInDTypeId rt_LoggedOutputDataTypeIds[] = { SS_DOUBLE }; static int_T rt_LoggedOutputComplexSignals[] = { 0 }; static const char_T *rt_LoggedOutputLabels[] = { "" }; static const char_T *rt_LoggedOutputBlockNames[] = { "xpcosc/Outport" }; static RTWLogDataTypeConvert rt_RTWLogDataTypeConvert[] = { { 0, SS_DOUBLE, SS_DOUBLE, 0, 0, 0, 1.0, 0, 0.0 } }; static RTWLogSignalInfo rt_LoggedOutputSignalInfo[] = { { 1, rt_LoggedOutputWidths, rt_LoggedOutputNumDimensions, rt_LoggedOutputDimensions, rt_LoggedOutputIsVarDims, rt_LoggedCurrentSignalDimensions, rt_LoggedOutputDataTypeIds, rt_LoggedOutputComplexSignals, (NULL), { rt_LoggedOutputLabels }, (NULL), (NULL), (NULL), { rt_LoggedOutputBlockNames }, { (NULL) }, (NULL), rt_RTWLogDataTypeConvert } }; rtliSetLogYSignalInfo(xpcosc_rtM->rtwLogInfo, rt_LoggedOutputSignalInfo); /* set currSigDims field */ rt_LoggedCurrentSignalDimensions[0] = &rt_LoggedOutputWidths[0]; } rtliSetLogY(xpcosc_rtM->rtwLogInfo, "yout"); } /* external mode info */ xpcosc_rtM->Sizes.checksums[0] = (1235351435U); xpcosc_rtM->Sizes.checksums[1] = (4143988505U); xpcosc_rtM->Sizes.checksums[2] = (362576123U); xpcosc_rtM->Sizes.checksums[3] = (1068881914U); { static const sysRanDType rtAlwaysEnabled = SUBSYS_RAN_BC_ENABLE; static RTWExtModeInfo rt_ExtModeInfo; static const sysRanDType *systemRan[1]; xpcosc_rtM->extModeInfo = (&rt_ExtModeInfo); rteiSetSubSystemActiveVectorAddresses(&rt_ExtModeInfo, systemRan); systemRan[0] = &rtAlwaysEnabled; rteiSetModelMappingInfoPtr(xpcosc_rtM->extModeInfo, &xpcosc_rtM->SpecialInfo.mappingInfo); rteiSetChecksumsPtr(xpcosc_rtM->extModeInfo, xpcosc_rtM->Sizes.checksums); rteiSetTPtr(xpcosc_rtM->extModeInfo, rtmGetTPtr(xpcosc_rtM)); } xpcosc_rtM->solverInfoPtr = (&xpcosc_rtM->solverInfo); xpcosc_rtM->Timing.stepSize = (0.001); rtsiSetFixedStepSize(&xpcosc_rtM->solverInfo, 0.001); rtsiSetSolverMode(&xpcosc_rtM->solverInfo, SOLVER_MODE_SINGLETASKING); /* block I/O */ xpcosc_rtM->ModelData.blockIO = ((void *) &xpcosc_B); { xpcosc_B.Integrator1 = 0.0; xpcosc_B.PCI6221AD = 0.0; xpcosc_B.RateTransition1 = 0.0; xpcosc_B.SignalGenerator = 0.0; xpcosc_B.RateTransition = 0.0; xpcosc_B.Gain = 0.0; xpcosc_B.Integrator = 0.0; xpcosc_B.Gain1 = 0.0; xpcosc_B.Gain2 = 0.0; xpcosc_B.Sum = 0.0; } /* parameters */ xpcosc_rtM->ModelData.defaultParam = ((real_T *)&xpcosc_P); /* states (continuous) */ { real_T *x = (real_T *) &xpcosc_X; xpcosc_rtM->ModelData.contStates = (x); (void) memset((void *)&xpcosc_X, 0, sizeof(ContinuousStates_xpcosc)); } /* states (dwork) */ xpcosc_rtM->Work.dwork = ((void *) &xpcosc_DWork); (void) memset((void *)&xpcosc_DWork, 0, sizeof(D_Work_xpcosc)); xpcosc_DWork.PCI6713DA_RWORK = 0.0; /* external outputs */ xpcosc_rtM->ModelData.outputs = (&xpcosc_Y); xpcosc_Y.Outport[0] = 0.0; xpcosc_Y.Outport[1] = 0.0; /* data type transition information */ { static DataTypeTransInfo dtInfo; (void) memset((char_T *) &dtInfo, 0, sizeof(dtInfo)); xpcosc_rtM->SpecialInfo.mappingInfo = (&dtInfo); xpcosc_rtM->SpecialInfo.xpcData = ((void*) &dtInfo); dtInfo.numDataTypes = 14; dtInfo.dataTypeSizes = &rtDataTypeSizes[0]; dtInfo.dataTypeNames = &rtDataTypeNames[0]; /* Block I/O transition table */ dtInfo.B = &rtBTransTable; /* Parameters transition table */ dtInfo.P = &rtPTransTable; } /* Initialize DataMapInfo substructure containing ModelMap for C API */ xpcosc_InitializeDataMapInfo(xpcosc_rtM); /* child S-Function registration */ { RTWSfcnInfo *sfcnInfo = &xpcosc_rtM->NonInlinedSFcns.sfcnInfo; xpcosc_rtM->sfcnInfo = (sfcnInfo); rtssSetErrorStatusPtr(sfcnInfo, (&rtmGetErrorStatus(xpcosc_rtM))); rtssSetNumRootSampTimesPtr(sfcnInfo, &xpcosc_rtM->Sizes.numSampTimes); xpcosc_rtM->NonInlinedSFcns.taskTimePtrs[0] = &(rtmGetTPtr(xpcosc_rtM)[0]); xpcosc_rtM->NonInlinedSFcns.taskTimePtrs[1] = &(rtmGetTPtr(xpcosc_rtM)[1]); rtssSetTPtrPtr(sfcnInfo,xpcosc_rtM->NonInlinedSFcns.taskTimePtrs); rtssSetTStartPtr(sfcnInfo, &rtmGetTStart(xpcosc_rtM)); rtssSetTFinalPtr(sfcnInfo, &rtmGetTFinal(xpcosc_rtM)); rtssSetTimeOfLastOutputPtr(sfcnInfo, &rtmGetTimeOfLastOutput(xpcosc_rtM)); rtssSetStepSizePtr(sfcnInfo, &xpcosc_rtM->Timing.stepSize); rtssSetStopRequestedPtr(sfcnInfo, &rtmGetStopRequested(xpcosc_rtM)); rtssSetDerivCacheNeedsResetPtr(sfcnInfo, &xpcosc_rtM->ModelData.derivCacheNeedsReset); rtssSetZCCacheNeedsResetPtr(sfcnInfo, &xpcosc_rtM->ModelData.zCCacheNeedsReset); rtssSetBlkStateChangePtr(sfcnInfo, &xpcosc_rtM->ModelData.blkStateChange); rtssSetSampleHitsPtr(sfcnInfo, &xpcosc_rtM->Timing.sampleHits); rtssSetPerTaskSampleHitsPtr(sfcnInfo, &xpcosc_rtM->Timing.perTaskSampleHits); rtssSetSimModePtr(sfcnInfo, &xpcosc_rtM->simMode); rtssSetSolverInfoPtr(sfcnInfo, &xpcosc_rtM->solverInfoPtr); } xpcosc_rtM->Sizes.numSFcns = (2); /* register each child */ { (void) memset((void *)&xpcosc_rtM->NonInlinedSFcns.childSFunctions[0], 0, 2*sizeof(SimStruct)); xpcosc_rtM->childSfunctions = (&xpcosc_rtM->NonInlinedSFcns.childSFunctionPtrs[0]); xpcosc_rtM->childSfunctions[0] = (&xpcosc_rtM->NonInlinedSFcns.childSFunctions[0]); xpcosc_rtM->childSfunctions[1] = (&xpcosc_rtM->NonInlinedSFcns.childSFunctions[1]); /* Level2 S-Function Block: xpcosc/<Root>/PCI-6221 AD (adnipcim) */ { SimStruct *rts = xpcosc_rtM->childSfunctions[0]; /* timing info */ time_T *sfcnPeriod = xpcosc_rtM->NonInlinedSFcns.Sfcn0.sfcnPeriod; time_T *sfcnOffset = xpcosc_rtM->NonInlinedSFcns.Sfcn0.sfcnOffset; int_T *sfcnTsMap = xpcosc_rtM->NonInlinedSFcns.Sfcn0.sfcnTsMap; (void) memset((void*)sfcnPeriod, 0, sizeof(time_T)*1); (void) memset((void*)sfcnOffset, 0, sizeof(time_T)*1); ssSetSampleTimePtr(rts, &sfcnPeriod[0]); ssSetOffsetTimePtr(rts, &sfcnOffset[0]); ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap); /* Set up the mdlInfo pointer */ { ssSetBlkInfo2Ptr(rts, &xpcosc_rtM->NonInlinedSFcns.blkInfo2[0]); } ssSetRTWSfcnInfo(rts, xpcosc_rtM->sfcnInfo); /* Allocate memory of model methods 2 */ { ssSetModelMethods2(rts, &xpcosc_rtM->NonInlinedSFcns.methods2[0]); } /* Allocate memory of model methods 3 */ { ssSetModelMethods3(rts, &xpcosc_rtM->NonInlinedSFcns.methods3[0]); } /* Allocate memory for states auxilliary information */ { ssSetStatesInfo2(rts, &xpcosc_rtM->NonInlinedSFcns.statesInfo2[0]); } /* outputs */ { ssSetPortInfoForOutputs(rts, &xpcosc_rtM->NonInlinedSFcns.Sfcn0.outputPortInfo[0]); _ssSetNumOutputPorts(rts, 1); /* port 0 */ { _ssSetOutputPortNumDimensions(rts, 0, 1); ssSetOutputPortWidth(rts, 0, 1); ssSetOutputPortSignal(rts, 0, ((real_T *) &xpcosc_B.PCI6221AD)); } } /* path info */ ssSetModelName(rts, "PCI-6221 AD"); ssSetPath(rts, "xpcosc/PCI-6221 AD"); ssSetRTModel(rts,xpcosc_rtM); ssSetParentSS(rts, (NULL)); ssSetRootSS(rts, rts); ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2); /* parameters */ { mxArray **sfcnParams = (mxArray **) &xpcosc_rtM->NonInlinedSFcns.Sfcn0.params; ssSetSFcnParamsCount(rts, 7); ssSetSFcnParamsPtr(rts, &sfcnParams[0]); ssSetSFcnParam(rts, 0, (mxArray*)xpcosc_P.PCI6221AD_P1_Size); ssSetSFcnParam(rts, 1, (mxArray*)xpcosc_P.PCI6221AD_P2_Size); ssSetSFcnParam(rts, 2, (mxArray*)xpcosc_P.PCI6221AD_P3_Size); ssSetSFcnParam(rts, 3, (mxArray*)xpcosc_P.PCI6221AD_P4_Size); ssSetSFcnParam(rts, 4, (mxArray*)xpcosc_P.PCI6221AD_P5_Size); ssSetSFcnParam(rts, 5, (mxArray*)xpcosc_P.PCI6221AD_P6_Size); ssSetSFcnParam(rts, 6, (mxArray*)xpcosc_P.PCI6221AD_P7_Size); } /* work vectors */ ssSetIWork(rts, (int_T *) &xpcosc_DWork.PCI6221AD_IWORK[0]); ssSetPWork(rts, (void **) &xpcosc_DWork.PCI6221AD_PWORK); { struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *) &xpcosc_rtM->NonInlinedSFcns.Sfcn0.dWork; struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *) &xpcosc_rtM->NonInlinedSFcns.Sfcn0.dWorkAux; ssSetSFcnDWork(rts, dWorkRecord); ssSetSFcnDWorkAux(rts, dWorkAuxRecord); _ssSetNumDWork(rts, 2); /* IWORK */ ssSetDWorkWidth(rts, 0, 41); ssSetDWorkDataType(rts, 0,SS_INTEGER); ssSetDWorkComplexSignal(rts, 0, 0); ssSetDWork(rts, 0, &xpcosc_DWork.PCI6221AD_IWORK[0]); /* PWORK */ ssSetDWorkWidth(rts, 1, 1); ssSetDWorkDataType(rts, 1,SS_POINTER); ssSetDWorkComplexSignal(rts, 1, 0); ssSetDWork(rts, 1, &xpcosc_DWork.PCI6221AD_PWORK); } /* registration */ adnipcim(rts); sfcnInitializeSizes(rts); sfcnInitializeSampleTimes(rts); /* adjust sample time */ ssSetSampleTime(rts, 0, 0.001); ssSetOffsetTime(rts, 0, 0.0); sfcnTsMap[0] = 1; /* set compiled values of dynamic vector attributes */ ssSetNumNonsampledZCs(rts, 0); /* Update connectivity flags for each port */ _ssSetOutputPortConnected(rts, 0, 1); _ssSetOutputPortBeingMerged(rts, 0, 0); /* Update the BufferDstPort flags for each input port */ } /* Level2 S-Function Block: xpcosc/<Root>/PCI-6713 DA (danipci671x) */ { SimStruct *rts = xpcosc_rtM->childSfunctions[1]; /* timing info */ time_T *sfcnPeriod = xpcosc_rtM->NonInlinedSFcns.Sfcn1.sfcnPeriod; time_T *sfcnOffset = xpcosc_rtM->NonInlinedSFcns.Sfcn1.sfcnOffset; int_T *sfcnTsMap = xpcosc_rtM->NonInlinedSFcns.Sfcn1.sfcnTsMap; (void) memset((void*)sfcnPeriod, 0, sizeof(time_T)*1); (void) memset((void*)sfcnOffset, 0, sizeof(time_T)*1); ssSetSampleTimePtr(rts, &sfcnPeriod[0]); ssSetOffsetTimePtr(rts, &sfcnOffset[0]); ssSetSampleTimeTaskIDPtr(rts, sfcnTsMap); /* Set up the mdlInfo pointer */ { ssSetBlkInfo2Ptr(rts, &xpcosc_rtM->NonInlinedSFcns.blkInfo2[1]); } ssSetRTWSfcnInfo(rts, xpcosc_rtM->sfcnInfo); /* Allocate memory of model methods 2 */ { ssSetModelMethods2(rts, &xpcosc_rtM->NonInlinedSFcns.methods2[1]); } /* Allocate memory of model methods 3 */ { ssSetModelMethods3(rts, &xpcosc_rtM->NonInlinedSFcns.methods3[1]); } /* Allocate memory for states auxilliary information */ { ssSetStatesInfo2(rts, &xpcosc_rtM->NonInlinedSFcns.statesInfo2[1]); } /* inputs */ { _ssSetNumInputPorts(rts, 1); ssSetPortInfoForInputs(rts, &xpcosc_rtM->NonInlinedSFcns.Sfcn1.inputPortInfo[0]); /* port 0 */ { real_T const **sfcnUPtrs = (real_T const **) &xpcosc_rtM->NonInlinedSFcns.Sfcn1.UPtrs0; sfcnUPtrs[0] = &xpcosc_B.RateTransition; ssSetInputPortSignalPtrs(rts, 0, (InputPtrsType)&sfcnUPtrs[0]); _ssSetInputPortNumDimensions(rts, 0, 1); ssSetInputPortWidth(rts, 0, 1); } } /* path info */ ssSetModelName(rts, "PCI-6713 DA"); ssSetPath(rts, "xpcosc/PCI-6713 DA"); ssSetRTModel(rts,xpcosc_rtM); ssSetParentSS(rts, (NULL)); ssSetRootSS(rts, rts); ssSetVersion(rts, SIMSTRUCT_VERSION_LEVEL2); /* parameters */ { mxArray **sfcnParams = (mxArray **) &xpcosc_rtM->NonInlinedSFcns.Sfcn1.params; ssSetSFcnParamsCount(rts, 6); ssSetSFcnParamsPtr(rts, &sfcnParams[0]); ssSetSFcnParam(rts, 0, (mxArray*)xpcosc_P.PCI6713DA_P1_Size); ssSetSFcnParam(rts, 1, (mxArray*)xpcosc_P.PCI6713DA_P2_Size); ssSetSFcnParam(rts, 2, (mxArray*)xpcosc_P.PCI6713DA_P3_Size); ssSetSFcnParam(rts, 3, (mxArray*)xpcosc_P.PCI6713DA_P4_Size); ssSetSFcnParam(rts, 4, (mxArray*)xpcosc_P.PCI6713DA_P5_Size); ssSetSFcnParam(rts, 5, (mxArray*)xpcosc_P.PCI6713DA_P6_Size); } /* work vectors */ ssSetRWork(rts, (real_T *) &xpcosc_DWork.PCI6713DA_RWORK); ssSetIWork(rts, (int_T *) &xpcosc_DWork.PCI6713DA_IWORK[0]); { struct _ssDWorkRecord *dWorkRecord = (struct _ssDWorkRecord *) &xpcosc_rtM->NonInlinedSFcns.Sfcn1.dWork; struct _ssDWorkAuxRecord *dWorkAuxRecord = (struct _ssDWorkAuxRecord *) &xpcosc_rtM->NonInlinedSFcns.Sfcn1.dWorkAux; ssSetSFcnDWork(rts, dWorkRecord); ssSetSFcnDWorkAux(rts, dWorkAuxRecord); _ssSetNumDWork(rts, 2); /* RWORK */ ssSetDWorkWidth(rts, 0, 1); ssSetDWorkDataType(rts, 0,SS_DOUBLE); ssSetDWorkComplexSignal(rts, 0, 0); ssSetDWork(rts, 0, &xpcosc_DWork.PCI6713DA_RWORK); /* IWORK */ ssSetDWorkWidth(rts, 1, 2); ssSetDWorkDataType(rts, 1,SS_INTEGER); ssSetDWorkComplexSignal(rts, 1, 0); ssSetDWork(rts, 1, &xpcosc_DWork.PCI6713DA_IWORK[0]); } /* registration */ danipci671x(rts); sfcnInitializeSizes(rts); sfcnInitializeSampleTimes(rts); /* adjust sample time */ ssSetSampleTime(rts, 0, 0.001); ssSetOffsetTime(rts, 0, 0.0); sfcnTsMap[0] = 1; /* set compiled values of dynamic vector attributes */ ssSetNumNonsampledZCs(rts, 0); /* Update connectivity flags for each port */ _ssSetInputPortConnected(rts, 0, 1); /* Update the BufferDstPort flags for each input port */ ssSetInputPortBufferDstPort(rts, 0, -1); } } }