I'm still trying to come up with my own solution to make this work...
Thanks to @Phil_B in this thread Perspective XY Chart Datasource Update Question
I am able to successfully display a live chart with a green target line and red limit lines.
However, when I do this the XY chart occasionally crashes. I would appreciate any insight that can help me understand why it's crashing, thank you.
The way I am currently achieving this is to bind the 'example' datasource of the XY chart to an expression, instead of trying to bind directly to a tag history.
The expression binding is
now(5000) #expression to run every 5 seconds
I then added the transform script...
def transform(self, value, quality, timestamp):
DataHtag = system.tag.queryTagHistory(paths=["[default]Realistic0"], returnFormat='Wide', columnNames=["t_stamp","Realistic0"],rangeMinutes=10)
LimitH = []
Target = []
LimitL = []
for row in range(DataHtag.rowCount):
LimitH.append(27.0)
Target.append(3.0)
LimitL.append(-27.0)
DataHtag = system.dataset.addColumn(DataHtag,2,LimitH,"LimitH",float)
DataHtag = system.dataset.addColumn(DataHtag,3,Target,"Target",float)
DataHtag = system.dataset.addColumn(DataHtag,4,LimitL,"LimitL",float)
return DataHtag
The '[default]Realistic0' tag is just a generic simulated tag from the gateway.
This transform script pulls 10 minutes worth of data from the tag history into a dataset and then I created 3 arrays full of nothing but the target and limit values and then added those arrays as columns to the dataset.
It works
but it occasionally crashes the webpage (Chrome Version 74.0.3729.157). I just have to reload the page to get it to work.
When the chart causes the designer to crash I get the following error when trying to close the view.
java.util.concurrent.TimeoutException
at java.base/java.util.concurrent.CompletableFuture.timedGet(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source)
at com.inductiveautomation.perspective.designer.workspace.ViewResourceEditor.getObjectForSave(ViewResourceEditor.java:357)
at com.inductiveautomation.perspective.designer.workspace.ViewResourceEditor.getObjectForSave(ViewResourceEditor.java:59)
at com.inductiveautomation.ignition.designer.tabbedworkspace.ResourceEditor.commit(ResourceEditor.java:160)
at com.inductiveautomation.ignition.designer.tabbedworkspace.TabbedResourceWorkspace.close(TabbedResourceWorkspace.java:255)
at com.inductiveautomation.ignition.designer.tabbedworkspace.TabbedResourceWorkspace.close(TabbedResourceWorkspace.java:242)
at com.inductiveautomation.ignition.designer.tabbedworkspace.TabbedResourceWorkspace$1.actionPerformed(TabbedResourceWorkspace.java:77)
at com.jidesoft.plaf.basic.BasicJideTabbedPaneUI$CloseTabAction.actionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at java.desktop/javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at java.desktop/javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
at java.desktop/java.awt.Component.processMouseEvent(Unknown Source)
at java.desktop/javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.desktop/java.awt.Component.processEvent(Unknown Source)
at java.desktop/java.awt.Container.processEvent(Unknown Source)
at java.desktop/java.awt.Component.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.desktop/java.awt.Container.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Window.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.Component.dispatchEvent(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.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue$5.run(Unknown Source)
at java.desktop/java.awt.EventQueue$5.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.1 (b2019050708)
Java: Azul Systems, Inc. 11.0.2