Triggering Tasks Externally

You can set up tasks to be triggered by external means such as keyboard shortcuts or RossTalk messages received from external systems. You can also use the ogScript function, ogscript.fireGPI.

Tasks are associated with certain types of components. You can create GPI triggers for these components so that when the correct message is received, the component’s tasks are executed.

Note: External triggering is in addition to normal task execution methods. For example, if you create a GPI trigger for a push button, that button’s tasks are executed when the GPI trigger message is received OR when the button is pushed.

Creating a GPI Trigger

To create a GPI trigger, you specify a text string that, when received by the component, prompts the component to run its tasks. GPI triggers can be set only on components with task lists, such as buttons, labels, and displayed parameters.

To create a GPI trigger:

1.Create the component and task list.

2.In edit mode, double-click the component to open its Edit Component window.

3.Select the Attributes tab for the component type (Param Attributes, Button Attributes, or Label Attributes).

4.In the GPI Trigger box, type the trigger text.

(Figure 1.23) shows the GPI Trigger box on the Button Attributes tab.

GPItrigger.png 

Figure 1.23  - Button Attributes tab, including the GPI Trigger box.

5.Click Apply and Close.

The component is configured for external triggering of its task list.

Triggering Tasks Using Keyboard Shortcuts

You can create a keyboard shortcut to trigger a component’s task list. When panel users type the shortcut, the tasks are executed.

To create a keyboard shortcut to trigger tasks:

1.Create the component (button, label, or displayed parameter), complete with task list and GPI trigger.

Note the GPI Trigger text.

2.On the Window menu, click Preferences.

The Preferences dialog appears.

3.In the menu list on the left side of the Preferences dialog, click Keyboard Shortcuts.

The Keyboard Shortcuts list appears.

4.Click the New Command button.

The Command Configuration Wizard dialog appears.

5.In the Available Commands list, click Fire GPI Trigger.

6.Click in the Shortcut box, and then type the shortcut sequence.

7.In the Active list, select DashBoard Context, and then click Next.

8.In the GPI Trigger box, type the GPI Trigger text.

9.Optionally, if you want to send an additional piece of text data when the keyboard shortcut is used, type the data in the State box.

The additional data can be used by ogScripts. For example, you may have two different keyboard shortcuts; one that triggers the task list and uses the State text to send an “ON” message to the ogScript to turn something on, and another shortcut with an “OFF” message.

10.In the Execution Level list, select one of the following:

All Editors — Sends the command to all open panels.

Active Editor — Sends the command only to the currently active panel.

11.Click Finish.

12.In the Preferences dialog, click OK.

Triggering Tasks Using RossTalk Messages

A component’s tasks are externally triggered when the GPI Trigger text is received by the panel. One method of sending the GPI Trigger text is to embed it in a RossTalk command. DashBoard must first be configured to listen for RossTalk commands.

The RossTalk sendMessage function is part of the ogScript language. In the following example, the GPI Trigger message “StartClock” is sent to the local computer (localhost), via port 7788:

rosstalk.sendMessage('localhost', 7788, 'GPI StartClock');

You can also include state data in the message. In the following example, the same GPI trigger is sent, but with state data, reset, appended to the GPI command. You can access the state data using the event.getState() function, as shown in the second line of the example. The second line checks whether the event.getState() function exists before calling it. This is important because the function is available only when the tasks are triggered through GPI, and not when triggered by other means such as a button click or parameter change.

rosstalk.sendMessage('localhost', 7788, 'GPI StartClock:reset');

var resetTimer = event.getState && event.getState() == 'reset';

For more information about using ogScript in CustomPanels, see Working with ogScript.

For detailed reference information about ogScript functions, see the DashBoard CustomPanel Development Guide (8351DR-007).

To Configure DashBoard to Listen for RossTalk Commands

1.On the Window menu, click Preferences.

The Preferences dialog appears.

2.In the menu list on the left side of the Preferences dialog, click RossTalk GPI Listener.

The RossTalk GPI Listener settings appear.

3.Beside Global GPI Listener, select Enable.

4.In the Listen Port box, specify the port for receiving RossTalk commands.

Tip: The default port is 7788.

5.Click OK.

Triggering Tasks Using the ogscript.fireGPI Function

A component’s tasks are externally triggered when the GPI Trigger text is received by the panel. One method of sending the GPI Trigger text is to use the ogscript.fireGPI function.

The ogscript.fireGPI function is part of the ogScript language. For more information about using ogScript, see Working with ogScript, and the DashBoard CustomPanel Development Guide (8351DR-007).