Tunable parameters interface in generated code used in an indirect manner.

I have a model, which has a set of tunable parameters. I want those tunable parameters to be accessed in the generated code in an indirect manner (i.e. through dereferencing a pointer) in a similar fashion as input and output signals are handled when the code is generated with settings:
  • Code interface packaging: Reusable function,
  • Pass root-level I/O as Individual arguments.
With those settings type definitions for input and output data structures types are present in model.h file together with static initializers. Those static initializers are used in model_initialize(...) function to initialize those variables. Definition of input and output variables are defined in an external code, which calls model functions and not in model file, although supplied initializers make it straight-forward to initialize those variables.
I'd like to achieve similar code structure for tunable parameters structure, so that the structure is instantiated by an external actor and not generated code. The generated code should just accept the pointer to this data and operate on it. One of the reasons I want to have it that way is to be able to implement a "double-buffering" mechanism for handling parameters. I want to have two structures holding tunable parameters, modify an inactive structure by populating it's fields and at a specific cycle switching from one structure to the other by passing different pointer to model_step(...) function maintaining consistency between parameters.
I tried different Storage Class options. The closest I get was defining the parameter as model argument and use "Model default" storage class for it, but it has following drawbacks:
1. It does not support Data Dictionary - parameters that are defined as arguments must go to model workspace.
2. It does not come with a default initializer in model files. Although, since initializer is supplied with ert_main.c code example I could probably live without it.
Is it possible to configure an embedded coder to achieve what I described above?

Answers (0)

Products

Release

R2019b

Asked:

on 8 Apr 2020

Community Treasure Hunt

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

Start Hunting!