Creation of versioned drivers
Each object created from Simulink® contains version information. Accordingly, you can build several versions of a Simulink® model and instantiate the created modules version-selectively in TwinCAT.
Define revision control in Simulink®
Switch to Advanced mode to make the following parameters visible.
TwinCAT.ModuleGenerator.Settings.Change('ConfigurationLevel', 'Advanced')
Before creating a PLC function block or a TcCOM object, you can define the version of the TcCOM and the created PLC library under TC General with the entries “Version source file” and “Version part for increment”.
Automatic version increments
The basic version on which a version update is to be created is specified via “Version source file”. In the standard case $<LatestTMFile> is specified there. This searches for the last available version of the model on the local engineering PC and then uses this as the basis for the version increment.
The version number consists of four digits, e.g. 1.0.3.2 or 2.12.123.14. Each digit can be incremented separately according to the scheme: <Major>.<Minor>.<Build>.<Revision>
For example, if the last version of a model named “MyModelXY” on the engineering PC is found to be 1.2.12.4 and the increment is set to “Revision”, a version 1.2.12.5 is created.
If “None” is selected, no version update takes place and the last version on the engineering PC is overwritten.
Default of a fixed version number
If a version is to be specified in Simulink®, this can be done via DrvFileVersion. Simply enter the target version in the input field.
In the Engineering Repository, a folder is created under the model name for each version created. Each version folder then contains the corresponding drivers and TwinCAT files. See also TwinCAT objects.
Presetting of a version number via an external file
You can also use an external file to specify a version. For example, this is a common method when using build agents at Continuous Integration.
For configuration in Simulink® set TC General Version part for increment to “None” and specify the full path to your version file at Version source file.
Structure of the external file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="major" value="1" />
<add key="minor" value="3" />
<add key="build" value="1301" />
<add key="revision" value="267" />
</appSettings>
</configuration>
Use versioned models in TwinCAT XAE
All models available in the Engineering Repository can also be instantiated in any available version. To do this, navigate through the tree as usual to find the TcCOM of your choice. In the last hierarchical level, you can now also select the version of the TcCOM.
As an example, two versions (0.0.0.4 and 0.0.0.5) of SimpleTempCtrl are available here: