Defining and Starting your first trigger

The second step is to define a trigger to read a variable from the device and send it to the Management Portal. Since triggers are members of projects, you must first define a project before you define the trigger.

Defining the project

  1. From the Workbench left pane, select and then expand the Asset Gateway node that you want to add the project too.
    An expanded tree view of the selected Asset Gateway node appears.
  2. Select the Projects icon.
    The Projects window appears as the right pane.
  3. From the bottom of the Projects tab, select New.
    The Create Project window appears.
  4. Enter My Project as the name for the project, and then select OK

    The project name is added to the Projects tab.
  5. Right-click the project to display its pop-up a menu, and then select Start. The project is started. 

Defining the trigger

Now that you have a project, you can define a trigger in the project.

  1. From Workbench left pane, select the Projects icon.
    The Projects window is displayed in the right pane.
  2. Double-click the My Project project.
    The My Projects tab is added to the Projects window.
  3. From the bottom of the My Project tab, select New

    For this example, the New Trigger window opens in Canvas Editor mode. 

  4. The areas of the Canvas Editor are as follows:

    Event pane

    This is where you choose what event causes the trigger to execute. For example, when data changes, or on a periodic schedule.

    Action list

    This is the list of available actions that you can use the canvas. You can drag the action and then drop it on the canvas.

    Canvas

    This is where you define the application logic, or workflow, of actions that will be executed when this trigger event occurs.

Defining the event

The following describes an example data trigger event. You are going to define the event to poll the CPU usage on the Asset Gateway every 5 seconds.
When the data changes by at least 10%, the trigger will execute. 



Reference

Description

a

In the trigger Name parameter, enter Update_CPU_usage.

b

Use the Trigger Event Type down-arrow, and then select Data.

c

Set the Priority parameter to 5000 milliseconds This will poll the System Monitor CPU usage variable every 5 seconds.

d

Set the Variable Name parameter to System Monitor.CPU.CPU Usage. The System Monitor device must be in a started state in order to be able to access the CPU usage variable.

e

Use the Condition down-arrow and then select On start or value changed. This condition is special, in that it will cause the trigger to execute when the value changes, and also when the trigger is first started. This is useful for when you want to seed the initial value to a remote system.

f

Set the Deadband Range to 10.

Adding the actions

Next, you are going to define a trigger action to send the value of the CPU usage to the Management Portal as a gateway attribute so it can easily be seen from the portal.

The following assumes that the New Trigger window is opened and you selected use Canvas Editor from the New menu when you defined the trigger. The left pane of the New Trigger window provides an expandable list of actions that you can drag to the canvas area.

  1. From the left pane of the New Trigger window, locate and then expand the action group named Thing.
  2. Drag the Publish Property action from the left pane action list onto the canvas below the Start icon. 

  3. Drag the End Execution (Success) icon from the Canvas Editor toolbar onto the canvas below the Publish Property action.
    Drag the End Execution (Failure) icon from the Canvas Editor toolbar onto the canvas to the right of the End Execution (Success) icon.
    The Canvas Editor toolbar is above the action list and the canvas (hover the mouse over the icons for icon tips).
  4. Connect the blue route arrows between Start and Publish Property and between Publish Property and End Execution (Success).
    Connect the red route arrow between Publish Property and End Execution (Failure)
    The completed trigger will look similar to this: 

  5. Double-click Publish Property action to edit its properties.
  6. Enter values for the parameters on the Input tab:
    • For the Property parameter, enter CPU_Usage in the value column. The valid characters for a key are letters, numbers, "_" (underscore), and "-" (hyphen).
    • For the Value parameter, select the down-arrow, expand EventVariables, and then select Data.
      This tells the action to use the data value that came from the variable that you defined for the data event above.
    • For this example, leave the ThingKey, Correlation ID, and Timestamp parameters empty. 


  7. Close the action properties window by selecting the red X in the upper right corner.
  8. Select Validate to have the trigger editor validate the trigger parameters, actions and action parameters.
    If there are any warnings or error displayed, review the topic and correct the problem.
  9. Select Save to save the trigger definition to the Asset Gateway.
    The new Update_CPU_usage trigger is added to the My Project project tab.

Starting the trigger

The next step is to start the trigger.

  1. From the My Project tab, right-click the new trigger to display its pop-up menu, and then select Start.
  2. Select the Refresh button at the bottom of the tab to refresh the view.
    You should see that your trigger is started, has loaded, and has at least one success.
  3. If your trigger has not fired, check to make sure the Status column shows Loaded; if not, then check that your project is started. 
    If the execution of the trigger failed, make sure that your Asset Gateway is still connected via TR50.
    This can be done from the TR50 window.