Quantcast
Channel: OSIsoft Users Community
Viewing all articles
Browse latest Browse all 1120

Add a custom value to trend

$
0
0

Hi

 

I'm not the admin of our PI-system, but just an advanced user.

 

We have a tag showing a processvalue, but not a tag with the target for that processvalue. Can I make a trend in Pi Processbook that contains a trend with both the value of the tag and a referenceline with the target?

 

I'm pretty comfortable with VBA, but can't really seem to find a way to add anything else than a PI-tag to a trend (e.g. using the MyTrend.AddTrace) 

 

I tried this found in another thread here, but it gives a run-time error saying the "Argument name already exist. Name has not been changed" for the line with "Set MyDataset = ..."

Sub CreateAndPlotDataset()
    Dim MyDatasets As Datasets
    Dim MyDataset As PIExpressionDataset
    Dim MyTrend As Trend
    Dim MyTrendFormat As TrendFormat
    Dim MyBool As Boolean

    Set MyDatasets = ThisDisplay.Datasets
    Set MyDataset = MyDatasets.Add("NewCalc", Nothing, True, 1, True, pbDatasetPIExpression)
    Set MyDataset = MyDatasets.GetDataset("NewCalc")
    MyDataset.ServerName = "DANIELSLAPTOP"
    MyDataset.Expression = "If TagVal('BA:Active.1','*') = ""Active"" Then 'CDT158' Else NoOutput()"
    MyDataset.RefreshInterval = 60000
    MyDataset.ColumnName = "Value"
    MyDataset.Interval = "1h"
    MyDataset.Description = "Calculated Dataset"
    MyDatasets.SetDataset MýDataset

    Set MyTrend = ThisDisplay.Symbols.Add(pbSymbolTrend)
    Set MyTrendFormat = MyTrend.GetFormat
    MyTrendFormat.ShowTraceMarkers = True
    MyTrend.SetFormat MyTrendFormat
    MyTrend.Top = 14900
    MyTrend.Left = -14900
    MyTrend.Height = 1000
    MyTrend.Width = 1500
    MyBool = MyTrend.SetStartAndEndTime("*-1d", "*")
    MyTrend.AddTrace "NewCalc.Value"
End Sub

But then again it looks a bit more advanced than what I need?

 

I made a temporary solution adding a symbol (line) on top of the trend and calculating it's position in pixel relative to the trend... but that's really a poor hack as you cant zoom in or do anything on the trend.

 

So how can I get a simple reference line in a trend without creating a new PI-tag on our server?

 

 


Viewing all articles
Browse latest Browse all 1120

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>