Multiple Conditional Statements


paulparry

Recommended Posts

Hi,

 

Just trying to work something out and need a bit of assistance.

 

I have multiple sites, each one has a standby generator and DaqFactory monitors the Local mains status, generator status and the like.

 

In the expression entry box I have a condition like this:

 

iif(GW_GENNY_Fault <0 && GW_MAINS_Fail>1,1,0)

 

This basically says that if my generator is happy, i.e. GW_GENNY_Fault is less than zero i.e. not a 1 and that I have mains in the buiding, i.e. GW_MAINS_Fail is a 1 and not a zero, then the expression returns a zero. I then have a descriptive text box that displays "Healthy" on zero threshold.

 

What I want to do is then have a 2nd iif expression - mains has failed, but generator happy so I can put a different message up warning that the Generator is powering the building.

 

I then need a 3rd iff expression to indicate that mains has failed and the generator has failed which will put up a more important message saying there is no power at all - get someone out of bed!

 

However if I put lots of iif statements into the expression box, it only evaluates the last one.

 

How do I get a conditional if / switch type statement into an expression / descriptive text box?

 

Cheers,

Paul

 

 

Link to comment
Share on other sites

You want to use bitwise math.

 

GW_Genny_Fault[0] + GW_Mains_Fail[0] * 2

 

will yield a number from 0 to 3.

 

0 = both Genny_Fault and Mains_Fail are 0

1 = Genny_Fault is 1, but Mains_Fail is 0

2 = Genny_Fault is 0, but Mains_Fail is 1

3 = both Genny_Fault and Mains_Fail are 1

 

You can put this directly into a descriptive text component assigning a text to display for each possible number.

Link to comment
Share on other sites

Archived

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