Steps to Create a Function Template

Overview

EcoStruxure Machine Expert provides 2 ways to create a function template:

  • From the Macros view using the Create New Template dialog box.

  • From the Applications tree or Functional tree using the Save as Function Template dialog box.

The following paragraphs list the steps that have to be performed in order to save already available application functions that meet the criteria stated in Application Functions as Basis for Function Templates as function templates.

Procedure via Macros View

The procedure via Macros view allows you to create your own function template by dragging and dropping elements:

Step

Action

1

In the Macros view, expand the section My Template.

2

Select the My Template node, and click the green plus button.

Result: A new node with the default name LIB1 is inserted below the MyTemplate node.

3

Select the LIB1 node and click the green plus button.

Result: The Create New Template dialog box displays.

4

In the Function Template tab of the Create New Template dialog box, enter a Name for your function template.

Drag the elements you want to include in the function template from the Applications tree to the Elements box of the Function Template tab. The elements listed in this box is inserted in your function template.

NOTE: The elements must belong to the same application.

5

The Parameters tab of the Create New Template dialog box displays those variables that are included in the elements you selected in the Function Template tab.

From the list of variables, select those you want to declare as template parameters by selecting the check box of the variable or of a node.

6

The Properties tab of the Create New Template dialog box allows you to add further information to the function template.

You can insert a link to the online help of this function template. The dialog box allows you to add further textual information that can be localized, and you can add a graphic illustrating this function template. For a description of these parameters, refer to the chapter Adding Further Information for Templates or Template Libraries.

7

Click the Save Template button.

Procedure via Applications tree or Functional tree

To save an already available application function as function template, proceed as follows:

Step

Action

1

Right-click a subfolder of an application node in the Applications tree or a functional model node in the Functional tree.

2

Execute the command Save As Function Template from the contextual menu.

Result: EcoStruxure Machine Expert automatically builds the application. After the built process has been successfully completed, the Save As Function Template dialog box is displayed.

3

Define the new function template as stated below.

4

Click OK to close the Save as Function Template dialog box and to create your new function template.

Result: EcoStruxure Machine Expert verifies that the function template can be created and displays a message that the function template has been created successfully or indicates the errors detected.

Assigning a Template Name

In the Template Name text box of the Save as Function Template dialog box, define the name under which the function template is stored in the template library. By default, this text box contains the name of the folder that contains your application function in the Applications tree but you can adapt the name to your individual requirements.

Selecting the Template Library

To select one of the previously installed or created template libraries in which your new function template should be stored, proceed as follows:

Step

Action

1

In the Save as Function Template dialog box, click the ... button next to the Template Library text box.

Result: The Select Template Library dialog box is displayed.

2

The Select Template Library dialog box displays the template libraries that have been installed for the open project or have been created. Write-protected libraries are not displayed.

To add your new function template to one of these template libraries, select the suitable entry and click OK.

Selecting Variables as Parameters

You can define variables of the function template as template parameters.

To define variables of the function template as template parameters, proceed as follows:

Step

Action

1

In the Save as Function Template dialog box, click the ... button to the right of the Parameters text box.

Result: The Select Variables as Parameters dialog box is displayed.

It displays the variables that are defined in the selected application.

2

Select the check box of an individual variable to select it as template parameter for the function template.

Or select the check box of a root node to select all elements below this node.

3

Click the OK button.

Result: The selected variables are displayed in the Parameters text box of the Save as Function Template dialog box.

They are displayed in the Parameters table of the Add Function From Template dialog box where you can assign New Values for these parameters.

Overwriting an Existing Function Template

To overwrite an existing function template with the selected application function, proceed as follows:

Step

Action

1

In the Save as Function Template dialog box, click the ... button right to the Template Name text box.

2

Browse to the already available function template you want to replace.

3

Select the function template you want to replace.

Result: The name of this function template is inserted in the Template Name text box and the name of the template library where it is stored in is inserted in the Template Library text box.

4

Click OK to close the Save as Function Template dialog box and to replace the selected function template with the new application function.

Adding Further Information to the New Function Template

To add further information to the new function template, click the Properties... button. The Properties dialog box opens. It allows you to enter further information for the function template. Since the dialog box is identical for device templates and template libraries, see the description in the Adding Further Information for Templates or Template Libraries chapter.