I'm trying to create a template in Perspective (kind of like how they have templates in Vision) using embedded views. I'm trying to get it to where I can have my tag path change based on a parameter so that I don't have to go in and change every single expression whenever I add a new machine.
I want my paths to look something like this: tag("[default]" + {view.params.machine} + "/Inputs/Running")
I'm pretty sure the syntax of my path is correct based on what others have done on the forum. I think my error lies in how I'm setting up the parameter in my embedded view.
Is there anything else I should attach or any additional information? I’m still relatively a beginner at ignition so I might not be the best at explaining things.
I eventually want to get it to the point where I can replace all my tag paths for my expressions to do stuff like this:
After doing that, hover over the result of the binding to see what the error could be (where it is written Bad_NotFound).
EDIT: To achieve what you are trying to do with your last screenshot, consider creating as many custom properties as needed, each of those custom properties should be an indirect tag binding.
Don't use magic colors (hard coded color codes). Instead use style classes and/or css variables. That way when you need to change a color, you only have to do it in one place.
Show us a screenshot of what you did. Make sure you follow exactly what I did in my screenshot (it is not enough to write {machine} in the tagpath, you have to also specify where this data points to, in this case {view.params.machine})
Alright thats good advice, I had my backgroundColor property binded using this expression for my label to automatically change colors based on a status of my machine so I’ll look into that.
One thing I’d suggest is consider offloading this into your Template UDT. Have a tag called machineState that references Running, Idle, Fault, Offline, etc and creates an integer based on what state you want to show. Example:
# Expresion binding for machineState, landed in the Inputs folder. Adjust accordingly if you want it up a folder.
case(
true, // Inspect for the value 'true'
{[.]/Inputs/Running}, 1,
{[.]/Inputs/Idle}, 2,
{[.]/Inputs/Fault}, 3,
{[.]../Machine_Activity/Offline}, 4,
5// Default if no states are active
)
# Order matters, it'll hit the first one it finds true, so you likely want Fault first, but I copied your original order.
Then in your view instead of doing a complex expression binding like that you simply point it at machineState and use a map binding instead where 1 is running, 2 is idle, 3 is fault, or whatever.
And as Irose said, use styles instead so that it’s easier to maintain down the road. Simple example being someone doesn’t like that color orange and wants it changed, right now you’d have to edit every view to tweak the colorcode. Instead make styles for each state and whatever background fill or border color you want. Then bind onto the props.style.classes and put your map to machineState there and then the output of the map expression is the name of the class you want to show.