How to set indicator value on Vision momentary Button Component with isAlarmActiveFiltered()

Hello ,

I am currently developing a gateway where I will have 5 zones and on a navigation bar I wanted to have 5 buttons that use indicator value bindings to drive a fault graphic. I found the isAlarmActiveFiltered expression and after playing with it I could get active alarms with specific display path key words to set the indicator value to 1, but if there is no alarm the component is broken like a "BadNotFound" quality tag. Since i ran into a wall there, I am curious if there is a way to bind the scripting function for filtering the alarm status table in a Custom Method script that will filter on associated data "Group" that can set the indicator value to 1 if there are any "associated data" filtered alarms?

IsAlarmActiveFilter returns True/False, so it's probably an issue with using a Boolean as an integer.

Add an if statement in your expression and return 1 if true and 0 if false.

Ok that makes a lot of sense, being that the binding would be broken unless there was an alarm present.

Forgive me , is there a certain way to implement the if statement in the expression. I am entry level at scripting and cant seam to see this in a way that makes sense to run trial and error in the expression binding window.

Change your expression to something like:

if(isAlarmActiveFiltered(your, settings, here),
   1,
   0
  )
1 Like

thank you I appreciate it. I was no where near close to this.

Some reference material:

https://docs.inductiveautomation.com/display/DOC81/Expression+Functions

Code Snippet

if ( 1 , "Yes" , "No" ) //Would return "Yes".

after reading the DOCs again, I still dont understand where the true false evaluation comes in.

if there more I to add besides the settings.

this is what i am trying to run in the expression:
if(isAlarmActiveFiltered("", "", "South Cold Storage", 4, 4, 0, 1, 0),
1,
0
)

if(condition, trueReturn, falseReturn)

The expression in the condition portion of the function needs to evaluate to true/false.

What is the result of this? (maybe make a separate expression to monitor it)

isAlarmActiveFiltered("", "", "South Cold Storage", 4, 4, 0, 1, 0)

the result is the Button component gets a 1 pushed to the indicator value property binding initiating a style change.

It worked to turn on the button but two things happened:
A. when there were no alarms present there was a BadNotFound quality assessment on the binding
B: when the true came back and pushed a 1 to the indicator value it never cleared back to 0 turning the component back to its 0 value for the Style Customizer settings.

Just noticed that perhaps it should be (note the asterisks in the first two arguments).

isAlarmActiveFiltered("*", "*", "South Cold Storage", 4, 4, 0, 1, 0)

For some reason they didnt transcend when i copied, but the asterisks are in place for the first two settings and still not the correct evaluation.

I think the idea that this is returning a boolean in the place where ignition is looking for a 1/0 is really good starting point, but it seams to be advanced expression to convert it. I think if i was to make this visible and not a style change maybe it would be more straight across because visible looks for boolean response automatically?

This isn't correct. For Boolean purposes, True, False and 1, 0 can be used interchangeably without issue, but my preference is True, False.

You can also use

1*isAlarmActiveFiltered(your, settings, here)

thank you for the correction.

After creating some test expression tags, I have found that if the state of the alarm is active in ignition when I set the expression up and press ok to create the tag it causes an evaluation that sets the value of the tag in that moment.

both parts of the expression work individually,

if({[.]AStatus}="true", 1, 0)

isAlarmActiveFiltered("", "", "Machine Area", 0, 4, 0, 1, 0)

But it doesn't constantly evaluate for the alarm that i can tell testing in the tag browser.

Does this sound right ?

I know very little about how expression tags execute.

i just figured out you can set a poll rate to evaluate constantly.

In my tag I had first set "Event Driven"
Then i realized i can set a fixed rate.

Thanks for all the input guys