Pydataset in SFC

Hi I am having trouble running a query in an SFC step.

[code]# reset index

chart.index = 1

query for routine where the remainder of chart.index divided by priorty is equal to 0

query = "SELECT path, priority FROM routine WHERE ?%priority = 0"
params = chart.index
chart.routine_dataset = system.db.runPrepQuery(query,[params])	

not sure if this is necessary

data = chart.routine_dataset

set the number of rows of the dataset to determine the number of times to loop through it

chart.routine_dataset_length = data.rowCount

[/code]

The next step this is what I am doing to write to the tag paths stored in the dataset.

[code] row = chart.routine_dataset_index # determine row based on routine dataset index

col = "path" #	we want the column named Path

chart.routine_path = chart.routine_dataset.getValueAt(row,col) #get the tag path based on row and column


system.tag.write(chart.routine_path,1) #	write the demand poll bit to true


[/code]

followed by

	chart.routine_dataset_index = chart.routine_dataset_index + 1

Hey Zack,

It looks like you may need to understand differences between PyDataSets and Datasets better. They are two different data structures that are related but different. They both hold the same kind of data but access it differently. Check out PyDataSets and Datasets in this documentation: inductiveautomation.com/support … atatyp.htm

Look at the examples of how data is accessed using PyDataSets and how data is accessed using Datasets. A database query returns a PyDataSet. So your code needs to access the data using the PyDataSet style unless you turn it into a Dataset.

Python scripts in SFC charts are gateway scripts. My article on debugging and testing gateway scripts may help you find out why scripts aren’t working. My article is here: perfectabstractions.com/blog … nt-scripts

Awesome that you are using SFC charts. I’d love to hear your experiences with them sometime.

Best,