I want to select multiple tags from a list of tags and display their tag history at runtime. On one screen I want to display the results to a Perspective Table control. On the other screen I want to display it to an XY Chart.
I have been able to get static versions of this functionality working but I’m not sure how to dynamically bind to tags at runtime.
I understand that I can export my bindings as json but I don’t know what mechanism I can use to send a json binding to a control. I suspect the answer is to use messaging or maybe json to send the bindings to the Perspective control at runtime but I don’t understand how to do that.
I just had a discussion regarding dynamic binding with some devs recently, and… you can’t. And… you shouldn’t. Bindings are meant to be static/unchanging/final. The underlying data the bindings would represent can and should be malleable, but the definition of a binding should never change.
Best way to go about what you’re doing: build a data structure which allows for defining or toggling data values.
For example, try:
Placing a “refresh” button into your View, along with some Toggle Switches.
Allow the Toggle Switches to define which Tags are displayed in the graph.
When your refresh button is clicked, refer to the Toggle Switches to determine which tags are included in a tag read request.
Build a dataset from the data.
Use system.perspective.sendMessage() to broadcast this dataset.
Place a listener on the Chart/Table which determines how the dataset is digested.
In this way your bindings do not change, but the underlying data built from their information can be changed.
Thank you. That should get me going in the right direction. I at least know which things I need to understand before I can execute this.
Do you have an example of how to set this up? I was going over the message documentation because I suspected that was part of the answer but it looked like it was still a work in progress (the documentation).
Import the tags from demotags.json
Extract the View from the .zip folder and place it in your Project.
You’ll want to configure a Page Configuration for the new View.
Navigate to the new Page.
Toggling the Toggle Switches and then pressing the button will result in one or the other or both (BUT NOT NONE - I was in a hurry) being rendered in the Chart.
Instead of Toggle Switches, a multi-select Dropdown would probably be better for determining which tags are displayed.
To examine the bulk of the logic, right-click the Refresh button and select “Configure Events”.
tag.split('/')[-1] is getting the last token of the split.
system.tag.readBlocking was used instead of readAsync because I didn’t want to get into using a callback function.
messageType must match exactly the name of the listener configured on the XYChart.
To examine the listener, right-click the Chart and select “Configure Scripts”, then select “XYDATACHANNEL”.
The self.props.series[i] properties must all be configured in order for a series to render.
I installed the latest daily on my testing station and tried to import this project file. It’s locking up and the objects don’t appear to be getting imported. There are other projects on this gateway but none of them are important. It’s just a testing station but I wanted to give details of my environment in case they matter (probably not).
I thought maybe the problem was how I created the project so I referenced my global project from the project I’m importing into and tried again. It locked up again.
I created the project from the designer launcher and tried importing the .zip file into it from within the designer. Before that I tried to import the .zip file from the configuration webpage as a new project and that threw an error saying the gateway was unable to import the file.
I’m also interested in anything you can tell me about using the expression definitions on the historic section of the XYChart. I was trying to use the expressions but wasn’t having a lot of success yesterday. I did see that the documentation is actively being updated as of yesterday so I’m sure this will become easier to figure out soon. You guys are really on top of things. It’s a big job.
Let me know if you need any details from my station that is crashing when I try to import this project.