LESSON

Enclosing Step

Description

Here is a detailed explanation of how the Enclosing Step functions in a Sequential Function Chart.

Video recorded using: Ignition 8.1

Transcript

(open in window)

[00:00] The enclosing step is another kind of step available for use in an SFC. Unlike the action step, which runs scripts, the enclosing step actually runs another sequential function chart. This is really powerful because it allows you to use the concept of encapsulation while designing your sequential function charts. So you can design charts that act like reusable pieces that can get called like functions from other charts. The main piece of configuration that you need to understand about the enclosing step other than of course picking which chart you want to run as your enclosed chart is the difference between block execution mode and cancel execution mode. If you remember back to our lesson about steps and transitions, you'll remember that a chart will move on past the transition when the transition is true and the step is ready to be stopped. When an enclosing step is in cancel execution mode and the transition beneath it becomes true, the enclosed chart is simply canceled right away, and as soon as that canceling is finished, flow will move past.

[01:05] If the enclosing step is in block execution mode, the step will refuse to move on until the enclosed chart is finished. For example, it would block the flow of this enclosing chart one until the enclosed chart that it's running has reached an end step. To see this in action, I have the charts transition set to this boolean tag named move on. We're going to use that to control whether or not this transition is true or false, and we're going to have our enclosing step run a chart I've made called delay chart. Delay chart simply waits for 15 seconds before reaching the end step. When I start enclosing chart one, we can see that it's running, and now our delay chart is running, but it will take 15 seconds to complete. I'm going to tell the transition to become true. This legend will remind us that the transition is now active and you can see that the enclosing step is still running, and this yellow indicates it's in the deactivating state. Now it's finished because the 15 seconds has elapsed. The important thing to realize here is that even though my transition became true, the enclosing step stayed in the deactivating state, which prevented the chart from moving to the end step until the enclosed chart was finished.

[02:11] We can compare that to if we ran the enclosing step in cancel mode. Let's set the boolean tag to false and run the chart. Again we have the same situation where the delay chart is running, but if I toggle the transition now in cancel mode, it moves through instantaneously because the delay chart was canceled. Besides block versus cancel mode the other configuration on the enclosing step is configuring how information is passed through the enclosed chart and how information is collected from the enclosed chart. To explain this, I'm going to use another example. I have a chart here called write and wait. This is a very simple chart that on start simply writes to a tag and it writes to the tag that has been sent to this chart as a tag path parameter, and it writes whatever value was sent to the chart as well, and then it waits for the value at that tag path to be confirmed as the value that was written. The action step also uses an on stop action that records the amount of time that the write took by comparing the current time to the time the chart started.

[03:06] Then it stores that as a string represented in milliseconds as a chart scope variable called write time. So I can use my enclosing chart two to call the write and wait chart. Within the enclosing step, it makes the most sense to use block execution mode since I want to wait for the write to be confirmed and read back from the device. I need to pass the tag path into this chart as a parameter. The tag path is an expression, so I need to use quotes and I need the value to write to the tag, So I'll set the value as three. I can take that write time variable that the write and wait chart is calculating and store it as a local chart variable called write time millis. All right, so let's go ahead and run this chart. You can see the chart has already finished. My example int tag has a value of three, and my right time millis is 10 milliseconds. So you can see how the concept of encapsulation can be used to create a series of utility charts that can be used at single steps from other charts that you have.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.