How to display alarms in object tooltip

In my application I have objects drawn to represent conveyors. The Name of the object is being used with indirect tagging to create an expression that changes the color of the object. What I want to do is display any active alarm from the UDT instance (same name as object) on the Mouseover Text Property. Currently we are displaying the status of the object using a translation of the number being spit out by the PLC. Example below. Can someone point me in the right direction? I know I can manually add the alarm to each object but I need to make it so it will filter the alarm based on the name of the object. so when I duplicate the object and rename it the expression will then filter by the new object name.

Root Container.CnvrName.name} +
if ({Root Container.CnvrName.Status}=6, " - ManualMode",
if ({Root Container.CnvrName.Status}=4, " - SleepMode",
if ({Root Container.CnvrName.Status}=3, " - Faulted",
if ({Root Container.CnvrName.Status}=2, " - Full",
if ({Root Container.CnvrName.Status}=1, " - Running",
" - Off")))))

Welcome to the forum, Jake.
Two tips:

  • Add either the vision or perspective tag to your question so we know what we're working with.
  • See Wiki - how to post code on this forum and then hit the pencil icon below your post to format it correctly. (It's not Python so it's not as critical but it does help it stand out.) You seem to be missing the opening { too.

I'm not quite clear on the problem. What's doesn't with the code you posted?

Root Container implies vision. I'm guessing this is the expression currently in the mouseover text.

This part is confising me a bit:

If the alarm is part of the UDT, then the alarm path follows the UDT instance. Are you using indirect Tag bindings to get your current data?

At a high level, and not knowing your structures the expression could something like:

stringFormat("<html>%s -%s<br>%s",
             {Root Container.CnvrName.name},
             case({Root Container.CnvrName.Status},
                  1, 'Running',
                  2, 'Full',
                  3, 'Faulted',
                  4, 'SleepMode',
                  6, 'ManualMode',
                  'Off'),
             {{Root Container.CnvrName.Alarm}
            )
2 Likes

I would definitely use a case statement instead of multiple ifs, like Jordan mentioned.
As for displaying alarms, that's more difficult. In case you find this as a "solution" yourself, do not run system.alarm.queryStatus to get this info from within your template. This will kill your client (or at the very least cause significant lag).

The simplest solution might be to read all of your alarm tags and if they on, produce a string concatenating the string of alarm names that are on. It's a bit tedious and won't update if tags change, I would do this in an expression tag in the udt if I did it this way to centralise the config