This example will guide you through the steps of raising and monitoring signals within a single flow chart using the Flux GUI. Signals are the mechanisms used to set up dependencies and correspondence between actions in a single flow chart. With this feature you can notify actions that a certain path in the flow chart has been followed, or that an error has occurred.
In this example you will set up a flow chart with a File Modified Trigger that searches for files changed in a certain directory. When a file is changed the change will inform an action to take the proper measures. For this example, the File Modified Trigger will fire which raises a signal that is then received by a Delay Trigger. Once the signal is received the Delay Trigger will flow down the specified signal flow.
This example also demonstrates the behavior of signals. When an action receives a signal, the action needs to finish what it is doing before flowing down its signal flow.
Viewing the Example Files
Your Flux installation includes a working, pre-constructed version of this example. To load the example file:
- Click the "Repository" tab.
- Choose the "Workflows" option.
- Click the "Upload" button.
In the dialog that appears, browse to <Flux Home>/examples/end_users/signals, and select the .ffc files located there.
When the workflow finishes uploading, select it from the grid and choose the "Edit" button to view the workflow in the Designer.
Navigating to the Designer
The Flux Designer will be used to create and execute the example workflow. To use the Designer, browse to the Operations Console and select the "Designer" tab.
When you visit the Designer, you'll se a blank workspace representing the new workflow. To create the example, we'll start by populating the workflow with a few actions.
When you return to the Designer, you will see a blank workspace representing the new workflow. To create the example, you will need to populate the new workflow with a few actions.
To add an action to the workflow, you'll first need to select the action's category in the panel to the left of the workspace. Once you've selected the appropriate category, the action will appear in the panel – left-click the action and drag it onto the Designer workspace to add it to the workflow.
The following table contains the type, category, and quantity of each trigger and action we'll use in this example.
|File Modified Trigger||File||
Setting up Flows
Using the image below as a guide, create flows between the actions. To create a flow:
- Click the connect button the Designer toolbar.
- Click and hold the left mouse button on the action you wish to draw the flow from.
- Drag your cursor to the action you wish to draw the flow to and release.
Editing the Action Properties
Now we need to set both “Delay Trigger” and “Delay Trigger 2” to be start actions. Start by right-click on the trigger labeled “Delay Trigger”. Click on the option “Start Action” on the drop down menu that appears. Do the same for “Delay Trigger 2”. You should now have two Delay Triggers as start actions.
Next, make sure no other actions within your flow chart besides “Delay Trigger” and “Delay Trigger 2” are start actions. If there are other start actions then use the steps above to deselect the start action check boxes.
Now, click on the trigger labeled “Delay Trigger”. The “Action Properties” window will appear at the right of the window. Move your cursor over the “Time Expression” field under the “Action Properties” window. Click on the “Delay Time Expression” value field until you are able to edit it. Type the time expression “+2s” into the “Delay Time Expression” field to give the trigger a delay time of two seconds before firing.
Do the same for “Delay Trigger 2” and “Delay Trigger 3” except set “Delay Trigger 2” with a delay time expression of “+4s” and “Delay Trigger 3” with a delay time expression of “+1m”. See Figure 7 below for a reference.
Figure7: Editing the "Time Expression" Field
Click your Console Action named “Console Action”, which should be directly under your “Delay Trigger”. Move your cursor over the “Message” field under the “Action Properties” tab. Edit this field to say: “The flow has started on the right!”.
Do the same for “Console Action 2” except have it read: “Flow has started on the left!”. Use Figure 8 below as a reference.
Figure8: Editing the Console Action Message
Add messages to the remaining Console Actions. Let’s start with the Console Action the File Modified Trigger flows into, “Console Action 3”. Type the String, “The File Modified Trigger has fired!” into its “Message” field.
Next, click on the Console Action to the left of “Delay Trigger 3”. Edit its message to read: “Regular work has started”.
Finally, edit the Console Action to the right of “Delay Trigger 3”, the signal action. Edit this Console Action’s “Message” field to read: “Signal flow has been followed!”.
File Modified Trigger
Next, click on the “File Modified Trigger”. Move your cursor over to its “Action Properties” panel and click the “File Criteria” field. Click the "Edit" box located to the right of the “File Criteria” field represented in Figure 9 below.
Figure9: "File Criteria" Property
A window similar to Figure 10 below will appear on your screen. Click the "Add" button and Figure 11, also displayed below, will appear.
Figure10: File Criteria
Figure11: File Criteria Editor
Click the "Next" button three times. You should now be at the “Base Directory” stage of the file criteria set-up. Click the Browse icon and browse to the directory this example is located in, "examples/end_users/signals", and click the “Open” button. You may also specify a relative path to the directory "signals" directory. Your screen will look similar to Figure 12 below. Click the "Next" button.
Figure12: File Criteria (Base Directory)
You will now be at the screen represented by Figure 13 below except your window will have a blank text field in the middle. Click the "Add" button and type in “*.txt”. This will tell the File Modified Trigger to search for any files that are of type “.txt”, or text files. See Figure 13 below for a reference. Click the "Next" button twice to skip the “Exclude” and “Regular Expression Filter” steps; we will not need them for this example. Now, click the "Finish" button at the bottom of the window.
Figure13: File Criteria (Include)
You should now be back at the window represented by “Figure 10: File Criteria” which was shown earlier but this time with your directory’s address and “Include” terms. Click the "OK" button at the bottom of the window.
Lastly, set the File Modified Trigger's "Stable Period" to "+1s". This will ensure the file is stable before the trigger fires.
Setting up Signals
Raising a Signal
You should now be back at the main Flux GUI screen. We need to now set up a signal to be raised if the File Modified Trigger fires.
Do this step by, first, right-clicking on the flow located between your File Modified Trigger and the Console Action it is flowing to. Use Figure 14 below as a guide.
Figure14: Flow Menu
Next, click the “Edit signals to raise” option on the drop down menu that appears. The window represented by Figure 15 below will appear.
Figure15: Signals to Raise Editor
Finally, click the "Add" button. The blank text box in the middle of the window will become editable. Type “filemod signal” into the text box, then click the "OK" button. Use Figure 16 below as a reference.
Figure16: Signals to Raise Editor (edited)
Monitoring for a Signal
You should be back at the main Flux screen. Now we can setup the Delay Trigger to monitor for a signal.
First, click on “Delay Trigger 3”, within your drawing canvas, and move to its “Action Properties” panel. Click on the “Signals To Monitor” field. Then double-click on the “Value” field of the “Signals To Monitor” field until the "Edit" box appears at the right. Click on this box and a window similar to Figure 17 below will appear.
Figure17: Signals To Monitor Editor
Click the "Add" button and the text field in the middle will become editable. Click the drop down menu arrow at the right of the text field. This will give you a list of signals that are being raised within your flow chart. Currently we have only one, so select that signal. The name of the signal should be “filemod signal”.
Once you have your signal selected click the "OK" button at the bottom of the window. You should now be back at the main Flux screen.
Setting up a Signal Flow
Next, we need to specify a signal flow that will be followed if the signal is received. Right-Click on the flow to the right of your “Delay Trigger 3” that flows into “Console Action 4” and a dialog as shown below in Figure 18 will appear. Click the “Edit flow condition” option and the dialog represented in Figure 19 below will appear.
Figure18: Flow menu
Figure19: Flow Conditions
Click on the “Signal Flow Condition” option. If the signal we are monitoring for, “filemod signal”, is not already in the “signal =” text box under the “Condition Expression” area at the bottom of the window, then click on the drop down arrow to the right of the “signal =” text box and select it. Then click .
You should now be back at the Flux main screen. Your flow chart should look similar to Figure 20 below.
Figure20: End Product Flow Chart
You should now have a working flow chart that uses a File Modified Trigger to watch for files in a specific directory. Once a file in that directory is changed it will send a signal to the Delay Trigger to flow into a specified action.
Creating a Flux Engine
Run the start-engine-unsecured script from the Flux installation directory to start an unsecured Flux engine.
Next, return to the Flux Designer and move your cursor over the “Flux Engines” tab located to the left of the workspace.
Click the button at the top of the “Flux Engines” tab and the window shown in Figure 18 below will appear.
Figure18: Job Scheduler Engine Setup
Click on the “Advanced” tab at the top of the window, then click the "OK" button.
You will return to the Designer workspace. Look at the “Flux Engines” tab again. The engine you just started should look like Figure 19, shown below.
Figure19: Indicator for running Engine
Running the Flow Chart
Next, export your flow chart to the engine. This can be accomplished by right-clicking anywhere on the Designer workspace and selecting the “Export to remote job scheduler engine” option. This menu is represented by Figure 23 below. Another way to export your job is by right-clicking on your drawing canvas and selecting the “Export to remote job scheduler engine” option. The menu and option are shown below in Figure 24.
Figure23: Export Menu
Figure24: Drawing Canvas Options
Click in the window represented by Figure 25 below.
Figure25: Export to Engine
A confirmation window, illustrated below as Figure 26, will appear if the job was successfully exported. Click the "OK" button on the confirmation message. If there is an error message, look over this example carefully, and correct any mistakes made.
Figure26: Successful Export of Job
Your job should now be running. If you look at the command prompt you are running the engine from, it should read: “Flow has started on the left!” and “Flow has started on the right!”.
For this example to demonstrate the use of signals, you need to open up the “File to be Modified.txt” file located within this example’s directory. Once you have this file open, type something into the body of the document. Now, close the document and say “yes” when prompted to save the changes to the document. When you have done this the File Modified Trigger will detect that the file has been changed and fire, sending a signal to the Delay Trigger. This Delay Trigger waits one minute for a signal to be sent, before moving on. If it receives the signal it will flow into its specified flow.
Once this example is completed, shut down the engine by running the shutdown-engine-unsecured script from the Flux installation directory.