Skip to main content
Version: 7.9

system.sfc.getVariables

New in 7.9.2

This function is used in Python Scripting.

Description

Get the variables in a chart instance's scope. Commonly used to check the value of a Chart Parameter, or determine how long the chart has been running for.

Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.sfc.getVariables(instanceId)

Parameters

TypeParameterDescription
StringinstanceIdThe instance identifier of the chart.

Returns

PyChartScope - A python dictionary of variables. Step scopes for active steps are found under the "activeSteps" key. Below is a list of keys in this dictionary. In addition to those keys, Chart Parameters will also be included in the dictionary as keys:

  • Dictionary parent - If the chart is enclosed in another chart, this Dictionary returns information on the parent chart. Otherwise, returns None. The keys returned by the parent dictionary is identical to calling system.sec.getVariables() directly on an instance of the parent chart.
  • Unicode instanceId - The instance identifier of the chart.
  • Date startTime - The datetime the chart started.
  • Long runningTime - A long representing the amount of time the the chart has been running.
  • String chartPath - The path to the chart.
  • Dictionary activeSteps - A dictionary of active steps in the chart. The number of keys in this dictionary depends on the number of steps:
    • Dictionary %stepId% - Contains keys for each active step in the chart. The key of each step is the same as the step's UUID and the value is another dictionary with information pertaining to the current step. Each step has the following keys:
      • Unicode id - The Step's UUID value.
      • Unicode name - Name of the active step
      • Long runningTime - The amount of time the step has been active

Scope

All

Code Examples

Example #1 - Show Chart Data to the User
# This example will show the chart path and start time of a single chart in a messageBox.
# We can make use of the SFC Monitor component to give the users the ability to pick a single running chart

# Fetch the ID of a running chart. In this case, we used the Instance ID property on a SFC Monitor component
id = event.source.parent.getComponent('SFC Monitor').instanceId

# Retrieve the variables from the chart
chartVars = system.sfc.getVariables(id)

# Show the path and starttime of the chart in a messageBox
system.gui.messageBox("Chart Path: %s has been running since %s" % (chartVars["chartPath"], chartVars["startTime"]))
Example #2 - Print the Name and Running Time for All Active Steps
# Get the name and running time for each step in each running chart.

# Return data for running instances at a specific path. "folder/myChart" should be replaced with a valid path.
data = system.sfc.getRunningCharts("folder/myChart")

# Initialize a list to contain all instance Ids
chartIds = []
# Iterate through each chart, and fetch the instanceId
for row in range(data.rowCount):
chartIds.append(data.getValueAt(row, "instanceId"))

# Now that we have the ID for all active charts, pull variables out of each.
for id in chartIds:
chartVars = system.sfc.getVariables(id)

# Prints the chart instance ID. In the context of this example, this line is used to delineate
# between all our print statements.
print "Details for Chart ID: %s" % chartVars["instanceId"]


# Create a variable that references the activeSteps dictionary. Creating a variable here
# makes the syntax below a bit cleaner.
allSteps = chartVars["activeSteps"]


# Iterate through the active steps. A "step" represents the key of each step
# in the activeSteps ("allSteps") dictionary
for step in allSteps:

# store the value of the current step dictionary in a variable. This is simply to keep
# the syntax below clean. Equivalent to: chartVars["activeSteps"][step]
currStep = allSteps[step]

# Print out the name and running time of each step.
print "Step %s has been running for %i seconds" % (currStep['name'], currStep['runningTime'])