Skip to main content
Version: 5.6

Creating Templates

The following example assumes that the OPC server and database are correctly connected in the plug-in area. The goal is to create a template from which you can later generate multiple instances. In this example, a single template variable is sufficient to capture the data.

Example of a template with a Multi Data Change Trigger and database destination

Creating a Template

  1. In the “Templates” snap-in, select the “New Template” button (“New Template” button). Alternatively, right-click an existing entry and select “New Template.”
  2. Enter a name for the template.
  3. Define the connection properties. These settings will later be applied to all instances created from this template.
  4. Configure the connection within the template.

In this example, the OPC server is configured so that the data points have identical names and differ only in their access path. This variable part is therefore created as a template variable.

Creating a Template Variable

Context menu for creating, inserting, and editing a template variable

  1. Place a Multi Data Change Trigger object in the template and double-click it to open it.
  2. Open the context menu in the “OPC Data Points” field. There, you can create a new template variable, insert an existing template variable, and edit the field value using the Expression Editor if necessary.
  3. Select “Create Template Variable” and assign the name Machine.

The template variable is then used directly for the variable part of the path.

Using a Template Variable in the Trigger Object

Enter the properties. Insert the template variable into the field via the context menu. Then complete the rest of the path, using the Expression Editor if necessary.

In the example shown, this creates a Kepware browse path in which the machine name is inserted via the template variable Machine.

NameValue
OPC Connection<name der="" anbindung="" aus="" plug-in-konfiguration="">
OPC Data Pointsbp=Objects/2:{Machine}/2:SPS/2:Heater1;

Then close the Multi Data Change trigger object.

Add a Database Object

Now configure a DB Insert transfer object for logging. In this example, the ProcessValues table is used. The measurement series is defined by the MachineID and ItemName fields. With the exception of the machine ID, the data is provided by the OPC server via the Multi Data Change Trigger.

NameConfiguration
Data Source<name der="" anbindung="" aus="" plug-in-konfiguration="">
TableProcessValues
Columns -> UsedItemName (String), Value (Single), Value Time (DateTime), MachineID (Int32)

Complete the Connection

  1. Define a constant using the template variable “Machine.”
  2. Connect the constant to MachineID.
  3. Also connect Value, Value Time, and Item Name from the Multi Data Change trigger object to the DB Insert transfer object.

The template is now complete. You can organize templates into groups just like regular connections.

Using Template Variables in Objects

You can add template variables in two ways:

  • Using the “Add” button in the trigger and transfer object dialogs.
  • Using the buttons with the blue plus sign next to the individual fields. This creates and populates a new variable of the correct type.

Use the button with the red minus sign to remove template variables from the fields.

You can drag and drop existing template variables into the corresponding field.

Template Variables with OPC UA

Please note the following special considerations for configuration:

  • If the OPC connection itself is a template variable, the OPC Router cannot recognize the specification, and you will no longer be able to browse the trigger path. This also applies to OPC triggers (Bit, Datachange, Message, Threshold).

Creating Templates from Connections

You can also generate a template from an existing connection:

Dialog for creating a template from an existing connection

  1. Go to the “Connections” snap-in.
  2. Right-click the existing connection and select “Create Template from Connection.”
  3. In the dialog, enter a unique name for the new template.
  4. Select a destination folder if needed.
  5. Check the “Open template directly” box if needed.
  6. Click “OK” to confirm.