# Can an SFC run another SFC?

**URL:** <https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471>\
**Category:** General Discussion\
**Created:** [December 16, 2016, 8:07pm UTC](https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471 "2016-12-16T20:07:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![trogdor](https://avatars.discourse-cdn.com/v4/letter/t/b5ac83/32.png) [@trogdor](https://forum.inductiveautomation.com/u/trogdor)\
**Post date:** [December 16, 2016, 8:07pm UTC](https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471/1 "2016-12-16T20:07:03Z")

</div>

I’m interested in using SFC’s like Unit Procedures and Operations typically found on other batch systems.

Can Ignition’s SFC’s call other SFC’s?  
If so, can you drill down into the bottom level SFC and see its state like you can for the top level SFC?

Example of usage: I make an SFC called op\_MODE (Mode Operation), which I use as an operation to set a controller mode (Auto, Man, Cascade). I make another SFC called up\_INIT (Initialize Unit Procedure), which runs op\_MODE 10 times, to set the controller modes on my 10 controllers to Manual 0%.

Thanks!

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [December 16, 2016, 9:40pm UTC](https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471/2 "2016-12-16T21:40:36Z")

</div>

Yes, in fact this exact use case is being used by other customers.

An SFC may call other SFCs using the Enclosing Step. SFC scopes nest, so that from a charts scope you can walk up the call tree to parent scopes.

---

<div class="post-metadata">

**Author:** ![michael.palmer](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@michael.palmer](https://forum.inductiveautomation.com/u/michael.palmer)\
**Post date:** [April 19, 2017, 11:58pm UTC](https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471/3 "2017-04-19T23:58:36Z")

</div>

I want to monitor the status of an enclosed step. How to I get the chart ID from the enclosed step into the vision portion? Right now when I call the parent, I capture the ID and store it in a memory tag, but I’m not sure how to get the ID of the enclosed step with SFC calling it instead of the HMI calling it.

---

<div class="post-metadata">

**Author:** ![michael.palmer](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@michael.palmer](https://forum.inductiveautomation.com/u/michael.palmer)\
**Post date:** [April 24, 2017, 7:22pm UTC](https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471/4 "2017-04-24T19:22:57Z")

</div>

Anyone figure out how to do this?

---

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [April 25, 2017, 2:09pm UTC](https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471/5 "2017-04-25T14:09:45Z")

</div>

What I would do is make a chart variable in the enclosed step a key parameter, then pass a unique value of your choice (could be the parent chart ID or something else) from the parent chart to the key parameter when it creates the enclosed chart. Then anything can call the following (global) function to find the enclosed chart ID using the key parameter value:

`
def findRunningSFC(chartPath, keyValue):
```
data = system.sfc.getRunningCharts(chartPath)

for row in range(data.rowCount):
	chartKeyValue = data.getValueAt(row, "keyParamValue")
	if chartKeyValue == keyValue:
		chartId = data.getValueAt(row, "instanceId")
		break
	else:
		continue
else:
	chartId = None
	
return chartId

```
`

---

<div class="post-metadata">

**Author:** ![michael.palmer](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@michael.palmer](https://forum.inductiveautomation.com/u/michael.palmer)\
**Post date:** [April 25, 2017, 4:28pm UTC](https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471/6 "2017-04-25T16:28:44Z")

</div>

Thank you very much. That makes sense, and I’ll give it a try later today. Just like you said, I’ll pass the parent id to the enclosed chart and put it in a keyParam and look for the parents id there to find the enclosed chart id.

---

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [April 26, 2017, 2:38pm UTC](https://forum.inductiveautomation.com/t/can-an-sfc-run-another-sfc/12471/7 "2017-04-26T14:38:04Z")

</div>

Should have mentioned that the above function will only work on v7.9.2 and later, since system.sfc.getRunningCharts() was modified to accept the chartPath argument. If you have an earlier version, you will have to add another condition to test for the chartPath, since getRunningCharts will return all running charts.
