Comment on page
For a Submodel named
my_submodel, instantiated in a model named
my_model, the zip file will be named
my_model.my_submodel-<date-time>.zip, and it will contain the following files:
The concept is that the C code generated from the Submodel is to be used as a translation unit in a C code project. Alone, the code generated from Collimator is insufficient to deploy your Submodel algorithm to hardware, you need to write a C program with an entry point, and other typical constructs, and this program will call the functions defined in the generated code.
C code egenration is limited to discrete and agnostic blocks. Code generation form Python Script blocks is not presently supported. If you inclide a Python Script block in your submodel, Collimator will treat it as a black box function, and generated template C code for it. You must manully
The detailed role of each file is explained below.
This file defines the initialization and step functions which reproduce the algorithm of your Submodel.
my_submodel_initialize()must called to initialize any states and/or outputs, before calling
The function names, and type definitions use the Submodel name so that you can generate code from several Submodels in your model, and you will not get C name clashes in your C project if you include multiple translation units form Collimator.
Declarations and type definitions for the content of
If you incluede da Pythin Script block in your Submodel, the function template generated for the block is in this file.
Some types used by the C code.
This is a helper file with some convenience code that you may choose to copy/paste in your C program.
For a copy of Collimator's MISRA C 2012 compliance matrix, please contact sales.
Below is a simple example program that calls the functions in the generated code.
int main( void)
// initialize time and other stimulous variables
float64_t stop_time = 10.0;
float64_t discrete_step = 0.1;
float64_t time = 0.0;
float64_t time1 = 5.0;
float64_t time2 = 7.0;
// call initialize function
// compute inputs
my_submodel_inputs_ptr->my_input = (time >= time) && (time <= time);
// call step function
// optionally read the outputs
if (my_submodel_outputs_ptr->my_stop_signal) break;
// increment step time
time = time + discrete_step;