Multi-State Indicator displaying three states-help

Hi I’m new to ignition (and have almost zero coding experience) and am using the Edge version to develop a SCADA system for a third party client. I’m currently trying to make an indicator light that will be green(1) if all tags are communicating, red(0) if no tags are communicating, and flash yellow(2) is some, but not all, tags are communicating. I have tried using if statements and can do the green or red scenario fairly easily, but I haven’t figured out how to accomplish my third state. Any suggestions? The current expression is shown below.

if(({WAD EMTR/TRUE_POWER}||{WAD EMTR/UnitId 1/1_V_phaseA359-1_V_phaseA360/1_V_phaseA359}
||{WAD EMTR/UnitId 1/1_V_phaseB363-1_V_phaseB364/1_V_phaseB363}
||{WAD EMTR/UnitId 1/1_V_phaseC361-1_V_phaseC362/1_V_phaseC361}
||{WAD EMTR/UnitId 1/batt_input}||{WAD EMTR/UnitId 1/performance_ratio}
||{WAD EMTR/UnitId 1/utility_import}||{WAD MTEO/UnitId 1/1_bom_temp301-1_bom_temp301/1_bom_temp301}
||{WAD MTEO/UnitId 1/1_irr_poa101-1_irr_poa102/1_irr_poa101}
||{WAD MTEO/UnitId 1/irr_temp103-irr_temp103/irr_temp103}=0),0,1)

//checks if any meter/weather tags aren’t communicating & displays “fault” if one is null

One way to do this would be to break it down in separate custom properties something like:
someTagsOnline with an expression that checks for any tags communicating
someTagsOffline with an expression that checks for any tags not communicating
status with an expression binding something like this:

binEnc(someTagsOffline, someTagsOnline)


This will give you the following status states:
1 = Red: all offline
2 = Green: all online
3 = Flashing Yellow: some online, some offline

While you could build all this logic into a single expression binding, it’ll likely be easier to follow if broken up something like the above.


This works perfectly, thank you!

1 Like

A follow-up issue to this, because I’ve run into a new problem.
I have two tags as suggested, the offline and online expressions. My third tag is the status and uses
binEnc(sometagsOffline, sometagsOnline)
The problem I’m running into is that if one tag is disabled, my sometagsOffline and sometagsOnline will both change to 1’s, which should change status to a 3. Instead, it displays a “2” and I think it is breaking because one of the tags in the expression is disabled. Is there a way to get around this?

The isNull expression can be used to check for disabled tags and incorporated into your logic accordingly. For example, here’s a code snippet of a binEnc() I happen to have in front of me that uses a different value ({} || {valve._doOpen}) if valve.isOpenRequested tag happens to be disabled:

// if isNull supports UDT with isOpenRequested member disabled for old PLC code
	{} || {valve._doOpen},

That said, I’m surprised binEnc() would return 2 if both of your inputs to it really are evaluating to 1.

I appreciate the suggestion and I’ve tried it with the same problem. I’m currently evaluating each of the tags to check if it is “=null”. When I disable one tag, I get this problem of my data status (with binEnc) not evaluating. I’ve included a snapshot to see if that helps; not quite sure where I went wrong. The data status is evaluating sometagsOffline and sometagsOnline

Right-click on sometagsOffline and look at Tag Diagnostics. I’m guessing you have a reference not found error. As long as at least one of the offline tags is not disabled, the expression is fine, but as soon as all offline tags are disabled, it ends up in error as in your screen clipping above (red X on tag). It looks like binEnc then evaluates the errored tag as zero, and also shows an error. You should be able to resolve this by using an expression structure something like this for sometagsOffline:

// Check for not all tags online. Disabled (null) tags defaulted to false/offline.
!(if(isNull({[.]Tag 1}), False, {[.]Tag 1})
	&& if(isNull({[.]Tag 2}), False, {[.]Tag 2})
	&& if(isNull({[.]Tag 3}), False, {[.]Tag 3})
	&& if(isNull({[.]Tag 4}), False, {[.]Tag 4})

If at some point no tags were online and some were disabled, I believe you would encounter the same problem with sometagsOnline, so you may want to use a similar expression structure for it.

1 Like