Subversion Repositories shark

Compare Revisions

Regard whitespace Rev 1367 → Rev 1368

/demos/trunk/rtw/makefile
8,9 → 8,9
include $(BASE)/config/config.mk
 
MATLAB_ROOT = /matlab
MATLAB_RTW_DEMO_DIR = /usr/local/home/giacomo/simulink_test_grt_rtw/
MATLAB_RTW_DEMO_DIR = /usr/local/home/giacomo/shark_mat/Subsystem_grt_rtw/
 
DEFINE_MODEL = simulink_test
DEFINE_MODEL = Subsystem
DEFINE_NUMST = 1
DEFINE_RTWLIB += -lrtw
 
/demos/trunk/rtw/rtw.c
56,6 → 56,10
* Global data local to this module *
*==================================*/
RT_MODEL *S;
const char *status;
real_T finaltime = -2.0;
volatile int simulation_run;
static struct {
int_T stopExecutionFlag;
int_T isrOverrun;
231,20 → 235,18
 
} /* end rtOneStep */
 
int main() {
void Init_RealTime_Workshop() {
 
RT_MODEL *S;
const char *status;
real_T finaltime = -2.0;
/****************************
* Initialize global memory *
****************************/
(void)memset(&GBLbuf, 0, sizeof(GBLbuf));
 
/************************
* Initialize the model *
************************/
rt_InitInfAndNaN(sizeof(real_T));
 
S = MODEL();
253,6 → 255,7
rtmGetErrorStatus(S));
sys_end();
}
if (finaltime >= 0.0 || finaltime == RUN_FOREVER) rtmSetTFinal(S,finaltime);
 
MdlInitializeSizes();
272,6 → 275,7
cprintf("Failed to initialize sample time engine: %s\n", status);
sys_end();
}
rt_CreateIntegrationData(S);
 
rtExtModeCheckInit();
278,7 → 282,7
rtExtModeWaitForStartMsg(rtmGetRTWExtModeInfo(S),
(boolean_T *)&rtmGetStopRequested(S));
 
cprintf("\n** starting the model **\n");
cprintf("\n** Starting the model **\n");
 
MdlStart();
if (rtmGetErrorStatus(S) != NULL) {
295,6 → 299,39
cprintf("\n**May run forever. Model stop time set to infinity.**\n");
}
}
 
void Close_RealTime_Workshop() {
 
/********************
* Cleanup and exit *
********************/
 
rtExtModeShutdown();
 
if (GBLbuf.errmsg) {
cprintf("%s\n",GBLbuf.errmsg);
sys_end();
}
 
if (GBLbuf.isrOverrun) {
cprintf("%s: ISR overrun - base sampling rate is too fast\n",QUOTE(MODEL));
sys_end();
}
 
if (rtmGetErrorStatus(S) != NULL) {
cprintf("%s\n", rtmGetErrorStatus(S));
sys_end();
}
 
MdlTerminate();
 
}
 
TASK RTW_body(void *arg) {
simulation_run = 1;
 
while (!GBLbuf.stopExecutionFlag &&
(rtmGetTFinal(S) == RUN_FOREVER ||
rtmGetTFinal(S)-rtmGetT(S) > rtmGetT(S)*DBL_EPSILON)) {
302,10 → 339,13
rtExtModePauseIfNeeded(rtmGetRTWExtModeInfo(S),
(boolean_T *)&rtmGetStopRequested(S));
 
cprintf(".");
cprintf(".(%dus)",(int)(rtmGetT(S)*1000000));
 
if (rtmGetStopRequested(S)) break;
rt_OneStep(S);
 
task_endcycle();
 
}
 
if (!GBLbuf.stopExecutionFlag && !rtmGetStopRequested(S)) {
313,29 → 353,39
rt_OneStep(S);
}
 
/********************
* Cleanup and exit *
********************/
simulation_run = 0;
 
rtExtModeShutdown();
return NULL;
 
if (GBLbuf.errmsg) {
cprintf("%s\n",GBLbuf.errmsg);
sys_end();
}
 
if (GBLbuf.isrOverrun) {
cprintf("%s: ISR overrun - base sampling rate is too fast\n",QUOTE(MODEL));
int main() {
 
HARD_TASK_MODEL RTW_task;
PID RTW_pid;
 
Init_RealTime_Workshop();
 
hard_task_default_model(RTW_task);
hard_task_def_mit(RTW_task,rtmGetStepSize(S) * 1000000);
hard_task_def_wcet(RTW_task,10000);
hard_task_def_usemath(RTW_task);
hard_task_def_ctrl_jet(RTW_task);
 
RTW_pid = task_create("RTW",RTW_body,&RTW_task,NULL);
if (RTW_pid == NIL) {
cprintf("Error creating RealTime Workshop Task\n");
sys_end();
}
 
if (rtmGetErrorStatus(S) != NULL) {
cprintf("%s\n", rtmGetErrorStatus(S));
task_activate(RTW_pid);
 
while(simulation_run);
Close_RealTime_Workshop();
 
sys_end();
}
 
MdlTerminate();
 
return 0;
 
} /* end main */
}