Configure Function Block Templates

Function block templates allow you to define reusable logic that can be applied across one or more flowsheets. This is especially useful when you anticipate that a particular function block will be used repeatedly.

When a function block template is updated, all flowsheets that reference it will automatically adopt the new logic.

Note

For templates already being used in flowsheets, the template changes are limited to equation updates. I/O pins cannot be added or removed.

To help organise your templates, you can group them into categories. These categories make it easier to locate and select the appropriate template within the Flowsheet Manager.

You can perform the following actions with function block templates:

  • Create new templates

  • Update existing templates

  • Delete templates that are no longer needed

  • Assign templates to categories

The steps for managing templates and categories are outlined below.

Create Function Block Templates

  1. Choose Configuration ‣ Calculation ‣ Function Block Templates from the menu.

  2. On the Function Block Templates tab, click add Add on the toolbar.

  3. In the FB Template Configuration dialog, enter data as follows:

    Field

    Description

    Name

    Enter a name that uniquely identifies the function block template.

    Description

    Provide additional information about the template’s purpose.

    Image

    You can add an image to the function block template, which will represent the function block in the flowsheet and will also appear next to the template in the Flowsheet Manager’s Palette.

    First upload the image using the Upload button (if it hasn’t been uploaded yet) and then select the image file from this field.

    For example, if you’ve uploaded a blue plus icon for the AddTwo function block template, it will appear in the Palette instead of the standard function block template icon:

    ../_images/conf.calc.fbtemplate.image.png

    Logic Type

    Select the logic engine that interprets the logic in the Expression field:

    • mXparser: for mathematical expressions using mXparser syntax.

    • Python: for logic written in Python.

    • Thermo: for thermodynamic-specific logic (if applicable).

    For more information about these logic engines, see Calculation Logics.

    Secure Equations

    Click this button to lock the expression and prevent unauthorised editing or viewing. Use this to protect sensitive or proprietary logic.

    Expression

    Enter the logic for the function block using one or more equations. Each equation must be placed on a separate line.

    If using mXparser logic, note the following:

    • Each equation must end with a semicolon (;).

    • You can include comment lines by prefixing them with //.

    • Any argument that matches a pin name or parameter name will use the corresponding pin I/O mapped value or parameter value.

    • Arguments that match a pin name with the suffix xQV will access or assign the quality of that pin.

    • Arguments that do not match any pin or parameter name will be treated as internal variables within the expression.

    For more information, see mXparser Calculation Logic.

    Validate Equations

    Click this button to check the syntax and logic of the expression based on the selected Logic Type.

    • If the expression is valid, a green message confirms successful validation.

    • If there are errors, a red message appears with details to help correct the issue.

    Equation Validated

    A system-controlled checkbox that is automatically checked when the expression passes validation. This provides a quick visual indicator of whether the logic has been successfully verified.

  4. Save your entries.

  5. Add pins to the function block template as required. If your expression contains variables, you have to create a pin for each:

    1. On the Function Block Templates tab, expand the details for the relevant template by clicking add at the start of the row. one

    2. On the Pins tab, at the top right side of the expanded view area, click add next to the Search box to add a new entry for input or output pins. two

    3. In the new row that is added, make the following entries:

      • Type field: Select IN or OUT to determine if the pin is an input or an output for the function block. three

      • Pin Name: Specify the variable that the pin represents in the expression. four

      • Description: Enter a description if required (optional).

    4. Click saveblue to save the new entry five.

    ../_images/conf.calc.fbtemplate.pins.png
  6. Optionally, you can define parameters to use within the expression of a function block template. A parameter is a named variable with a constant value, such as a fixed number or unit. To create a parameter:

    1. On the Function Block Templates tab, expand the details of the relevant template by clicking add at the start of the row. one

    2. Go to the Parameters tab.

    3. At the top right side of the view area, click add next to the Search box to add a new entry. two

    4. In the new row, make the following entries three:

      • Name field: Enter a unique name for the parameter

      • Description: (Optional) Add a brief description of the parameter.

      • Value: Enter the constant value for the parameter.

      • Unit Type: Select the appropriate unit type (for example, Area, Distance).

      • Unit of Measure: Choose the unit (for example, m², m, kg).

      • Read Only: Select this option if the parameter should not be modified during execution.

    5. Click saveblue to save the new entry four.

    Once defined, you can reference the parameter by name in the expression field. For example, if you define X1 as an area with a value of 5 m², you can use X1 in your logic, and it will be replaced with the defined value during calculation.

    ../_images/conf.calc.fbtemplate.parameter.png
  7. If required, you can validate the expression using the tick button in the Action column for the function block template.

    ../_images/conf.calc.fbtemplate.verify.png

Update Function Block Templates

To update the main attributes of a function block template:

  1. On the Function Block Templates tab, click edit in the row of the relevant function block template.

  2. In the FB Template Configuration dialog, update values as required.

  3. Save your entries.

To update the pins or parameters of a function block template:

  1. Ensure that the template is not in use in any flowsheets.

  2. Expand the details of the relevant template by clicking the add icon at the start of the row.

  3. Go to the Pins or Parameters tab as required.

  4. Update the entries:

    • Click edit in the row of an item to update its values.

    • Click delete in the row of an item to delete it.

Delete Function Block Templates

You can delete one or more function block templates as follows:

  1. On the Function Block Templates tab, select one ore more rows using the selection icon at the start of the row. one

  2. Click delete Delete on the toolbar of the tab. two

  3. Confirm the deletion in the dialog that appears.

    ../_images/conf.calc.fbtemplate.delete.png

Create Categories for Function Block Templates

You can group function block templates into categories to organise them more effectively and simplify selection in the Flowsheet Manager. To create a new category:

  1. Choose Configuration ‣ Calculation ‣ Function Block Templates from the menu.

  2. On the Function Block Templates pane, go to the Categories tab.

  3. Click add Add on the toolbar.

  4. Enter a name and a description in the Category dialog.

  5. Save your entries.

    ../_images/conf.calc.fbtemplate.category.png

Assign Function Block Templates to Categories

You can assign function block templates to categories in the Flowsheet Manager as follows:

  1. Choose Configuration ‣ Calculation ‣ Flowsheets from the menu.

  2. At the top of the pane, click Configuration to enter editing mode.

  3. In the Palettes area on the left side of the Flowsheet Manager, right-click the function block template you want to assign.

    Templates that haven’t been assigned to a category yet appear under the UnAssigned category.

  4. From the context menu, select Assign To and choose the required category from the list of predefined options.

    For example, you want to assign the MultiplyThree function block template to the Multiplication category:

    ../_images/conf.calc.fbtemplate.category.assign.png

Result

The function block template gets added under the selected category:

../_images/conf.calc.fbtemplate.category.assign2.png