Ignition Designer Freezing with a History Tag

Multiple things going wrong here:

  • Never import libraries within a function. Imports should be at the top of a script library. Performance impact
  • Never import system. This is always* available and can cause issues if imported.
  • You’re trying to run a history query from the start of this year until now, every second. This is impossible. You’re likely ending up with stacked threads all querying tag history, and they’re building up not able to keep up with your request rate. The database is also being hammered with queries looking at significant amounts of data.

I would be curious to see exactly how long it does take the script to run..

However, I'll say that I would move this into a tag instead which accumulates hours and historise the tag if you need to trend it, but use the accumulator tag value to show runtime, not queries / tag history. Ideally the tag should be accumulated in the plc, not scada. But if youre just wanting “decent” runtime values, scada will be OK.

I think this looks OK, although I don't know how accurate it will be…

A bit dated though.

For the expression tag expression I'd be using:

if({[.]running tag}, getSecond(now()) % 2, -1)

That will flip flop the value every second to create the accumulation pulse trigger. Use that to trigger its value change script to run if value >=0 which reads the current value of your memory accumulator tag, and add 1s to it

Note: it's not usually recommended to call tag.read / writeBlocking from tag event handlers since they can sometimes take time to read if there are issues, but memory tags are an exception.

5 Likes