Tag Scripting alarm event - Alarm Active Event Never Fires

I have a UDT tag with a alarm and that tag has an alarm active event as follows:

def alarmActive(tag, tagPath, alarmName, alarmEvent, alarmPath, missedEvents):
	msg_nr = "[.]../obj/nr"
	action = 1
	project.operatorIndexScript.auto_select_operator_interaction(msg_nr, action)

But for some reason this never fires when the alarms gets active. Any solutions to this problem or is there something wrong with my code?

Whatever project this function is defined in needs to be configured as the Gateway Scripting Project: Project Library - Ignition User Manual 8.1 - Ignition Documentation

1 Like

The function is in my project that this events is triggered in. So I think that my way of calling the function is wrong then. How do you call the function when it is in the same project? Because if I delete 'project' it doesn't work either.

No, it's not.

Like the documentation I just linked you to explains, tags are not part of a project, they are a global resource.

ah I understand! I think this is enough for me to get it working!

Okay I thought that I would be able to get it working now but I'm not. I added my project name in the gateway scripting project. And run the code again but it is still not working. I have tried multiple ways to call my function but nothing seems to work. Any Idea's of what could be wrong now?

Do you get an error in the logs ?

No not that I can see on the gateway

My project name where the script is in is named as follows:
image
and I entered this in the gateway scripting project:
image
with the same code as at the beginning of the post:

def alarmActive(tag, tagPath, alarmName, alarmEvent, alarmPath, missedEvents):
	msg_nr = "[.]../obj/nr"
	action = 1
	project.operatorIndexScript.auto_select_operator_interaction(msg_nr, action)

And I get no errors and don't see any errors in my log on the gateway. What could be wrong here? some bug??

Try this and see if there's anything in the logs:

def alarmActive(tag, tagPath, alarmName, alarmEvent, alarmPath, missedEvents):
    system.util.getLogger("doesItRun").info("The script does run")

If there's no entry that matches in your gateway logs, the script doesn't even run.
If there is, it runs but doesn't do what you think it does... what does the script you call here do ?

okay it does run! but it gives me the error that project is not defined:

The script that is called places a tag number in an array.

Go to your script library, and copy the path of your function to make sure you get it right.
Right click on the function's name on the right part of the editor:
image

It is working now!! I have still some other issue with my coding that gives me another error but I will try to fix it my self first. Thanks for the help.

I'm trying to figure out if it is possible do pass a UDT tag to the alarm event I have.
As you can see in the function alarmActive I send earlier I have a UDT tag passed as parameter to my script.

"[.]../obj/nr"

But this does not work and I can understand why, but maybe someone knows a way that I can pass this tag as a parameter in my UDT?


As you can see in the picture above, I have the alarm event bound to the prompt tag and I want to pass the nr tag in obj to the event. But the way I have configured it now doesn't work.

this error is what I'm getting:

after changing the tags datatype to an integer the error goes away but the tag still isn't passed to the script.
When msg_nr is changed to any number it does work so why does't it when you give it a tag that also has a integer?

This doesn't work because you're trying to use a relative path somewhere there's nothing to be relative to.
Do you need the actual path, or would the value be enough ?

well I just need the value of 'nr' that is in the same UDT as where the tag 'prompt' is in.

Then read the value and pass it to the script.

If you can't rewrite the script because it's used in other places...
Use this:

path = '/'.join(tagPath.split('/')[:-2]) + "/obj/nr"

Reading it did some good work but the value is an integer and it says that it is not or atleast it can't convert it:

Because you're using the list of qualified value instead of just the value.

qval_list = system.tag.readBlocking(tags_paths)
single_qval = qval_list[0]
value = single_qval.value

# in just one line:
value = system.tag.readBlocking(tags_paths)[0].value