Error in Expression Binding

Hi, I am making a template for a pump on a VFD. I have a template parameter VFDTag which I use in expression bindings. Most work fine, however I need to change the color of the Fill Paint for several shapes based on the status of a “Running” tag. I am using the following expression:

if((tag(’[default]Pumps/VFD’ + {VFD.VFDTag} + ‘/Running’)),color(255,250,250),color(155,140,140))

The expression changes the Fill Paint color but I also get (2) repeated error messages:

java.lang.ClassCastException: Cannot coerce value ‘true’ into type: interface java.awt.Paint
at com.inductiveautomation.ignition.common.TypeUtilities.coerce(TypeUtilities.java:1427)
at com.inductiveautomation.factorypmi.application.binding.AbstractPropertyAdapter.setQValue(AbstractPropertyAdapter.java:222)
at com.inductiveautomation.factorypmi.application.binding.AbstractPropertyAdapter.updateValue(AbstractPropertyAdapter.java:264)
at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter.runExpression(ExpressionPropertyAdapter.java:89)
at com.inductiveautomation.factorypmi.application.binding.ExpressionPropertyAdapter$1.run(ExpressionPropertyAdapter.java:59)
at com.inductiveautomation.ignition.client.util.EDTUtil$ProcessQueue.run(EDTUtil.java:127)
at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

Ignition v8.0.12 (b2020042115)
Java: Azul Systems, Inc. 11.0.6

Is there any way to eliminate the error messages?

Thanks,

Dennis Hoskins

Considering you’re not using tags for your colours, you can just use an indirect binding and select your colours instead from the colour pickers

Also if possible using the hex string instead of the color() expression may solve this too

I’ve only ever had issues using color(...) if i’m trying to use it in combination with strings (e.g. HEX, or even just the RGB values as a string). The expression language doesn’t handle type-casting, I think it grabs the data type from the first return value (in an if, that would be the true value) and expects that data type for all return values

2 Likes

Thank you nminchin, that worked although I think my original approach should have also worked.
Dennis

1 Like

Yes, it should have worked, not sure why you were getting errors :thinking: