It is possible to analyze Simulink
models in TICS.
For a successful Simulink
integration, the following prerequisites
must be met:
The following prerequisites concern the environment of the buildserver:
The following prerequisites are necessary for a complete analysis of a project:
To be able to analyze a Simulink model the language must be added in the SERVER.txt with a PREPARE step. Note that Simulink model analysis is only possible with TICSQServer
, and must always include a PREPARE step.
The following language properties have to be declared on SERVER level:
'LANGUAGES' => { 'SIMULINK' => { 'EXTENSIONS' => [ 'simulink', ], 'RULESETS' => [ { 'METRIC' => 'CODINGSTANDARD', 'NAME' => 'Simulink Coding Standard', 'RULESDIR' => 'codingstandards/SIMULINK', }, { 'METRIC' => 'COMPILERWARNING', 'NAME' => 'Simulink Compiler Warnings', 'RULESDIR' => 'compilerwarnings/SIMULINK', }, { 'METRIC' => 'ABSTRACTINTERPRETATION', 'NAME' => 'Simulink Abstract Interpretation', 'RULESDIR' => 'abstractinterpretation/SIMULINK', }, ], 'FANOUT' => { 'TOOL' => 'Simulink', }, 'TESTCOVERAGE' => { 'TOOLS' => ['Simulink'], }, 'CYCLOMATICCOMPLEXITY' => { 'TOOL' => 'Simulink', }, 'DEADCODE' => { 'TOOL' => 'Simulink', }, 'DUPLICATEDCODE' => { 'TOOL' => 'Simulink', }, }, }
and:
'PREPAREQDB' => 'PREPAREQDB.pm',
Furthermore, it is necessary to define the 'SIMULINKSTARTMODEL' property, which contains a starting model (which is the Simulink model from which you want to start your analysis) on the PROJECTS level. This can be defined either for each branch or for an entire project, but it is necessary to provide this starting model to run a successful Simulink analysis.
'your_project_name' => { 'TOOLS' => { 'Simulink' => { 'SIMULINKSTARTMODEL' => 'C:/somewhere/your_starting_model.slx', }, }, }
The following needs to be included in PREPAREQDB.pm:
use TICSPrepSimulink; sub PrepareQDB ($$$) : Private { my ($project, $branchdir, $branchname) = @_; &TICSPrepSimulink::PrepareSimulink($project, $branchdir, $branchname); }
For more information please refer to the implementation ticket.
The following properties can be configured in addition to the Simulink start model, in either SERVER.txt or PROJECTS.txt:
LOOKUNDERMASKING
property defines how masked subsystems are treated by the Simulink integration. In case LOOKUNDERMASKING is equal to 1, then the integration will look beyond masked blocks what it can find.HOOKSCRIPTS
property defines where to look for hook scripts of TargetLink: scripts that are necessary to prepare, or process, the compiling of code by Simulink. If a HOOKSCRIPTS dir is specified in the configuration, then the Simulink integration will attempt to use these scripts when compiling the model to get Compiler Warnings.PREPARESCRIPT
property defines a preparation script that is necessary to get all data necessary to correctly analyze the model by the Simulink integration. In case a preparation script is specified, this script is always run when MATLAB is called before executing the actual analysis on the model.SIMULINKRESULTDIR
property defines a result directory in the case that we do not wish to run a live Simulink analysis for some metrics, and instead want to import results from a list of reports in a directory (currently, this behaviour is only supported for Simulink Coding Standards). In the case a Simulink result directory has been defined, this Simulink result directory is used to import the results instead of running a live Simulink analysis.An example of the properties in use at the PROJECTS.txt level.
'your_project' => { 'TOOLS' => { 'Simulink' => { 'LOOKUNDERMASKING' => 0, 'HOOKSCRIPTSDIR' => 'C:/your_model_dir/your_scripts_dir', 'PREPARESCRIPT' => 'C:/your_model_dir/startup.m', 'SIMULINKSTARTMODEL' => 'C:/your_model_dir/starting_model.slx' }, }, },