I am converting a VB6 Processbook addin that shifts a trace in a trend by time to give you an offset trace. The addin uses a Dataset to create the offset data. this part works fine. But I cannot get the new dataset value added to the Processbook trend. When I look at the trend after running the addin, I can see the new trace, but it has no values. If I look in the trend setup I can see that the code attempted to add the dataset as if it were a PI Tag. Of course, the PI tag cannot be found.
If I delete the trace from the trend and add back the Dataset.Value I just created with the code, it works fine.
Here is the C# code I'm using:
PBObjLib.Dataset tgtDataSet = this.app.ActiveDisplay.Datasets.Add( dsName, null, false, 1, true, (int)PBObjLib.pbDatasetType.pbDatasetPIExpression); PBObjLib.PIExpressionDataset peDS = (PBObjLib.PIExpressionDataset)this.app.ActiveDisplay.Datasets.GetDataset(dsName); peDS.ServerName = srvName; peDS.ColumnName = "Value"; peDS.Interval = "+30m"; peDS.Expression = "TagVal('" + tgtTagName + "','*-" + cboDelay.Text + "')"; peDS.Description = dsName; peDS.Stepped = false; this.app.ActiveDisplay.Datasets.SetDataset((PBObjLib.Dataset)peDS); // Add the dataset to the target trend m_tgtTrend.AddTrace(dsName); m_tgtTrend.SetTraceScale(ScaleMin, ScaleMax);
I am currently using Processbook version 22.214.171.124. I'll be testing this on Processbook 2012 next as these are the two version used here.
Thanks for the help.
I believe I have the answer to this. When adding the created Dataset to a trend (should work for any symbol on a procbook) you need to append the value type (column) to the dataset name.
m_tgtTrend.AddTrace(dsName + ".Value");
from the example above. This should also work for other value types such as "Average".