Skip to main content

Section: SourceTemplate

The subsections of section SourceTemplate defines the function blocks to be copied into the project.

In the module editor the here-defined function blocks get listed. There you can activate or deactivate the copying.

. See also
SEC std.SourceTemplate
 SEC SourceFB : <Identifier>               // optional: no
  SourceType := <FunctionBlock>;           // optional: no, type: InstancePath
  Variable := <variable name>;             // optional: no, type: InstancePath
            Default := TRUE/FALSE;                   // optional: yes, type: Bool Flag
            IsMandatory := TRUE/FALSE;               // optional: yes, type: Bool Flag
            FBVariable := <variable name>;           // optional: yes, type: InstancePath
            DestinationType := <default name>;       // optional: yes, Type: String/Literal
 END_SEC
END_SEC

Details regarding the syntax of definition types are described in the section Module Declaration.

. Specification:
  • The Identifier is used in the module editor. It defines the name of the copied function block if DestinationType is not defined.

  • SourceType defines the function block to be copied.

  • Variable defines an input variable of the module function block. It must be a pointer to a basic class of the copied function or an interface, which is implemented by the function block to be copied.

  • Default defines if the function block is copied by default for this module. If the definition is missing, TRUE is set. This option can be adjusted in the module editor.

  • If IsMandatory is set to TRUE, the user cannot change the IsToCopy option in the module editor.

  • FBVariable defines an input variable of the function block to be copied. The input variable is then instantiated with the module instance. The type of the input is a pointer to a basis type of the module FB or a pointer to the interface of the module FB.

  • DestinationType defines a standard name for the copied function block. If the definition is missing the following naming convention is used: <Name of the module instance>_<Identifier>[_<consecutive number>].

The specified SourceTemplates are copied to the AC_SourceTemplate folder. They are instantiated and initialized by the assigned module FB. SourceTemplates, once created, can be edited and will not be overwritten by renewed generator runs. SourceTemplates, which are no longer required, get renamed (with the <_unused> suffix) and moved to the <UnusedSourceTemplates> folder.

Example 22. Example
SEC std.SourceTemplate
        SEC SourceFB : ID_ConnectSwitches
                SourceType := ConnectSwitches;
                Variable := itfConnect;
                FBVariable := pBuilding;
                Default := TRUE;
                IsMandatory := FALSE;
                DestinationType := 'TypeInModuleDescription';
        END_SEC
END_SEC