Now() in Expression Tags

Hello,

If I put “now(5000)” in an expression tag the tag will keep updating the time once a second instead of once every 5 seconds. If I put “now(0)” in a tag expression the time will continue to be polled once a second. This is contrary to the documentation in the Ignition User Manual.

The pollRate argument to “now” is being ignored in expression tags.

How it is currently working is “now” is executed by the scan class for the tag and the polling is being done according to the poll rate of the scan class.

This is in Ignition 7.6.6 on Linux.

[derp] didn’t try exactly what you said the problem was. Never mind! :blush:

I didn’t see what you must have originally written. In any case it is all good. :slight_smile:

I finally got a chance to test this out while I was waiting for code to compile. :slight_smile: I think this is working exactly like the documentation. Here’s why:

Expression tags execute each time the scan class executes. So if your scan class is 1 second, the expression tag will execute now(x) every second, and give you the current time. So what happens if you change your scan class to 10 seconds? The expression tag won’t execute for 10 seconds, and your time won’t update for 10 seconds, even though now() has executed every second.

Try putting two labels on a screen, one with the text bound to now() and one to now(5000). You’ll see that the times are updating every second and every five seconds.

Kathy, I think your explanation is interesting but it ignores that the “now(pollRate)” function in an expression tag does not exhibit the end result expected behaviour that is documented in the Ignition User Manual for that function.

The pollRate argument is clobbered by the scan rate and is effectively useless in a tag expression.

The runScript expression function with its “pollRate” parameter has the same problem that now(pollRate) has. Someone else wrote about it here: viewtopic.php?f=72&t=12271&p=44499&hilit=now+expression+tag#p44499

I can test if runScript with a pollRate of one second runs once a second in an expression tag with a scan rate of 10 seconds.

I used this expression in an expression tag and the “[default]test” tag to test this:

toint(runScript("system.tag.write('[default]test',system.tag.read('[default]test').value+1)",1000),7)

This expression should increment the “[default]test” tag every second even though the scan class on the expression tag is 10 seconds, but it does not. The runScript “pollRate” argument is effectively and pedantically not working.

Anyway, I think the real issue and the real question is why do expression tags have scan classes associated with them? If they need them then why should they clobber the pollRate parameters of now and runScript? I might be wrong but it seems to me that in an earlier version of Ignition expression tags didn’t have scan classes or they didn’t effect the pollRate of now() and runScript.

Perhaps the issue I have brought up here in the first place is a bit persnickety since it is easy to configure and use a scan class on an expression tag that uses now() or runScript(). I do at least think that some additional documentation should be added to the now() and runScript() functions saying that the pollRate parameter doesn’t work in expression tags and that the scan class is used for polling instead.