SFC Instance with key parameter

I have an SFC that also includes a key parameter. I would like to be able to only have one instance of this running at a time (same key parameter). I’m trying to figure out how to detect if an instance is running with the same key. How can I tell if one is running? I’d like to disable the start button that runs the startChart command if it is already running another instance with the same key parameter.

I think that this function should help you out with that:
docs.inductiveautomation.com/di … ningCharts

This function will return a dataset with the columns instanceId, chartPath, startDate, startedBy, chartState, keyParamName, keyParamValue

[quote=“adam.morales”]I think that this function should help you out with that:
docs.inductiveautomation.com/di … ningCharts

This function will return a dataset with the columns instanceId, chartPath, startDate, startedBy, chartState, keyParamName, keyParamValue[/quote]

This works. Thank you very much. I’m looking to see if there is a chart that has the same keyParamValue, and it works great. Interesting when i look at the dataset and look at the chartPath (and compare to a string) that works fine, but when looking at chartState, and compare to “Running” it never seems to work. I’ve tried several ways, and even though in a table it shows up as Running, when I do a compare to the value it is always false. also tried RUNNING and running. I skipped this for now, since it is only a problem for a few seconds after the SFC stops. It sits at stopped for a few seconds before the instance disappears from the list of charts. I’ll just have to make sure that they can’t attempt to start right after the sequence ends.

The chartState is a ChartStateEnum object, rather than a string. But you can obtain a stringified version by calling its toString() method. For example:

[code]ds = system.sfc.getRunningCharts()

for row in range(ds.rowCount):
state = ds.getValueAt(row,‘chartState’)
print state.toString() == ‘Running’[/code]