This lesson is part of the Sequential Function Charts in Ignition course. You can browse the rest of the lessons below.

LESSON LIST

Autoplay Off

Description

Even the best designed chart isn't any good unless it is started correctly. You can start a chart in four different ways: from scripting (using system.sfc.startChart and the Callable execution mode), from an Enclosing Step, automatically (using the RunAlways execution mode when the Gateway starts), and from the Designer.

Video recorded using: Ignition 7.9

Transcript

(open in window)

[00:00] In this lesson, we're going to learn all of the different ways in which you can start a Sequential Function Chart. The first way that we've already seen a number of times during these lessons is in the Designer, if you have a Chart open for design view, and that Chart is valid, it compiles without any errors, and the Execution Mode is Callable, then you can start an instance of that Chart, right within the Designer, using the Chart Control panel's Start button. So, I can go ahead and start this Chart up, and you can see I've got a running instance of it. If I hit Start again, it starts a second instance. This method of starting a Chart is also compatible with parameters to a limited extent. This Chart has two parameters, one of which is a Key Parameter. So, you can pass this Chart the total number of times in which to execute this Loop, and then it also initializes an internal variable that's not the Key Parameter count. So, if I start this Chart through the Designer, it's going to ask me to provide a value for the Key Parameter. So, I can go ahead and give it a value of, let's say three, and you can see that the Loop Total Key Parameter is three, and this thing is going to Loop three times, after which point, it simply ends. To pass multiple parameters, use scripting to start your Chart. Now, let's see how to use scripting to start a Chart Instance. You'll use the system.sfc.start Chart function to start a Chart via scripting. The Chart needs to be in Callable Mode, and be aware that you're starting whatever Chart you've last saved. So, if you have edits in the Designer, those aren't going to take effect until you've saved them. So, you can call system.sfc.start Chart from anywhere in the system. In this case, I'm just going to use the script playground, but you could use a button press, or a tag change script, anywhere that can use scripting in Ignition. You can call system.sfc.startChart, and you pass system.sfc.startChart, the path to the Chart. So, I'm going to go ahead call our LooperCount Chart. And then you give it a Python Dictionary with all the parameters you want to pass. So, in this case, I'm going to pass one parameter, my Key Parameter, which is the LoopTotal. So, the keys of your dictionary should be strings representing the parameter names, and the values can be whatever values you want to pass. So, I'm going to go ahead and pass 10 to Loop 10 times, and run this script, and we should see that we've got a new instance of LoopTotal running now, and it's going to Loop 10 times because that's what I passed for the Key Parameter. I'll go ahead and cancel this Chart, and then we can look at some other ways that we start Charts. A Chart might also be started by the Gateway itself if the Chart is set to RunAlways Mode. You can see, if I change this Chart, we'll cancel these ones I'd already started, and I set the Mode to RunAlways, and save this Chart, the system will start up one instance of this Chart. Of course, with RunAlways Charts, it doesn't make any sense to have Key Parameters because nobody is manually invoking an instance of the Chart, so there's no parameters to be passed. I'm going to go ahead and change this chart back to Callable, and Save, and we can cancel the RunAlways Instance that had gotten started. The final method of starting a Chart that we're going to look at is starting a Chart via an Enclosing step. So, we're going to make a Chart that runs the LooperCount Chart using an Enclosing step. So, I'll open up a new Chart, and we'll make a very simple Chart here that just has an Enclosing step, and the Enclosing step's going to run LooperCount in Block mode because we want to wait for all the Loops to complete. And, it has to pass the LoopTotal, which we'll make five. So, go ahead and Save this Chart, and Start it up, and here you can see this Chart is running, but if we go back to LooperCount, you can see that our instance of LooperCount with a LoopTotal of five is also running. And, if you monitor this Chart, you'll notice that the Scope is pretty much the same as we saw before, except that now we have a parent entry. This is a reference to the Parent Chart Scope. And those are all the different ways that you can a Sequential Function Chart.

You are editing this transcript.

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