Gateway Tag Change script issue

Hi Everyone,

I have written a gateway tag change scripts for a integer tag,
the script will execute every time when the value is changed in the tag.

but the question is how to execute script everytime even if the value in the tag remains same?

If the intention is that the script execute at a specified interval then you could create an expression tag that uses the runScript expression function. One of the parameters of runScript is the interval it executes on.

I…e…
The value of the tag will be passed as an argument to your function.

runScript(‘SomeGatewayScopedFunction’,1000,{[.]SomeTag})

I believe that using it this way could potentially eliminate the need for triggering on change.

The other option is Gateway Event Scripts that use the timer. A well documented path and also valid.

Excerpt From:
https://docs.inductiveautomation.com/display/DOC79/runScript

“The runScript function can be used in expression tags, but the poll rate doesn’t work exactly the same as in an expression binding. All Tags have a Scan Class that dictates the minimum amount of time between each evaluation. The runScript poll rate only polls up to the rate of the scan class set on the tag.
For example, if an Expression Tag is configured with runScript to run at a poll rate of 60 seconds and is using the “default” (1 second) scan class, the Tag’s Expression will still execute every 1 second. So a scan class rate of 60 seconds will be necessary for a runScript expression to poll at any rate between 0 and 60 seconds.”

The docs on runScript in gateway expression tags is terribly garbled. The poll rate in the expression is simply ignored, and the expression runs whenever the class is scanned.
There has been some past discussion of creating a special scan class that would function the way client tags and property bindings poll – on changes in bound values. I haven’t seen anything like that yet.
Bottom line: A gateway timer event script is the right solution for this problem.

1 Like

Hi,
the integer Tag i am using is linked to one of Card reader hardware. whenever RfID card is shown on card reader the Tag Change script should run.Even if same card is shown again the script should run.

But i dont want script to run based on timer , i want script to run at the time whenever the card is flashed on card reader even if it is same card or different ,using timer event script will not be much helpful in this case.

You’ll need some other signal from the reader to be your trigger, then. How can you expect a change event to fire if the value doesn’t change?

Is there any other way to achieve it?, because in my project i am controlling a batch process which when stopped in between then it should continue only when the same card is flashed.(different card is used when the batch process is started again from beginning)

What’s the source of the value? An OPC tag or is it coming into the system another way?

The gateway tag change scripts (the centrally configured ones, not the ones that are per-tag) can be configured to fire on timestamp changes as well. The problem is that OPC values don’t update on timestamp only changes so this value would have to be coming from somewhere else for that to work.

Can you write back to the card reader? You could set it back to zero or something like that after each read, having your script save the most recent non-zero value in a memory tag. The write will trigger another tag change event with newValue == 0, but you can have your script ignore those.

The RFID hardware should have a timestamp whenever it has a successful read. Can you set an event trigger based on changes to the RFID read timestamp and use that script to read the value you are interested in?

Hi pturmel,

i am able to write back to OPC tag which having attribute read/write. now after every read i am writing back zero to the tag.

Thanks for suggestion.

1 Like

Hi, everyone!
I see the problem I had before still remains. I wish this could be fixed somehow or solution is already found for my case, becouse for instance we needed to use additional PLC output tag to make a signal :slight_smile:
The task is to scan and register barcodes through TCP/IP stream. Very often we have similar barcodes, but they also have to be registered. In OPC tag we have same value and the tag value change event do not workas well.
In this case it should be something like ‘tag data received’ event. We tried to use recieve time, but sometimes wehave 2 similar barcodes in 1 second so time stamp does not changes as well. The only robust way (unfortunately) was to attach PLC to generate pulse each time we have to value from the tag. Becouse if we send somethingto barcode reader in this mode it just ignores us. No ability to receive something like ‘NO_DATA’ like some other models can. May be I can get some new ideas here? :slight_smile:

P.S. We asked support team a lot to help with this, but it works as it supposed to just no any solution was found for the task…

Regards,
Ihor

1 Like