8 Replies Latest reply on Oct 16, 2012 1:31 PM by rdube02

    Create Processbook trend from values in an array

    Aantje

      Hi everybody!

       

       

       

      I'm trying to create a trend in processbook from values that are stored in an array (this array is read from a PI tag. I read this tag in the VBA code from my processbook).

       

      My array is filled as follows:

       

      g_splittedValue(0) = "17.10.2012 14:00" 

       

      g_splittedValue(1) = "290"

       

       

       

      g_splittedValue(2) = "17.10.2012 14:15" 

       

      g_splittedValue(3) = "295"

       

      g_splittedValue(4) = "17.10.2012 14:30" 

       

      g_splittedValue(5) = "297"

       

      g_splittedValue(6) = "17.10.2012 14:45" 

       

      g_splittedValue(7) = "298"

       
      etc. 
      As you can see, the array first shows a timestamp (in the future), with the corresponding value.
      But now I want to create a trend in Processbook, but I've got no idea to proceed.
      Any ideas?
      Greetings, Arie

       

       

       

        • Re: Create Processbook trend from values in an array

          Hello Arie,

           

          Arie van Boven

          I'm trying to create a trend in processbook from values that are stored in an array (this array is read from a PI tag

           

          PI does not (natively) support array data types nor future data. Is this array data possibly stored as annotation of an event?

           

          I doubt you will be able assigning events (an event consists of value + timestamp) to a ProcessBook Trace.

           

          What may work is using an ODBC data source e.g. with the data stored in a relational data source. This however can be problematic because PI ProcessBook will update the Trend with the specified update rate (default = 5 seconds). In your case this would mean your query is executed every 5 seconds.

           

          I had the pleasure working with a prerelease of the PI AF Server 2012 that is about to be released soon. The new version supports time series data with table lookup functionality. I haven't trended future data in PI ProcessBook but could imagine this may work quite well.

           

          Gregor

            • Re: Create Processbook trend from values in an array
              rdube02

              Hi Arie,

               

              Not sure if this will help you, but if you are loading values into an array that you would like the graph, one of the best approaches I've used in the past for this is the Microsoft Chartspace object. You can add it to Processbook by going into the VBA editor and clicking on Tools -> References, and then adding either "Microsoft Office 14.0 Object Library" or "Microsoft Office Web Components 11.0"....I can't remember which of those has the Chartspace object, but I know one does.

               

              I've written about how to program with the chart and load your values into it here: www.makeuseof.com/.../add-chart-office-web-components

               

              It's a very powerful and flexible object for charting data. I've used it to make some very cool pareto charts inside of Processbook pages.

               

              Best,

               

              -Ryan

                • Re: Create Processbook trend from values in an array
                  Asle Frantzen

                  If 5 seconds update rate is too quick you can just create some quick VBA logic to slow down this, or maybe just load it once.

                   

                  I've done that for one client, which allows them to get relational data updates every 15 minutes if they decide to leave the display open for that long.

                    • Re: Create Processbook trend from values in an array
                      dhollebeek

                      The 5 second refresh rate is configureable (as long as you want the same refresh rate accross all displays).  I can dig up the INI setting for this if you are interested.

                       

                      Thanks,

                       

                      :D

                        • Re: Create Processbook trend from values in an array

                          Gregor has hit the nail on the head on this issue.  I would have said the exact same thing.

                            • Re: Create Processbook trend from values in an array
                              Aantje

                              Maybe I wasn't really clear what I want to do.

                               

                              The values I want to trend are future values, so I can't send them to PI. The values are stored in a PI string tag. The source of these values is an SQL database, but I have good reasons not to connect to this database (so I have to do it with my values in an array).

                               

                              I thought it should be possible to enter these values (timestamp, value) in a (programmed) DataSet, and then use the AddTrace method the present my values in Processbook.

                               

                              I was hoping to find some examples here on vcampus, but still haven't found anything.

                                • Re: Create Processbook trend from values in an array
                                  rdube02

                                  Arie - what you are describing is exactly what the MS Chartspace object is for, loading preset values in arrays into any kind of chart. Using AddTrace with a PI trend when you're working with data like this would not work.

                                   

                                  It's very easy to add the Chartspace object to ProcessBook, you just have to add the reference for it, as I mentioned above. Loading it with the values from your array is very easy, although you may need to reorganize the data into two arrays instead of 1 (the x/y plot points).

                                   

                                  Good luck,

                                   

                                  -Ryan

                                  • Re: Create Processbook trend from values in an array
                                    rdube02

                                    Here's how you load data into the chart (in this example I've named the Chartspace object "oChart2". In this example, I'm loading x,y values for a column "pareto" chart. In your case you'd just change the chart properties to "line" type (I'm assuming you're looking for a line chart), and load the x,y values from arrays in the same way. X array is time/date, Y array is your data.

                                     
                                      With ChartSpace2
                                            .Clear
                                            .Refresh
                                            Set oChart2 = .Charts.Add
                                            
                                            oChart2.HasTitle = True
                                            oChart2.Title.Caption = "Occurrences"
                                            
                                            Set oSeries12 = oChart2.SeriesCollection.Add
                                            
                                            With oSeries12
                                                .Caption = strTagName & " Alarms"
                                                .SetData chDimCategories, chDataLiteral, xValues2
                                                .SetData chDimValues, chDataLiteral, yValues2
                                                .Type = chChartTypeColumnClustered
                                            End With
                                            
                                    
                                            'Format the Value Axes
                                            oChart2.Axes(chAxisPositionLeft).NumberFormat = "####0"
                                           ' oChart.Axes(chAxisPositionRight).NumberFormat = "0"
                                            oChart2.Axes(chAxisPositionLeft).MajorUnit = yMax2 + 10
                                            oChart2.Axes(chAxisPositionLeft).Scaling.Minimum = 0
                                            oChart2.Axes(chAxisPositionLeft).Scaling.Maximum = yMax2 + 10
                                            'oChart.Axes(chAxisPositionRight).MajorUnit = 20000
                                        
                                            'Show the legend at the bottom of the chart
                                            oChart2.HasLegend = True
                                            oChart2.Legend.Position = chLegendPositionBottom
                                    
                                            
                                       End With