Settings

The Settings tab can be used to configure whether the static code analysis is automatically performed when the code is generated. The current configuration of the Static Analysis can be saved in an external file, or a configuration can be loaded from an external file.

Perform Static Analysis automatically after compilation

If this option is enabled, TwinCAT performs the Static Analysis whenever code is generated without error (e.g. when the command Build Project is executed). The analysis can be started manually via the command Command 'Run static analysis', irrespective of the configuration of this option.

Load

This button opens the standard dialog for a locating of a file. Select the required configuration file *.csa for the Static Analysis, which may previously have been created via Save (see below). Since the Static Analysis properties are "solution options", the project properties for the Static Analysis, as described in the csa file, are applied to all PLC projects in the development environment.

Save

This button is used to save the current project properties for the Static Analysis in an xml file. The standard dialog for saving a file appears, and the file type is preset to "Static analysis files" (*.csa). Such a file can later be applied to the project via the Load button (see above).

Please note that the setting of the error limit "Maximum number of errors" is not saved in this file.

Maximum number of errors

Preset: 500

In this box you can enter the desired error limit, which is checked during the execution of the Static Analysis. If either the error limit or the warning limit (see below) is reached, execution of the Static Analysis is canceled and the previous analysis result is output.

 

Performance vs. completeness:

Please note: The more objects are checked by the Static Analysis, the longer the execution of the Static Analysis takes. And the more errors are entered in the output window, the longer the results output of the Static Analysis takes.

In the assumed case that there are more than 500 Static Analysis errors in a PLC project, the following use cases arise.

  • Use of a small error limit (e.g. 500):
    You wish to gradually process the output errors by correcting the respective program code and executing the Static Analysis again to check the correction. In this case it wouldn't be necessary to check all the objects at once and to display all the errors at once. Instead, it is usually sufficient in this case to display a subset as the Static Analysis result, wherein the Static Analysis is executed with a good performance.
  • Use of a large error limit (e.g. 5000):
    You wish to output a total report from the Static Analysis in order to be able to roughly estimate the total work required for the correction of the program code. You can attain this goal by increasing the error limit. Please note that, depending on the project situation, the execution of the Static Analysis takes (much) longer the higher the error limit is set.

 

Detailed explanation of the behavior:

If there are more than 500 Static Analysis errors in a project, then configuring the error limit to 500 does not mean that the Static Analysis outputs exactly 500 errors. In fact, the following happens during the execution of the Static Analysis: Before checking a further POU, a check is performed to see whether the Static Analysis errors found so far already exceed the configured limit. If this is the case, the execution of the Static Analysis is aborted and the analysis result so far is output. If on the other hand the limit has not been reached, this POU is checked by the Static Analysis and the errors found in this POU are added to the analysis result. If this newly formed error total (e.g. 530) exceeds the configured error limit, the execution of the Static Analysis is aborted before the checking of the next POU and the errors found so far (e.g. 530) are output.

Maximum number of warnings

Preset: 500

In this field, you can enter the desired warning limit, which is checked during the execution of Static Analysis. If either the error limit (see above) or the warning limit is reached, execution of the Static Analysis is canceled and the previous analysis result is output.

Further information on the use cases can be found in the description of the "Maximum number of errors" option (see above).