Basic Alarming in Express using blink function


Recommended Posts

I want to be able to get a basic visual alarm if a variable goes out of range (I.e. If pressures too high, the variable should become red, larger font, and blink).

I'm trying to use the color and size tabs in the component properties, but it won't work.

I'm attempting for the color to use the thresholds, but it won't work.

Also, for the increased size and blinking, I wanted to put simple "if" statements in for the expression, but the box stays pink. For example my code for size change:

If (pressure > 15)

25 // larger font size

Else

12 // normal font size

End

Using the below expression in the box dis work, but it wouldn't change back, hence why I tried the if-statement:

Pressure > 15, 25

and this did indeed change the font size, but it stayed large.

Thanks in advance.

Dan

Link to comment
Share on other sites

Okay, so I basically got the component (variable value) to flash and change color as needed, so that's good.

(I read in the help section that the color slowly-fades between the 2 selected colors as it approaches the "threshold" value, but for an alarm, you want an instant change.

So I basically put 14.99 = Black, and 15.00 = Red, so there's no annoying slow-fade, but quick color change).

But I still have that issue that the size increases above 15 PSIG, but then doesn't decrease once going back below 15PSIG.

I'd also like to have some way of whenever one of the variable values goes above the user-setpoint, that it also (in the expression somewhere I assume) sets for example "Daniel'sAlarm = 1", and then I can have an "ALARM" flashing text object on every screen alerting the user to go to the "Daniels Process Data" page that displays all the data so the user can then pinpoint where the issue is.

Any ideas.

Thanks for the great software and support.

Dan

Link to comment
Share on other sites

Sorry. I posted a nice reply shortly after your original post but then my connection timed out and I didn't check it. Now its gone...

Anyhow, you can't use if() in an expression. If() is a statement and expressions aren't script so can't take statements. Think of it this way: whatever you put in an expression must work on the right side of an = sign in script, and must return a value. So, since what you want to do is quite common, there is the iif() function, which stands for "inline if". Its common across all languages. Using your sample, it'd be:

iif(pressure[0] > 15, 25, 15)

And continuing with the expression thing, all three of the parameters of the iif() and any other function really, can be expressions themselves, so you could do:

iif(pressure[0] > userSetpoint, fontSize * 1.5, fontSize)

where userSetPoint and fontSize are varaibles.

Link to comment
Share on other sites

So I tried the iff function, and unfortunately the expression box is still pink and the variable value doesn't resize when I take the pressure up over 15 PSIG.

the exact text I have in the X Size Expression Box is:

"iff(CA_Skid_Pressure > 15, 20, 12)"

I.e. when the pressure goes over 15 PSIG, I want the text size to increase from 12 to 20 points.

Thanks,

Dan

Link to comment
Share on other sites

I am what is termed "an absolute plonker"... I just realized that I'd put "iff" (me thinking it was a mathematical operator 'if and only if') and not "iif".

Just made the change and it works perfectly!

Thanks once again for solving this for me.

Now... one more question following on from the basic alarming using DAQFact Express.

Is there anyway that when a pressure for example goes out of range, I can have some sequence 'alarm mode = 1' triggered in either the screen component or in a sequence somewhere, so that means I can display a Text screen component on ALL of my screens saying "ALARM" (in very large writing).

For example, I will have possibly 20+ ALARM instances, and could write 20+ "iif" expressions in the single screen component, but I think it may be easier to do in a sequence method.

Gracias.

Dan

Link to comment
Share on other sites

Now you are getting out of using it in expressions and need to do script. Just create a loop that cycles and using regular if() statements, sets a global flag to 1 if an alarm occurs, and to 0 if nothing triggers. Don't forget a delay() inside the while() loop.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.