Perspective interactions with Gateway Scripts

Hi, I’m looking for some help in setting up an interaction between a component in Perspective (an on/off toggle) and a Gateway Timer Script. The script is setup to generate a series of tasks (DB insert operations basically) every hour and I’d like that script to be something that can be turned on or off by a user using the toggle. Can this be done?

So you want it so your gateway timer script only runs if and only if that toggle button is in the “on” position essentially?

I would make a Gateway Memory tag thats a bool or int, lets call it enable_timer_script, and in your perspective project, the value of your button is bound to this tag/writes to it. So if your button is on, the tag = 1 or True (depending on what type you used).

Then, in your gateway timer script, I would start off the entire thing with

if system.tag.value("enable_timer_script").value:
    # Do rest of script

Unless I am misinterpreting what you are asking for.

That’s exactly what I’m looking to do.
Thanks so much! I’ll that out.

A small note:

This should be

if system.tag.readBlocking(['path to enable_timer_script'])[0].value:

Can you explain why in this instance? I thought readBlocking was only necessary if you had a list of tags you needed to get at the same time? Since this is only one tag, I thought system.tag.read().value would work here.

Also, I meant system.tag.read("enable_timer_script").value, not system.tag.value("enable_timer_script").value

system.tag.read is technically deprecated

1 Like

I was mainly meaning that system.tag.value didn’t exist. However, as @bschroeder said, system.tag.read has been deprecated, so any new scripts should use the appropriate functions for the case.

system.tag.readBlocking(), system.tag.readAsync(), system.tag.writeBlocking(), system.tag.writeAsync()

1 Like

One more question actually:
Can new system tags be freely created? ‘Create new tag’ options are grayed out when using the System tag provider for me.
If not, I’m wondering if a Project scoped tag would work just as well even though it’s a Gateway script. that’ll be referencing the tag. This should be the only project running on the Gateway so I don’t see a conflict there.

So tags are gateway scoped not project scoped (Except for Vision Client tags).

System tags are pre-defined tags that the gateway creates, not tags that are available across the entire system. Each tag, except for Vision Client Tags, is available across all projects on the gateway.

1 Like