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


Autoplay Off

Supplemental Videos


Chart scope is used to store information for a chart instance that can be used in any Step or Transition. The variables are stored in a Python dictionary.

Video recorded using: Ignition 8.1


(open in window)

[00:00] In this lesson, we'll define the concept of a chart scope and demonstrate the usage of one chart scope variable on a Sequential Function Chart. A chart scope is a place where variables can be stored for the lifespan of a chart instance. Each chart instance gets its own chart scope. Even if a single chart definition has many instances running, each one gets its own separate scope object. The variables inside the chart scope are accessed by the steps and transitions of the chart. Let's demonstrate this. We'll start by creating a new Action Step and connecting it. Then we'll create an On Start action. We can see that the new On Start action is given an input variable named chart. If we expand the Parameters pane and widen it a bit, we see that chart is a reference to the chart scope. A chart scope is stored as a Python dictionary object. Creating a new variable in it is very easy.

[01:06] We can just type chart.myValue = 5. This defined a new variable, myValue in chart scope, and assigns it the value 5 in integer. However, the values inside of the chart scope don't have to be scalar values like integers or floats, they could be any complex types such as Python lists or Ignition datasets, really anything that you could store in a Python dictionary. So this is how we create a new variable in chart scope. Next, let's use this new variable to control the chart flow by referencing it in a Transition. We'll start by adding left and right Transition elements, connecting them from the Action Step S1, and connecting each branch to an End Step, giving us an initially valid chart. Then let's configure both transitions using our created variable. In transition expressions we can reference variables in chart scope directly using curly braces.

[02:09] So for the left transition, we'll write {myValue} != 5. Then we will copy this expression so we can use it for the right transition, and for the right transition, we'll copy that over and update it to {myValue} = 5. As a side note, be aware that the curly braces are needed for Expression language syntax on transitions, but they are not needed for Python statements on Action Step functions. Finally, when we go ahead and save this chart, then head on over to the Chart Control pane to start it up, and monitor it, we see that it's followed the right side. myValue = 5 branch because we initialized myValue to be 5 in Action Step S1. Down here in the Chart Monitoring panel, this shows us all of the variables available in chart scope, including our value of myValue = 5, as well as other values automatically in chart scope for us.

[03:16] If we refer to the User Manual System Functions Reference for SFCs, the system library system.sfc, we will find a definition for all such available variables. So now we have seen what chart scope variables are and an example of how to use them on a Sequential Function Chart.

You are editing this transcript.

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