Is there something like a pre-build callback function?

I have a Simulink model whose goal is to automatically generate code.

My model uses S-functions (developed by the other side), which has hard-coded assumptions about the path. For example, several external data files are required, which are referred to in the S-function through a relative path, for example ..\Bin\data\datafile.bin . This forces you to set the current MATLAB working directory to a specific path before starting the model.

I can automatically check and set the correct path through the model callback functions. However, all the model callback functions are apparently related to the modeling process, and not to the assembly process. This means that I can run the model no matter which directory I enter, but when I try to create a model, it always fails if I do not manually go back to the correct directory in MATLAB.

Needless to say, this is pretty annoying. So I was wondering if there is something like a “preBuildFcn” callback fnuction, a function that runs before the start of the build process? Any other solution (not related to the modification of the S-function) is also very welcome.

+5
source share
2 answers

There are many hooks during the build process in the Simulink / Embedded Coder build process ("entry", "before_tlc", "after_tlc", "before_make", "after_make", "exit" and "error"). I assume you need an entry hook.

All you have to do is write an M function called your_system_target_file name_make_rtw_hook, as described in the documentation Configure the build process with the STF_make_rtw_hook file .

If you cannot open the online documentation (login required), here is the HTML path in your MATLAB installation: MATLAB root \ help \ rtw \ ug \ customizing-the-target-build-process-with -The-STP makeup RTW- hook-file.html

+3
source

I'm not sure that modeling simulation models is quite similar to creating regular MATLAB programs, but here's what I used in the past:

  • Manually set up a project
  • Build a project programmatically

The program that is used to build the project should be able to set the path or perform other user-defined things.

+1
source

Source: https://habr.com/ru/post/1202142/


All Articles