Editing Individual Cells Background Colors Comapred to UDT Nested Tag Values (configureCell)

Hi Everyone!

Relatively new ignition user here. I have a question regarding the best way to approach changing individual cells in my Power Table based on the cells value. Lets say I have a table that looks like this:

Tank Mass Balance Mass Balance Average
TK109 value value
TK110 value value
TK111 value value
TK112 value value
TK113 value value
TK114 value value

Based on what I had read/examples, I was planning on writing something similar to the following:

paramValue = tag['parameters']['TankName']
tolerancepath = "[default]Feed Tank MBs/%s/Tank Mass Balance Tolerance" % paramValue
tolerance = system.tag.read(tolerancepath).value
data = self.data
for row, value in range(data.getRowCount()):
        if value >= tolerance
 then return {'background': 'red'}

I know the code isnt correct, its more of just pseudocode. Obviously, this doesnt work though because UDT is specific to its specific UDT, also nowhere the parameter is stored for each tank. Is there any way I could instead reference the zero indice column name and use that in the tag path instead? Is there a better to do this in general overall? Any help would really be appreciated, thanks!

In summary: I want to change the color of my mass balance cells based on if they are over a tolerance limit set by another tag.

To make sure I'm understanding, each tank has its own tolerance? And each of those tolerances are present in the UDT for the tank? Or is there a single tolerance that applies to all tanks?

Also, how are you populating the data in this table?

In general, for coloring or changing cell visuals on a power table, utilize the configureCell extension function available on the power table:

Vision - Power Table Scripting Functions | Ignition User Manual.

If you haven't overwritten it, it should contain an example script for changing the background color of the cell.

I recommend creating two custom properties, one for 'normal' background color and one for 'bad' background color. You'll be able to reference the properties in the extension script, and because they are custom properties, you can change their color values from the normal component properties editor instead of having to go into the script editor.

Also, DON'T perform a system.tag.read call in the extension function. It runs for every cell and you will lock your interface.

Instead, if you have a specific tolerance per tank, create a custom dataset property on the table called massLimits or similar, and populate that with all the limits for your tanks, with tank Id's in one column and the limit value in the other. Reference this in the extension script to search through it for the limit value of the associated tank.

If you are running with a single limit value for all tanks, then change the name of the property to massTolerance and make it a float datatype. Reference this when doing your comparison to change the cell background color.

2 Likes

Thanks!