Execute SubTrigger


The Execute SubTrigger executes a subtrigger that is defined on the local node. The trigger that is the target of this action must be a SubTrigger event type trigger. The Fire Trigger action is used to execute an On-Demand event type trigger. Both On-Demand and SubTrigger event type triggers can use all of the available actions on the node.

  • Subtriggers can define input and output variables, pass data between the calling Execute SubTrigger action and the subtrigger. For more information on defining SubTrigger event type triggers, see SubTrigger
  • On-Demand triggers can be executed by the calling Fire Trigger action and by the Workbench from the triggers project window. For more information on defining On-Demand event type triggers, see On-Demand
  • Both can be executed with an option to wait for its completion.

Because subtriggers can define input and output parameters, they are very useful for defining common application logic that needs to be executed from multiple triggers. The data passed between the calling trigger and the subtrigger is used to provide the dynamic runtime information from the context of the calling trigger to the common subtrigger.
This is a common application pattern of consolidating common application logic into a sub routine or common function.

Parameter descriptions

Parameter Description
Project Name The project on the local node where the subtrigger resides.
SubTrigger Name The subtrigger to execute.
Wait for Completion The options are:
  • True - Initiates the execution of the subtrigger and waits for the subtrigger to complete its execution. This is referred to as synchronous processing.
  • False - Initiates the execution of the sub Trigger but does not wait for the subtrigger to complete its execution. This is referred to as asynchronous processing. There is no guarantee as to the concurrent execution of the calling trigger and its actions and the called subtrigger and its actions. Either one may be executed first or complete first. Any access to common resources, such as device variables must be understood by the application developer.
Dynamic Project If set to True, you need to provide the Project name in the input tab. The Sub Trigger will be executed in the provided project at the same time when this trigger is executed.

Input tab


The Input tab will display the input variables as defined by the subtrigger. These parameters are passed from the calling Execute SubTrigger action to the subtrigger. Each input variable has the data type that it was defined with by the subtrigger. If the data types of the input variables do not match the data types as defined by the subtrigger, the subtrigger will fail.

Output tab


The Output tab will display the output variables as defined by the subtrigger. These parameters are passed from the subtrigger back to the calling Execute SubTrigger action. Output parameters can only be passed back from the subtrigger when the Wait for Completion parameter is True.

Each out variable has the data type that it was defined with by the subtrigger

Example usage of the Execute SubTrigger action

In this scenario there is a need to select rows from a database at various phases of the production cycle. The selected data is used as input in various calculations and the results are fed down to a series of device variables, which vary depending upon the point in the production cycle the product currently resides. Many different triggers are defined that are launched when various device variables are activated. Each of these triggers could contain an action that would select the data from the database table and perform the calculations against the data. This presents a maintenance problem in that typos could be introduced into the definition of the calculations from one trigger to the next. Likewise, error or exception handling may be needed that would be replicated through each of the triggers.

A more desirable solution is to move these routines that are common to all of the triggers into a subtrigger. Now each trigger will reference the subtrigger in the Execute SubTrigger action and the caller of the subtrigger can be assured that the data will be processed in a like manner regardless of where it is called.

Related Topics Link IconRelated Topics