Unable to add Dynamically created Dataset to PI-Processbook Trend in C#

Discussion created by DavidMFairchild on Mar 1, 2013
Latest reply on Mar 5, 2013 by DavidMFairchild

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,

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;

// Add the dataset to the target trend
m_tgtTrend.SetTraceScale(ScaleMin, ScaleMax);

 I am currently using Processbook version  I'll be testing this on Processbook 2012 next as these are the two version used here.


Thanks for the help.