Create a dataset of live tag values, what is best practice?

I would like to create a dataset that contains a list of tags with various live values of tag properties (value, converted value, units, timestamp, quality). Currently I am running a script every second that reads the tag values, calculates and creates a dataset. The script is driven by a power table custom datetime property event I call “clock”. I bind the custom property “clock” to the tag “[System]Client/System/CurrentDateTime”. Then in the power table propertyChange event handler I have the following code:

if event.propertyName == 'clock':
	udtPath = event.source.udtTagPath
	ds = makeLocalizedTagDataset(udtPath)
	event.source.myDataset = ds

# prototype code...
def makeLocalizedTagDataset(udtPath):
     #get a list of tag paths for all tags in UDT with system.tag.browseTags()
     #read the tag values  with  system.tag.readAll()
     #convert some of the tag values to local units
     #create a dataset
    # return dataset

This works just fine, but it does a tag read of a group of tags every second which may or may not play nicely with the GUI thread, I don’t know. I am thinking there might be a better more event driven way to do this. Ideas ? Will I run into any issues the way I have written this ?

Example output:

Can you just use a cell update binding? You’ve got to ‘hand crank’ the many bindings once, but you also never have to worry about the EDT, and we’ll batch things together for you automatically.

The list of tags is dynamic , there are calculations on some cells that are fairly complicated, special formatting and I am not sure how to set cell bindings in a script.
Thanks for reply !

Ah, yeah, then you’ll have to do something via script. The EDT won’t be an issue unless you manually invoke an asynchronous thread, but you probably will want to, and separate your browsing from your tag reading operations. Ideally, I would say to cache the browse results to another custom property on the table, then reference those in the script that actually puts values on the table.

Not sure what you mean by EDT ?

EDT = Event Dispatch Thread (what you don’t want to hang up if you’d rather not freeze the interface).

1 Like