AnsweredAssumed Answered

PI Processbook display improvements and applying display to 100+ entries

Question asked by msj_ on Dec 14, 2017
Latest reply on Dec 19, 2017 by kduffy

Hi, first post here. I've just started using PI Processbook with some prior experience with VBA in excel. I have scripted a prototype display which has scatters and trends.

The scatter plot (graphing 2 PI tags) is actually 3 scatter plots of the same tags stacked on top of each other, so that I can see the same data and their statistics over 3 periods.


The trend (graphing 2 datasets with PI expressions) is also 2 trends stacked on top so I can see the same dataset values over two different periods. Red & pink is same dataset, grey and black is same dataset.

The update button takes user selected variables and changes the PI tags and dataset expressions (remove previous then add new).

e.g. for one of the 3 scatter plots:

     'Update scatter plot

    With scatter.Tags

        .RemoveAll 'remove all data from plot

        .Add "\\" & list_server.SelectedServer & "\" & tag_de 'add Y tag data

        .Add "\\" & list_server.SelectedServer & "\" & tag_nde, True 'add X tag and set as X values

        .Item(2).SetRetrievalMethod pbRMRecordedValues 'set Y to retrieve recorded values

        .Item(1).SetRetrievalMethod pbRMSynchronize 'set X to retrieve synchronized values

        .Item(2).SetTimeRange False, starttime, endtime, "10m"

        .Item(1).SetScaleConfiguration False, pbScaleAbsolute, 20, pbScaleAbsolute, 100

        .Item(2).SetScaleConfiguration False, pbScaleAbsolute, 20, pbScaleAbsolute, 100

    End With


e.g. for the trend:

    'Update datasets

    Set ds = Datasets

    Set de_gen = ds.GetDataset("DE_GEN")

    Set nde_gen = ds.GetDataset("NDE_GEN")


    With de_gen

        .ServerName = list_server.SelectedServer

        .Expression = tag_de_excess_by_gen

        .ColumnName = "Value"

        .Interval = list_interval.Value

    End With


    With nde_gen

        .ServerName = list_server.SelectedServer

        .Expression = tag_nde_excess_by_gen

        .ColumnName = "Value"

        .Interval = list_interval.Value

    End With


    ds.SetDataset de_gen

    ds.SetDataset nde_gen


Question 1:

Is there any way to speed up the processing time? Maybe by combining the different time periods onto the same plot/trends?


Question 2:

I want to build a dashboard which shows data from each of the tags.

Instead of using the update button to change the PI tags and dataset expressions to display scatters and trends for a single set of tags, what is the best way to replicate the same layout and dataset format for all of my variables (100+)?

I saw the WithEvents function but I do not really understand it. My idea was to have a textbox within each display which contains the variable used in PI tags and expressions. But I'm not sure if this is the best way.





edit: Another option might be to just link the existing display file to a piw file and run loops from the piw file? Is this possible? How can I run a macro/sub/private sub on another display?