Custom Wrapper Exchanges with the OML Library

The Custom wrapper creates the OML structures needed by the target code generator function.

The custom wrapper provides the name of body callback functions associated with different activations (by generating inline code for the model after replacing wrapper blocks by port blocks), the parameters of the wrapper blocks, and the system parameters. In addition to information about the corresponding ports (data type, variable name, size), the block parameters contain the C code snippets associated with different keywords. These code snippets are provided by the parameters of the wrapper blocks. When an OML library is used, the code snippets are defined by the blocks by calling the corresponding OML library function. In this case, the Custom wrapper calls the OML library function several times to create the OML structures to be passed to the target code generator.

Target Code Generator Function

The Target code generator is an OML function in charge of creating the main.c file for the specified target.

The target code generator receives information regarding the body ports and the corresponding body APIs, in addition to the properties of the wrapper blocks and their correspondence with the body inputs and outputs.

The following shows the start of a typical target code generator function:
function RaspberryPiWrapper(callbacks, Wparams, Sysparams)
  period=Sysparams.period; % period in secs of the main loop
  folder=Sysparams.folder;   % path of folder where main.c should be saved
  extlibs=Sysparams.extlibs; % list of possible external libraries
  clocks=Sysparams.clocks; % info on interrupt and main activations
  %
 [wparams0, lwparams] = vssWrapperSeparatewparams(Wparams);
 [globaldecl, localdecl, args] = vssGetWrapperIOList(Wparams);

The sysparams period, folder, extlibs, and clocks fields are automatically added by the Custom code generator. The variable clocks is an OML cell containing two rows and as many columns as there are interrupts, plus one if the main loop is not empty. The first row contains the name of the interrupt or 'mainloop' for the main loop, if present, and the second row contains the name of the corresponding body API.

The vssWrapperSeparatewparams function separates and organizes the wrapper block Wparams into wparams0 corresponding to the blocks activated in the main loop, and lwparams containing the Wparams associated with different interrupts.

The vssGetWrapperIOList function extracts and returns the C code for the global declarations, the local declarations and the arguments of the body APIs.

These functions simplify the creation of main.c. The Custom wrapper generator provides several utility functions.