Cell binding using indirect tag / change dataset by scripting

Hi all,

I have an easy chart object, and I would like the axis to automatically update according to an indirect tag.

When I call the window, I pass a tag path in as a custom parameter. This tag path points me to a UDT instance which has:

Value
Value_Min
Value_Max

I can use cell binding to add the “Value” tag to the Tag Pens:

[~]{Root Container.TagPath}/Value

But I can’t find a way to do this to bind the Value_Min and ValueMax to the axis upper bound and lower bound. Is there a way?

Alternatively, I can try to script it. I understand that you can’t alter a dataset with scripting, but that you can use system.dataset.setValue to return a new dataset which is identical to the original except with your changes made. So, once I have this dataset, how do I make the Easy Chart look at my new DataSet for its Axes? I tried

AxesDataset = [path to trend].axes MinScale = system.tag.read([path to tag]).value MaxScale = system.tag.read([path to tag]).value system.dataset.SetValue(AxesDataset,[row],'lower_bound', MinScale) system.dataset.SetValue(AxesDataset,[row],'upper_bound', MaxScale) [path to trend].axes = AxesDataset

But so far no luck

system.dataset.setValue() returns a new dataset each time, as the original is immutable. You have to assign the return value to your AxesDataset variable each time. Also, note that case matters in the function name.

If you can use cell binding to bind the Value tag to the Tag Pens dataset TAG_PATH property, what’s stopping you binding the Value_Max and Value_Min tags to the Axes dataset UPPER_BOUND and LOWER_BOUND properties? Make sure you also set the Axes dataset AUTO_RANGE property to false.

1 Like

pturmel - assigning the return value to the AxesDataset is what I can’t work out. How do I do that? I’m sure it’s simple, it’s just my first foray into Ignition and I’m on the learning curve.

AlThePal - I’d guess why it’s not working in this case is because the tag path is expecting a tag, so when I pass it a string which resolves to a valid tag path, it interprets it as such. Whereas the upper and lower bounds are expecting an integer, so when I pass it a string, it doesn’t know what to do with it. Similar problem if I try to set units with cell binding - I have a string tag where I store the units to display on one of the axes. The tag is an indirect tag since I’m passing a tag path to the display initially. So I can bind the units cell to {Root Container.TagPath}/Units, and it resolves to Analogs/TT1234/Units - but then that’s exactly what’s displayed on the graphics. “Analogs/TT1234/Units”, not “°C”, which is the value of the tag.

I guess all of this would be solved if I could find a way to have it interpret my input as the value of the tag path I pass to it, instead of literally just the tag path as a string, but I haven’t found a way to do that yet. Any ideas?

This is more of a python question than an Ignition question.... but something like this:

AxesDataset = [path to trend].axes
MinScale = system.tag.read([path to tag]).value
MaxScale = system.tag.read([path to tag]).value
AxesDataset = system.dataset.SetValue(AxesDataset,[row],'lower_bound', MinScale)
AxesDataset = system.dataset.SetValue(AxesDataset,[row],'upper_bound', MaxScale)
[path to trend].axes = AxesDataset

The best way to do this is to use a custom property as an intermediate value, of the correct datatype, with an indirect tag binding. That's exactly what indirect tag bindings exist for. The indirect binding takes your string as a tag path (or combines it to produce a tag path), and delivers that tag's value. Then use that custom property in your cell binding.

Consider taking a couple weeks to go through Inductive University. That'll greatly cut down on not knowing what is possible with Ignition.

2 Likes

Thanks, I’ll have a play with both options.

I have gone through most of IU. It’s a lot of information to take in, I figure I’m remembering about 50%, able to find another 40% by going back through the videos to jog my memory, and the folks here are being extremely helpful with the remaining 10% :slight_smile:

On most SCADA packages I’d be thrilled to have it be as simple as adding a custom property - but when going through the IU videos I was repeatedly struck by how many workarounds I didn’t need any more because Ignition has a feature built in. So every so often I just get caught up wondering if there’s a neater or “more correct” way to achieve my aim. That’s where I ended up here. I ended up solving the problem of cell-update-binding the units to the easy chart by using a custom property as an intermediate value, as you suggest. When I got to the upper and lower bounds, I just started to wonder if there was a smarter way of doing it than just adding more and more custom properties. But, if that’s the way it’s generally done, then great!

I’ll have a play with the scripting regardless, for my own knowledge, and see if I can get it to work. But the more I think about it, the more I think that custom properties is overall a much simpler and easier to follow solution.

Thanks for your tips!

1 Like

The simplest way I can think of is create two custom properties somewhere and bind the min and max tag values to these using indirect tags. Then in the cell bindings you can use the two custom properties created.