Raising and Monitoring Signals Example Flow Chart

Raising and Monitoring Signals Example Flow Chart

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.

Running this Example from the XML File

If you wish to run this example using an existing flow chart, create a new flow chart and select the “Import one flow chart from XML file:” check box. Then click the folder browse icon to browse for the “.ffc” file to import. Select the flow chart located in the same directory as this example and click “Open” then click the OK button. See Figure 1 below.


Figure1: Importing a Flux Flow Chart

Before running the imported flow chart, you must set up the File Modified Trigger's file criteria manually. For steps on how to set up the file criteria, follow the instructions in the “File Modified Trigger” sub-heading of this document.

Getting Started

Open the Flux Designer by executing the desktop-designer script from the Flux installation directory. The Designer will be used to create and execute the example flow chart.

Once you have the Flux Designer running, open the project that is located within the same directory as this example resides in, “/examples/end_users/signals”. To open the project, click the Open Project icon, browse to the previously mentioned directory, open the “fluxproject.fpr” file.

Next, make a new flow chart, by either going to the “file” pull down menu at the top left of the screen and selecting “New”. Select the “New Flow Chart” option and click .


Figure3: "New" Options

Name the flow chart “Signals” and click .

Creating Actions

Next, create the actions used in the flow chart. Locate the actions and triggers needed within the “Action” and “Trigger” tabs to the left of the drawing canvas as shown in Figure 4 below. Drag the actions listed below in the bulleted list into your drawing canvas and arrange them according to Figure 5 displayed below.


Figure4: "Action" and "Trigger" Tabs

The bulleted list below gives you the following information: The name of the action or trigger you need, the category that the action or trigger is located under, and how many instances are needed for this example.

 “Action” Tab:

· Action: “Console Action”, Category: “Core”, Quantity: 5

“Trigger” Tab:

· Trigger: “Delay Trigger”, Category: “Most Popular”, Quantity: 3

· Trigger: “File Modified Trigger”, Category: “Most Popular”, Quantity: 1


Figure5: Raising and Monitoring Signals Actions Layout

Setting up Flows

Next we need to create the flow from each action and trigger. Use Figure 6 displayed below as a guide to set up the flows for your flow chart. Follow the list of instructions below to create the flows.

1. Click the blank white space within your drawing canvas.

2. Click and hold on the action you wish to draw the flow from.

3. Drag your cursor to the action you wish to draw the flow to and release.


Figure6: Signals Flow Chart Layout

Editing the Action Properties

Delay Triggers

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

Console Actions

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.

 
 
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.