Attaching generated list to a data table for a pop up window

Hello Everyone,

Application: I have accumulation section with 24 beds and there's individual PE's for each section. I want to create a pop up window with all the PE's listed in table to show where exactly the jam is using the following script.

step 1: I have multiple tags that I'm reading form a folder for an accumulation zone with 24 tags. so naturally built a tagpath list to read from.
step 2: read all the tags and used list comprehension to generate another list to store values that i read.
****part I'm currently cant get past is step 3
step 3: tag_value_list is what I'm trying to attach to a data table. and where should I apply this script on. possibilities i have considered so far (button action performed, project scripts).

acc_number = 12093701
bed_number = 24
end_acc_number = acc_number + bed_number
x = [item for item in list(range(acc_number, end_acc_number))]

#tag_base_path = "JAM_PHOTOEYES/12093730/1209370"
tag_base_path = "JAM_PHOTOEYES/12093730/"
tag_paths = [ ]
# These two for loops iterate over a range and generate tag paths for us to read from
for i in x:
    tag_path = tag_base_path + str(i)+"/AFE_Recirc_Pecblockage"

# this line reads all the tags at the path we specified
tag_values = system.tag.readAll(tag_paths)
#this list comprehension allows us to wrap all the values read in a list for us
tag_value_list = [tag.value for tag in tag_values]

# new to convert list into a dataset and bind data property of the table to this dataset tag

Please edit your post, highlight all of the code, then click the "preformatted text" button on the comment editor. This will make your code readable for us.

Thank you for your suggestion!!

1 Like

So, you need to use the system.dataset.toDataSet function to convert from lists to a dataset. Note that it needs a list of lists, where the inner list represents the row.

(Lots of examples scattered over the forum.)

1 Like

so according to the manual parameters/arguments this function calls for is (header, rows). However, when I do so it gives me error showed in the pictures.
PecblockageDataset = system.dataset.toDataSet("value",tag_value_list)

In your code, tag_value_list is not a list of lists (yet). Consider something like this for rows:

[[x] for x in tag_value_list]

Thank you!. Now that I have a dataset to work with. can you guide me through the last process/question i had for this problem. where should i apply to script to? action performed on the button? and how can I link to data table in my pop window?

From a script, you would assign the dataset to a component's data property. Or to a property that fed a binding to the actual display property. Or provide the dataset to a popup window via parameters, using a dataset custom property in the popup's root container. (Or view parameter, in Perspective)