Using a Database in RTWS and Simulink with the same code

조회 수: 4 (최근 30일)
Jan
Jan 2011년 1월 24일
Hi,
i'm developing a model which will be used to simulate and verify some FSM and write the results into a database.
Currently im using SQLite via extrinsics aka mksqlite, which works perfectly in the simulation. Of course it won't work after building embedded target code because there are no equivalent c functions for mksqlite.
My plan is to rewrite all database operations to use S-functions but this causes problems. I know that RTWS can specify an initialisation function for the embedded target where i could open the database etc. but this wont work in the simulation.
how can i open my database in an initialisation function written in C which is executed in the simulation and the embedded target? is this possible?
regards,
Jan

답변 (1개)

Sebastian
Sebastian 2011년 1월 25일
I cannot comment on the task or feasibility to rewrite all database operations as S-functions. However, within a C-code S-function you can use the preprocessor symbol MATLAB_MEX_FILE to do host (simulation) and target specific things:
#ifdef MATLAB_MEX_FILE /* host/simulation */
/* simulation code, typically nothing */
#else /* target */
/* code to access I/O board */
#endif
So I would use this in the initialization part of your S-function.

카테고리

Help CenterFile Exchange에서 Simulink Coder에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by