Trigger gateway event on seconds

Hi Team ,

We need to trigger transaction groups hourly using a tag, with the trigger written via a gateway event script. The requirement is to execute it at the 29th minute and 55th second of every hour, but we’re unable to find a way to schedule it at the second level. Could someone please help?

I assume you are currently using the Scheduled Gateway Event Script?

Have you concidered using a Gateway Tag Change script? You could look at the gateway time (now) and toggle a tag whenever the time is equal to xx:29:55.

I’m not sure how sturdy this solution is, but it might be worth a try. Good luck!

1 Like

We are not using a scheduled script. The trigger is handled through an expression tag, and when the condition evaluates to true, a memory tag is set to true to trigger the transaction group.

Okay. I’m not sure what exactly your question is. Would you like help with the expression in the expression tag? If so, please share your current solution and the solution you’re looking for.

This is our current solution - The trigger is handled through an expression tag, and when the condition evaluates to true, a memory tag is set to true to trigger the transaction group.

In order to avoid more threads , we are trying to move the expression to gateway event script .

The current Gateway Event Scripts don’t have a more sophisticated way to send this trigger with your wished precision.

If you compromise on precision, and trigger at xx:29:00 instead of xx:29:55, it can be done easily, but I understand if you’re not willing to do that.

Whilst scheduled scripts don’t have a [Seconds] property (Feature request, IA?), before scheduled scripts were introduced, you would create a timer script and compare if CurTime == Target, with that you can do any custom range, including what the OP wants.

I’m not a big fan of TGs, I generally script my inserts instead, but with the TG triggers it should be possible to have multiple trigger tags that are on a combined condition of each, one for hour, one for minute and the last for seconds. Or create a single tag for trigger, and use my aforementioned gateway timer script to check if it should be set high or not.

If I understand it correctly, you’re suggesting a timer script that checks every second, whether the time is xx:29:55?

I’m not too familiar with efficiency, but wouldn’t an expression tag with the same check, which is their current solution (i assume), be just as sophisticated?

Two expression tags:

TriggerVal
dateFormat(now(), 'mm:ss')

Trigger
{[.]TriggerVal} = '29:55'

Then use the trigger tag in a gateway event script EDIT: This will also work with TGs

1 Like

Yes, but TG’s have their limitations, which is why I never generally sell that module to my customers.

So I script both the time check and the DB inserts.

1 Like

How accurate of data are you expecting? Specifying 59:55 makes me think this is some kind of accounting before an hourly volume rollover? Either way I would do this all in the PLC instead.

Build a routine that compares system min/secs to 59:55 then when true it moves your live values into holding tags. If your PLC is clearing it at the top of the hour then that's even better. Just add moves into new tags on the same rung. Then run a scheduled event in Ignition shortly after that captures all those values and records them. This ensure that even if some tasks are executing on the gateway it will never be delayed or missed..

1 Like

Never use real time clocks in PLCs for reporting purposes, they’re always wrong. Gateways are best for this as they become the single source of truth on the timestamps

1 Like

Unless they are Rockwell, and using PTP time synchronization to a proper grand master. They will be more accurate than any general purpose system using NTP.

2 Likes

There's no warnings when the PTP drops and the existence of a properly configured grand master is very rare. This is why I recommend against it. You can also use NTP on most PLCs, but its never set up and you shoudn't rely on it.

#Added this script to record the time at 29 min 50 sec to get Target 60
    if not initialChange:
    
        if currentValue.value :
            
            provider = 'MES'
            
            query = {
              "options": {
                "includeUdtMembers": True,
                "includeUdtDefinitions": False
              },
              "condition": {
                "path": "Chennai/*/Hourly Recording/Record",
                "attributes": {
                  "values": [],
                  "requireAll": True
                }
              },
              "returnProperties": [
                "tagType",
                "quality"
              ]
            }
            results = system.tag.query(provider, query)
            for tag in results:
                    system.tag.writeBlocking(str(tag["fullPath"]), True)	

I have been using this expression in global tags -

if ( dateExtract({[.]Current Time},"minute")= 29 && (dateExtract({[.]Current Time},"second") >= 54 && dateExtract({[.]Current Time},"second")<= 59), 1, 0)

The global tag becomes true at the 29th minute and around the 54th second. Based on this, another memory record tag is being set to true across nearly 100 instances. However, the record tag write is getting delayed by about 10 seconds, and this delay occurs randomly across different machines.

I have attached the code which is triggering the record tag to true

this expression is written in every 100 instances , we just changed it to global tags instead of every instance