I am trying to run a named query based on a change in a PLC tag to update a perspective screen. I have a named query defined and which runs at an absolute rate. How to write an expression for poll rate field, to define a rate based on the tag from PLC like if that is ON, poll rate is this etc.
I did the same as above for a dataset on a named query. What I observed is, unless I open the binding and click ‘Ok’, the data is not getting refreshed for the time mentioned. Intention is poll every 6sec for tag ON and 30sec if OFF.
If I have to add another tag to the same expression, can I use if( {tag1} AND/OR {tag2}, 6, 30) as in meeting both tag conditions or atleast one of them?
I never noticed you can add an expression to the poll rate in a named query binding, lol. Although, I usually turn polling off, and refresh with refreshBinding() as needed.
^^ This method. its effectively only running the query when its required, not constantly in the background. Minimises the unnecessary resource usage, which will bog down your DB server as you put more load on it as you scale.
Any system that polls will become a resource hog as demand grows, thats why you see the rise of webhooks, event based systems (Event Streams) and listeners. Polling is essentially what makes the AB driver use so many resources, it transfers data on a timeline instead of when it changes. MQTT is generally so lightweight because its only normally set up to transmit changes of state, not variables that are stagnant.
Keep in mind that MQTT (and built-in PLC OPC servers) still depends on polling, but is doing it outside Ignition. This is why such technologies in PLCs have rather strict quantity limits--those devices have CPUs that are optimized for logic solving, not change detection. (Change detection is additional state to manage, somewhere.)