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")))))
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?
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