Main Content

Define the Compile Option for Custom Model Advisor Checks

Depending on the implementation of your model and what you want your custom check to achieve, it is important that you specify the correct compile option. You specify the compile option for the check definition function of a ModelAdvisor.Check object by setting the CallbackContext property as follows:

  • None specifies that the Model Advisor does not have to compile your model before analysis by your custom check. None is the default setting of the CallbackContext property.

  • PostCompile specifies that the Model Advisor must compile the model to update the model diagram and then simulate the model to execute your custom check. The Model Advisor does not flag modeling issues that fail during code generation because these issues do not affect the simulated model.

  • PostCompileForCodegen specifies that the Model Advisor must compile and update the model diagram specifically for code generation, but does not simulate the model. Use this option for Model Advisor checks that analyze the code generation readiness of the model. This option is not supported for custom edit-time checks.

Checks that Evaluate the Code Generation Readiness of the Model

You can create custom Model Advisor checks that enable the Model Advisor engine to identify code generation setup issues in a model at an earlier stage so you can avoid unexpected errors during code generation. For example, in this model, the Red enumeration in BasicColors and OtherColors are OK for use in a simulated model. In the generated code, however, these Red enumerations result in an enumeration clash. By using the 'PostCompileForCodegen' option, your custom Model Advisor check can identify this type of code generation setup issue.

Class definitions for BasicColors and OtherColors, showing the enumeration clash from Red enumeration

See Also

|

Topics