Update table data populated from a script - best practice

We are using the Sepasoft SPC module, however this question is really about general Ignition functionality around it, so it feels appropriate to post here.

We have a perspective view containing a table to display upcoming samples. The table data is bound to a location property and then a script transform is applied to run a sepasoft script which returns a dataset containing a list of samples.

The issue we have run into with the script transform is there seems to be no good way to make the table update when new samples are generated from the SPC module. In the sepasoft 'sample due' event script I have included the following:

system.util.sendMessage('SPC_proj','SampleUpdate',scope="S")

I then have a 'SampleUpdate' session event message handler which sets a session property:

session.custom.sampleUpdate = True

On the view containing the table I have a label whose text property is bound to the the 'sampleUpdate' session property, and the text property has an change script which resets the custom session prop and sends another message:

system.perspective.sendMessage('TableUpdate')
self.session.custom.sampleUpdate = False

And my table then has a TableUpdate message handler to refresh its data binding.

This all works but it seems like a particularly clunky way to go about things. What is the best way to refresh a component binding other than a message handler which by design needs to come from another component?

1 Like

Your verbiage suggests you aren't using your table's .refreshBinding() method to trigger re-execution of your data binding. You haven't provided any code that does, so I think not. That's probably your answer.

If the update from Sepasoft is supposed to be global, consider using an integer gateway tag as your UI trigger, and simply increment it. On your table, include a custom property bound to this tag, and attach an onChange event to it that calls self.refreshBinding('data'). I suspect you will find that architecture easier to reason about than messaging.

2 Likes

I am using refreshBinding() and the existing set up works, I was simply looking for a neater solution.

I don't love the idea of a hardcoded global tag path in a custom sepasoft script but it does appear to be the best option.