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¶
Choose
from the menu.On the Function Block Templates tab, click
Add on the toolbar.
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:
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.
Save your entries.
Add pins to the function block template as required. If your expression contains variables, you have to create a pin for each:
On the Function Block Templates tab, expand the details for the relevant template by clicking
at the start of the row.
On the Pins tab, at the top right side of the expanded view area, click
next to the Search box to add a new entry for input or output pins.
In the new row that is added, make the following entries:
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:
On the Function Block Templates tab, expand the details of the relevant template by clicking
at the start of the row.
Go to the Parameters tab.
At the top right side of the view area, click
next to the Search box to add a new entry.
In the new row, make the following entries
:
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.
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.
If required, you can validate the expression using the
button in the Action column for the function block template.
Update Function Block Templates¶
To update the main attributes of a function block template:
On the Function Block Templates tab, click
in the row of the relevant function block template.
In the FB Template Configuration dialog, update values as required.
Save your entries.
To update the pins or parameters of a function block template:
Ensure that the template is not in use in any flowsheets.
Expand the details of the relevant template by clicking the
icon at the start of the row.
Go to the Pins or Parameters tab as required.
Update the entries:
Click
in the row of an item to update its values.
Click
in the row of an item to delete it.
Delete Function Block Templates¶
You can delete one or more function block templates as follows:
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:
Choose
from the menu.On the Function Block Templates pane, go to the Categories tab.
Click
Add on the toolbar.
Enter a name and a description in the Category dialog.
Save your entries.
Assign Function Block Templates to Categories¶
You can assign function block templates to categories in the Flowsheet Manager as follows:
Choose
from the menu.At the top of the pane, click Configuration to enter editing mode.
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.
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:
Result
The function block template gets added under the selected category:
