Note: This topic is featured in the "Build a Quality Inspection App" section of Tulip University.
Using Conditions, you can add if/else logic to Triggers.
You can think of conditions as a way to route an operator to a specific outcome depending on the trigger inputs.
Tulip allows you to add a single or multiple conditions and to choose whether “all” conditions or “any” condition must be met to result in an action being triggered.
You can do this on all three types of triggers:
- Button triggers
- Step triggers
- App triggers
Check out this article if you need an introduction to triggers.
Once you have selected the event, you must choose the type of value you will be checking.
Adding an "If" statement
Within the "If" statement, click "Add New Condition" on the right and choose from one of the eight options.
Here's an explanation of each option.
Then, you need to define the condition during the event required to trigger an output. Available conditional operators in Tulip are:
- Equals (=)
- Greater than (>)
- Greater than or equal to (≥)
- Inside range ( Y<X<Z)
- Is Blank (X=_)
- Is Not Blank (X≠_)
- Less Than or Equal To (≤)
- Less Than (<)
- Does Not Equal (≠)
- Outside range (X<Y | X >Z)
Note: The available operators depend on the type of values you are using for the condition.
To complete a Trigger, create the desired action or actions in the "Then" section.
- "Device" "Barcode Scanner" outputs at "this station"
- "Variable" "num" "=" "Static Value" "integer" "5"
- "Data Manipulation" "Store" data: "Device Output" "data" location: "test_variable"
How to Create an Example Trigger with Conditions
In this example, we will test to ensure that measurements from connected calipers are in range:
- Open a step within the desired app in the Tulip App Builder.
- Select the Step Trigger by clicking on the plus icon in the Context Pane.
- Name the trigger by clicking title in the Trigger Editor.
4. Set the Event:
- Select “device” in the dropdown menu
- Select “Caliper or Depth Gauge” in the second dropdown menu
- Select “this station” in the third dropdown menu
5. Set a Condition:
- Click the plus icon in the right side of the Conditions row.
- Select “Device Output” in the dropdown menu
- Select “data” in the dropdown menu
- Select “Inside range” in the operator dropdown to make sure the output is within the desired range
- Select “Static value” in the greater or equal to dropdown
- Select “Number” and input the number 20.
- Select “Static value” in the less than or equal to dropdown
- Select “Number” and input the number 40.
6. Set an Action:
- Click the plus icon in the right side of the Actions row.
- Select “Data Manipulation” in the dropdown menu
- Select “Store”
- Select “Device Output”
- Select “Length measured”.
- Select “New Variable” in the location dropdown menu and name new variable “In_Range”
Here's the full example from the Trigger Editor.
For more examples of commonly used triggers we recommend reading, "What are the 10 most commonly used triggers?"